@maiaos/client-core 0.1.0-canary.6 → 0.1.0-canary.61

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/README.md CHANGED
@@ -5,9 +5,10 @@ a client's renderer and
5
5
  [`@maiaos/sdk`](https://github.com/vllnt/maia/blob/main/packages/sdk/README.md),
6
6
  so every client reads Maia Node state and sends requests the same way.
7
7
 
8
- > **Pre-release.** npm carries only `nightly` and `canary` builds, which are
9
- > not release-qualified. No stable release exists
10
- > ([D-132](https://github.com/vllnt/maia/blob/main/docs/decisions.md#d-132)).
8
+ > **Pre-release.** Maia publishes `canary` builds to npm only, and `latest` follows the newest
9
+ > one (earlier nightly builds are historical). They are not release-qualified,
10
+ > and Maia has no stable release
11
+ > ([D-202](https://maia-os.vllnt.com/en/docs/decisions#d-202)).
11
12
  > Nothing in this package is a stability promise: entry points, names and
12
13
  > shapes can change in any build.
13
14
 
@@ -15,7 +16,7 @@ Two Maia clients share it. The Expo client,
15
16
  [`@maiaos/client`](https://github.com/vllnt/maia/blob/main/apps/client/README.md)
16
17
  (Desktop and mobile), uses it today. The `maia` CLI will use it for its
17
18
  terminal dashboard
18
- ([D-161](https://github.com/vllnt/maia/blob/main/docs/decisions.md#d-161),
19
+ ([D-161](https://maia-os.vllnt.com/en/docs/decisions#d-161),
19
20
  planned; the CLI does not use it yet).
20
21
 
21
22
  ## Requirements
@@ -26,7 +27,7 @@ installs with this package.
26
27
  ## Install
27
28
 
28
29
  ```sh
29
- pnpm add @maiaos/client-core@nightly # or @canary, or an exact version
30
+ pnpm add @maiaos/client-core@canary # or an exact version
30
31
  ```
31
32
 
32
33
  ## Usage
@@ -100,7 +101,7 @@ protocol client and Maia Node is the authority.
100
101
  not release-qualified. The cockpit follows today's `observe.events` feed; the
101
102
  planned R1 aggregate subscription, view store and reconnect policy will replace
102
103
  its index load here; see the
103
- [client architecture](https://github.com/vllnt/maia/blob/main/docs/clients/architecture.md).
104
+ [client architecture](https://maia-os.vllnt.com/en/docs/clients/architecture).
104
105
 
105
106
  - **Bulk creation.** A preview fixes every target, task and command ID and
106
107
  carries a digest; one confirmation runs it once, within its expiry. Each
@@ -119,7 +120,7 @@ its index load here; see the
119
120
 
120
121
  ## Links
121
122
 
122
- - [Desktop and mobile client architecture](https://github.com/vllnt/maia/blob/main/docs/clients/architecture.md)
123
+ - [Desktop and mobile client architecture](https://maia-os.vllnt.com/en/docs/clients/architecture)
123
124
  - [`@maiaos/sdk`](https://github.com/vllnt/maia/blob/main/packages/sdk/README.md)
124
125
  - [Security policy](https://github.com/vllnt/maia/blob/main/SECURITY.md)
125
126
  - [Repository](https://github.com/vllnt/maia)
@@ -261,7 +261,9 @@ const requestPreview = (client, item, workspaceId) => Effect.flatMap(nextCompact
261
261
  executor: item.executor,
262
262
  nativeId: item.nativeId,
263
263
  workspaceId,
264
- }, options)));
264
+ }, options))).pipe(Effect.flatMap((outcome) => "alreadyAdopted" in outcome
265
+ ? Effect.fail(refusal("session.adopt.preview", `Maia Session ${outcome.alreadyAdopted.sessionId} already adopted this session.`))
266
+ : Effect.succeed(outcome)));
265
267
  const previewOne = (client, ref, { item, projectId }) => adoptionWorkspace(client, projectId).pipe(Effect.flatMap((workspaceId) => requestPreview(client, item, workspaceId)), Effect.matchEffect({
266
268
  onFailure: (error) => refuseAdoption(ref, item, error),
267
269
  onSuccess: (preview) => setAdoption(ref, { ...item, preview, stage: "previewed" }),
@@ -60,11 +60,13 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
60
60
  readonly updatedAt: string;
61
61
  readonly workspaceId: string;
62
62
  readonly workspaceRevision: string;
63
+ readonly activity?: "idle" | "stopped" | "waiting_approval" | "working" | undefined;
63
64
  readonly agentDefinitionRef?: {
64
65
  readonly contentDigest: string;
65
66
  readonly key: string;
66
67
  readonly version: string;
67
68
  } | undefined;
69
+ readonly containment?: "none" | undefined;
68
70
  readonly executor?: {
69
71
  readonly connectionId: string;
70
72
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
@@ -75,7 +77,29 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
75
77
  readonly code: string;
76
78
  readonly message: string;
77
79
  } | undefined;
80
+ readonly labels?: {
81
+ readonly [x: string]: string;
82
+ } | undefined;
83
+ readonly latestTurnId?: string | undefined;
84
+ readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
85
+ readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
86
+ readonly prompt?: {
87
+ readonly approvalId: string;
88
+ readonly expiresAt: string;
89
+ readonly kind: "command" | "file_change" | "question" | "tool";
90
+ readonly options?: readonly {
91
+ readonly label: string;
92
+ readonly optionId: string;
93
+ }[] | undefined;
94
+ readonly summary?: string | undefined;
95
+ } | undefined;
96
+ readonly recovery?: {
97
+ readonly code: string;
98
+ readonly message: string;
99
+ } | undefined;
78
100
  readonly schemaVersion: 4;
101
+ readonly settledReason?: "failed" | "idle" | "stopped" | undefined;
102
+ readonly status?: "approval" | "compacting" | "done" | "ended" | "error" | "idle" | "question" | "rate_limited" | "starting" | "unknown" | "working" | undefined;
79
103
  readonly title?: string | undefined;
80
104
  readonly worktree?: {
81
105
  readonly baseRef: string;
@@ -104,11 +128,13 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
104
128
  readonly updatedAt: string;
105
129
  readonly workspaceId: string;
106
130
  readonly workspaceRevision: string;
131
+ readonly activity?: "idle" | "stopped" | "waiting_approval" | "working" | undefined;
107
132
  readonly agentDefinitionRef?: {
108
133
  readonly contentDigest: string;
109
134
  readonly key: string;
110
135
  readonly version: string;
111
136
  } | undefined;
137
+ readonly containment?: "none" | undefined;
112
138
  readonly executor?: {
113
139
  readonly connectionId: string;
114
140
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
@@ -119,7 +145,29 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
119
145
  readonly code: string;
120
146
  readonly message: string;
121
147
  } | undefined;
148
+ readonly labels?: {
149
+ readonly [x: string]: string;
150
+ } | undefined;
151
+ readonly latestTurnId?: string | undefined;
152
+ readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
153
+ readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
154
+ readonly prompt?: {
155
+ readonly approvalId: string;
156
+ readonly expiresAt: string;
157
+ readonly kind: "command" | "file_change" | "question" | "tool";
158
+ readonly options?: readonly {
159
+ readonly label: string;
160
+ readonly optionId: string;
161
+ }[] | undefined;
162
+ readonly summary?: string | undefined;
163
+ } | undefined;
164
+ readonly recovery?: {
165
+ readonly code: string;
166
+ readonly message: string;
167
+ } | undefined;
122
168
  readonly schemaVersion: 4;
169
+ readonly settledReason?: "failed" | "idle" | "stopped" | undefined;
170
+ readonly status?: "approval" | "compacting" | "done" | "ended" | "error" | "idle" | "question" | "rate_limited" | "starting" | "unknown" | "working" | undefined;
123
171
  readonly title?: string | undefined;
124
172
  readonly worktree?: {
125
173
  readonly baseRef: string;
@@ -91,11 +91,13 @@ export declare const watchSessionList: (view: import("./collection-view.js").Col
91
91
  readonly updatedAt: string;
92
92
  readonly workspaceId: string;
93
93
  readonly workspaceRevision: string;
94
+ readonly activity?: "idle" | "stopped" | "waiting_approval" | "working" | undefined;
94
95
  readonly agentDefinitionRef?: {
95
96
  readonly contentDigest: string;
96
97
  readonly key: string;
97
98
  readonly version: string;
98
99
  } | undefined;
100
+ readonly containment?: "none" | undefined;
99
101
  readonly executor?: {
100
102
  readonly connectionId: string;
101
103
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
@@ -106,7 +108,29 @@ export declare const watchSessionList: (view: import("./collection-view.js").Col
106
108
  readonly code: string;
107
109
  readonly message: string;
108
110
  } | undefined;
111
+ readonly labels?: {
112
+ readonly [x: string]: string;
113
+ } | undefined;
114
+ readonly latestTurnId?: string | undefined;
115
+ readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
116
+ readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
117
+ readonly prompt?: {
118
+ readonly approvalId: string;
119
+ readonly expiresAt: string;
120
+ readonly kind: "command" | "file_change" | "question" | "tool";
121
+ readonly options?: readonly {
122
+ readonly label: string;
123
+ readonly optionId: string;
124
+ }[] | undefined;
125
+ readonly summary?: string | undefined;
126
+ } | undefined;
127
+ readonly recovery?: {
128
+ readonly code: string;
129
+ readonly message: string;
130
+ } | undefined;
109
131
  readonly schemaVersion: 4;
132
+ readonly settledReason?: "failed" | "idle" | "stopped" | undefined;
133
+ readonly status?: "approval" | "compacting" | "done" | "ended" | "error" | "idle" | "question" | "rate_limited" | "starting" | "unknown" | "working" | undefined;
110
134
  readonly title?: string | undefined;
111
135
  readonly worktree?: {
112
136
  readonly baseRef: string;
@@ -75,11 +75,13 @@ export declare const makeSessionListView: (target: PortfolioProject, emit: (stat
75
75
  readonly updatedAt: string;
76
76
  readonly workspaceId: string;
77
77
  readonly workspaceRevision: string;
78
+ readonly activity?: "idle" | "stopped" | "waiting_approval" | "working" | undefined;
78
79
  readonly agentDefinitionRef?: {
79
80
  readonly contentDigest: string;
80
81
  readonly key: string;
81
82
  readonly version: string;
82
83
  } | undefined;
84
+ readonly containment?: "none" | undefined;
83
85
  readonly executor?: {
84
86
  readonly connectionId: string;
85
87
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
@@ -90,7 +92,29 @@ export declare const makeSessionListView: (target: PortfolioProject, emit: (stat
90
92
  readonly code: string;
91
93
  readonly message: string;
92
94
  } | undefined;
95
+ readonly labels?: {
96
+ readonly [x: string]: string;
97
+ } | undefined;
98
+ readonly latestTurnId?: string | undefined;
99
+ readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
100
+ readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
101
+ readonly prompt?: {
102
+ readonly approvalId: string;
103
+ readonly expiresAt: string;
104
+ readonly kind: "command" | "file_change" | "question" | "tool";
105
+ readonly options?: readonly {
106
+ readonly label: string;
107
+ readonly optionId: string;
108
+ }[] | undefined;
109
+ readonly summary?: string | undefined;
110
+ } | undefined;
111
+ readonly recovery?: {
112
+ readonly code: string;
113
+ readonly message: string;
114
+ } | undefined;
93
115
  readonly schemaVersion: 4;
116
+ readonly settledReason?: "failed" | "idle" | "stopped" | undefined;
117
+ readonly status?: "approval" | "compacting" | "done" | "ended" | "error" | "idle" | "question" | "rate_limited" | "starting" | "unknown" | "working" | undefined;
94
118
  readonly title?: string | undefined;
95
119
  readonly worktree?: {
96
120
  readonly baseRef: string;
@@ -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.6",
3
+ "version": "0.1.0-canary.61",
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.6",
97
+ "@maiaos/sdk": "0.1.0-canary.61",
98
98
  "effect": "4.0.0"
99
99
  },
100
100
  "devDependencies": {