@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.
- package/LICENSE +21 -0
- package/README.md +7 -2
- package/lib/client.js +4 -0
- package/lib/index.js +4300 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +5013 -0
- package/lib/typert.remote-client.d.ts +115 -0
- package/lib/typert.remote-client.js +2714 -0
- package/lib/types/agent.d.ts +164 -0
- package/lib/types/agent.js +484 -0
- package/lib/types/archived-session-gate.d.ts +33 -0
- package/lib/types/archived-session-gate.js +54 -0
- package/lib/types/assistant-stream.d.ts +26 -0
- package/lib/types/assistant-stream.js +82 -0
- package/lib/types/catalog.d.ts +24 -0
- package/lib/types/catalog.js +107 -0
- package/lib/types/client/contract/events.d.ts +102 -0
- package/lib/types/client/contract/events.js +111 -0
- package/lib/types/client/contract/session.d.ts +178 -0
- package/lib/types/client/contract/session.js +1 -0
- package/lib/types/client/contract/sessions.d.ts +162 -0
- package/lib/types/client/contract/sessions.js +1 -0
- package/lib/types/client/contract/snapshot.d.ts +84 -0
- package/lib/types/client/contract/snapshot.js +1 -0
- package/lib/types/client/index.d.ts +39 -0
- package/lib/types/client/index.js +60 -0
- package/lib/types/client/ordered-baseline.d.ts +12 -0
- package/lib/types/client/ordered-baseline.js +40 -0
- package/lib/types/client/scope.d.ts +46 -0
- package/lib/types/client/scope.js +46 -0
- package/lib/types/client/session-wire-event.d.ts +11 -0
- package/lib/types/client/session-wire-event.js +42 -0
- package/lib/types/client/sessions/assistant-stream.d.ts +56 -0
- package/lib/types/client/sessions/assistant-stream.js +182 -0
- package/lib/types/client/sessions/history-records.d.ts +22 -0
- package/lib/types/client/sessions/history-records.js +25 -0
- package/lib/types/client/sessions/lineage.d.ts +48 -0
- package/lib/types/client/sessions/lineage.js +55 -0
- package/lib/types/client/sessions/manager.d.ts +272 -0
- package/lib/types/client/sessions/manager.js +774 -0
- package/lib/types/client/sessions/notifier.d.ts +39 -0
- package/lib/types/client/sessions/notifier.js +97 -0
- package/lib/types/client/sessions/projection-store.d.ts +128 -0
- package/lib/types/client/sessions/projection-store.js +161 -0
- package/lib/types/client/sessions/remotes.d.ts +29 -0
- package/lib/types/client/sessions/remotes.js +7 -0
- package/lib/types/client/sessions/service.d.ts +263 -0
- package/lib/types/client/sessions/service.js +597 -0
- package/lib/types/client/sessions/session.d.ts +303 -0
- package/lib/types/client/sessions/session.js +991 -0
- package/lib/types/client/time-zone.d.ts +8 -0
- package/lib/types/client/time-zone.js +13 -0
- package/lib/types/client/transport.d.ts +77 -0
- package/lib/types/client/transport.js +130 -0
- package/lib/types/commands.d.ts +92 -0
- package/lib/types/commands.js +575 -0
- package/lib/types/continuation.d.ts +35 -0
- package/lib/types/continuation.js +47 -0
- package/lib/types/control.d.ts +20 -0
- package/lib/types/control.js +106 -0
- package/lib/types/file-references.d.ts +27 -0
- package/lib/types/file-references.js +68 -0
- package/lib/types/history/assistant-stream.d.ts +43 -0
- package/lib/types/history/assistant-stream.js +79 -0
- package/lib/types/history/controller.d.ts +104 -0
- package/lib/types/history/controller.js +293 -0
- package/lib/types/history/listener.d.ts +105 -0
- package/lib/types/history/listener.js +296 -0
- package/lib/types/history.d.ts +58 -0
- package/lib/types/history.js +152 -0
- package/lib/types/index.d.ts +262 -0
- package/lib/types/index.js +693 -0
- package/lib/types/list.d.ts +62 -0
- package/lib/types/list.js +343 -0
- package/lib/types/media-references.d.ts +18 -0
- package/lib/types/media-references.js +84 -0
- package/lib/types/remote-events.d.ts +8 -0
- package/lib/types/remote-events.js +1 -0
- package/lib/types/skill-catalog.d.ts +28 -0
- package/lib/types/skill-catalog.js +203 -0
- package/lib/types/state/controller.d.ts +45 -0
- package/lib/types/state/controller.js +288 -0
- package/lib/types/state/listener.d.ts +40 -0
- package/lib/types/state/listener.js +111 -0
- package/lib/types/types.d.ts +687 -0
- package/lib/types/types.js +5 -0
- package/lib/types/web/controller.d.ts +25 -0
- package/lib/types/web/controller.js +138 -0
- package/locale/de.json +6 -0
- package/locale/en.json +5 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +119 -4
- package/src/agent.ts +474 -0
- package/src/archived-session-gate.ts +59 -0
- package/src/assistant-stream.ts +102 -0
- package/src/catalog.ts +117 -0
- package/src/client/contract/events.ts +205 -0
- package/src/client/contract/session.ts +174 -0
- package/src/client/contract/sessions.ts +169 -0
- package/src/client/contract/snapshot.ts +94 -0
- package/src/client/index.ts +149 -0
- package/src/client/ordered-baseline.ts +43 -0
- package/src/client/scope.ts +76 -0
- package/src/client/session-wire-event.ts +46 -0
- package/src/client/sessions/assistant-stream.ts +229 -0
- package/src/client/sessions/history-records.ts +35 -0
- package/src/client/sessions/lineage.ts +96 -0
- package/src/client/sessions/manager.ts +857 -0
- package/src/client/sessions/notifier.ts +97 -0
- package/src/client/sessions/projection-store.ts +244 -0
- package/src/client/sessions/remotes.ts +44 -0
- package/src/client/sessions/service.ts +741 -0
- package/src/client/sessions/session.ts +1055 -0
- package/src/client/time-zone.ts +14 -0
- package/src/client/transport.ts +247 -0
- package/src/commands.ts +602 -0
- package/src/continuation.ts +58 -0
- package/src/control.ts +121 -0
- package/src/file-references.ts +42 -0
- package/src/history/assistant-stream.ts +102 -0
- package/src/history/controller.ts +256 -0
- package/src/history/listener.ts +302 -0
- package/src/history.ts +189 -0
- package/src/index.ts +651 -0
- package/src/list.ts +382 -0
- package/src/media-references.ts +84 -0
- package/src/remote-events.ts +14 -0
- package/src/skill-catalog.ts +108 -0
- package/src/state/controller.ts +221 -0
- package/src/state/listener.ts +116 -0
- package/src/types.ts +720 -0
- package/src/web/controller.ts +78 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// flattenLineage: summaries -> flat list with lineage indentation (pure function).
|
|
2
|
+
// The input order is authoritative; lineage only makes each child adjacent to its parent.
|
|
3
|
+
// Orphaned lineage degrades to root level; cycles fail soft and emit as roots.
|
|
4
|
+
|
|
5
|
+
import type { SessionId } from '@unieai/rabi-session/types'
|
|
6
|
+
import type { SessionProjectionSummaryValues } from '@unieai/rabi-session-projection/types'
|
|
7
|
+
import type { SessionSummary } from '../../types.ts'
|
|
8
|
+
|
|
9
|
+
/** Host list summary enriched with the latest Session Controller title projection. */
|
|
10
|
+
export interface TitledSessionSummary extends SessionSummary {
|
|
11
|
+
title?: string
|
|
12
|
+
/**
|
|
13
|
+
* The row's summary projection values, never the full projection set. A
|
|
14
|
+
* connected Session's client store may hold more values from its
|
|
15
|
+
* control/follow baseline; those are outside the list contract and must not
|
|
16
|
+
* be read here.
|
|
17
|
+
*/
|
|
18
|
+
projectionValues?: Readonly<Partial<SessionProjectionSummaryValues>>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** One flattened session-list row with lineage depth. */
|
|
22
|
+
export interface SessionListEntry {
|
|
23
|
+
sessionId: SessionId
|
|
24
|
+
title?: string
|
|
25
|
+
updatedAt: number
|
|
26
|
+
running: boolean
|
|
27
|
+
/**
|
|
28
|
+
* New Session presentation and reuse eligibility, reconciled with
|
|
29
|
+
* `sessionListMetadata`; lists hide blank sessions (filtering stays with the consumer).
|
|
30
|
+
*/
|
|
31
|
+
blank: boolean
|
|
32
|
+
parentSessionId?: SessionId
|
|
33
|
+
/** Coarse durable origin for navigation filtering; not a continuation capability. */
|
|
34
|
+
origin?: 'subagent'
|
|
35
|
+
/** Format classification supplied by the Host list. */
|
|
36
|
+
formatStatus?: SessionSummary['formatStatus']
|
|
37
|
+
cwd?: string
|
|
38
|
+
/**
|
|
39
|
+
* The row's summary projection values, never the full projection set; see
|
|
40
|
+
* `TitledSessionSummary.projectionValues`.
|
|
41
|
+
*/
|
|
42
|
+
projectionValues?: Readonly<Partial<SessionProjectionSummaryValues>>
|
|
43
|
+
/** Lineage indent depth: root = 0; the UI just multiplies by the indent width. */
|
|
44
|
+
depth: number
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Summaries -> flat list with lineage indentation. Root and sibling order
|
|
49
|
+
* follows the established input order; this projection never re-sorts a
|
|
50
|
+
* hydrated list from mutable timestamps.
|
|
51
|
+
* @param summaries - the host's session.list items.
|
|
52
|
+
* @returns display rows in render order.
|
|
53
|
+
*/
|
|
54
|
+
export function flattenLineage(
|
|
55
|
+
summaries: readonly TitledSessionSummary[],
|
|
56
|
+
): SessionListEntry[] {
|
|
57
|
+
const byId = new Map<SessionId, TitledSessionSummary>()
|
|
58
|
+
for (const s of summaries) byId.set(s.sessionId, s)
|
|
59
|
+
|
|
60
|
+
const children = new Map<SessionId, TitledSessionSummary[]>()
|
|
61
|
+
const roots: TitledSessionSummary[] = []
|
|
62
|
+
for (const s of summaries) {
|
|
63
|
+
// Historical ordinary forks may retain a parent id without being subagents.
|
|
64
|
+
if (s.origin === 'subagent' && s.parentSessionId !== undefined && byId.has(s.parentSessionId)) {
|
|
65
|
+
const list = children.get(s.parentSessionId) ?? []
|
|
66
|
+
list.push(s)
|
|
67
|
+
children.set(s.parentSessionId, list)
|
|
68
|
+
} else {
|
|
69
|
+
roots.push(s) // root, or an orphan whose parent is absent from summaries (degrade to root, never drop)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const out: SessionListEntry[] = []
|
|
74
|
+
const visited = new Set<SessionId>()
|
|
75
|
+
const walk = (s: TitledSessionSummary, depth: number): void => {
|
|
76
|
+
if (visited.has(s.sessionId)) {
|
|
77
|
+
console.warn(`[session-controller] lineage cycle at ${s.sessionId}; emitting as root`)
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
visited.add(s.sessionId)
|
|
81
|
+
const { agentAvailable: _agentAvailable, ...row } = s
|
|
82
|
+
out.push({
|
|
83
|
+
...row,
|
|
84
|
+
depth,
|
|
85
|
+
})
|
|
86
|
+
const kids = children.get(s.sessionId)
|
|
87
|
+
if (kids === undefined) return
|
|
88
|
+
for (const kid of kids) walk(kid, depth + 1)
|
|
89
|
+
}
|
|
90
|
+
for (const root of roots) walk(root, 0)
|
|
91
|
+
// Cycle members (unreachable from any root): emit as roots so no entry is lost.
|
|
92
|
+
for (const s of summaries) {
|
|
93
|
+
if (!visited.has(s.sessionId)) walk(s, 0)
|
|
94
|
+
}
|
|
95
|
+
return out
|
|
96
|
+
}
|