@markmo/europacore-session-ui 0.2.0 → 0.3.0

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.
@@ -1,7 +1,7 @@
1
1
  import type { BackgroundSubagent } from '../features/chat/model/subagents';
2
2
  import { type Transport } from '../host';
3
3
  import { type ConnectionState, type SseHandle } from './chatStream';
4
- import type { AcceptResult, AddedDir, AgentInfo, BackgroundTask, ContextUsage, CreateRun, CreateSession, Envelope, FleetRunSummary, FleetTaskDiff, McpServer, ModelInfo, Page, RedoResult, RestoreResult, ResumeRequest, Run, ServerInfo, Session, SessionPullRequest, SessionStatus, SnapshotInfo, TaskInfo, TranscriptItem, UndoRequest, UndoResult, WorkspaceDiff, WorkspaceInfo } from './wire';
4
+ import type { AcceptResult, AddedDir, AgentInfo, BackgroundTask, ContextUsage, CreateRun, CreateSession, Envelope, FleetRunSummary, FleetTaskDiff, McpServer, RunInspection, RunSummary, ModelInfo, Page, RedoResult, RestoreResult, ResumeRequest, Run, ServerInfo, Session, SessionPullRequest, SessionStatus, SnapshotInfo, TaskInfo, TranscriptItem, UndoRequest, UndoResult, WorkspaceDiff, WorkspaceInfo } from './wire';
5
5
  export interface StreamHandlers {
6
6
  onEnvelope: (env: Envelope) => void;
7
7
  onState?: (state: ConnectionState, detail?: string) => void;
@@ -70,6 +70,10 @@ export declare class EuropacoreClient {
70
70
  compact(id: string, instructions?: string): Promise<Record<string, unknown>>;
71
71
  /** The slash commands the session's agent runs itself. */
72
72
  commands(id: string): Promise<ServerCommand[]>;
73
+ /** The session's runs from its journal, oldest first. */
74
+ runs(id: string): Promise<RunSummary[]>;
75
+ /** One run step by step: tokens, cache and cost per call, tool calls with arguments and results, events. */
76
+ runSteps(id: string, runId: string): Promise<RunInspection>;
73
77
  /** The session's agent's MCP servers and how each is doing. */
74
78
  mcpServers(id: string): Promise<McpServer[]>;
75
79
  /** Connect an enabled MCP server again, after it failed or its process died. */
@@ -590,6 +590,8 @@ export interface McpServer {
590
590
  }
591
591
  export interface HarnessResult {
592
592
  output: Record<string, unknown> | null;
593
+ /** What to change when the run stopped short (europacore's `agents.stop_hints`); null when it ended normally. */
594
+ hint?: string | null;
593
595
  text?: string | null;
594
596
  error: string | null;
595
597
  error_code: string | null;
@@ -659,6 +661,31 @@ export type ToolDisplay = {
659
661
  export declare function isDiffDisplay(display: ToolDisplay | null | undefined): display is DiffDisplay;
660
662
  export declare function isExecDisplay(display: ToolDisplay | null | undefined): display is ExecDisplay;
661
663
  export declare function isAnswersDisplay(display: ToolDisplay | null | undefined): display is AnswersDisplay;
664
+ /** How the model router decided a turn's tier (`model_route`; europacore's docs/model-routing.md). */
665
+ export type RouteBasis = 'choice' | 'probability' | 'baseline' | 'floor' | 'escalation' | 'budget' | 'held' | 'shadow' | 'pinned';
666
+ /** `model_route`: the tier and model a turn runs on, and why; sent per turn and when the tier changes within it. */
667
+ export interface ModelRouteData {
668
+ /** `fast`, `standard` or `capable`; null when the session's model is not routed (`pinned`). */
669
+ tier: string | null;
670
+ /** The model serving the turn (in shadow mode, the one still serving it). */
671
+ model: string | null;
672
+ basis: RouteBasis;
673
+ reason: string;
674
+ /** The classifier's answer: its tier, confidence and each option's probability. */
675
+ judged?: string | null;
676
+ confidence?: number | null;
677
+ probabilities?: Record<string, number>;
678
+ classifier?: string | null;
679
+ latency_ms?: number | null;
680
+ spent_usd?: number | null;
681
+ budget_usd?: number | null;
682
+ /** The model the turn was on before; the cache gate weighed staying on it. */
683
+ incumbent?: string | null;
684
+ cache_warm?: boolean | null;
685
+ /** What staying and switching would cost over the gate's horizon, when it weighed a switch. */
686
+ stay_usd?: number | null;
687
+ switch_usd?: number | null;
688
+ }
662
689
  export interface TokenUsageData {
663
690
  last_call_tokens?: number;
664
691
  total_tokens?: number;
@@ -777,3 +804,55 @@ export interface HandoffFinding {
777
804
  line: number | null;
778
805
  reason: string;
779
806
  }
807
+ /** One run of a session, from its journal (`GET /v1/sessions/{sid}/runs`). */
808
+ export interface RunSummary {
809
+ run_id: string;
810
+ status: 'running' | 'completed' | 'failed' | 'paused' | 'cancelled' | 'abandoned' | string;
811
+ started_at?: string | null;
812
+ ended_at?: string | null;
813
+ input?: string | null;
814
+ steps: number;
815
+ total_tokens: number;
816
+ cache_read_tokens: number;
817
+ cache_write_tokens: number;
818
+ cost_usd?: number | null;
819
+ wall_seconds?: number | null;
820
+ stop_reason?: string | null;
821
+ error_code?: string | null;
822
+ error?: string | null;
823
+ hint?: string | null;
824
+ }
825
+ /** One tool call of a step, with its arguments and result. */
826
+ export interface ToolCallView {
827
+ call_id: string;
828
+ name: string;
829
+ arguments?: unknown;
830
+ status?: string | null;
831
+ result?: string | null;
832
+ }
833
+ /** One step of a run: its model call, tool calls and other events. */
834
+ export interface StepView {
835
+ step: number;
836
+ model?: string | null;
837
+ input_tokens: number;
838
+ output_tokens: number;
839
+ reasoning_tokens: number;
840
+ cache_read_tokens: number;
841
+ cache_write_tokens: number;
842
+ cost_usd?: number | null;
843
+ text?: string | null;
844
+ tools: ToolCallView[];
845
+ events: {
846
+ type: string;
847
+ name?: string | null;
848
+ data?: Record<string, unknown>;
849
+ }[];
850
+ }
851
+ /** A run step by step (`GET /v1/sessions/{sid}/runs/{rid}/steps`). */
852
+ export interface RunInspection {
853
+ summary: RunSummary;
854
+ session_id?: string | null;
855
+ steps: StepView[];
856
+ pause?: Record<string, unknown> | null;
857
+ output?: unknown;
858
+ }
@@ -1,3 +1,4 @@
1
+ import type { RouteView } from './routing';
1
2
  import type { ImageInput, Pause, PlanItem, RunKind, ToolDisplay, ToolStatus } from '../../../api/wire';
2
3
  /** One row of the transcript. Entries are append-only; their contents change in place. */
3
4
  export type Entry = UserEntry | AssistantEntry | ToolEntry | NoticeEntry | SteerEntry | DecisionEntry | RunEndEntry | DiffEntry | WakeEntry;
@@ -91,6 +92,8 @@ export interface RunEndEntry {
91
92
  waiting?: string | null;
92
93
  /** Calls the permission rules or mode turned down in the run. */
93
94
  denied?: number;
95
+ /** What to change, when the run stopped short (`HarnessResult.hint`). */
96
+ hint?: string | null;
94
97
  }
95
98
  export interface ActiveRun {
96
99
  id: string;
@@ -111,6 +114,8 @@ export interface UsageView {
111
114
  inputTokens: number;
112
115
  sessionCostUsd: number | null;
113
116
  costComplete: boolean;
117
+ /** The model router's tier for the turn (`model_route`); null when the session's model is not routed. */
118
+ route: RouteView | null;
114
119
  }
115
120
  export interface PlanView {
116
121
  items: PlanItem[];
@@ -49,3 +49,14 @@ export declare function taskProgress(task: FleetTaskEntry): string | null;
49
49
  export declare function pauseOf(pauses: Pause[], pendingId: string | null | undefined): Pause | null;
50
50
  /** The message that sends a fleet session's run a command (europacore's fleet agent parses it). */
51
51
  export declare function fleetCommand(kind: 'cancel' | 'retry' | 'steer' | 'approve' | 'release', task?: string | null, text?: string): string;
52
+ /** A fleet spec sent as a prompt, read back for a person: its name, and what it runs. */
53
+ export interface FleetSpecSummary {
54
+ name: string | null;
55
+ /** "3 tasks", or for one task run several ways, "add token refresh · 3 variants (a, b, c)". */
56
+ runs: string;
57
+ }
58
+ /**
59
+ * What a fleet spec (JSON, or TOML as `/fleet` sends it) runs, or null when `text` is not one. The fleet agent's
60
+ * prompt is the whole spec; the transcript and the brief show this instead, with the spec one click away.
61
+ */
62
+ export declare function fleetSpecSummary(text: string): FleetSpecSummary | null;
@@ -0,0 +1,11 @@
1
+ import type { RunSummary, StepView, ToolCallView } from '../../../api/wire';
2
+ /** ``value`` on one line, cut to ``limit`` characters (0: whole). */
3
+ export declare function clip(value: unknown, limit?: number): string;
4
+ /** Why the run stopped, in a word: its stop reason, else its error code, else its status. */
5
+ export declare function stoppedBecause(run: RunSummary): string;
6
+ /** A run's line in the list: steps, tokens, cost and why it stopped. */
7
+ export declare function runLine(run: RunSummary): string;
8
+ /** A step's model call: model, tokens in and out, cache read/written, cost. */
9
+ export declare function stepLine(step: StepView): string;
10
+ /** A tool call: its name with arguments, how it ended and what it returned. */
11
+ export declare function toolLine(call: ToolCallView, limit?: number): string;
@@ -90,7 +90,7 @@ export type MemoryArgs = {
90
90
  } | {
91
91
  error: string;
92
92
  };
93
- /** Parses the arguments of /memory. */
93
+ /** Parses the arguments of /decisions. */
94
94
  export declare function parseMemoryArgs(args: string): MemoryArgs;
95
95
  /** Decisions and requirements the agent marked in its text: "Decision: …" lines and "## Decisions" sections. */
96
96
  export declare function extractMarked(text: string): MarkedItem[];
@@ -101,7 +101,7 @@ export declare function parseExtraction(text: string): {
101
101
  } | {
102
102
  error: string;
103
103
  };
104
- /** Sent by /memory extract. Avoids the words the mock server picks scenarios from. */
104
+ /** Sent by /decisions extract. Avoids the words the mock server picks scenarios from. */
105
105
  export declare const EXTRACT_PROMPT = "List the key decisions and requirements agreed so far in this conversation. Reply with only a ```json fence containing a JSON array of objects with the fields kind (\"decision\" or \"requirement\"), text and rationale (a string or null). Reply with [] when there are none.";
106
106
  /** A well-formed copy of a stored or mirrored entry, or null when it is malformed. */
107
107
  export declare function parseEntry(value: unknown): MemoryEntry | null;
@@ -109,7 +109,7 @@ export declare function parseEntry(value: unknown): MemoryEntry | null;
109
109
  export declare function mirroredEntries(metadata: Record<string, unknown> | null | undefined): MemoryEntry[];
110
110
  /** Register order: decisions before requirements, then by id number. */
111
111
  export declare function compareEntries(a: MemoryEntry, b: MemoryEntry): number;
112
- /** The /memory notice: counts, one line per entry (rationale below it) and the commands. */
112
+ /** The /decisions notice: counts, one line per entry (rationale below it) and the commands. */
113
113
  export declare function formatMemoryList(entries: MemoryEntry[], heading: string, now?: number): string;
114
114
  /** "D-001 Use pnpm for…" for pickers and notices. */
115
115
  export declare function memoryLabel(entry: MemoryEntry, width?: number): string;
@@ -0,0 +1,20 @@
1
+ /** The model router's `model_route` events as a transcript notice and a footer badge. */
2
+ import type { ModelRouteData } from '../../../api/wire';
3
+ import type { NoticeLevel } from './entries';
4
+ /** The turn's tier as the footer shows it; null when the session's model is not routed. */
5
+ export interface RouteView {
6
+ tier: string;
7
+ /** The model serving the turn, which may differ from the session's model id (`router`). */
8
+ model: string | null;
9
+ shadow: boolean;
10
+ }
11
+ /**
12
+ * One line saying which tier and model a turn runs on and why, or null for a session whose model is not
13
+ * routed: the server sends `pinned` every turn, and saying so each time would only be noise.
14
+ */
15
+ export declare function routeNotice(data: ModelRouteData): {
16
+ level: NoticeLevel;
17
+ text: string;
18
+ } | null;
19
+ /** The footer's badge for a route, or null when the session's model is not routed. */
20
+ export declare function routeView(data: ModelRouteData): RouteView | null;
@@ -20,6 +20,11 @@ export interface ViewState {
20
20
  plan: PlanView | null;
21
21
  usage: UsageView;
22
22
  undeliveredSteers: string[];
23
+ /** The hint of a run whose `run.result` came with an error, kept for the `run.failed` that follows. */
24
+ pendingHint: {
25
+ runId: string;
26
+ hint: string;
27
+ } | null;
23
28
  /** The session's workspace status (spec §3.7), refreshed by `workspace.updated`. */
24
29
  workspace: WorkspaceInfo | null;
25
30
  connection: ConnectionState;
@@ -6,7 +6,7 @@ import { type KeyboardEvent, type RefObject } from 'react';
6
6
  */
7
7
  export declare function useHistoryWalk(text: string, setText: (value: string) => void, textarea: RefObject<HTMLTextAreaElement | null>): {
8
8
  onKeyDown: (event: KeyboardEvent<HTMLTextAreaElement>) => boolean;
9
- reset: () => null;
9
+ reset: () => void;
10
10
  };
11
11
  /**
12
12
  * Ctrl+R: the prompts sent, newest first (this workspace's before the rest), narrowed by the words typed in any
@@ -0,0 +1,3 @@
1
+ import type { DialogProps } from './dialogs';
2
+ /** `/inspect`: the session's runs from the server's journal; choose one to see it step by step. */
3
+ export declare function InspectDialog({ open, onClose }: DialogProps): import("react").JSX.Element | null;
@@ -5,7 +5,7 @@ export interface DialogProps {
5
5
  onClose: () => void;
6
6
  [key: string]: unknown;
7
7
  }
8
- /** Features register the dialogs commands open: `/undo` opens "undo", `/memory` "memory", and so on. */
8
+ /** Features register the dialogs commands open: `/undo` opens "undo", `/decisions` "decisions", and so on. */
9
9
  export declare function registerDialog(kind: string, component: ComponentType<DialogProps>): void;
10
10
  export declare function openDialog(kind: string, props?: Record<string, unknown>): void;
11
11
  export declare function closeDialog(): void;
@@ -1,5 +1,5 @@
1
1
  import type { SessionController } from '../chat/session/SessionController';
2
- export type CommandGroup = 'Session' | 'Decide' | 'Workspace' | 'Fleet' | 'Memory' | 'Go to' | 'App' | 'Prompt' | "This session's";
2
+ export type CommandGroup = 'Session' | 'Decide' | 'Workspace' | 'Fleet' | 'Decisions' | 'Go to' | 'App' | 'Prompt' | "This session's";
3
3
  export interface Completion {
4
4
  value: string;
5
5
  description?: string;
@@ -7,7 +7,7 @@ export declare function MemoryDialog({ open, onClose, controller, initialView, }
7
7
  open: boolean;
8
8
  onClose: () => void;
9
9
  controller: MemoryController;
10
- /** `/memory all` opens on the whole scope. */
10
+ /** `/decisions all` opens on the whole scope. */
11
11
  initialView?: View;
12
12
  }): import("react").JSX.Element;
13
13
  export default MemoryDialog;
@@ -101,15 +101,15 @@ export declare function recordApproval(controller: MemoryController, info: Decid
101
101
  export interface MemoryList {
102
102
  heading: string;
103
103
  scope: string;
104
- /** Whole scope (`/memory all`) or just this session. */
104
+ /** Whole scope (`/decisions all`) or just this session. */
105
105
  all: boolean;
106
106
  entries: MemoryEntry[];
107
107
  }
108
108
  /** The scope's entries as this window knows them, the controller's session read from its live copy. */
109
109
  export declare function scopeOf(controller: MemoryController, sessions?: Iterable<MemorySession>): MemoryEntry[];
110
- /** `/memory` (this session's entries) and `/memory all` (the whole scope's), for the memory dialog. */
110
+ /** `/decisions` (this session's entries) and `/decisions all` (the whole scope's), for the decisions dialog. */
111
111
  export declare function listMemory(controller: MemoryController, all?: boolean): MemoryList;
112
- /** Active labels, for completing `/memory retire|edit|supersede <id>`. */
112
+ /** Active labels, for completing `/decisions retire|edit|supersede <id>`. */
113
113
  export declare function memoryIds(controller: MemoryController): string[];
114
114
  export interface ScopeTarget {
115
115
  scope: string;
@@ -137,18 +137,18 @@ export declare function supersedeIn(scope: ScopeTarget, id: string, text: string
137
137
  }): Promise<MemoryResult & {
138
138
  sessions?: Session[];
139
139
  }>;
140
- /** `/memory retire <id>`. */
140
+ /** `/decisions retire <id>`. */
141
141
  export declare function retire(controller: MemoryController, id: string, options?: WriteOptions): Promise<MemoryResult<MemoryEntry> & {
142
142
  session?: Session | null;
143
143
  }>;
144
- /** `/memory edit <id> <text> [-- why]`. */
144
+ /** `/decisions edit <id> <text> [-- why]`. */
145
145
  export declare function edit(controller: MemoryController, id: string, text: string | {
146
146
  text: string;
147
147
  rationale?: string | null;
148
148
  }, options?: WriteOptions): Promise<MemoryResult<MemoryEntry> & {
149
149
  session?: Session | null;
150
150
  }>;
151
- /** `/memory supersede <id> <text> [-- why]`. */
151
+ /** `/decisions supersede <id> <text> [-- why]`. */
152
152
  export declare function supersede(controller: MemoryController, id: string, text: string | {
153
153
  text: string;
154
154
  rationale?: string | null;
@@ -174,7 +174,7 @@ export declare function awaitAnswer(controller: MemoryController, runId: string,
174
174
  text: string;
175
175
  }>;
176
176
  /**
177
- * `/memory extract`: asks the agent for the decisions and requirements agreed so far, waits for its answer and
177
+ * `/decisions extract`: asks the agent for the decisions and requirements agreed so far, waits for its answer and
178
178
  * reads it. The proposal's `fresh` items are the ones to confirm (ExtractConfirmDialog), then `addExtracted`.
179
179
  */
180
180
  export declare function extract(controller: MemoryController, options?: WriteOptions & {
@@ -204,10 +204,10 @@ export type MemoryCommand = {
204
204
  } | {
205
205
  error: string;
206
206
  };
207
- /** The command a memory slash command names (`decision`, `dec`, `requirement`, `req`, `memory`, `register`), or null. */
208
- export declare function memoryCommandName(name: string): 'decision' | 'requirement' | 'memory' | 'register' | null;
207
+ /** The command a register slash command names (`decision`, `dec`, `requirement`, `req`, `decisions`, `register`), or null. */
208
+ export declare function memoryCommandName(name: string): 'decision' | 'requirement' | 'decisions' | 'register' | null;
209
209
  /**
210
- * Parses a memory slash command: `parseMemoryCommand(args)` for `/memory <args>`, or with a command name
210
+ * Parses a register slash command: `parseMemoryCommand(args)` for `/decisions <args>`, or with a command name
211
211
  * (`/dec`, `/req`, …) for the others. Builds on parseMemoryArgs.
212
212
  */
213
213
  export declare function parseMemoryCommand(args: string, command?: string): MemoryCommand;