@maiaos/client-core 0.1.0-canary.7 → 0.1.0-canary.71

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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -23
  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 +10 -8
  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 +76 -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 +35 -2
  18. package/dist/presentation/session-view.d.ts +35 -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/dist/session-view/session-view.d.ts +2 -0
  43. package/dist/session-view/session-view.js +9 -6
  44. package/dist/session-view/timeline.d.ts +10 -1
  45. package/dist/session-view/timeline.js +12 -4
  46. 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
@@ -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
@@ -46,22 +47,24 @@ uncertain requests and projections of Node state. It owns no transport,
46
47
  credentials, native API, Node lifecycle or durable state: the SDK is the
47
48
  protocol client and Maia Node is the authority.
48
49
 
49
- | Entry point | Responsibility |
50
- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
51
- | `boot` | The Desktop boot sequence: lifecycle status, one start, then status reads until the host reports a ready Node |
52
- | `navigation` | Route names, the `?q=&state=&page=` list query, parent routes and the one pagination model |
53
- | `node-status` | One truthful, point-in-time Node status projection |
54
- | `workspace-scope` | The one active Workspace scope, loaded from and replaced only by Node |
55
- | `single-session` | Voice setup, Node-provided orchestrator context and local proposals |
56
- | `terminal`, `terminal-unavailable` | Live terminal client and its explicit unavailable state |
57
- | `interaction`, `interaction-view` | Record-only questions and answers, with recovery of unknown outcomes |
58
- | `presentation` | Bounded Workspace, Project and Session list reads |
59
- | `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 |
60
- | `session-view` | Focused Session detail: live items over `session.attach`, recent turns, summary, diff and a send, interrupt and wait composer |
61
- | `commands` | The keyboard command registry: stable IDs, Desktop and terminal keymaps, rebinding, conflicts and reserved chords |
62
- | `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) |
63
- | `session-attach` | The SDK's Session attach reducer, re-exported unchanged |
64
- | `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 |
65
68
 
66
69
  - **Deadlines and uncertainty.** Every request gets a unique message ID from
67
70
  the package `IdGenerator` (Effect `Random` by default) and a 5.5-second
@@ -100,7 +103,7 @@ protocol client and Maia Node is the authority.
100
103
  not release-qualified. The cockpit follows today's `observe.events` feed; the
101
104
  planned R1 aggregate subscription, view store and reconnect policy will replace
102
105
  its index load here; see the
103
- [client architecture](https://github.com/vllnt/maia/blob/main/docs/clients/architecture.md).
106
+ [client architecture](https://maia-os.vllnt.com/en/docs/clients/architecture).
104
107
 
105
108
  - **Bulk creation.** A preview fixes every target, task and command ID and
106
109
  carries a digest; one confirmation runs it once, within its expiry. Each
@@ -119,7 +122,7 @@ its index load here; see the
119
122
 
120
123
  ## Links
121
124
 
122
- - [Desktop and mobile client architecture](https://github.com/vllnt/maia/blob/main/docs/clients/architecture.md)
125
+ - [Desktop and mobile client architecture](https://maia-os.vllnt.com/en/docs/clients/architecture)
123
126
  - [`@maiaos/sdk`](https://github.com/vllnt/maia/blob/main/packages/sdk/README.md)
124
127
  - [Security policy](https://github.com/vllnt/maia/blob/main/SECURITY.md)
125
128
  - [Repository](https://github.com/vllnt/maia)
@@ -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
@@ -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" }),
@@ -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;
@@ -60,22 +68,55 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
60
68
  readonly updatedAt: string;
61
69
  readonly workspaceId: string;
62
70
  readonly workspaceRevision: string;
71
+ readonly activity?: "idle" | "stopped" | "waiting_approval" | "working" | undefined;
63
72
  readonly agentDefinitionRef?: {
64
73
  readonly contentDigest: string;
65
74
  readonly key: string;
66
75
  readonly version: string;
67
76
  } | undefined;
77
+ readonly containment?: "none" | undefined;
68
78
  readonly executor?: {
69
79
  readonly connectionId: string;
70
80
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
71
- readonly kind: "claude-code" | "codex-cli";
81
+ readonly kind: string;
72
82
  readonly model?: string | undefined;
73
83
  } | undefined;
74
84
  readonly failure?: {
75
85
  readonly code: string;
76
86
  readonly message: string;
77
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;
96
+ readonly labels?: {
97
+ readonly [x: string]: string;
98
+ } | undefined;
99
+ readonly latestTurnId?: string | undefined;
100
+ readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
101
+ readonly parentSessionId?: string | undefined;
102
+ readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
103
+ readonly prompt?: {
104
+ readonly approvalId: string;
105
+ readonly expiresAt: string;
106
+ readonly kind: "command" | "file_change" | "question" | "tool";
107
+ readonly options?: readonly {
108
+ readonly label: string;
109
+ readonly optionId: string;
110
+ }[] | undefined;
111
+ readonly summary?: string | undefined;
112
+ } | undefined;
113
+ readonly recovery?: {
114
+ readonly code: string;
115
+ readonly message: string;
116
+ } | undefined;
78
117
  readonly schemaVersion: 4;
118
+ readonly settledReason?: "failed" | "idle" | "stopped" | undefined;
119
+ readonly status?: "approval" | "compacting" | "done" | "ended" | "error" | "idle" | "question" | "rate_limited" | "starting" | "unknown" | "working" | undefined;
79
120
  readonly title?: string | undefined;
80
121
  readonly worktree?: {
81
122
  readonly baseRef: string;
@@ -104,22 +145,55 @@ export declare const makePortfolioService: (client: PortfolioClient) => {
104
145
  readonly updatedAt: string;
105
146
  readonly workspaceId: string;
106
147
  readonly workspaceRevision: string;
148
+ readonly activity?: "idle" | "stopped" | "waiting_approval" | "working" | undefined;
107
149
  readonly agentDefinitionRef?: {
108
150
  readonly contentDigest: string;
109
151
  readonly key: string;
110
152
  readonly version: string;
111
153
  } | undefined;
154
+ readonly containment?: "none" | undefined;
112
155
  readonly executor?: {
113
156
  readonly connectionId: string;
114
157
  readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
115
- readonly kind: "claude-code" | "codex-cli";
158
+ readonly kind: string;
116
159
  readonly model?: string | undefined;
117
160
  } | undefined;
118
161
  readonly failure?: {
119
162
  readonly code: string;
120
163
  readonly message: string;
121
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;
173
+ readonly labels?: {
174
+ readonly [x: string]: string;
175
+ } | undefined;
176
+ readonly latestTurnId?: string | undefined;
177
+ readonly latestTurnState?: "completed" | "dispatching" | "failed" | "interrupted" | "outcome-unknown" | "queued" | "running" | undefined;
178
+ readonly parentSessionId?: string | undefined;
179
+ readonly permission?: "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "never" | "on-request" | "plan" | "untrusted" | undefined;
180
+ readonly prompt?: {
181
+ readonly approvalId: string;
182
+ readonly expiresAt: string;
183
+ readonly kind: "command" | "file_change" | "question" | "tool";
184
+ readonly options?: readonly {
185
+ readonly label: string;
186
+ readonly optionId: string;
187
+ }[] | undefined;
188
+ readonly summary?: string | undefined;
189
+ } | undefined;
190
+ readonly recovery?: {
191
+ readonly code: string;
192
+ readonly message: string;
193
+ } | undefined;
122
194
  readonly schemaVersion: 4;
195
+ readonly settledReason?: "failed" | "idle" | "stopped" | undefined;
196
+ readonly status?: "approval" | "compacting" | "done" | "ended" | "error" | "idle" | "question" | "rate_limited" | "starting" | "unknown" | "working" | undefined;
123
197
  readonly title?: string | undefined;
124
198
  readonly worktree?: {
125
199
  readonly baseRef: 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";