@maiaos/client-core 0.1.0-canary.4 → 0.1.0-canary.40

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.
@@ -65,6 +65,7 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
65
65
  readonly key: string;
66
66
  readonly version: string;
67
67
  } | undefined;
68
+ readonly containment?: "none" | undefined;
68
69
  readonly executor?: {
69
70
  readonly connectionId: string;
70
71
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
@@ -75,6 +76,7 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
75
76
  readonly code: string;
76
77
  readonly message: string;
77
78
  } | undefined;
79
+ readonly latestTurnId?: string | undefined;
78
80
  readonly schemaVersion: 4;
79
81
  readonly title?: string | undefined;
80
82
  readonly worktree?: {
@@ -109,6 +111,7 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
109
111
  readonly key: string;
110
112
  readonly version: string;
111
113
  } | undefined;
114
+ readonly containment?: "none" | undefined;
112
115
  readonly executor?: {
113
116
  readonly connectionId: string;
114
117
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
@@ -119,6 +122,7 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
119
122
  readonly code: string;
120
123
  readonly message: string;
121
124
  } | undefined;
125
+ readonly latestTurnId?: string | undefined;
122
126
  readonly schemaVersion: 4;
123
127
  readonly title?: string | undefined;
124
128
  readonly worktree?: {
@@ -96,6 +96,7 @@ export declare const watchSessionList: (view: import("./collection-view.js").Col
96
96
  readonly key: string;
97
97
  readonly version: string;
98
98
  } | undefined;
99
+ readonly containment?: "none" | undefined;
99
100
  readonly executor?: {
100
101
  readonly connectionId: string;
101
102
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
@@ -106,6 +107,7 @@ export declare const watchSessionList: (view: import("./collection-view.js").Col
106
107
  readonly code: string;
107
108
  readonly message: string;
108
109
  } | undefined;
110
+ readonly latestTurnId?: string | undefined;
109
111
  readonly schemaVersion: 4;
110
112
  readonly title?: string | undefined;
111
113
  readonly worktree?: {
@@ -80,6 +80,7 @@ export declare const makeSessionListView: (target: PortfolioProject, emit: (stat
80
80
  readonly key: string;
81
81
  readonly version: string;
82
82
  } | undefined;
83
+ readonly containment?: "none" | undefined;
83
84
  readonly executor?: {
84
85
  readonly connectionId: string;
85
86
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
@@ -90,6 +91,7 @@ export declare const makeSessionListView: (target: PortfolioProject, emit: (stat
90
91
  readonly code: string;
91
92
  readonly message: string;
92
93
  } | undefined;
94
+ readonly latestTurnId?: string | undefined;
93
95
  readonly schemaVersion: 4;
94
96
  readonly title?: string | undefined;
95
97
  readonly worktree?: {
@@ -43,6 +43,8 @@ export type SessionViewState = {
43
43
  readonly observedAt?: number;
44
44
  /** An interrupt prepared for confirmation, bound to one turn revision. */
45
45
  readonly pendingInterrupt?: TurnInterruptParameters;
46
+ /** The oldest cursor the Node still holds, when it pruned earlier history. */
47
+ readonly prunedBefore?: string;
46
48
  readonly session?: Session;
47
49
  readonly source: TimelineSource["kind"];
48
50
  readonly turns: readonly TimelineTurn[];
@@ -38,14 +38,17 @@ const readDiff = (context, session) => session.worktree === undefined
38
38
  }),
39
39
  onSuccess: (diff) => ({ diffError: _error, ...state }) => ({ ...state, diff }),
40
40
  }), Effect.flatMap((change) => SubscriptionRef.update(context.ref, change)));
41
+ /** A fresh read replaces the turns and the pruned marker, and clears an error. */
42
+ const withTimeline = (session, { prunedBefore, turns }) => ({ error: _error, prunedBefore: _pruned, ...state }) => ({
43
+ ...state,
44
+ ...(prunedBefore === undefined ? {} : { prunedBefore }),
45
+ session,
46
+ turns,
47
+ });
41
48
  const refresh = (context) => Effect.gen(function* () {
42
49
  const shown = yield* read("session.show", (options) => context.client.showSession({ sessionId: context.sessionId }, options));
43
- const turns = yield* context.timeline.load(context.sessionId);
44
- yield* SubscriptionRef.update(context.ref, ({ error: _error, ...state }) => ({
45
- ...state,
46
- session: shown.session,
47
- turns,
48
- }));
50
+ const loaded = yield* context.timeline.load(context.sessionId);
51
+ yield* SubscriptionRef.update(context.ref, withTimeline(shown.session, loaded));
49
52
  yield* observed(context);
50
53
  yield* Effect.all([
51
54
  readDiff(context, shown.session),
@@ -20,7 +20,16 @@ export type TimelineTurn = {
20
20
  */
21
21
  export type TimelineSource = {
22
22
  readonly kind: "final-text";
23
- readonly load: (sessionId: string) => Effect.Effect<readonly TimelineTurn[], CockpitError>;
23
+ readonly load: (sessionId: string) => Effect.Effect<TimelineLoad, CockpitError>;
24
+ };
25
+ /**
26
+ * The recent turns and, when the Node pruned older events, the oldest cursor
27
+ * it still holds. The detail has no older-page load, so the read from cursor 0
28
+ * is the one place a hole can show.
29
+ */
30
+ export type TimelineLoad = {
31
+ readonly prunedBefore?: string;
32
+ readonly turns: readonly TimelineTurn[];
24
33
  };
25
34
  /** The most recent turns a detail shows; older ones stay on the Node. */
26
35
  export declare const MAX_TIMELINE_TURNS = 20;
@@ -14,6 +14,9 @@ const eventPage = (client, sessionId, after) => read("session.events.list", (opt
14
14
  ...(result.nextSessionCursor === undefined
15
15
  ? {}
16
16
  : { next: result.nextSessionCursor }),
17
+ ...(result.oldestRetainedCursor === undefined
18
+ ? {}
19
+ : { oldest: result.oldestRetainedCursor }),
17
20
  })));
18
21
  /** Reads the last `EVENT_WINDOW` events, never the whole history. */
19
22
  const recentEvents = (client, sessionId) => Effect.gen(function* () {
@@ -22,9 +25,11 @@ const recentEvents = (client, sessionId) => Effect.gen(function* () {
22
25
  const collect = (after, seen) => Effect.flatMap(eventPage(client, sessionId, after), (page) => page.next === undefined || page.items.length === 0
23
26
  ? Effect.succeed([...seen, ...page.items])
24
27
  : collect(page.next, [...seen, ...page.items]));
25
- return from <= 0n
26
- ? yield* collect("0", [])
27
- : yield* collect(String(from), []);
28
+ const events = from <= 0n ? yield* collect("0", []) : yield* collect(String(from), []);
29
+ return {
30
+ events,
31
+ ...(probe.oldest === undefined ? {} : { oldest: probe.oldest }),
32
+ };
28
33
  });
29
34
  const toTimeline = (turn) => ({
30
35
  ...("failureReason" in turn ? { failureReason: turn.failureReason } : {}),
@@ -38,6 +43,9 @@ const toTimeline = (turn) => ({
38
43
  /** The final-text source over `session.events.list` and `turn.show`. */
39
44
  export const finalTextTimeline = (client) => ({
40
45
  kind: "final-text",
41
- load: (sessionId) => recentEvents(client, sessionId).pipe(Effect.map((events) => [...new Set(events.flatMap((event) => turnIdOf(event) ?? []))].slice(-MAX_TIMELINE_TURNS)), Effect.flatMap((turnIds) => Effect.forEach(turnIds, (turnId) => read("turn.show", (options) => client.showTurn({ turnId }, options)).pipe(Effect.map((result) => toTimeline(result.turn))), { concurrency: 4 }))),
46
+ load: (sessionId) => recentEvents(client, sessionId).pipe(Effect.flatMap(({ events, oldest }) => Effect.forEach([...new Set(events.flatMap((event) => turnIdOf(event) ?? []))].slice(-MAX_TIMELINE_TURNS), (turnId) => read("turn.show", (options) => client.showTurn({ turnId }, options)).pipe(Effect.map((result) => toTimeline(result.turn))), { concurrency: 4 }).pipe(Effect.map((turns) => ({
47
+ ...(oldest === undefined ? {} : { prunedBefore: oldest }),
48
+ turns,
49
+ }))))),
42
50
  });
43
51
  //# sourceMappingURL=timeline.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiaos/client-core",
3
- "version": "0.1.0-canary.4",
3
+ "version": "0.1.0-canary.40",
4
4
  "description": "Platform-neutral client use cases for Maia OS: Effect services between a client's renderer and the SDK, so every client reads Maia Node state and sends requests the same way.",
5
5
  "homepage": "https://github.com/vllnt/maia/tree/main/packages/client-core#readme",
6
6
  "bugs": "https://github.com/vllnt/maia/issues",
@@ -94,7 +94,7 @@
94
94
  "node": "24.22.1"
95
95
  },
96
96
  "dependencies": {
97
- "@maiaos/sdk": "0.1.0-canary.4",
97
+ "@maiaos/sdk": "0.1.0-canary.40",
98
98
  "effect": "4.0.0"
99
99
  },
100
100
  "devDependencies": {