@unieai/rabi-api-session-controller 0.0.0-stage → 0.2.2-rc.5

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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -2
  3. package/lib/client.js +4 -0
  4. package/lib/index.js +4300 -0
  5. package/lib/typert.host.d.ts +3 -0
  6. package/lib/typert.host.js +5013 -0
  7. package/lib/typert.remote-client.d.ts +115 -0
  8. package/lib/typert.remote-client.js +2714 -0
  9. package/lib/types/agent.d.ts +164 -0
  10. package/lib/types/agent.js +484 -0
  11. package/lib/types/archived-session-gate.d.ts +33 -0
  12. package/lib/types/archived-session-gate.js +54 -0
  13. package/lib/types/assistant-stream.d.ts +26 -0
  14. package/lib/types/assistant-stream.js +82 -0
  15. package/lib/types/catalog.d.ts +24 -0
  16. package/lib/types/catalog.js +107 -0
  17. package/lib/types/client/contract/events.d.ts +102 -0
  18. package/lib/types/client/contract/events.js +111 -0
  19. package/lib/types/client/contract/session.d.ts +178 -0
  20. package/lib/types/client/contract/session.js +1 -0
  21. package/lib/types/client/contract/sessions.d.ts +162 -0
  22. package/lib/types/client/contract/sessions.js +1 -0
  23. package/lib/types/client/contract/snapshot.d.ts +84 -0
  24. package/lib/types/client/contract/snapshot.js +1 -0
  25. package/lib/types/client/index.d.ts +39 -0
  26. package/lib/types/client/index.js +60 -0
  27. package/lib/types/client/ordered-baseline.d.ts +12 -0
  28. package/lib/types/client/ordered-baseline.js +40 -0
  29. package/lib/types/client/scope.d.ts +46 -0
  30. package/lib/types/client/scope.js +46 -0
  31. package/lib/types/client/session-wire-event.d.ts +11 -0
  32. package/lib/types/client/session-wire-event.js +42 -0
  33. package/lib/types/client/sessions/assistant-stream.d.ts +56 -0
  34. package/lib/types/client/sessions/assistant-stream.js +182 -0
  35. package/lib/types/client/sessions/history-records.d.ts +22 -0
  36. package/lib/types/client/sessions/history-records.js +25 -0
  37. package/lib/types/client/sessions/lineage.d.ts +48 -0
  38. package/lib/types/client/sessions/lineage.js +55 -0
  39. package/lib/types/client/sessions/manager.d.ts +272 -0
  40. package/lib/types/client/sessions/manager.js +774 -0
  41. package/lib/types/client/sessions/notifier.d.ts +39 -0
  42. package/lib/types/client/sessions/notifier.js +97 -0
  43. package/lib/types/client/sessions/projection-store.d.ts +128 -0
  44. package/lib/types/client/sessions/projection-store.js +161 -0
  45. package/lib/types/client/sessions/remotes.d.ts +29 -0
  46. package/lib/types/client/sessions/remotes.js +7 -0
  47. package/lib/types/client/sessions/service.d.ts +263 -0
  48. package/lib/types/client/sessions/service.js +597 -0
  49. package/lib/types/client/sessions/session.d.ts +303 -0
  50. package/lib/types/client/sessions/session.js +991 -0
  51. package/lib/types/client/time-zone.d.ts +8 -0
  52. package/lib/types/client/time-zone.js +13 -0
  53. package/lib/types/client/transport.d.ts +77 -0
  54. package/lib/types/client/transport.js +130 -0
  55. package/lib/types/commands.d.ts +92 -0
  56. package/lib/types/commands.js +575 -0
  57. package/lib/types/continuation.d.ts +35 -0
  58. package/lib/types/continuation.js +47 -0
  59. package/lib/types/control.d.ts +20 -0
  60. package/lib/types/control.js +106 -0
  61. package/lib/types/file-references.d.ts +27 -0
  62. package/lib/types/file-references.js +68 -0
  63. package/lib/types/history/assistant-stream.d.ts +43 -0
  64. package/lib/types/history/assistant-stream.js +79 -0
  65. package/lib/types/history/controller.d.ts +104 -0
  66. package/lib/types/history/controller.js +293 -0
  67. package/lib/types/history/listener.d.ts +105 -0
  68. package/lib/types/history/listener.js +296 -0
  69. package/lib/types/history.d.ts +58 -0
  70. package/lib/types/history.js +152 -0
  71. package/lib/types/index.d.ts +262 -0
  72. package/lib/types/index.js +693 -0
  73. package/lib/types/list.d.ts +62 -0
  74. package/lib/types/list.js +343 -0
  75. package/lib/types/media-references.d.ts +18 -0
  76. package/lib/types/media-references.js +84 -0
  77. package/lib/types/remote-events.d.ts +8 -0
  78. package/lib/types/remote-events.js +1 -0
  79. package/lib/types/skill-catalog.d.ts +28 -0
  80. package/lib/types/skill-catalog.js +203 -0
  81. package/lib/types/state/controller.d.ts +45 -0
  82. package/lib/types/state/controller.js +288 -0
  83. package/lib/types/state/listener.d.ts +40 -0
  84. package/lib/types/state/listener.js +111 -0
  85. package/lib/types/types.d.ts +687 -0
  86. package/lib/types/types.js +5 -0
  87. package/lib/types/web/controller.d.ts +25 -0
  88. package/lib/types/web/controller.js +138 -0
  89. package/locale/de.json +6 -0
  90. package/locale/en.json +5 -0
  91. package/locale/es.json +6 -0
  92. package/locale/fr.json +6 -0
  93. package/locale/ja.json +6 -0
  94. package/locale/pt.json +6 -0
  95. package/locale/ru.json +6 -0
  96. package/locale/zh.json +6 -0
  97. package/package.json +119 -4
  98. package/src/agent.ts +474 -0
  99. package/src/archived-session-gate.ts +59 -0
  100. package/src/assistant-stream.ts +102 -0
  101. package/src/catalog.ts +117 -0
  102. package/src/client/contract/events.ts +205 -0
  103. package/src/client/contract/session.ts +174 -0
  104. package/src/client/contract/sessions.ts +169 -0
  105. package/src/client/contract/snapshot.ts +94 -0
  106. package/src/client/index.ts +149 -0
  107. package/src/client/ordered-baseline.ts +43 -0
  108. package/src/client/scope.ts +76 -0
  109. package/src/client/session-wire-event.ts +46 -0
  110. package/src/client/sessions/assistant-stream.ts +229 -0
  111. package/src/client/sessions/history-records.ts +35 -0
  112. package/src/client/sessions/lineage.ts +96 -0
  113. package/src/client/sessions/manager.ts +857 -0
  114. package/src/client/sessions/notifier.ts +97 -0
  115. package/src/client/sessions/projection-store.ts +244 -0
  116. package/src/client/sessions/remotes.ts +44 -0
  117. package/src/client/sessions/service.ts +741 -0
  118. package/src/client/sessions/session.ts +1055 -0
  119. package/src/client/time-zone.ts +14 -0
  120. package/src/client/transport.ts +247 -0
  121. package/src/commands.ts +602 -0
  122. package/src/continuation.ts +58 -0
  123. package/src/control.ts +121 -0
  124. package/src/file-references.ts +42 -0
  125. package/src/history/assistant-stream.ts +102 -0
  126. package/src/history/controller.ts +256 -0
  127. package/src/history/listener.ts +302 -0
  128. package/src/history.ts +189 -0
  129. package/src/index.ts +651 -0
  130. package/src/list.ts +382 -0
  131. package/src/media-references.ts +84 -0
  132. package/src/remote-events.ts +14 -0
  133. package/src/skill-catalog.ts +108 -0
  134. package/src/state/controller.ts +221 -0
  135. package/src/state/listener.ts +116 -0
  136. package/src/types.ts +720 -0
  137. package/src/web/controller.ts +78 -0
@@ -0,0 +1,687 @@
1
+ /** Browser-safe request, result, and lifecycle vocabulary for the Session Remote service. */
2
+ import type { NativeFileApplication } from '@unieai/rabi-native-command/types';
3
+ import type { ImageAttachmentLimits, ImageAttachmentRef, ImageMediaType } from '@unieai/rabi-attachment';
4
+ import type { Branded } from '@unieai/rabi-brand';
5
+ import type { LlmAttemptId, MessageId } from '@unieai/rabi-llm/brand';
6
+ import type { LlmModelBadge, TextBlock } from '@unieai/rabi-llm';
7
+ import type { SessionId, SessionSeq, SessionSeqCursor } from '@unieai/rabi-session/types';
8
+ import type { SessionProjectionMap, SessionProjectionSummaryValues } from '@unieai/rabi-session-projection/types';
9
+ import type { Principal } from '@unieai/rabi-typert-protocol';
10
+ import type { JsonValue } from '@unieai/rabi-util-values';
11
+ import type { WorkspaceId } from '@unieai/rabi-workspace/types';
12
+ declare module '@unieai/rabi-session-projection/types' {
13
+ interface SessionProjectionMap {
14
+ /** Eligible latest failed turn/end for an empty prompt, or null. */
15
+ conversationContinuation: SessionSeq | null;
16
+ /** Persisted facts used to summarize a Session without activating it. */
17
+ sessionListMetadata: SessionListMetadata;
18
+ /**
19
+ * Image-intake limits enforced by the Session prompt endpoint. Boot
20
+ * constant, excluded from Session summary payloads: every Session shares
21
+ * it, so a list row would repeat one host-wide fact.
22
+ */
23
+ imageLimits: SessionProjectionSummaryExcluded<ImageAttachmentLimits>;
24
+ }
25
+ }
26
+ /** Persisted hints used to summarize a cold Session. */
27
+ export interface SessionListMetadata {
28
+ /** Whether the folded prefix contains no turn. */
29
+ readonly blank: boolean;
30
+ /** Latest human-authored prompt time in the folded prefix. */
31
+ readonly lastPromptAt: number | null;
32
+ }
33
+ /**
34
+ * Summary wire values a Session-list row carries. A `sequenced` block carries
35
+ * every summary key computed at its `asOfSeq`; a `cached` block carries the
36
+ * values the persisted cache holds and may omit keys or trail the Session.
37
+ * The block omits the keys whose unit declares `summary: false`. `kind` and `asOfSeq` are independent facts: `kind` says
38
+ * which sequence space `asOfSeq` belongs to, and therefore how a client may
39
+ * merge the block; `asOfSeq` is the producer's watermark in that space.
40
+ */
41
+ export interface SessionProjectionHints {
42
+ /**
43
+ * `sequenced`: the Host's live registry produced the block for an attached
44
+ * Session, so `asOfSeq` is comparable with baselines and frames of the same
45
+ * connection. `cached`: a header-only listing viewed the block from the
46
+ * persisted projection cache, so `asOfSeq` is the stored record's own
47
+ * watermark and must not be compared with the connected Session's values.
48
+ */
49
+ readonly kind: 'cached' | 'sequenced';
50
+ /** Watermark of the block in the sequence space named by `kind`. */
51
+ readonly asOfSeq: number;
52
+ /** Provider-validated summary values present in the block; omitted keys remain unknown. */
53
+ readonly values: Partial<SessionProjectionSummaryValues>;
54
+ }
55
+ /** Complete projection values at an exact Session event cursor. */
56
+ export interface SessionProjectionBaseline {
57
+ readonly asOfSeq: number;
58
+ /** Provider-validated values; omitted keys are absent capabilities at this cut. */
59
+ readonly values: SessionProjectionValues;
60
+ }
61
+ /** Typed known projections plus JSON-safe values contributed outside this compilation face. */
62
+ export type SessionProjectionValues = Partial<SessionProjectionMap> & Readonly<Record<string, SessionProjectionValue>>;
63
+ /**
64
+ * Browser-submitted prompt content; the Host promotes image bytes to durable
65
+ * references. File parts carry the opaque receipt returned by a preceding
66
+ * upload on the same Session; the receipt of an image upload enters the
67
+ * message as that image.
68
+ */
69
+ export type PromptContentPart = {
70
+ readonly type: 'text';
71
+ readonly text: string;
72
+ } | {
73
+ readonly type: 'image';
74
+ readonly mediaType: ImageMediaType;
75
+ readonly data: string;
76
+ readonly name?: string;
77
+ } | {
78
+ readonly type: 'file';
79
+ readonly receiptId: Branded<'file-upload-receipt-id'>;
80
+ };
81
+ /** Complete model selection for one Session. */
82
+ export interface ModelSelection {
83
+ readonly provider: string;
84
+ readonly model: string;
85
+ readonly reasoningEffort?: string;
86
+ }
87
+ /** One adapter-owned reasoning effort for an exact model route. */
88
+ export interface ModelReasoningEffort {
89
+ readonly id: string;
90
+ readonly name: string;
91
+ readonly description?: string;
92
+ }
93
+ /** Selectable reasoning metadata for one exact model route. */
94
+ export interface ModelReasoning {
95
+ readonly efforts: readonly ModelReasoningEffort[];
96
+ readonly defaultEffort?: string;
97
+ }
98
+ /** One model displayed inside its provider group. */
99
+ export interface ModelCatalogModel {
100
+ readonly id: string;
101
+ readonly name: string;
102
+ readonly description?: string;
103
+ readonly reasoning?: ModelReasoning;
104
+ /** Provider-authored label shown beside the name; display data only. */
105
+ readonly badge?: LlmModelBadge;
106
+ }
107
+ /** One provider and its successfully loaded model catalog. */
108
+ export interface ModelProviderGroup {
109
+ readonly id: string;
110
+ readonly name: string;
111
+ readonly models: readonly ModelCatalogModel[];
112
+ }
113
+ /** One provider whose model catalog lookup failed. */
114
+ export interface ModelCatalogFailure {
115
+ readonly id: string;
116
+ readonly name: string;
117
+ readonly message: string;
118
+ }
119
+ /** Host-generation model catalog and the default used by unconfigured Sessions. */
120
+ export interface ModelCatalog {
121
+ readonly default: ModelSelection;
122
+ /** Provider routes with at least one currently available catalog model. */
123
+ readonly routableProviders: readonly string[];
124
+ readonly groups: readonly ModelProviderGroup[];
125
+ readonly failures: readonly ModelCatalogFailure[];
126
+ }
127
+ /** One client-requested mutation of a still-pending queue item. */
128
+ export type QueueAction = {
129
+ readonly kind: 'edit';
130
+ /** Non-empty text-only replacement content. */
131
+ readonly content: readonly TextBlock[];
132
+ } | {
133
+ readonly kind: 'remove';
134
+ } | {
135
+ readonly kind: 'steer';
136
+ };
137
+ /** One Session list entry. */
138
+ export interface SessionSummary {
139
+ /** Whether this Session currently owns a live Agent. */
140
+ readonly agentAvailable: boolean;
141
+ /** Current for attached Sessions; otherwise the persistence format status when reported. */
142
+ readonly formatStatus?: 'current' | 'migration-required';
143
+ readonly sessionId: SessionId;
144
+ readonly updatedAt: number;
145
+ readonly running: boolean;
146
+ readonly blank: boolean;
147
+ readonly parentSessionId?: SessionId;
148
+ readonly origin?: 'subagent';
149
+ readonly cwd?: string;
150
+ readonly projections?: SessionProjectionHints;
151
+ }
152
+ /** One session-content search result. */
153
+ export interface SessionSearchItem {
154
+ readonly sessionId: SessionId;
155
+ readonly snippet: string;
156
+ }
157
+ /** Maximum number of Sessions returned by one search. */
158
+ export declare const SESSION_SEARCH_RESULT_LIMIT = 20;
159
+ /** Maximum search snippet length in Unicode code points. */
160
+ export declare const SESSION_SEARCH_SNIPPET_MAX_CODE_POINTS = 240;
161
+ declare module '@unieai/rabi-typert-protocol' {
162
+ interface RemoteErrorDetailsMap {
163
+ /** A wait observation ended before a stopping state; the caller should reread. */
164
+ 'session/observation-ended': Record<string, never>;
165
+ /** No state arrived before the deadline; a timeout after a state returns its value instead. */
166
+ 'session/wait-timeout': Record<string, never>;
167
+ 'session/provider-credentials-unavailable': Record<string, never>;
168
+ 'session/provider-models-unavailable': {
169
+ readonly provider: string;
170
+ };
171
+ 'session/model-unavailable': {
172
+ readonly provider: string;
173
+ readonly model: string;
174
+ };
175
+ 'session/conflict': {
176
+ readonly sessionId: SessionId;
177
+ readonly requestedCwd: string;
178
+ readonly existingCwd?: string;
179
+ };
180
+ 'session/projections-unavailable': Record<string, never>;
181
+ 'session/writer-held': {
182
+ readonly sessionId: SessionId;
183
+ };
184
+ 'session/agent-busy': {
185
+ readonly reason: string;
186
+ };
187
+ 'session/invalid-time-zone': {
188
+ readonly value: string;
189
+ };
190
+ 'session/workspace-attach-failed': {
191
+ readonly sessionId: SessionId;
192
+ readonly workspaceId: string;
193
+ };
194
+ 'agent-preset/conflict': {
195
+ readonly sessionId: SessionId;
196
+ readonly requestedPreset: string;
197
+ };
198
+ 'session/attachment-invalid': {
199
+ readonly reason: string;
200
+ };
201
+ 'session/queue-item-not-found': {
202
+ readonly itemId: MessageId;
203
+ };
204
+ 'session/steer-unavailable': {
205
+ readonly itemId: MessageId;
206
+ };
207
+ 'session/title-invalid': {
208
+ readonly sessionId: SessionId;
209
+ };
210
+ 'session/fork-unavailable': {
211
+ readonly sessionId: SessionId;
212
+ };
213
+ 'session/migration-required': {
214
+ readonly sessionId: SessionId;
215
+ };
216
+ 'subagent/not-found': {
217
+ readonly parentSessionId: SessionId;
218
+ readonly childSessionId: SessionId;
219
+ };
220
+ 'subagent/catalog-diagnostic': {
221
+ readonly parentSessionId: SessionId;
222
+ readonly childSessionId: SessionId;
223
+ readonly reason: 'corrupt' | 'unsupported' | 'unavailable';
224
+ };
225
+ }
226
+ }
227
+ /** Session-addressed request for the human-invocable skill catalog. */
228
+ export interface SkillListRequest {
229
+ readonly sessionId: SessionId;
230
+ }
231
+ /** One skill available to the Session's human-facing composer. */
232
+ export interface SkillEntry {
233
+ /** Absolute SKILL.md path when supplied by a filesystem provider. */
234
+ readonly path?: string;
235
+ /** Kebab-case identifier referenced as `/name`. */
236
+ readonly name: string;
237
+ /** Short routing description. */
238
+ readonly description: string;
239
+ /** Optional extra routing guidance. */
240
+ readonly whenToUse?: string;
241
+ /** Whether the same skill is also advertised to the model. */
242
+ readonly modelInvocable: boolean;
243
+ }
244
+ /** Human-invocable skills visible through one Session's composition. */
245
+ export interface SkillListValue {
246
+ readonly skills: readonly SkillEntry[];
247
+ }
248
+ /** Session list request. */
249
+ export interface SessionListRequest {
250
+ readonly cursor?: string;
251
+ }
252
+ /** Session list response value. */
253
+ export interface SessionListValue {
254
+ readonly items: readonly SessionSummary[];
255
+ }
256
+ /** Session search request. */
257
+ export interface SessionSearchRequest {
258
+ readonly query: string;
259
+ }
260
+ /** Session search response value. */
261
+ export interface SessionSearchValue {
262
+ readonly items: readonly SessionSearchItem[];
263
+ readonly hasMore: boolean;
264
+ }
265
+ /** Request for a Session for a new conversation. */
266
+ export interface SessionCreateRequest {
267
+ /** Workspace the Session joins; exclusive with `cwd`. */
268
+ readonly workspaceId?: WorkspaceId;
269
+ /** Directory the Session owns when no Workspace is named. */
270
+ readonly cwd?: string;
271
+ /** Blank Session to reuse while it is reusable, or the identity of a new Session when none is stored under it. */
272
+ readonly sessionId?: SessionId;
273
+ /** Preset the Session runs, replacing a reused Session's recorded preset; the configured default when omitted. */
274
+ readonly agentPreset?: string;
275
+ }
276
+ /** Session creation response value. */
277
+ export interface SessionCreateValue {
278
+ /** The created or reused Session, which may differ from the requested `sessionId`. */
279
+ readonly sessionId: SessionId;
280
+ /** Preset the Session runs, when the deployment composes a preset roster. */
281
+ readonly agentPreset?: string;
282
+ }
283
+ /** Session model-selection request. */
284
+ export interface SessionSelectModelRequest extends ModelSelection {
285
+ readonly sessionId: SessionId;
286
+ }
287
+ /** Accepted model selection after Host resolution. */
288
+ export interface SessionSelectModelValue {
289
+ readonly selected: ModelSelection;
290
+ }
291
+ /** Session rename request. */
292
+ export interface SessionRenameRequest {
293
+ readonly sessionId: SessionId;
294
+ readonly title: string;
295
+ }
296
+ /** Normalized title and the durable event position that committed it. */
297
+ export interface SessionRenameValue {
298
+ readonly title: string;
299
+ readonly seq: number;
300
+ }
301
+ /** Session fork request. */
302
+ export interface SessionForkRequest {
303
+ readonly sessionId: SessionId;
304
+ /** Exact inclusive source event seq; omission selects the latest completed-turn prefix. */
305
+ readonly atSeq?: number;
306
+ /** False asks the Host to check for required migration before forking. Defaults to true. */
307
+ readonly allowMigration?: boolean;
308
+ }
309
+ /** Identity of a newly forked Session. */
310
+ export interface SessionForkValue {
311
+ readonly sessionId: SessionId;
312
+ }
313
+ /** Session prompt request. */
314
+ export interface SessionPromptRequest {
315
+ /** Client-minted identity persisted on the accepted inbox input, including empty continuation. */
316
+ readonly requestId: SessionRequestId;
317
+ readonly sessionId: SessionId;
318
+ readonly mode: 'queue' | 'steer';
319
+ /** Non-whitespace text or attachments; an empty array continues an eligible failed idle Session. */
320
+ readonly content: readonly PromptContentPart[];
321
+ readonly clientTimeZone?: string;
322
+ }
323
+ /** Receipt after one prompt enters the target Agent inbox. */
324
+ export interface SessionPromptValue {
325
+ readonly accepted: true;
326
+ }
327
+ /** Durable image read request. */
328
+ export interface SessionAttachmentRequest {
329
+ /** Gateway permission scope only; neither Session existence nor its image references are checked. */
330
+ readonly sessionId: SessionId;
331
+ readonly attachment: ImageAttachmentRef;
332
+ }
333
+ /** Durable image read response value. */
334
+ export interface SessionAttachmentValue {
335
+ /** Supplied reference after ID, format, byte length, and dimensions verification; display fields are preserved. */
336
+ readonly attachment: ImageAttachmentRef;
337
+ readonly data: string;
338
+ }
339
+ /** Pending queue mutation request. */
340
+ export interface SessionUpdateQueueRequest {
341
+ readonly sessionId: SessionId;
342
+ readonly itemId: MessageId;
343
+ readonly action: QueueAction;
344
+ }
345
+ /** Receipt after one pending queue mutation commits. */
346
+ export interface SessionUpdateQueueValue {
347
+ readonly accepted: true;
348
+ }
349
+ /** Active-turn cancellation request. */
350
+ export interface SessionCancelRequest {
351
+ readonly sessionId: SessionId;
352
+ }
353
+ /** Receipt after cancellation is admitted to the live Agent. */
354
+ export interface SessionCancelValue {
355
+ readonly accepted: true;
356
+ }
357
+ /** Request to open one path prepared by a Session-aware caller on the Host desktop. */
358
+ export interface SessionOpenWorkspacePathRequest {
359
+ /** File-manager navigation when requested; omission uses the default application. */
360
+ readonly action?: 'reveal';
361
+ /** Registered application identifier; ignored for reveal. Omission preserves the operating system default. */
362
+ readonly application?: string;
363
+ /** Path after best-effort Session workspace resolution, in Host filesystem syntax. */
364
+ readonly path: string;
365
+ }
366
+ /** Confirmation that the Host handed a workspace path to its native opener. */
367
+ export interface SessionOpenWorkspacePathValue {
368
+ readonly opened: true;
369
+ }
370
+ /** Client-minted prompt identity used to reconcile optimistic and durable messages. */
371
+ export type SessionRequestId = Branded<'session-request-id'>;
372
+ declare module '@unieai/rabi-llm' {
373
+ interface MessageSourceMap {
374
+ /**
375
+ * Browser prompt correlation, optional Host-validated time zone, and the
376
+ * caller that submitted the prompt. `principal` is written only for a
377
+ * caller other than the owner, so an absent `principal` means the owner.
378
+ */
379
+ 'user-rpc': {
380
+ kind: 'user';
381
+ rpcId: SessionRequestId;
382
+ clientTimeZone?: string;
383
+ principal?: Principal;
384
+ };
385
+ /** Empty retry user message with browser prompt correlation and caller metadata. */
386
+ 'retry-rpc': {
387
+ kind: 'retry';
388
+ rpcId: SessionRequestId;
389
+ clientTimeZone?: string;
390
+ principal?: Principal;
391
+ };
392
+ }
393
+ }
394
+ /** Durable identity selecting an ordinary Session or one direct subagent child. */
395
+ export type SessionAddress = {
396
+ readonly kind: 'session';
397
+ readonly sessionId: SessionId;
398
+ } | {
399
+ readonly kind: 'subagent';
400
+ readonly parentSessionId: SessionId;
401
+ readonly childSessionId: SessionId;
402
+ readonly mode: 'one-shot' | 'continuable' | 'unknown';
403
+ };
404
+ /** One non-activating Session projection read. */
405
+ export interface SessionProjectionsRequest {
406
+ readonly sessionId: SessionId;
407
+ }
408
+ /** Exact projections carry their event cut; required migration returns sequence-free cache hints. Null means absent. */
409
+ export type SessionProjectionsValue = (SessionProjectionBaseline & {
410
+ readonly kind: 'sequenced';
411
+ }) | {
412
+ readonly kind: 'migration-required';
413
+ readonly values: SessionProjectionValues;
414
+ } | null;
415
+ /** One raw Session event in the Remote journal. */
416
+ export interface SessionEventEntry {
417
+ readonly type: 'event';
418
+ readonly event: SessionWireEvent;
419
+ }
420
+ /** Current logical Session metadata carried on the browser wire. */
421
+ export interface SessionWireHeader {
422
+ readonly version: number;
423
+ readonly id: SessionId;
424
+ readonly createdAt: number;
425
+ readonly cwd?: string;
426
+ readonly parentSession?: SessionId;
427
+ /** Whether the Session contains a fork-inherited prefix. */
428
+ readonly isSeeded: boolean;
429
+ readonly origin?: 'subagent';
430
+ readonly delegationDepth?: number;
431
+ readonly agentPreset?: string;
432
+ }
433
+ /** Browser wire surface operation; replacement endpoints are earlier event seqs in surface order. */
434
+ export type SessionWireSurfaceOp = 'append' | {
435
+ readonly op: 'replace';
436
+ readonly startSeq: number;
437
+ readonly endSeq: number;
438
+ };
439
+ /** One history-page record with compact Assistant streams embedded inside events. */
440
+ export type SessionHistoryRecord = SessionEventEntry;
441
+ /**
442
+ * Exact Session event envelope accepted by the Client journal adapter.
443
+ * Surface events require surfaceOp; only non-Assistant surface events may cite earlier sources.
444
+ * Durable readers own recognition of merge-extensible event names.
445
+ */
446
+ export interface SessionWireEvent {
447
+ readonly type: string;
448
+ readonly seq: number;
449
+ readonly time: number;
450
+ readonly data: JsonValue;
451
+ readonly ignorable?: true;
452
+ /** Earlier sources on current surface events; opaque JSON on unknown ignorable events. */
453
+ readonly sourceEventSeqs?: JsonValue;
454
+ /** Canonical placement on current surface events; opaque JSON on unknown ignorable events. */
455
+ readonly surfaceOp?: JsonValue;
456
+ }
457
+ /** One message-aligned backwards-history request. */
458
+ export interface SessionPageRequest {
459
+ readonly address: SessionAddress;
460
+ /**
461
+ * Inclusive log cut; omission selects the observed log end. A follow opening
462
+ * reports the cut it covered so a caller can pin the same point.
463
+ */
464
+ readonly throughSeq?: number;
465
+ readonly beforeSeq?: number;
466
+ readonly maxMessages?: number;
467
+ /** Stop at a Turn start after both minima, unless maxMessages or history exhaustion wins. */
468
+ readonly turnWindow?: {
469
+ /** Minimum append-origin user/assistant messages; must not exceed maxMessages. */
470
+ readonly minMessages: number;
471
+ /** Minimum Turn starts crossed, including the partial Turn at beforeSeq. */
472
+ readonly minTurns: number;
473
+ };
474
+ }
475
+ /** One live event request for a durable Session address. */
476
+ export interface SessionFollowRequest extends Pick<SessionPageRequest, 'maxMessages' | 'turnWindow'> {
477
+ readonly address: SessionAddress;
478
+ /** Request background activation; omission leaves the read passive. */
479
+ readonly activate?: boolean;
480
+ /** Include process-local assistant presentation frames for the Web client. */
481
+ readonly assistantStream?: true;
482
+ }
483
+ /** One active assistant attempt in a reconnect opening snapshot. */
484
+ export interface SessionAssistantStreamAttempt {
485
+ readonly attemptId: LlmAttemptId;
486
+ /** Last durable Session seq observed when this attempt started. */
487
+ readonly startedAfterSeq: SessionSeqCursor;
488
+ readonly turn: number;
489
+ readonly step: number;
490
+ /** Dense position expected for the next live chunk frame. */
491
+ readonly nextIndex: number;
492
+ /** Compact detached stream accumulated at this opening revision. */
493
+ readonly stream: readonly JsonValue[];
494
+ }
495
+ /** Complete process-local assistant state at one follow opening. */
496
+ export interface SessionAssistantStreamBaseline {
497
+ readonly revision: number;
498
+ readonly activeAttempt?: SessionAssistantStreamAttempt;
499
+ }
500
+ /** Browser wire form of one process-local assistant frame. */
501
+ export type SessionAssistantStreamFrame = {
502
+ readonly type: 'start';
503
+ readonly attemptId: LlmAttemptId;
504
+ readonly revision: number;
505
+ readonly startedAfterSeq: SessionSeqCursor;
506
+ readonly turn: number;
507
+ readonly step: number;
508
+ } | {
509
+ readonly type: 'chunk';
510
+ readonly attemptId: LlmAttemptId;
511
+ readonly revision: number;
512
+ readonly index: number;
513
+ readonly time: number;
514
+ readonly chunk: JsonValue;
515
+ } | {
516
+ readonly type: 'end';
517
+ readonly attemptId: LlmAttemptId;
518
+ readonly revision: number;
519
+ /** Number of chunk frames represented by this terminal marker. */
520
+ readonly index: number;
521
+ readonly outcome: {
522
+ readonly kind: 'committed';
523
+ readonly eventType: 'assistant/message' | 'assistant/attempt';
524
+ readonly seq: number;
525
+ } | {
526
+ readonly kind: 'abandoned';
527
+ };
528
+ };
529
+ /** One contiguous backwards page of a Session log. */
530
+ export interface SessionPage {
531
+ readonly records: readonly SessionHistoryRecord[];
532
+ readonly hasMore: boolean;
533
+ }
534
+ /** Complete opening window followed by ordered durable events and opted-in assistant frames. */
535
+ export type SessionFollowFrame = {
536
+ readonly type: 'snapshot';
537
+ readonly header: SessionWireHeader;
538
+ readonly cursor: number;
539
+ readonly records: readonly SessionHistoryRecord[];
540
+ readonly hasMore: boolean;
541
+ readonly projections: SessionProjectionBaseline;
542
+ readonly assistantStream?: SessionAssistantStreamBaseline;
543
+ } | SessionEventEntry | {
544
+ readonly type: 'assistant-stream';
545
+ readonly frame: SessionAssistantStreamFrame;
546
+ };
547
+ /** Complete live control baseline emitted once per control stream generation. */
548
+ export interface SessionControlBaseline {
549
+ readonly projections: Readonly<Record<SessionId, SessionProjectionBaseline>>;
550
+ }
551
+ /**
552
+ * Projection changes caused by one committed Session event; the Host emits one
553
+ * update per event that changed at least one client-visible projection view.
554
+ */
555
+ export interface SessionProjectionUpdate {
556
+ readonly sessionId: SessionId;
557
+ /** Seq of the committed event that caused every listed change. */
558
+ readonly seq: number;
559
+ /**
560
+ * One entry per client-visible key whose view the event changed, in
561
+ * registration order without duplicate keys, with the key's new value as
562
+ * `val`. A key absent from `changes` is unchanged; unlike a baseline, absence
563
+ * does not mean an absent capability.
564
+ */
565
+ readonly changes: readonly {
566
+ readonly key: string;
567
+ readonly val: SessionProjectionValue;
568
+ }[];
569
+ }
570
+ /** Host-wide live state stream. Each generation starts with exactly one baseline. */
571
+ export type SessionControlFrame = {
572
+ readonly type: 'baseline';
573
+ readonly value: SessionControlBaseline;
574
+ } | ({
575
+ readonly type: 'projection';
576
+ } & SessionProjectionUpdate);
577
+ /** One pending live-Agent inbox item, preserving placement and content order. */
578
+ export interface SessionQueuedItem {
579
+ readonly id: MessageId;
580
+ readonly placement: 'queued' | 'steering' | 'context';
581
+ readonly rpcId?: SessionRequestId;
582
+ readonly content: readonly JsonValue[];
583
+ }
584
+ /** State-owned classification of pending forwarded Remote events. */
585
+ export type SessionPendingInput = 'approval' | 'question' | 'other';
586
+ /** Passive Session state; a missing live Agent has no readable queue. */
587
+ export interface SessionState {
588
+ readonly cursor: number;
589
+ readonly active: boolean;
590
+ readonly running: boolean;
591
+ readonly queue: readonly SessionQueuedItem[] | null;
592
+ /**
593
+ * Pending Remote requests sampled when this state was read. A pending change alone does not
594
+ * trigger `observeState`; `wait` refreshes on its own interval.
595
+ */
596
+ readonly pendingInput: readonly SessionPendingInput[];
597
+ }
598
+ /** Session identity for a passive state read or subscription. */
599
+ export interface SessionStateRequest {
600
+ readonly sessionId: SessionId;
601
+ }
602
+ /** Wait bounds and assistant output window; timeout omission uses the fixed 30-second default. */
603
+ export interface SessionWaitRequest extends SessionStateRequest {
604
+ readonly timeoutMs?: number;
605
+ /** Exclusive output cursor; omission includes all available assistant records. */
606
+ readonly afterSeq?: number;
607
+ /** Positive assistant-record limit; omission uses the history message budget. */
608
+ readonly maxMessages?: number;
609
+ }
610
+ /** Assistant messages after afterSeq through the stopping state's cursor, newest first. */
611
+ export interface SessionWaitOutput {
612
+ readonly records: readonly SessionHistoryRecord[];
613
+ /** More eligible assistant messages exist in the selected interval. */
614
+ readonly truncated: boolean;
615
+ }
616
+ /** A stopping condition, the last complete passive state and its bounded assistant output. */
617
+ export interface SessionWaitValue {
618
+ readonly reason: 'idle' | 'input-required' | 'timeout';
619
+ readonly state: SessionState;
620
+ readonly output: SessionWaitOutput;
621
+ }
622
+ /**
623
+ * One `session.events` page (or its deprecated `page` alias) with its inclusive cut:
624
+ * the supplied `throughSeq`, otherwise the log end it was read at.
625
+ */
626
+ export interface SessionEventsPage extends SessionPage {
627
+ readonly cursor: number;
628
+ }
629
+ /** Address for a passive event subscription. */
630
+ export interface SessionObserveEventRequest {
631
+ readonly address: SessionAddress;
632
+ }
633
+ /** Readiness confirms subscription only; event continuity starts with the first delivered event. */
634
+ export type SessionEventFrame = {
635
+ readonly type: 'ready';
636
+ } | SessionEventEntry;
637
+ /** Projection changes caused by one committed event of the observed Session. */
638
+ export type SessionProjectionChange = {
639
+ readonly type: 'projection';
640
+ } & Omit<SessionProjectionUpdate, 'sessionId'>;
641
+ /** Subscription readiness without a baseline, followed by one change frame per committed event. */
642
+ export type SessionProjectionFrame = {
643
+ readonly type: 'ready';
644
+ } | SessionProjectionChange;
645
+ declare module '@unieai/cordis' {
646
+ interface Events {
647
+ /**
648
+ * A Session became visible or its Agent was created or disposed.
649
+ * Consumers upsert the summary and replace its current running and availability state.
650
+ * @mode emit
651
+ * @param summary - current list row for the Session.
652
+ */
653
+ 'api-session/added'(summary: SessionSummary): void;
654
+ /**
655
+ * A Session left the live Host registry.
656
+ * @mode emit
657
+ * @param sessionId - removed Session identity.
658
+ */
659
+ 'api-session/removed'(sessionId: SessionId): void;
660
+ /**
661
+ * One Agent changed running state.
662
+ * @mode emit
663
+ * @param sessionId - Agent and Session identity.
664
+ * @param running - whether the Agent is running.
665
+ */
666
+ 'api-session/status'(sessionId: SessionId, running: boolean): void;
667
+ /**
668
+ * One user-authored durable message advanced Session list activity.
669
+ * @mode emit
670
+ * @param sessionId - addressed Session identity.
671
+ * @param updatedAt - durable message time used for list ordering.
672
+ */
673
+ 'api-session/activity'(sessionId: SessionId, updatedAt: number): void;
674
+ /**
675
+ * One Agent failed outside a durable turn position.
676
+ * @mode emit
677
+ * @param sessionId - Agent and Session identity.
678
+ * @param message - user-safe failure chain.
679
+ */
680
+ 'api-session/error'(sessionId: SessionId, message: string): void;
681
+ }
682
+ }
683
+ /** JSON-compatible projection value accepted by list consumers. */
684
+ export type SessionProjectionValue = JsonValue;
685
+ /** Application metadata returned by the serving desktop for one file. */
686
+ export type SessionWorkspacePathApplication = NativeFileApplication;
687
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Browser-safe request, result, and lifecycle vocabulary for the Session Remote service. */
2
+ /** Maximum number of Sessions returned by one search. */
3
+ export const SESSION_SEARCH_RESULT_LIMIT = 20;
4
+ /** Maximum search snippet length in Unicode code points. */
5
+ export const SESSION_SEARCH_SNIPPET_MAX_CODE_POINTS = 240;