@maiaos/client-core 0.1.0-canary.64 → 0.1.0-canary.65

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -16
  3. package/dist/cockpit/creation.d.ts +6 -2
  4. package/dist/cockpit/creation.js +11 -3
  5. package/dist/cockpit/index.d.ts +1 -1
  6. package/dist/cockpit/index.js +1 -1
  7. package/dist/cockpit/launcher.js +2 -8
  8. package/dist/cockpit/onboarding.js +7 -7
  9. package/dist/cockpit/routing.d.ts +1 -1
  10. package/dist/cockpit/routing.js +1 -0
  11. package/dist/interaction/recovery.d.ts +2 -0
  12. package/dist/portfolio/portfolio.d.ts +28 -2
  13. package/dist/presentation/collection-view.d.ts +14 -1
  14. package/dist/presentation/collection-view.js +67 -22
  15. package/dist/presentation/index.d.ts +1 -0
  16. package/dist/presentation/index.js +1 -0
  17. package/dist/presentation/live.d.ts +11 -2
  18. package/dist/presentation/session-view.d.ts +11 -2
  19. package/dist/records/agents.d.ts +36 -0
  20. package/dist/records/agents.js +20 -0
  21. package/dist/records/held.d.ts +82 -0
  22. package/dist/records/held.js +95 -0
  23. package/dist/records/index.d.ts +15 -0
  24. package/dist/records/index.js +7 -0
  25. package/dist/records/interactions.d.ts +62 -0
  26. package/dist/records/interactions.js +33 -0
  27. package/dist/records/kind.d.ts +44 -0
  28. package/dist/records/kind.js +36 -0
  29. package/dist/records/records.d.ts +41 -0
  30. package/dist/records/records.js +103 -0
  31. package/dist/records/routines.d.ts +28 -0
  32. package/dist/records/routines.js +35 -0
  33. package/dist/records/service.d.ts +42 -0
  34. package/dist/records/service.js +46 -0
  35. package/dist/records/state.d.ts +34 -0
  36. package/dist/records/state.js +26 -0
  37. package/dist/records/surface.d.ts +19 -0
  38. package/dist/records/surface.js +23 -0
  39. package/dist/records/watch.d.ts +24 -0
  40. package/dist/records/watch.js +68 -0
  41. package/dist/session-view/conversation.js +2 -5
  42. package/package.json +23 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VLLNT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -47,22 +47,24 @@ uncertain requests and projections of Node state. It owns no transport,
47
47
  credentials, native API, Node lifecycle or durable state: the SDK is the
48
48
  protocol client and Maia Node is the authority.
49
49
 
50
- | Entry point | Responsibility |
51
- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
- | `boot` | The Desktop boot sequence: lifecycle status, one start, then status reads until the host reports a ready Node |
53
- | `navigation` | Route names, the `?q=&state=&page=` list query, parent routes and the one pagination model |
54
- | `node-status` | One truthful, point-in-time Node status projection |
55
- | `workspace-scope` | The one active Workspace scope, loaded from and replaced only by Node |
56
- | `single-session` | Voice setup, Node-provided orchestrator context and local proposals |
57
- | `terminal`, `terminal-unavailable` | Live terminal client and its explicit unavailable state |
58
- | `interaction`, `interaction-view` | Record-only questions and answers, with recovery of unknown outcomes |
59
- | `presentation` | Bounded Workspace, Project and Session list reads |
60
- | `cockpit` | Work cockpit per Node and a combined view: one bounded index, one change feed, attention, lists, launcher search, single or bulk Session creation over the SDK batch and first-run onboarding |
61
- | `session-view` | Focused Session detail: live items over `session.attach`, recent turns, summary, diff and a send, interrupt and wait composer |
62
- | `commands` | The keyboard command registry: stable IDs, Desktop and terminal keymaps, rebinding, conflicts and reserved chords |
63
- | `node-registry` | The local and registered remote Nodes a client addresses: connecting, ready, stale or unreachable (with ssh's reason, or `auth` when the Node rejects the credential) |
64
- | `session-attach` | The SDK's Session attach reducer, re-exported unchanged |
65
- | `dictation` | Composer dictation state: listening, partial text at the caret, cancel, language |
50
+ | Entry point | Responsibility |
51
+ | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
+ | `boot` | The Desktop boot sequence: lifecycle status, one start, then status reads until the host reports a ready Node |
53
+ | `navigation` | Route names, the `?q=&state=&page=` list query, parent routes and the one pagination model |
54
+ | `node-status` | One truthful, point-in-time Node status projection |
55
+ | `workspace-scope` | The one active Workspace scope, loaded from and replaced only by Node |
56
+ | `single-session` | Voice setup, Node-provided orchestrator context and local proposals |
57
+ | `terminal`, `terminal-unavailable` | Live terminal client and its explicit unavailable state |
58
+ | `interaction`, `interaction-view` | Record-only questions and answers, with recovery of unknown outcomes |
59
+ | `presentation` | Bounded Workspace, Project and Session list reads |
60
+ | `records` | Live, revision-safe Agents, Routines and Interactions: a bounded snapshot, rereads of the records a committed change names, a reload on resync, and `available`, `unavailable`, `denied` or `offline` with no data outside `available` |
61
+ | `cockpit` | Work cockpit per Node and a combined view: one bounded index, one change feed, attention, lists, launcher search, single or bulk Session creation over the SDK batch and first-run onboarding |
62
+ | `session-view` | Focused Session detail: live items over `session.attach`, recent turns, summary, diff and a send, interrupt and wait composer |
63
+ | `commands` | The keyboard command registry: stable IDs, Desktop and terminal keymaps, rebinding, conflicts and reserved chords |
64
+ | `node-registry` | The local and registered remote Nodes a client addresses: connecting, ready, stale or unreachable (with ssh's reason, or `auth` when the Node rejects the credential) |
65
+ | `session-attach` | The SDK's Session attach reducer, re-exported unchanged |
66
+ | `dictation` | Composer dictation state: listening, partial text at the caret, cancel, language |
67
+ | `id-generator` | The `IdGenerator` service and `nextUuid` and `nextCompactId`: request, command and message IDs from Effect `Random`, so a test provides a fixed generator |
66
68
 
67
69
  - **Deadlines and uncertainty.** Every request gets a unique message ID from
68
70
  the package `IdGenerator` (Effect `Random` by default) and a 5.5-second
@@ -1,7 +1,7 @@
1
- import { type Connection, type DetectedExecutor, type SessionCreationItem, type SessionCreationOutcome, type SessionCreationRefusal, type SessionCreationStage, type Workspace } from "@maiaos/sdk";
1
+ import { type Connection, type DetectedExecutor, type SessionCreationItem, type SessionCreationOutcome, type SessionCreationRefusal, type SessionCreationStage, type VendorExecutorId, type Workspace } from "@maiaos/sdk";
2
2
  import { Effect } from "effect";
3
3
  import { type CockpitClient, CockpitError } from "./client.js";
4
- export type ExecutorKind = "claude-code" | "codex-cli";
4
+ export type ExecutorKind = VendorExecutorId;
5
5
  /**
6
6
  * What a person asked for. `bulk` turns every non-empty line into one
7
7
  * Session whose first turn is that line; `single` makes one Session and
@@ -61,6 +61,10 @@ export type CreationPreview = {
61
61
  export declare const previewDigest: (text: string) => string;
62
62
  /** The executors a Session can run, as the protocol names them. */
63
63
  export declare const EXECUTOR_KINDS: readonly ExecutorKind[];
64
+ /** The executor a new Session starts on. */
65
+ export declare const DEFAULT_EXECUTOR: ExecutorKind;
66
+ /** An executor in its product name; a kind with no name shows as itself. */
67
+ export declare const executorLabel: (kind: string) => string;
64
68
  /** A gateway serves every executor; a vendor account serves its own. */
65
69
  export declare const connectionsFor: (connections: readonly Connection[], executor: ExecutorKind) => readonly Connection[];
66
70
  /** A model is a choice on a gateway Connection, never on a vendor account. */
@@ -1,4 +1,4 @@
1
- import { connectionModelIdSchema, createSessions, orderExecutionWorkspaces, planSessionCreation, sessionBaseRefSchema, } from "@maiaos/sdk";
1
+ import { connectionModelIdSchema, createSessions, EXECUTOR_IDS, orderExecutionWorkspaces, planSessionCreation, sessionBaseRefSchema, } from "@maiaos/sdk";
2
2
  import { Clock, Duration, Effect, Fiber, Option, Queue, Random, Ref, Stream, } from "effect";
3
3
  import { nextCompactId } from "../id-generator/index.js";
4
4
  import { CockpitError, read, toCockpitError, } from "./client.js";
@@ -44,9 +44,17 @@ const invalid = (message) => new CockpitError({ message, operation: "session.cre
44
44
  const randomNewId = Effect.map(Effect.service(Random.Random), (random) => (prefix) => `${prefix}_${Array.from({ length: 32 }, () => Math.floor(random.nextDoubleUnsafe() * 16).toString(16)).join("")}`);
45
45
  /** The executors a Session can run, as the protocol names them. */
46
46
  export const EXECUTOR_KINDS = [
47
- "codex-cli",
48
- "claude-code",
47
+ EXECUTOR_IDS.codex,
48
+ EXECUTOR_IDS.claudeCode,
49
49
  ];
50
+ /** The executor a new Session starts on. */
51
+ export const DEFAULT_EXECUTOR = EXECUTOR_IDS.codex;
52
+ const EXECUTOR_LABELS = new Map([
53
+ [EXECUTOR_IDS.claudeCode, "Claude Code"],
54
+ [EXECUTOR_IDS.codex, "Codex"],
55
+ ]);
56
+ /** An executor in its product name; a kind with no name shows as itself. */
57
+ export const executorLabel = (kind) => EXECUTOR_LABELS.get(kind) ?? kind;
50
58
  /** A gateway serves every executor; a vendor account serves its own. */
51
59
  export const connectionsFor = (connections, executor) => connections.filter((connection) => connection.executor === executor || connection.executor === "gateway");
52
60
  /** A model is a choice on a gateway Connection, never on a vendor account. */
@@ -7,7 +7,7 @@ export { makeCockpit, OBSERVE_CAP } from "./cockpit.js";
7
7
  export type { NodeCockpitState, NodePage, PagedNode, RemoteNodeSummary, } from "./combine.js";
8
8
  export { ALL_NODES, combineCockpits, combinePages, readRemoteNodes, } from "./combine.js";
9
9
  export type { ConnectionSummary, CreationDispatch, CreationDraft, CreationItem, CreationOutcome, CreationPreview, CreationReport, CreationStage, ExecutionWorkspace, ExecutorConnection, ExecutorDetection, ExecutorKind, ExecutorReadiness, ExecutorStatus, LineRefusal, SessionCreation, } from "./creation.js";
10
- export { acceptsModel, connectionsFor, detectExecutors, EXECUTOR_KINDS, executorStatuses, listCreationConnections, listExecutionWorkspaces, makeSessionCreation, MAX_CREATION_BATCH, MAX_TASK_BYTES, previewCreation, previewDigest, } from "./creation.js";
10
+ export { acceptsModel, connectionsFor, DEFAULT_EXECUTOR, detectExecutors, EXECUTOR_KINDS, executorLabel, executorStatuses, listCreationConnections, listExecutionWorkspaces, makeSessionCreation, MAX_CREATION_BATCH, MAX_TASK_BYTES, previewCreation, previewDigest, } from "./creation.js";
11
11
  export type { CommandAvailability, LauncherResult } from "./launcher.js";
12
12
  export { MAX_LAUNCHER_RESULTS, searchLauncher } from "./launcher.js";
13
13
  export type { Adoptability, Adoption, AdoptionChoice, CliDetection, DiscoveredRow, DiscoveryView, Onboarding, OnboardingState, Pending, ProposedProject, Registration, VendorAccount, VendorSignIn, } from "./onboarding.js";
@@ -2,7 +2,7 @@ export { attentionLabel, deriveAttention, MAX_ATTENTION_ITEMS, } from "./attenti
2
2
  export { COCKPIT_CLIENT_METHODS, COCKPIT_OPERATIONS, CockpitError, CONFIRMATION_DEADLINE_MILLISECONDS, confirmMutation, mutate, PLATFORM_DENIED, read, ReadAdmission, REQUEST_DEADLINE_MILLISECONDS, } from "./client.js";
3
3
  export { makeCockpit, OBSERVE_CAP } from "./cockpit.js";
4
4
  export { ALL_NODES, combineCockpits, combinePages, readRemoteNodes, } from "./combine.js";
5
- export { acceptsModel, connectionsFor, detectExecutors, EXECUTOR_KINDS, executorStatuses, listCreationConnections, listExecutionWorkspaces, makeSessionCreation, MAX_CREATION_BATCH, MAX_TASK_BYTES, previewCreation, previewDigest, } from "./creation.js";
5
+ export { acceptsModel, connectionsFor, DEFAULT_EXECUTOR, detectExecutors, EXECUTOR_KINDS, executorLabel, executorStatuses, listCreationConnections, listExecutionWorkspaces, makeSessionCreation, MAX_CREATION_BATCH, MAX_TASK_BYTES, previewCreation, previewDigest, } from "./creation.js";
6
6
  export { MAX_LAUNCHER_RESULTS, searchLauncher } from "./launcher.js";
7
7
  export { firstSessionReady, isConfirmableAdoption, makeOnboarding, MAX_ADOPTION_BATCH, MAX_REGISTRATION_BATCH, projectAccounts, projectDiscovery, } from "./onboarding.js";
8
8
  export { finishedTurn, isWorking, OVERVIEW_PREVIEW_ROWS, projectOverview, sessionStateLabel, sessionStatusLabel, } from "./overview.js";
@@ -1,4 +1,5 @@
1
1
  import { COMMANDS, } from "../commands/index.js";
2
+ import { executorLabel } from "./creation.js";
2
3
  import { sessionStatusLabel } from "./overview.js";
3
4
  import { runtimeStatus, scopeProjects, } from "./portfolio-list.js";
4
5
  export const MAX_LAUNCHER_RESULTS = 50;
@@ -35,10 +36,6 @@ const portfolioResults = (index) => [
35
36
  title: project.name,
36
37
  })),
37
38
  ];
38
- const EXECUTOR_NAMES = new Map([
39
- ["claude-code", "Claude Code"],
40
- ["codex-cli", "Codex"],
41
- ]);
42
39
  /** The status the lists show: the Node's attention reason first. */
43
40
  const statusOf = (index, runtimes, session) => {
44
41
  const reason = index.attention.get(session.id);
@@ -64,10 +61,7 @@ const sessionResults = (index, runtimes, scope) => {
64
61
  `Session ${shortId(session.id)}`,
65
62
  ...(session.executor === undefined
66
63
  ? []
67
- : [
68
- EXECUTOR_NAMES.get(session.executor.kind) ??
69
- session.executor.kind,
70
- ]),
64
+ : [executorLabel(session.executor.kind)]),
71
65
  statusOf(index, runtimes, session),
72
66
  ].join(" · "),
73
67
  kind: "session",
@@ -1,11 +1,11 @@
1
- import { ADOPTION_REFUSED_ERROR_CODE, } from "@maiaos/sdk";
1
+ import { ADOPTION_REFUSED_ERROR_CODE, EXECUTOR_IDS, } from "@maiaos/sdk";
2
2
  import { Clock, Effect, Option, Semaphore, SubscriptionRef, } from "effect";
3
3
  import { nextCompactId } from "../id-generator/index.js";
4
4
  import { CockpitError, confirmMutation, mutate, read, } from "./client.js";
5
- import { listExecutionWorkspaces } from "./creation.js";
5
+ import { executorLabel, listExecutionWorkspaces, } from "./creation.js";
6
6
  const VENDORS = [
7
- { executor: "claude-code", label: "Claude Code", short: "claude" },
8
- { executor: "codex-cli", label: "Codex", short: "codex" },
7
+ { executor: EXECUTOR_IDS.claudeCode, short: "claude" },
8
+ { executor: EXECUTOR_IDS.codex, short: "codex" },
9
9
  ];
10
10
  const signInOf = (connections) => {
11
11
  if (connections.length === 0)
@@ -19,17 +19,17 @@ const signInOf = (connections) => {
19
19
  : "unchecked";
20
20
  };
21
21
  /** One row per vendor, whatever Connections the Node holds. */
22
- export const projectAccounts = (connections) => VENDORS.map(({ executor, label, short }) => {
22
+ export const projectAccounts = (connections) => VENDORS.map(({ executor, short }) => {
23
23
  const own = connections.filter((connection) => connection.executor === executor);
24
24
  return {
25
25
  connections: own,
26
26
  executor,
27
27
  hasSystemDefault: own.some((connection) => connection.configRoot.kind === "system-default" &&
28
28
  connection.state === "enabled"),
29
- label,
29
+ label: executorLabel(executor),
30
30
  loginCommand: `maia login ${short}`,
31
31
  signIn: signInOf(own),
32
- systemDefaultCommand: `maia connection create --name ${short} --executor ${executor} --root system-default`,
32
+ systemDefaultCommand: `maia connection create --name ${short} --harness ${executor} --root system-default`,
33
33
  };
34
34
  });
35
35
  const groupKey = (group) => group.repository === undefined
@@ -1,7 +1,7 @@
1
1
  import * as Result from "effect/Result";
2
2
  import type { PortfolioIndex } from "./portfolio-index.js";
3
3
  /** What an action can target; a command ID names the receipt of one mutation. */
4
- export type RouteKind = "approval" | "command" | "project" | "routine" | "session" | "terminal" | "turn" | "workspace";
4
+ export type RouteKind = "approval" | "command" | "inbox" | "project" | "routine" | "session" | "terminal" | "turn" | "workspace";
5
5
  declare const NodeRouteError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
6
6
  readonly _tag: "NodeRouteError";
7
7
  } & Readonly<A>;
@@ -17,6 +17,7 @@ const holders = (index, kind) => {
17
17
  return { nodes: index.sessionNodes, shared: index.shared?.sessions };
18
18
  case "approval":
19
19
  case "command":
20
+ case "inbox":
20
21
  case "routine":
21
22
  case "terminal":
22
23
  case "turn":
@@ -23,6 +23,7 @@ export declare const makeInteractionRecovery: (api: InteractionService) => Effec
23
23
  readonly createdAt: string;
24
24
  readonly eventCursor: string;
25
25
  readonly method: string;
26
+ readonly proposedBy?: string | undefined;
26
27
  readonly receiptId: string;
27
28
  readonly schemaVersion: 1;
28
29
  readonly state: "succeeded";
@@ -110,6 +111,7 @@ export declare const makeInteractionRecovery: (api: InteractionService) => Effec
110
111
  readonly createdAt: string;
111
112
  readonly eventCursor: string;
112
113
  readonly method: string;
114
+ readonly proposedBy?: string | undefined;
113
115
  readonly receiptId: string;
114
116
  readonly schemaVersion: 1;
115
117
  readonly state: "succeeded";
@@ -51,6 +51,14 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
51
51
  }, PortfolioError, never>;
52
52
  session: (target: PortfolioProject, sessionId: string) => Effect.Effect<{
53
53
  readonly method: "session.show";
54
+ readonly remoteChildren?: readonly {
55
+ readonly linkedAt: string;
56
+ readonly node: string;
57
+ readonly observedState?: "failed" | "idle" | "interrupted" | "recovering" | "running" | "starting" | "stopped" | "stopping" | "waiting-approval" | undefined;
58
+ readonly orphanedAt?: string | undefined;
59
+ readonly sessionId: string;
60
+ readonly state: "linked" | "orphaned";
61
+ }[] | undefined;
54
62
  readonly session: {
55
63
  readonly createdAt: string;
56
64
  readonly id: string;
@@ -70,18 +78,27 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
70
78
  readonly executor?: {
71
79
  readonly connectionId: string;
72
80
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
73
- readonly kind: "claude-code" | "codex-cli";
81
+ readonly kind: string;
74
82
  readonly model?: string | undefined;
75
83
  } | undefined;
76
84
  readonly failure?: {
77
85
  readonly code: string;
78
86
  readonly message: string;
79
87
  } | undefined;
88
+ readonly heldTaskCount?: number | undefined;
89
+ readonly heldTasks?: readonly {
90
+ readonly claimedAt: string;
91
+ readonly id: string;
92
+ readonly leaseExpiresAt: string;
93
+ readonly state: "claimed";
94
+ readonly title: string;
95
+ }[] | undefined;
80
96
  readonly labels?: {
81
97
  readonly [x: string]: string;
82
98
  } | undefined;
83
99
  readonly latestTurnId?: string | undefined;
84
100
  readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
101
+ readonly parentSessionId?: string | undefined;
85
102
  readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
86
103
  readonly prompt?: {
87
104
  readonly approvalId: string;
@@ -138,18 +155,27 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
138
155
  readonly executor?: {
139
156
  readonly connectionId: string;
140
157
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
141
- readonly kind: "claude-code" | "codex-cli";
158
+ readonly kind: string;
142
159
  readonly model?: string | undefined;
143
160
  } | undefined;
144
161
  readonly failure?: {
145
162
  readonly code: string;
146
163
  readonly message: string;
147
164
  } | undefined;
165
+ readonly heldTaskCount?: number | undefined;
166
+ readonly heldTasks?: readonly {
167
+ readonly claimedAt: string;
168
+ readonly id: string;
169
+ readonly leaseExpiresAt: string;
170
+ readonly state: "claimed";
171
+ readonly title: string;
172
+ }[] | undefined;
148
173
  readonly labels?: {
149
174
  readonly [x: string]: string;
150
175
  } | undefined;
151
176
  readonly latestTurnId?: string | undefined;
152
177
  readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
178
+ readonly parentSessionId?: string | undefined;
153
179
  readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
154
180
  readonly prompt?: {
155
181
  readonly approvalId: string;
@@ -8,6 +8,12 @@ export type CollectionState<TPage> = {
8
8
  };
9
9
  type Profile<TPage, TSelection, TTarget> = {
10
10
  readonly identifier: Effect.Effect<string, PresentationError>;
11
+ /**
12
+ * Settles a fresh page against the one on screen. It runs under the gate for
13
+ * the current generation, so a view that patches its page never loses a
14
+ * newer row to a read that began earlier.
15
+ */
16
+ readonly merge?: (fresh: TPage, current?: TPage) => TPage;
11
17
  readonly read: (input: DirectoryRequest) => Effect.Effect<TPage, PresentationError>;
12
18
  readonly selected: (page: TPage, selection: TSelection) => Option.Option<TTarget>;
13
19
  };
@@ -15,13 +21,20 @@ export type CollectionView<TPage, TSelection extends {
15
21
  readonly generation: number;
16
22
  }, TTarget> = {
17
23
  readonly load: (cursor?: string) => Effect.Effect<void>;
24
+ /** Reads the page again from any state without emitting `loading`; the state on screen stays until the read settles. */
25
+ readonly loadQuietly: Effect.Effect<void>;
26
+ readonly patch: (change: (page: TPage) => TPage) => Effect.Effect<void>;
18
27
  readonly read: Effect.Effect<CollectionState<TPage>>;
19
28
  readonly refresh: Effect.Effect<void>;
20
29
  readonly revoke: Effect.Effect<void>;
21
30
  readonly run: (effect: Effect.Effect<void>) => void;
22
31
  readonly select: (expected: TSelection, selected: (target: TTarget) => void) => Effect.Effect<void>;
23
32
  };
24
- /** Shared ownership for the two admitted unary portfolio presentations. */
33
+ /**
34
+ * Shared ownership of one paged read: a generation per read that drops the
35
+ * result of an older read, one read in flight, and a revoke. The portfolio
36
+ * presentations and the records views build on it.
37
+ */
25
38
  export declare const makeCollectionView: <TPage, TSelection extends {
26
39
  readonly generation: number;
27
40
  }, TTarget>(profile: Profile<TPage, TSelection, TTarget>, emit: (state: CollectionState<TPage>) => void) => Effect.Effect<CollectionView<TPage, TSelection, TTarget>, PresentationError, import("effect/Scope").Scope>;
@@ -2,23 +2,53 @@ import { Effect, FiberHandle, FiberSet, Option, Ref, Semaphore } from "effect";
2
2
  const publish = (view, next) => Ref.set(view.state, next).pipe(Effect.andThen(Effect.sync(() => {
3
3
  view.emit(next);
4
4
  })));
5
+ /** Emits `state` unless the view closed or moved on while it waited. */
6
+ const announce = (view, state) => Effect.gen(function* () {
7
+ if ((yield* Ref.get(view.closed)) || (yield* Ref.get(view.state)) !== state)
8
+ return;
9
+ yield* Effect.sync(() => {
10
+ view.emit(state);
11
+ });
12
+ });
5
13
  const deliver = (view, next) => view.gate
6
14
  .withPermits(1)(Effect.gen(function* () {
7
15
  if (yield* Ref.get(view.closed))
8
- return false;
9
- if ((yield* Ref.get(view.state)).generation !== next.generation)
10
- return false;
16
+ return Option.none();
17
+ const current = yield* Ref.get(view.state);
18
+ if (current.generation !== next.generation)
19
+ return Option.none();
20
+ const settled = next.page === undefined || view.profile.merge === undefined
21
+ ? next
22
+ : { ...next, page: view.profile.merge(next.page, current.page) };
23
+ yield* Ref.set(view.state, settled);
24
+ return Option.some(settled);
25
+ }))
26
+ .pipe(Effect.flatMap(Option.match({
27
+ onNone: () => Effect.void,
28
+ onSome: (settled) => announce(view, settled),
29
+ })));
30
+ /**
31
+ * Changes the page on screen in place, under the same generation, so a view
32
+ * can apply one committed row without a read of the whole page. A view with no
33
+ * page yet, or whose `change` returns the page unchanged, emits nothing.
34
+ */
35
+ const patch = (view, change) => view.gate
36
+ .withPermits(1)(Effect.gen(function* () {
37
+ if (yield* Ref.get(view.closed))
38
+ return Option.none();
39
+ const current = yield* Ref.get(view.state);
40
+ if (current.page === undefined)
41
+ return Option.none();
42
+ const page = change(current.page);
43
+ if (page === current.page)
44
+ return Option.none();
45
+ const next = { ...current, page };
11
46
  yield* Ref.set(view.state, next);
12
- return true;
47
+ return Option.some(next);
13
48
  }))
14
- .pipe(Effect.flatMap((accepted) => Effect.gen(function* () {
15
- if (!accepted ||
16
- (yield* Ref.get(view.closed)) ||
17
- (yield* Ref.get(view.state)) !== next)
18
- return;
19
- yield* Effect.sync(() => {
20
- view.emit(next);
21
- });
49
+ .pipe(Effect.flatMap(Option.match({
50
+ onNone: () => Effect.void,
51
+ onSome: (next) => announce(view, next),
22
52
  })));
23
53
  const revoke = (view) => Effect.gen(function* () {
24
54
  yield* Ref.set(view.closed, true);
@@ -38,18 +68,27 @@ const read = (view, input) => view.profile.read(input).pipe(Effect.matchEffect({
38
68
  }),
39
69
  onSuccess: (page) => deliver(view, { generation: input.generation, page, status: "ready" }),
40
70
  }));
41
- /** Starts one read under the gate; a refresh keeps the current page shown. */
71
+ /** The state of a read in flight; a refresh keeps its page shown. */
72
+ const loadingOf = (generation, keep) => ({
73
+ generation,
74
+ ...(keep === undefined ? {} : { page: keep }),
75
+ status: "loading",
76
+ });
77
+ /**
78
+ * Starts one read under the gate; a refresh keeps the current page shown. A
79
+ * quiet start keeps the state on screen, so it emits no `loading` until the
80
+ * read settles.
81
+ */
42
82
  const start = (view, input) => Effect.gen(function* () {
43
83
  const prior = yield* Ref.get(view.state);
44
84
  if (prior.generation >= 2_147_483_647)
45
85
  return yield* revoke(view);
46
86
  const generation = prior.generation + 1;
47
87
  yield* Ref.set(view.cursor, Option.fromUndefinedOr(input.afterCursor));
48
- yield* publish(view, {
49
- generation,
50
- ...(input.keep === undefined ? {} : { page: input.keep }),
51
- status: "loading",
52
- });
88
+ const loading = loadingOf(generation, input.keep);
89
+ yield* input.quiet === true
90
+ ? Ref.set(view.state, loading)
91
+ : publish(view, loading);
53
92
  if (yield* Ref.get(view.closed))
54
93
  return;
55
94
  yield* FiberHandle.run(view.request, read(view, {
@@ -60,11 +99,11 @@ const start = (view, input) => Effect.gen(function* () {
60
99
  : { afterCursor: input.afterCursor }),
61
100
  }));
62
101
  });
63
- const load = (view, afterCursor) => view.gate
102
+ const load = (view, input = {}) => view.gate
64
103
  .withPermitsIfAvailable(1)(Effect.gen(function* () {
65
104
  if (yield* Ref.get(view.closed))
66
105
  return;
67
- yield* start(view, afterCursor === undefined ? {} : { afterCursor });
106
+ yield* start(view, input);
68
107
  }))
69
108
  .pipe(Effect.asVoid);
70
109
  /**
@@ -103,7 +142,9 @@ const select = (view, expected, selected) => view.gate
103
142
  }))
104
143
  .pipe(Effect.asVoid);
105
144
  const controls = (view, run) => ({
106
- load: (cursor) => load(view, cursor),
145
+ load: (cursor) => load(view, cursor === undefined ? {} : { afterCursor: cursor }),
146
+ loadQuietly: load(view, { quiet: true }),
147
+ patch: (change) => patch(view, change),
107
148
  read: Ref.get(view.state),
108
149
  refresh: refresh(view),
109
150
  revoke: revoke(view),
@@ -112,7 +153,11 @@ const controls = (view, run) => ({
112
153
  },
113
154
  select: (expected, selected) => select(view, expected, selected),
114
155
  });
115
- /** Shared ownership for the two admitted unary portfolio presentations. */
156
+ /**
157
+ * Shared ownership of one paged read: a generation per read that drops the
158
+ * result of an older read, one read in flight, and a revoke. The portfolio
159
+ * presentations and the records views build on it.
160
+ */
116
161
  export const makeCollectionView = (profile, emit) => Effect.gen(function* () {
117
162
  const view = {
118
163
  closed: yield* Ref.make(false),
@@ -1,4 +1,5 @@
1
1
  export type { CollectionState, CollectionView } from "./collection-view.js";
2
+ export { makeCollectionView } from "./collection-view.js";
2
3
  export type { NodeChangesService } from "./live.js";
3
4
  export { hasRunningTurn, NodeChanges, pollingNodeChangesLayer, unavailableNodeChangesLayer, watchSessionList, } from "./live.js";
4
5
  export type { ProjectListState, ProjectListView, ProjectSelection, } from "./project-view.js";
@@ -1,3 +1,4 @@
1
+ export { makeCollectionView } from "./collection-view.js";
1
2
  export { hasRunningTurn, NodeChanges, pollingNodeChangesLayer, unavailableNodeChangesLayer, watchSessionList, } from "./live.js";
2
3
  export { makeProjectListView } from "./project-view.js";
3
4
  export { makePresentationLayer, PresentationApi, PresentationError, unavailablePresentationLayer, } from "./service.js";
@@ -61,7 +61,7 @@ export declare const watchSessionList: (view: import("./collection-view.js").Col
61
61
  readonly rssBytes?: number | undefined;
62
62
  readonly wallTimeMilliseconds?: number | undefined;
63
63
  } | undefined;
64
- readonly runtime: "claude-code" | "codex-cli" | "pi";
64
+ readonly runtime: string;
65
65
  readonly runtimeThreadId: string;
66
66
  readonly startedAt: string;
67
67
  readonly turn?: {
@@ -101,18 +101,27 @@ export declare const watchSessionList: (view: import("./collection-view.js").Col
101
101
  readonly executor?: {
102
102
  readonly connectionId: string;
103
103
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
104
- readonly kind: "claude-code" | "codex-cli";
104
+ readonly kind: string;
105
105
  readonly model?: string | undefined;
106
106
  } | undefined;
107
107
  readonly failure?: {
108
108
  readonly code: string;
109
109
  readonly message: string;
110
110
  } | undefined;
111
+ readonly heldTaskCount?: number | undefined;
112
+ readonly heldTasks?: readonly {
113
+ readonly claimedAt: string;
114
+ readonly id: string;
115
+ readonly leaseExpiresAt: string;
116
+ readonly state: "claimed";
117
+ readonly title: string;
118
+ }[] | undefined;
111
119
  readonly labels?: {
112
120
  readonly [x: string]: string;
113
121
  } | undefined;
114
122
  readonly latestTurnId?: string | undefined;
115
123
  readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
124
+ readonly parentSessionId?: string | undefined;
116
125
  readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
117
126
  readonly prompt?: {
118
127
  readonly approvalId: string;
@@ -45,7 +45,7 @@ export declare const makeSessionListView: (target: PortfolioProject, emit: (stat
45
45
  readonly rssBytes?: number | undefined;
46
46
  readonly wallTimeMilliseconds?: number | undefined;
47
47
  } | undefined;
48
- readonly runtime: "claude-code" | "codex-cli" | "pi";
48
+ readonly runtime: string;
49
49
  readonly runtimeThreadId: string;
50
50
  readonly startedAt: string;
51
51
  readonly turn?: {
@@ -85,18 +85,27 @@ export declare const makeSessionListView: (target: PortfolioProject, emit: (stat
85
85
  readonly executor?: {
86
86
  readonly connectionId: string;
87
87
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
88
- readonly kind: "claude-code" | "codex-cli";
88
+ readonly kind: string;
89
89
  readonly model?: string | undefined;
90
90
  } | undefined;
91
91
  readonly failure?: {
92
92
  readonly code: string;
93
93
  readonly message: string;
94
94
  } | undefined;
95
+ readonly heldTaskCount?: number | undefined;
96
+ readonly heldTasks?: readonly {
97
+ readonly claimedAt: string;
98
+ readonly id: string;
99
+ readonly leaseExpiresAt: string;
100
+ readonly state: "claimed";
101
+ readonly title: string;
102
+ }[] | undefined;
95
103
  readonly labels?: {
96
104
  readonly [x: string]: string;
97
105
  } | undefined;
98
106
  readonly latestTurnId?: string | undefined;
99
107
  readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
108
+ readonly parentSessionId?: string | undefined;
100
109
  readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
101
110
  readonly prompt?: {
102
111
  readonly approvalId: string;
@@ -0,0 +1,36 @@
1
+ import { type AgentRecord } from "@maiaos/sdk";
2
+ import { Effect } from "effect";
3
+ import type { RecordsState } from "./state.js";
4
+ /** The Project whose Agents a view holds. */
5
+ export type AgentsScope = {
6
+ readonly projectId: string;
7
+ };
8
+ /** The state of an Agents view. */
9
+ export type AgentsState = RecordsState<AgentRecord>;
10
+ /**
11
+ * The Agents of one Project, live: `agents.list` fills the snapshot and
12
+ * `agents.show` reads each Agent a committed change names.
13
+ */
14
+ export declare const makeAgentsView: (scope: AgentsScope, emit: (state: AgentsState) => void) => Effect.Effect<import("./records.js").RecordsView<{
15
+ readonly contentDigest: string;
16
+ readonly createdAt: string;
17
+ readonly id: string;
18
+ readonly projectId: string;
19
+ readonly revision: string;
20
+ readonly schemaVersion: "maia.agent/v1";
21
+ readonly spec: {
22
+ readonly accountableActorId: string;
23
+ readonly connectionId?: string | undefined;
24
+ readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
25
+ readonly harness: "claude-code" | "codex-cli" | "maia-agent" | "pi";
26
+ readonly homeSessionId?: string | undefined;
27
+ readonly instruction: string;
28
+ readonly managerAgentId?: string | undefined;
29
+ readonly model?: string | undefined;
30
+ readonly name: string;
31
+ readonly placement: "local";
32
+ };
33
+ readonly state: "active" | "disabled";
34
+ readonly updatedAt: string;
35
+ }>, never, import("./service.js").RecordsApi | import("effect/Scope").Scope>;
36
+ //# sourceMappingURL=agents.d.ts.map