@unieai/rabi-api-session-controller 0.0.0-stage → 0.2.1-rc.3

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