@vehicle-sil/gui-client 0.2.0-rc.1 → 0.2.0-rc.2

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.
@@ -34,6 +34,8 @@ export interface FromLauncher {
34
34
  export type Severity = Open<'error' | 'warning' | 'note'>;
35
35
  /** A finding of the check or the run. message and detail are shown in English, unchanged. */
36
36
  export interface Finding extends FromLauncher {
37
+ /** Launcher event sequence on a finding kept by a GUI server, when available. */
38
+ event_seq?: number;
37
39
  severity: Severity;
38
40
  code: string;
39
41
  file: string | null;
@@ -146,6 +148,7 @@ export interface CheckResult extends FromLauncher {
146
148
  warnings: number;
147
149
  notes: number;
148
150
  stop_at_ms: number | null;
151
+ time_step_ms?: number | null;
149
152
  participants: CheckParticipant[];
150
153
  networks: CheckNetwork[];
151
154
  findings: Finding[];
@@ -9,11 +9,13 @@ import { CheckResult, ControlLink, Finding, LauncherEvent, ParticipantState, Pha
9
9
  * read a hello or an api/app of another version (their fields may mean something else). When to raise the version:
10
10
  * "Versioning and compatibility" in gui/protocol/README.md.
11
11
  */
12
- export declare const PROTOCOL_VERSION = 2;
12
+ export declare const PROTOCOL_VERSION = 3;
13
13
  /**
14
14
  * A server notice (an API error, a WebSocket error, problems of the session). message is shown in English, unchanged.
15
15
  */
16
16
  export interface ServerProblem {
17
+ /** Monotonic per-run diagnostic identifier, absent on older servers. */
18
+ problem_seq?: number;
17
19
  code: string;
18
20
  message: string;
19
21
  /** For launcher-stderr, the number of lines dropped at this point (`detail.skipped`). Other notices lack it. */
@@ -74,6 +76,8 @@ export declare const readAppInfo: (value: unknown) => AppInfo;
74
76
  export interface ConfigFile {
75
77
  /** Path relative to root (separator /). */
76
78
  path: string;
79
+ /** The server recognized a simulation configuration. Older servers may omit this flag. */
80
+ simulation?: boolean;
77
81
  }
78
82
  /** GET api/configs: the configuration files under root. */
79
83
  export interface ConfigList {
@@ -106,6 +110,10 @@ export interface CheckRequest {
106
110
  params?: Record<string, string | number | boolean>;
107
111
  /** true: fail on warnings too. */
108
112
  strict?: boolean;
113
+ /** Exact virtual time at which to stop. Omit for no automatic stop. */
114
+ stop_at_ms?: number;
115
+ /** Wall-clock milliseconds of lateness before a paced step counts as late. */
116
+ late_tolerance_ms?: number;
109
117
  /**
110
118
  * Where networks are connected outside the simulation: network name to target. For a network of the file, a target
111
119
  * other than `none` must be a `value` that the last `POST api/connections` of that network gave with `usable: true`
@@ -302,6 +310,8 @@ export interface LogCounts {
302
310
  */
303
311
  export interface SessionSummary {
304
312
  id: number;
313
+ /** Server capture order within this instance and run; absent on older servers. */
314
+ snapshot_rev?: number | null;
305
315
  /** Path relative to root. */
306
316
  file: string;
307
317
  disable: string[];
@@ -310,7 +320,7 @@ export interface SessionSummary {
310
320
  * is in the check result).
311
321
  */
312
322
  manual: string[];
313
- /** Speed given at the start (null means as in the configuration file). The current speed is `speed` of launcher_state. */
323
+ /** Speed requested at the start (null means no speed was requested). The current speed is `speed` of launcher_state. */
314
324
  speed: Speed;
315
325
  /** Whether the run started paused. */
316
326
  start_paused: boolean;
@@ -352,6 +362,8 @@ export interface SessionSummary {
352
362
  log: Record<string, LogCounts>;
353
363
  problems: ServerProblem[];
354
364
  problems_omitted: number;
365
+ /** Highest diagnostic identifier allocated by the server, including omitted diagnostics. */
366
+ problem_seq?: number | null;
355
367
  /** Progress of the scenario run (`scenario` of `api/run`). null for a run without a scenario. */
356
368
  scenario: SummaryScenario | null;
357
369
  /**
@@ -423,6 +435,8 @@ export interface ServerAllowed {
423
435
  export declare const readServerAllowed: Reader<ServerAllowed>;
424
436
  /** Answer of GET api/session, POST api/run and POST api/stop (the current session; null if none). */
425
437
  export declare const readSessionResponse: (value: unknown) => SessionSummary | null;
438
+ /** GET api/session and POST api/run must identify the GUI server that supplied the run ID. */
439
+ export declare const readSessionInstance: (value: unknown) => string;
426
440
  /** What the server accepts, from `allowed` of an `api/session` response: also there when there is no run. */
427
441
  export declare const readSessionAllowed: (value: unknown) => ServerAllowed | null;
428
442
  /**
@@ -431,6 +445,11 @@ export declare const readSessionAllowed: (value: unknown) => ServerAllowed | nul
431
445
  export interface StopRequestBody {
432
446
  force: boolean;
433
447
  }
448
+ /** POST api/stop-session: the server stops only this session. */
449
+ export interface StopSessionRequestBody extends StopRequestBody {
450
+ session: number;
451
+ instance: string;
452
+ }
434
453
  /** Names of the time commands (the launcher's stdin commands other than stop). */
435
454
  export type TimeCommandName = 'pause' | 'resume' | 'step' | 'run_until' | 'speed';
436
455
  /**
@@ -520,6 +539,8 @@ export interface OperationReport {
520
539
  }
521
540
  /** `variables` of the summary: state of the variable API, variables per participant, recent operations. */
522
541
  export interface VariablesSummary {
542
+ /** Server capture order for variable snapshots and availability deltas; absent on older servers. */
543
+ rev?: number | null;
523
544
  state: Open<'off' | 'connecting' | 'ready' | 'failed' | 'ended'>;
524
545
  reason: string | null;
525
546
  peers: {
@@ -749,6 +770,7 @@ export type ServerMessage =
749
770
  | {
750
771
  type: 'availability';
751
772
  session: number;
773
+ rev?: number | null;
752
774
  peers: Record<string, Record<string, VariableAvailability>>;
753
775
  };
754
776
  /**
package/types/run.d.ts CHANGED
@@ -4,12 +4,18 @@ import { SessionFeed } from './session.js';
4
4
  import { ErrorSink, Readable } from './values.js';
5
5
  /** Stop action: stop in order, or stop without waiting. */
6
6
  export type StopAction = 'stop' | 'force';
7
+ export interface StopCapture {
8
+ readonly key: object | string;
9
+ readonly send: (force: boolean) => Promise<SessionSummary | null>;
10
+ }
7
11
  /** Run control and its state (GuiClient.run). */
8
12
  export interface ClientRun {
9
13
  /** A start was sent and its answer is pending. */
10
14
  readonly starting: Readable<boolean>;
11
15
  /** A stop was sent and its answer is pending (which kind of stop). */
12
16
  readonly stopping: Readable<StopAction | null>;
17
+ /** A pending stop of the current session or current start, if any. */
18
+ readonly currentStopping: Readable<StopAction | null>;
13
19
  /** A stop was asked for while the answer to a start was pending. */
14
20
  readonly stopWhileStarting: Readable<boolean>;
15
21
  /** Why the last action was refused (the server's text, unchanged). null once a run starts or ends. */
@@ -22,19 +28,22 @@ export interface ClientRun {
22
28
  * have started it.
23
29
  */
24
30
  start(request: RunRequest): Promise<SessionSummary | null>;
25
- /** Stops in order (`POST api/stop` `{force: false}`). Asking again has no further effect. */
31
+ /**
32
+ * Stops the session currently seen by this client. During its own pending start, waits for the answer and targets
33
+ * that session. If the ID or server instance is unknown, or the start answer is lost, rejects without sending an
34
+ * unscoped stop. An older server without `api/stop-session` is refused, rather than stopping an unrelated run.
35
+ */
26
36
  stop(): Promise<SessionSummary | null>;
27
- /** Stops without waiting (`POST api/stop` `{force: true}`). */
37
+ /** Stops without waiting for participants. A stop during this client's pending start is targeted the same way. */
28
38
  forceStop(): Promise<SessionSummary | null>;
29
39
  }
30
40
  /**
31
- * Run control: start (`POST api/run`), stop in order or without waiting (`POST api/stop`), and the state for them.
41
+ * Run control: start (`POST api/run`), stop in order or without waiting (`POST api/stop-session`), and their state.
32
42
  *
33
43
  * - The answer to an action (the current summary) is applied to the session copy without waiting for the notification
34
44
  * (no stale display right after a click).
35
- * - Start and stop are sent separately. A stop can be asked for while the answer to a start is pending (the server
36
- * delivers it once the launcher has started; stopping in order has no further effect when asked again, so if the
37
- * summary in the start's answer does not show the stop as asked for yet, it is asked for again).
45
+ * - A stop requested while a start is pending waits for its answer, then names that session in the stop request. The
46
+ * server checks the ID atomically, so a later run cannot be stopped by the delayed request.
38
47
  * - error holds the reason for a refusal (the server's English text). It is cleared once a run starts or ends.
39
48
  * - The Promises of start() and stop() resolve with the summary in the answer (null if unreadable) and reject with an
40
49
  * HttpError when refused. No answer (`timedOut`) is not a refusal: the session copy tells whether the run started.
@@ -47,12 +56,16 @@ export declare class RunControl implements ClientRun {
47
56
  * How long to wait for the answer to a start (ms). Long, because the server may check again as part of the start.
48
57
  */
49
58
  private readonly startTimeoutMs;
59
+ private startOperation;
60
+ private readonly pendingStops;
61
+ private readonly pendingRevision;
50
62
  private readonly startSending;
51
63
  private readonly stopSending;
52
64
  private readonly stopAskedWhileStarting;
53
65
  private readonly failure;
54
66
  readonly starting: Readable<boolean>;
55
67
  readonly stopping: Readable<StopAction | null>;
68
+ readonly currentStopping: Readable<StopAction | null>;
56
69
  readonly stopWhileStarting: Readable<boolean>;
57
70
  readonly error: Readable<string | null>;
58
71
  constructor(feed: SessionFeed, transport: HttpTransport, onError?: ErrorSink,
@@ -66,6 +79,8 @@ export declare class RunControl implements ClientRun {
66
79
  stop(): Promise<SessionSummary | null>;
67
80
  /** Stops without waiting (kills the participants). */
68
81
  forceStop(): Promise<SessionSummary | null>;
82
+ captureStop(): StopCapture;
83
+ private requestStop;
69
84
  /**
70
85
  * Sends and applies the summary in the answer. done is called after the answer (failures too), before the Promise
71
86
  * settles.
@@ -45,6 +45,7 @@ export interface LogLine {
45
45
  count: number;
46
46
  atLeast: boolean;
47
47
  launcher?: boolean;
48
+ notKept?: boolean;
48
49
  };
49
50
  }
50
51
  /** Log counts per source. */
@@ -167,6 +168,25 @@ export interface ScenarioView {
167
168
  export interface SessionView {
168
169
  /** Session number the server assigned. */
169
170
  id: number;
171
+ /** Server snapshot capture order for this run, null on older servers. */
172
+ snapshotRev?: number | null;
173
+ /** Capture order of the last adopted launcher projection, independent of server state. */
174
+ projectionRev?: number | null;
175
+ /** Highest launcher event position included in an adopted summary projection. */
176
+ projectionSeq?: number;
177
+ /** Highest diagnostic identifier represented in this view. */
178
+ problemSeq?: number;
179
+ /** Highest diagnostic delivered by the ordered WebSocket stream. */
180
+ problemEventSeq?: number;
181
+ /** Summary findings awaiting possible earlier buffered live events. */
182
+ pendingFindings?: {
183
+ through: number;
184
+ keys: readonly string[];
185
+ };
186
+ /** Highest live or replay event observed, retained across full log replay. */
187
+ observedSeq?: number;
188
+ /** Last event position for each launcher projection, retained across replay. */
189
+ eventSeqs?: Readonly<Record<string, number>>;
170
190
  /** seq of the last event received (-1 if none). On reconnect, the resend is requested from the next one. */
171
191
  lastSeq: number;
172
192
  /** The configuration file (relative to root). */
@@ -177,7 +197,7 @@ export interface SessionView {
177
197
  * Participants the user chose on the screen to start themselves (manual: true in the configuration file is in check).
178
198
  */
179
199
  manual: readonly string[];
180
- /** Speed given at the start (null means as in the configuration file). The current speed is `speed` of launcherState. */
200
+ /** Speed requested at the start (null means no speed was requested). The current speed is `speed` of launcherState. */
181
201
  speed: Speed;
182
202
  /** Whether the run started paused. */
183
203
  startPaused: boolean;
@@ -287,3 +307,5 @@ export declare function phaseIndex(phase: Phase | null): number;
287
307
  * staleEvents (seq went back). The log array is rebuilt once per batch (not copied for every event).
288
308
  */
289
309
  export declare function applyEvents(session: SessionView, events: readonly LauncherEvent[], countStale?: boolean): SessionView;
310
+ /** Combines a same-run full replay with lines only the client still holds. */
311
+ export declare function recoverReplayLogs(session: SessionView, recovered: readonly LogLine[], notKept: ReadonlyMap<string, number>): SessionView;
@@ -23,6 +23,13 @@ export interface Notice {
23
23
  export interface ClientSession {
24
24
  /** The current (or last) session. null while the server has none yet. */
25
25
  readonly session: Readable<SessionView | null>;
26
+ /** Identity of the session suitable for a targeted action. */
27
+ currentTarget(): {
28
+ session: number;
29
+ instance: string;
30
+ } | null;
31
+ /** The last authenticated server instance, even when there is no session. */
32
+ currentInstance(): string | null;
26
33
  /**
27
34
  * The session copy matches the server: connected, and hello and the resent events have all arrived. Until then,
28
35
  * Start and Stop are disabled so that nobody acts on a stale display. Other features (values and so on) have their
@@ -64,6 +71,11 @@ export interface ClientSession {
64
71
  /** Removes a notice. */
65
72
  dismissNotice(id: number): void;
66
73
  }
74
+ interface Adoption {
75
+ revision: number;
76
+ instance: string | null;
77
+ session: number | null;
78
+ }
67
79
  /**
68
80
  * Copy of a session (one run of the launcher). Reads the notifications of the connection (Connection) and builds the
69
81
  * state from the server's summary and events.
@@ -82,6 +94,12 @@ export interface ClientSession {
82
94
  export declare class SessionFeed implements ClientSession {
83
95
  private readonly connection;
84
96
  private readonly onError;
97
+ private readonly rawListeners;
98
+ private snapshotVersion;
99
+ private instanceId;
100
+ private adoptionRevision;
101
+ private instanceListener;
102
+ private stopTarget;
85
103
  private readonly current;
86
104
  private readonly synced;
87
105
  private readonly allowedValue;
@@ -92,6 +110,7 @@ export declare class SessionFeed implements ClientSession {
92
110
  private readonly messageListeners;
93
111
  private noticeId;
94
112
  private stoppedFlag;
113
+ private replayLogs;
95
114
  readonly session: Readable<SessionView | null>;
96
115
  readonly ready: Readable<boolean>;
97
116
  readonly allowed: Readable<ServerAllowed | null>;
@@ -115,7 +134,19 @@ export declare class SessionFeed implements ClientSession {
115
134
  * request for the same run (the rest arrives in notifications). A summary of an earlier run never brings back an old
116
135
  * run over a new one.
117
136
  */
118
- adopt(summary: SessionSummary | null): void;
137
+ onRawMessages(listener: (batch: readonly unknown[], current: () => boolean, snapshotVersion: number) => void): () => void;
138
+ onSnapshotVersion(read: () => number): void;
139
+ /** Called before a new server's session can be published. */
140
+ onInstance(listener: (instance: string, current: () => boolean) => void): void;
141
+ /** Instance associated with the current session, or null if its origin is not known. */
142
+ currentInstance(): string | null;
143
+ currentTarget(): {
144
+ session: number;
145
+ instance: string;
146
+ } | null;
147
+ adopt(summary: SessionSummary | null, instance: string, resyncFrom?: string | null): Adoption | null;
148
+ sameRun(adoption: Adoption): boolean;
149
+ isCurrent(revision: number): boolean;
119
150
  /**
120
151
  * Takes what the server accepts (an HTTP answer or a notification): the one with the larger `rev` wins (rev 0 is a
121
152
  * server that does not number it: the newest arrival wins). Used inside the library.
@@ -125,6 +156,9 @@ export declare class SessionFeed implements ClientSession {
125
156
  dismissNotice(id: number): void;
126
157
  /** Reads and applies a batch from the connection. */
127
158
  private receive;
159
+ /** Keep messages at or after the run already observed over HTTP, within each server instance. */
160
+ private filterOlderRuns;
128
161
  private apply;
129
162
  private notify;
130
163
  }
164
+ export {};
package/types/values.d.ts CHANGED
@@ -39,6 +39,8 @@ export declare class Writable<T> implements Readable<T> {
39
39
  onError?: ErrorSink);
40
40
  get(): T;
41
41
  set(value: T): void;
42
+ /** Changes the value immediately and returns its notification, for an atomic multi-value update. */
43
+ setDeferred(value: T): () => void;
42
44
  update(change: (value: T) => T): void;
43
45
  subscribe(listener: (value: T) => void): () => void;
44
46
  /** Read-only view (get and subscribe only). */
@@ -112,6 +112,7 @@ export interface BindingSources {
112
112
  write(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<OperationView>;
113
113
  };
114
114
  readonly connection: Readable<ConnectionState>;
115
+ readonly connectionEpoch: () => number;
115
116
  readonly session: Readable<SessionView | null>;
116
117
  readonly onError: ErrorSink;
117
118
  }
@@ -0,0 +1,25 @@
1
+ import type { Front, VariableView } from './front-types.js';
2
+ import { type Readable } from './values.js';
3
+ import type { VariableInfo, VariableRef } from './variables.js';
4
+ import type { WriteValue } from './variable-state.js';
5
+ export interface VariableEditorState {
6
+ readonly info: (Omit<Readonly<VariableInfo>, 'enum'> & {
7
+ readonly enum: readonly Readonly<{
8
+ name: string;
9
+ value: number;
10
+ }>[] | null;
11
+ }) | undefined;
12
+ readonly view: VariableView;
13
+ readonly shown: WriteValue | null;
14
+ readonly waiting: boolean;
15
+ readonly canWrite: boolean;
16
+ }
17
+ export interface VariableEditor {
18
+ readonly state: Readable<VariableEditorState>;
19
+ /** Returns false when no edit can be attempted. Read the write result in state. */
20
+ write(value: WriteValue): boolean;
21
+ setVisible(visible: boolean): void;
22
+ close(): void;
23
+ }
24
+ /** Binds a typed editor to a variable, including the acknowledgement and readback of a Boolean edit. */
25
+ export declare function createVariableEditor(front: Front, ref: VariableRef): VariableEditor;
@@ -277,7 +277,7 @@ export declare function readOperation(value: unknown, session: number): Operatio
277
277
  export interface VariablesLink {
278
278
  /** Sends if connected (does nothing otherwise; resume() sends what is needed on connect). */
279
279
  send(message: unknown): unknown;
280
- onBatch(listener: (batch: readonly unknown[]) => void): () => void;
280
+ onBatch(listener: (batch: readonly unknown[], current?: () => boolean, snapshotVersion?: number) => void): () => void;
281
281
  }
282
282
  /**
283
283
  * ECU variables: list and state, value watches, writes and their results. No framework needed.
@@ -299,6 +299,10 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
299
299
  private readonly onError;
300
300
  /** Limits (from limits of api/app; the defaults until then). */
301
301
  private readonly limits;
302
+ private instanceId;
303
+ private snapshotVersionValue;
304
+ private snapshotIdentity;
305
+ private serverRevision;
302
306
  private readonly stateValue;
303
307
  private readonly operationsValue;
304
308
  private readonly handles;
@@ -334,8 +338,15 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
334
338
  private receive;
335
339
  /** Returns whether any state changed. Only the availability table changes: `peers` keeps its identity. */
336
340
  private takeAvailability;
337
- /** Applies the variables part of hello and of an HTTP summary (`session`). */
338
- adoptSummary(summary: unknown): void;
341
+ snapshotVersion(): number;
342
+ /** Compare server capture order when available; legacy peers use the local best-effort watermark. */
343
+ isSnapshotCurrent(version: number, instance: string | null, session: number | null, rev: number | null): boolean;
344
+ private markSnapshot;
345
+ private applySnapshot;
346
+ /** A reused numeric session on another server is a different run. */
347
+ adoptInstance(value: unknown): void;
348
+ /** Applies a summary: an older snapshot can still carry a terminal write result. */
349
+ adoptSummary(summary: unknown, current?: () => boolean, snapshotCurrent?: () => boolean): number | null;
339
350
  /**
340
351
  * With the summary after a reconnect (or from api/session), settles as "no answer came" (lost) the writes waiting for
341
352
  * a result that will no longer arrive. For writes whose number is not known yet (before the HTTP answer), the summary
@@ -359,6 +370,7 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
359
370
  * settled operations cut from the list are picked up from here.
360
371
  */
361
372
  private setOperations;
373
+ private prepareOperations;
362
374
  private settle;
363
375
  write(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<OperationView>;
364
376
  watch(variables: readonly VariableRef[] | 'all', options?: WatchOptions): VariableWatch;
@@ -0,0 +1,14 @@
1
+ import { type GuiClient } from './client.js';
2
+ import { type Readable } from './values.js';
3
+ import type { HistoryPoint, VariableRef, WatchOptions } from './variables.js';
4
+ export interface WaveformSeries {
5
+ readonly ref: Readonly<VariableRef>;
6
+ readonly points: readonly Readonly<HistoryPoint>[];
7
+ }
8
+ export interface Waveforms {
9
+ readonly series: Readable<readonly WaveformSeries[]>;
10
+ setSignals(refs: readonly VariableRef[]): void;
11
+ close(): void;
12
+ }
13
+ /** Keeps histories for the selected signals of the current run in selection order. */
14
+ export declare function createWaveforms(client: GuiClient, options?: WatchOptions): Waveforms;