@vehicle-sil/gui-client 0.3.0 → 0.4.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vehicle-sil/gui-client",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-rc.1",
4
4
  "description": "Client library of the vehicle-sil GUI server: connection, run and time control, ECU variables. No dependencies; browser and Node.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/types/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ClientConnection, SocketFactory } from './connection.js';
2
2
  import { HttpTransport } from './http.js';
3
- import { AppInfo, CheckRequest, CheckTextRequest, ConfigText, DescribeRequest, CheckResult, ConfigList, Connections, ConnectionsRequest, DashboardResponse, PrepareRequest, PrepareResponse, Recording, SaveConfigRequest, SavedConfig, ScenarioList, SessionSummary } from './protocol.js';
3
+ import { AppInfo, CheckRequest, CheckTextRequest, ConfigText, DescribeRequest, CheckResult, ConfigList, Connections, ConnectionsRequest, DashboardResponse, PrepareRequest, PrepareResponse, Recording, SaveConfigRequest, SavedConfig, ScenarioList } from './protocol.js';
4
4
  import { ClientRun, RunControl } from './run.js';
5
5
  import { ClientSession } from './session.js';
6
6
  import { ClientTime } from './time.js';
@@ -114,8 +114,6 @@ export interface GuiClient {
114
114
  connections(request: ConnectionsRequest): Promise<Connections>;
115
115
  /** `POST api/prepare`: prepares a persistent launcher when eligible. */
116
116
  prepare(request: PrepareRequest): Promise<PrepareResponse>;
117
- /** `GET api/session`: summary of the current session (null if none). Also applied to the session copy. */
118
- fetchSession(): Promise<SessionSummary | null>;
119
117
  /**
120
118
  * `GET api/dashboard`: reads the dashboard file next to the configuration file (relative to root) in the form the
121
119
  * server checked (found is false if there is none; problems are in errors).
@@ -5,7 +5,7 @@ import { ActionError } from './front-types.js';
5
5
  import type { Snapshot } from './front-compose.js';
6
6
  import type { StopCapture } from './run.js';
7
7
  import { type RunTarget } from './session.js';
8
- import type { CheckResult, ConfigText, SavedConfig, SessionSummary } from './protocol.js';
8
+ import type { CheckResult, ConfigText, RunAck, SavedConfig } from './protocol.js';
9
9
  import { ErrorSink, Readable } from './values.js';
10
10
  /** A failed action, kept for `status.problem`. */
11
11
  export interface Failure {
@@ -39,6 +39,8 @@ export declare class FrontActions {
39
39
  private readonly src;
40
40
  private readonly busyValue;
41
41
  private readonly failureValue;
42
+ private readonly startedRunIdValue;
43
+ private readonly stopConfirmedForValue;
42
44
  private readonly waiting;
43
45
  private readonly inFlight;
44
46
  /** The checks not answered yet, in the order they are sent: the first is on its way, the others wait. */
@@ -52,13 +54,17 @@ export declare class FrontActions {
52
54
  private disposed;
53
55
  readonly busy: Readable<ReadonlySet<OperationName>>;
54
56
  readonly failure: Readable<Failure | null>;
57
+ readonly startedRunId: Readable<string | null>;
58
+ readonly stopConfirmedFor: Readable<string | null>;
55
59
  constructor(src: ActionSources,
56
60
  /** Where the ids start (they must differ between pages that send to the same run). */
57
61
  idStart?: number);
58
62
  start(intent?: Intent, options?: {
59
63
  file?: string;
60
- onStarted?: (session: SessionSummary) => void;
64
+ onStarted?: (started: RunAck) => void;
61
65
  }): Promise<void>;
66
+ isAwaitingRunSession(): boolean;
67
+ isStopConfirmed(): boolean;
62
68
  /**
63
69
  * Checks what `intent` would start (`api/check`). Its failure is the caller's: it is not kept for `status.problem`.
64
70
  * One check at a time: a check is sent after the answer to the one before (the server runs them one at a time, and
@@ -97,10 +103,7 @@ export declare class FrontActions {
97
103
  /** What the client refuses before it sends a start: the connection, and a start of this page still on its way. */
98
104
  private refusalOfStart;
99
105
  stop(): Promise<void>;
100
- forceStop(target?: {
101
- session: number;
102
- instance: string;
103
- }): Promise<void>;
106
+ forceStop(target?: RunTarget): Promise<void>;
104
107
  /** Pending stop only affects controls of the run it was sent for. */
105
108
  busyForCurrent(): ReadonlySet<OperationName>;
106
109
  private stopKey;
@@ -20,6 +20,10 @@ export interface Snapshot {
20
20
  limits: AppInfo['limits'];
21
21
  /** Operations of this page whose request has not been answered yet. */
22
22
  busy: ReadonlySet<OperationName>;
23
+ /** A start of this page succeeded (`POST api/run` returned `run_id`), waiting for its WebSocket session summary. */
24
+ awaitingRunSession?: boolean;
25
+ /** A stop of this page for the current run was confirmed by `POST api/stop-session`. */
26
+ stopConfirmed?: boolean;
23
27
  }
24
28
  export declare function linkOf(s: Snapshot): Link;
25
29
  export declare function runOf(s: Snapshot): RunState;
@@ -1,6 +1,6 @@
1
1
  import type { GuiClient } from './client.js';
2
2
  import type { RunTarget } from './session.js';
3
- import type { CheckResult, ConfigList, ConfigText, SavedConfig, Finding, OutsideState, Recording, RunEnd, RuntimeStatus, ScenarioFile, ScenarioStatus, ScenarioStep, SessionSummary } from './protocol.js';
3
+ import type { CheckResult, ConfigList, ConfigText, SavedConfig, Finding, OutsideState, Recording, RunAck, RunEnd, RuntimeStatus, ScenarioFile, ScenarioStatus, ScenarioStep } from './protocol.js';
4
4
  import type { ValueCondition, WriteBlock, WriteStatus } from './variable-state.js';
5
5
  import type { VariableRef, VariableValue } from './variables.js';
6
6
  import type { Readable } from './values.js';
@@ -201,15 +201,12 @@ export interface FrontRun {
201
201
  /** Starts a run of `file` (default: the start-up file). Rejects with `check-failed` and the findings if the check refuses it. */
202
202
  start(intent?: Intent, options?: {
203
203
  file?: string;
204
- onStarted?: (session: SessionSummary) => void;
204
+ onStarted?: (started: RunAck) => void;
205
205
  }): Promise<void>;
206
206
  /** Stops in order. Works whatever the state of the connection (the request is sent if the network is up). */
207
207
  stop(): Promise<void>;
208
208
  /** Stops without waiting for the participants. */
209
- forceStop(target?: {
210
- session: number;
211
- instance: string;
212
- }): Promise<void>;
209
+ forceStop(target?: RunTarget): Promise<void>;
213
210
  }
214
211
  /**
215
212
  * Time operations. `pause`, `resume` and `setSpeed` resolve when the launcher has answered; `step` and `runUntil`
@@ -285,7 +282,7 @@ export interface Front {
285
282
  disable?: string[];
286
283
  enable?: string[];
287
284
  manual?: string[];
288
- }): Promise<RuntimeStatus>;
285
+ }): Promise<RuntimeStatus | null>;
289
286
  /** Lists the configuration files under the server root (`GET api/configs`). */
290
287
  configs(): Promise<ConfigList>;
291
288
  /** Returns applied writes recorded in the current or last run as scenario YAML (`GET api/recording`). */
package/types/index.d.ts CHANGED
@@ -24,8 +24,8 @@ export { DEFAULT_TIMEOUT_MS, HttpError, errorMessage, fetchTransport } from './h
24
24
  export type { FetchTransportOptions, HttpOutcome, HttpRequest, HttpTransport } from './http.js';
25
25
  export { isHolding, isLauncherAlive, isLauncherFinishing, isRunActive, isSessionRunning, launcherAnswer, phaseIndex, runOutcome, } from './session-state.js';
26
26
  export type { CommandView, LauncherAnswer, LauncherView, LogLine, LogSource, ParticipantView, RunOutcome, ScenarioView, SessionView, TimeView, } from './session-state.js';
27
- export { PHASES, PROTOCOL_VERSION, ProtocolError, readAppInfo, readCheckResponse, readConfigList, readConfigText, readSavedConfig, readConnections, readDashboardResponse, readPrepareResponse, readRecording, readRuntimeStatus, readScenarioList, readServerMessage, readSessionAllowed, readSessionResponse, readSessionRuntime, readTimeResponse, readVariablesSummary, readWriteResponse, severityRank, } from './protocol.js';
28
- export type { AppInfo, AuthMessage, CheckNetwork, CheckOutcome, CheckParticipant, CheckRequest, CheckResult, CheckScenario, CheckStatus, CheckTextRequest, Caution, CommandReport, ConfigFile, ConfigList, ConfigText, SaveConfigRequest, SavedConfig, Connections, ConnectionsRequest, ControlLink, ControlOffer, ControlState, DashboardFile, DashboardFileError, DashboardFileItem, DashboardFileSection, DashboardPanelModule, DashboardResponse, DescribeRequest, DashboardVariable, Dropped, Finding, FromLauncher, LauncherAllowedItem, LauncherEvent, LauncherFields, LauncherMode, LogCounts, Open, OutsideState, ParticipantRole, ParticipantState, Phase, PrepareRequest, PrepareResponse, Recording, Replay, RunParticipant, RunRequest, RunResult, RunEnd, RunResultName, RunTiming, RunTraffic, RuntimeMode, RuntimeState, RuntimeStatus, ScenarioFile, ScenarioList, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerAllowed, ServerAllowedItem, ServerSaveItem, ServerMessage, ServerProblem, SessionSummary, Severity, Speed, StateReport, StopRequest, StopRequestBody, StopSessionRequestBody, SummaryCommand, SummaryLauncher, SummaryParticipant, SummaryScenario, SummaryState, TimeAnswer, TimeCommand, TimeCommandName, TimeReport, TrafficNetwork, TrafficParticipant, TrafficUnplaced, ValuesMessage, Variable, VariableSummary, VariablesSummary, OperationReport, VariableAvailability, WatchMessage, WriteAnswer, } from './protocol.js';
27
+ export { PHASES, PROTOCOL_VERSION, ProtocolError, readAppInfo, readCheckResponse, readConfigList, readConfigText, readSavedConfig, readConnections, readDashboardResponse, readPrepareResponse, readRecording, readRunResponse, readRuntimeStatus, readScenarioList, readServerMessage, readSessionAllowed, readSessionResponse, readSessionRuntime, readTimeResponse, readVariablesSummary, readWriteResponse, severityRank, } from './protocol.js';
28
+ export type { AppInfo, AuthMessage, CheckNetwork, CheckOutcome, CheckParticipant, CheckRequest, CheckResult, CheckScenario, CheckStatus, CheckTextRequest, Caution, CommandReport, ConfigFile, ConfigList, ConfigText, SaveConfigRequest, SavedConfig, Connections, ConnectionsRequest, ControlLink, ControlOffer, ControlState, DashboardFile, DashboardFileError, DashboardFileItem, DashboardFileSection, DashboardPanelModule, DashboardResponse, DescribeRequest, DashboardVariable, Dropped, Finding, FromLauncher, LauncherAllowedItem, LauncherEvent, LauncherFields, LauncherMode, LogCounts, Open, OutsideState, ParticipantRole, ParticipantState, Phase, PrepareRequest, PrepareResponse, Recording, Replay, RunAck, RunParticipant, RunRequest, RunResult, RunEnd, RunResultName, RunTiming, RunTraffic, RuntimeMode, RuntimeState, RuntimeStatus, ScenarioFile, ScenarioList, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerAllowed, ServerAllowedItem, ServerSaveItem, ServerMessage, ServerProblem, SessionSummary, Severity, Speed, StateReport, StopRequest, StopSessionRequestBody, SummaryCommand, SummaryLauncher, SummaryParticipant, SummaryScenario, SummaryState, TimeAnswer, TimeCommand, TimeCommandName, TimeReport, TrafficNetwork, TrafficParticipant, TrafficUnplaced, ValuesMessage, Variable, VariableSummary, VariablesSummary, OperationReport, VariableAvailability, WatchMessage, WriteAnswer, } from './protocol.js';
29
29
  export { createWaveforms } from './waveforms.js';
30
30
  export type { Waveforms, WaveformSeries } from './waveforms.js';
31
31
  export { createVariableEditor } from './variable-editor.js';
@@ -34,8 +34,6 @@ 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;
39
37
  severity: Severity;
40
38
  code: string;
41
39
  file: string | null;
@@ -354,6 +352,10 @@ export type LauncherEvent = (EventBase & {
354
352
  pid: number | null;
355
353
  file: string | null;
356
354
  arguments: string[];
355
+ }) | (EventBase & {
356
+ event: 'run_start';
357
+ id: number | null;
358
+ run: string | null;
357
359
  }) | (EventBase & {
358
360
  event: 'phase';
359
361
  phase: Phase;
@@ -9,13 +9,11 @@ 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 = 3;
12
+ export declare const PROTOCOL_VERSION = 4;
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;
19
17
  code: string;
20
18
  message: string;
21
19
  /** For launcher-stderr, the number of lines dropped at this point (`detail.skipped`). Other notices lack it. */
@@ -191,7 +189,7 @@ export declare const readScenarioList: (value: unknown) => ScenarioList;
191
189
  * YAML. The server writes no file (the screen hands it over as a browser download).
192
190
  */
193
191
  export interface Recording {
194
- session_id: number;
192
+ run_id: string;
195
193
  /** The run's configuration file (relative to root). */
196
194
  file: string;
197
195
  state: Open<'running' | 'ended'>;
@@ -299,7 +297,7 @@ export interface PrepareRequest {
299
297
  }
300
298
  export interface PrepareResponse {
301
299
  instance: string;
302
- runtime: RuntimeStatus;
300
+ runtime?: RuntimeStatus;
303
301
  }
304
302
  export declare const readPrepareResponse: (value: unknown) => PrepareResponse;
305
303
  /** launcher of the summary: whether the launcher process is running and, if it ended, how. */
@@ -336,9 +334,9 @@ export interface LogCounts {
336
334
  * authoritative).
337
335
  */
338
336
  export interface SessionSummary {
339
- id: number;
340
- /** Server capture order within this instance and run; absent on older servers. */
341
- snapshot_rev?: number | null;
337
+ id: string;
338
+ /** Baseline launcher t_ms at run start (0 on cold runs). */
339
+ run_t0_ms?: number | null;
342
340
  /** Path relative to root. */
343
341
  file: string;
344
342
  disable: string[];
@@ -378,8 +376,7 @@ export interface SessionSummary {
378
376
  */
379
377
  allowed?: ServerAllowed | null;
380
378
  /**
381
- * The check result of this run (the check event). null until it arrives. The `session` notifications of a connection
382
- * that asked for `session_without_check` lack the field and read it as null (the local check result is used as is).
379
+ * The check result of this run (the check event). null until it arrives.
383
380
  */
384
381
  check: CheckResult | null;
385
382
  /** The checked stop time when the full check was too large to keep. */
@@ -391,8 +388,6 @@ export interface SessionSummary {
391
388
  log: Record<string, LogCounts>;
392
389
  problems: ServerProblem[];
393
390
  problems_omitted: number;
394
- /** Highest diagnostic identifier allocated by the server, including omitted diagnostics. */
395
- problem_seq?: number | null;
396
391
  /** Progress of the scenario run (`scenario` of `api/run`). null for a run without a scenario. */
397
392
  scenario: SummaryScenario | null;
398
393
  /**
@@ -449,12 +444,6 @@ export interface ServerSaveItem extends ServerAllowedItem {
449
444
  * `launcher_state.allowed`.
450
445
  */
451
446
  export interface ServerAllowed {
452
- /**
453
- * Goes up by one each time what `allowed` says changes, the same in every place that carries it (`hello`,
454
- * `api/session`, the summary, the `allowed` message): keep the one with the larger rev. 0 from a server that does not
455
- * number it.
456
- */
457
- rev: number;
458
447
  start: ServerAllowedItem;
459
448
  stop: ServerAllowedItem;
460
449
  force: ServerAllowedItem;
@@ -462,29 +451,33 @@ export interface ServerAllowed {
462
451
  save: ServerSaveItem;
463
452
  }
464
453
  export declare const readServerAllowed: Reader<ServerAllowed>;
465
- /** Answer of GET api/session, POST api/run and POST api/stop (the current session; null if none). */
454
+ /** Answer of GET api/session (the current session; null if none). */
466
455
  export declare const readSessionResponse: (value: unknown) => SessionSummary | null;
467
- /** GET api/session and POST api/run must identify the GUI server that supplied the run ID. */
456
+ /** GET api/session, POST api/run and POST api/stop-session must identify the GUI server that supplied the run ID. */
468
457
  export declare const readSessionInstance: (value: unknown) => string;
458
+ /** Answer of POST api/run and POST api/stop-session. */
459
+ export interface RunAck {
460
+ instance: string;
461
+ run_id: string;
462
+ }
463
+ export declare const readRunResponse: (value: unknown) => RunAck;
469
464
  /** What the server accepts, from `allowed` of an `api/session` response: also there when there is no run. */
470
465
  export declare const readSessionAllowed: (value: unknown) => ServerAllowed | null;
471
466
  /** Persistent runtime status carried alongside `api/session` (undefined on older servers). */
472
467
  export declare const readSessionRuntime: (value: unknown) => RuntimeStatus | null | undefined;
473
468
  /**
474
- * Body of POST api/stop. force: false stops in order (asking again has no further effect); true stops without waiting.
469
+ * POST api/stop-session: the server stops only this session. force: false stops in order (asking again has no further
470
+ * effect); true stops without waiting.
475
471
  */
476
- export interface StopRequestBody {
472
+ export interface StopSessionRequestBody {
477
473
  force: boolean;
478
- }
479
- /** POST api/stop-session: the server stops only this session. */
480
- export interface StopSessionRequestBody extends StopRequestBody {
481
- session: number;
474
+ run_id: string;
482
475
  instance: string;
483
476
  }
484
477
  /** Names of the time commands (the launcher's stdin commands other than stop). */
485
478
  export type TimeCommandName = 'pause' | 'resume' | 'step' | 'run_until' | 'speed';
486
479
  /**
487
- * The command sent in POST api/time. The GUI Client adds the run's session and server instance to the request.
480
+ * The command sent in POST api/time. The GUI Client adds the run's run_id and server instance to the request.
488
481
  * The server passes the command to the launcher as one line. The answer arrives as a command event.
489
482
  */
490
483
  export type TimeCommand = ({
@@ -512,9 +505,9 @@ export type TimeCommand = ({
512
505
  */
513
506
  id?: number;
514
507
  };
515
- /** Answer of POST api/time: the number of the run it was sent to, and the command passed to the launcher. */
508
+ /** Answer of POST api/time: the run_id of the run it was sent to, and the command passed to the launcher. */
516
509
  export interface TimeAnswer {
517
- session_id: number;
510
+ run_id: string;
518
511
  command: TimeCommandName;
519
512
  /** The `id` the request had (null if none). */
520
513
  id: number | null;
@@ -570,8 +563,6 @@ export interface OperationReport {
570
563
  }
571
564
  /** `variables` of the summary: state of the variable API, variables per participant, recent operations. */
572
565
  export interface VariablesSummary {
573
- /** Server capture order for variable snapshots and availability deltas; absent on older servers. */
574
- rev?: number | null;
575
566
  state: Open<'off' | 'connecting' | 'ready' | 'failed' | 'ended'>;
576
567
  reason: string | null;
577
568
  peers: {
@@ -597,7 +588,8 @@ export interface ValuesMessage {
597
588
  type: 'values';
598
589
  /** id of the watch. */
599
590
  id: number;
600
- session: number;
591
+ watch_id: number;
592
+ run_id: string;
601
593
  /** The controller's virtual time (ms; null if unknown). */
602
594
  sim_ms: number | null;
603
595
  /** true: paused, and the values include every step that began before sim_ms. */
@@ -612,7 +604,7 @@ export interface ValuesMessage {
612
604
  }
613
605
  /** Answer of `api/write`. */
614
606
  export interface WriteAnswer {
615
- session_id: number;
607
+ run_id: string;
616
608
  /** Operation number. The result arrives in `operation` notifications. */
617
609
  operation: number;
618
610
  }
@@ -701,22 +693,19 @@ export type WatchMessage = {
701
693
  export interface AuthMessage {
702
694
  type: 'auth';
703
695
  token: string;
704
- session?: number;
705
- from_seq?: number;
706
- /**
707
- * If true, the summaries in this connection's `session` notifications leave out `check` (it arrives in the `hello`
708
- * summary and the `check` event), because the check result is large and does not change during the run.
709
- */
710
- session_without_check?: boolean;
696
+ instance?: string;
697
+ run_id?: string;
698
+ after_stream_seq?: number;
711
699
  }
712
700
  /** replay of hello: where the resend starts (null: from the beginning). */
713
701
  export interface Replay {
714
- from_seq: number | null;
702
+ after_stream_seq: number | null;
715
703
  }
716
704
  /** dropped: how much was not sent to this screen. */
717
705
  export interface Dropped {
718
706
  type: 'dropped';
719
- session: number | null;
707
+ stream_seq?: number;
708
+ run_id: string | null;
720
709
  /**
721
710
  * not-kept: the server no longer holds it (before the resend); slow-client: the screen read too slowly and the server
722
711
  * dropped some of what it was to send.
@@ -737,6 +726,7 @@ export type ServerMessage =
737
726
  {
738
727
  type: 'hello';
739
728
  instance: string;
729
+ stream_seq?: number;
740
730
  session: SessionSummary | null;
741
731
  /** What the server accepts now; also there when `session` is null. null from a server that does not say. */
742
732
  allowed: ServerAllowed | null;
@@ -744,32 +734,37 @@ export type ServerMessage =
744
734
  runtime?: RuntimeStatus | null;
745
735
  } | {
746
736
  type: 'runtime';
737
+ stream_seq?: number;
747
738
  runtime: RuntimeStatus;
748
739
  }
749
740
  /**
750
741
  * What the server accepts changed with no `session` to carry it (a start begins or fails, the server begins to end).
751
- * session is the current run's id (null if none). Other changes arrive in the summary.
742
+ * run_id is the current run's id (null if none). Other changes arrive in the summary.
752
743
  */
753
744
  | {
754
745
  type: 'allowed';
755
- session: number | null;
746
+ stream_seq?: number;
747
+ run_id: string | null;
756
748
  allowed: ServerAllowed;
757
749
  }
758
750
  /** A launcher event (resent log lines as well as new events). */
759
751
  | {
760
752
  type: 'event';
761
- session: number;
753
+ stream_seq?: number;
754
+ run_id: string;
762
755
  event: LauncherEvent;
763
756
  }
764
757
  /** The resend has finished. */
765
758
  | {
766
759
  type: 'synced';
767
- session: number | null;
760
+ stream_seq?: number;
761
+ run_id: string | null;
768
762
  last_seq: number | null;
769
763
  }
770
764
  /** The session summary changed (started, stop requested, the launcher exited, the run ended). */
771
765
  | {
772
766
  type: 'session';
767
+ stream_seq?: number;
773
768
  session: SessionSummary;
774
769
  }
775
770
  /**
@@ -778,7 +773,8 @@ export type ServerMessage =
778
773
  */
779
774
  | ({
780
775
  type: 'error';
781
- session: number | null;
776
+ stream_seq?: number;
777
+ run_id: string | null;
782
778
  } & ServerProblem)
783
779
  /** How much was not sent. */
784
780
  | Dropped
@@ -790,7 +786,8 @@ export type ServerMessage =
790
786
  /** The state or the list of the variable API changed (also once right after a run starts). */
791
787
  | {
792
788
  type: 'variables';
793
- session: number;
789
+ stream_seq?: number;
790
+ run_id: string;
794
791
  variables: VariablesSummary;
795
792
  }
796
793
  /** Values of the watched variables. */
@@ -798,7 +795,8 @@ export type ServerMessage =
798
795
  /** The result of a write changed. */
799
796
  | ({
800
797
  type: 'operation';
801
- session: number;
798
+ stream_seq?: number;
799
+ run_id: string;
802
800
  } & OperationReport)
803
801
  /**
804
802
  * Whether ECUs use their variables changed. For each participant listed, the state of every variable it reports
@@ -806,8 +804,8 @@ export type ServerMessage =
806
804
  */
807
805
  | {
808
806
  type: 'availability';
809
- session: number;
810
- rev?: number | null;
807
+ stream_seq?: number;
808
+ run_id: string;
811
809
  peers: Record<string, Record<string, VariableAvailability>>;
812
810
  };
813
811
  /**
package/types/run.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { HttpTransport } from './http.js';
2
- import { RunRequest, SessionSummary } from './protocol.js';
3
- import { SessionFeed } from './session.js';
2
+ import { RunAck, RunRequest } from './protocol.js';
3
+ import { RunTarget, 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
7
  export interface StopCapture {
8
8
  readonly key: object | string;
9
- readonly send: (force: boolean) => Promise<SessionSummary | null>;
9
+ readonly send: (force: boolean) => Promise<RunAck>;
10
10
  }
11
11
  /** Run control and its state (GuiClient.run). */
12
12
  export interface ClientRun {
@@ -21,33 +21,29 @@ export interface ClientRun {
21
21
  /** Why the last action was refused (the server's text, unchanged). null once a run starts or ends. */
22
22
  readonly error: Readable<string | null>;
23
23
  /**
24
- * Starts a run (`POST api/run`). Resolves with the summary in the answer; rejects with an HttpError if refused.
25
- * The server may check the configuration file again as part of the start, so this waits up to twice the check limit
26
- * (waiting its turn, then checking) plus a margin. If there is still no answer, it rejects with an HttpError with
27
- * `timedOut` and error says that no answer came (the WebSocket state tells whether the run started). The server may
28
- * have started it.
24
+ * Starts a run (`POST api/run`). Resolves with the `{instance, run_id}` acknowledgement; rejects with an HttpError
25
+ * if refused. The server may check the configuration file again as part of the start, so this waits up to twice the
26
+ * check limit (waiting its turn, then checking) plus a margin. If there is still no answer, it rejects with an
27
+ * HttpError with `timedOut` and error says that no answer came (the WebSocket state tells whether the run started).
29
28
  */
30
- start(request: RunRequest): Promise<SessionSummary | null>;
29
+ start(request: RunRequest): Promise<RunAck>;
31
30
  /**
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.
31
+ * Stops the session currently seen by this client (`POST api/stop-session`). During its own pending start, waits for
32
+ * the answer and targets that session. If the ID or server instance is unknown, or the start answer is lost, rejects
33
+ * without sending an unscoped stop.
35
34
  */
36
- stop(): Promise<SessionSummary | null>;
35
+ stop(): Promise<RunAck>;
37
36
  /** Stops without waiting for participants. A stop during this client's pending start is targeted the same way. */
38
- forceStop(): Promise<SessionSummary | null>;
37
+ forceStop(): Promise<RunAck>;
39
38
  }
40
39
  /**
41
40
  * Run control: start (`POST api/run`), stop in order or without waiting (`POST api/stop-session`), and their state.
42
41
  *
43
- * - The answer to an action (the current summary) is applied to the session copy without waiting for the notification
44
- * (no stale display right after a click).
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.
42
+ * - HTTP commands return `{instance, run_id}` acknowledgements; state transitions arrive over the single WebSocket
43
+ * stream.
44
+ * - A stop requested while a start is pending waits for its answer, then names that `run_id` and `instance` in the
45
+ * stop request. The server checks the ID atomically, so a later run cannot be stopped by the delayed request.
47
46
  * - error holds the reason for a refusal (the server's English text). It is cleared once a run starts or ends.
48
- * - The Promises of start() and stop() resolve with the summary in the answer (null if unreadable) and reject with an
49
- * HttpError when refused. No answer (`timedOut`) is not a refusal: the session copy tells whether the run started.
50
- * The state (starting and so on) has already changed when the Promise resolves.
51
47
  */
52
48
  export declare class RunControl implements ClientRun {
53
49
  private readonly feed;
@@ -57,6 +53,7 @@ export declare class RunControl implements ClientRun {
57
53
  */
58
54
  private readonly startTimeoutMs;
59
55
  private startOperation;
56
+ private startedTarget;
60
57
  private readonly pendingStops;
61
58
  private readonly pendingRevision;
62
59
  private readonly startSending;
@@ -74,16 +71,17 @@ export declare class RunControl implements ClientRun {
74
71
  */
75
72
  startTimeoutMs?: () => number);
76
73
  /** Starts a run. */
77
- start(request: RunRequest): Promise<SessionSummary | null>;
74
+ start(request: RunRequest): Promise<RunAck>;
75
+ activeTarget(): RunTarget | null;
78
76
  /** Stops in order (waits for the participants to end). Asking again never turns it into a stop without waiting. */
79
- stop(): Promise<SessionSummary | null>;
77
+ stop(): Promise<RunAck>;
80
78
  /** Stops without waiting (kills the participants). */
81
- forceStop(): Promise<SessionSummary | null>;
79
+ forceStop(): Promise<RunAck>;
82
80
  captureStop(): StopCapture;
83
81
  private requestStop;
84
82
  /**
85
- * Sends and applies the summary in the answer. done is called after the answer (failures too), before the Promise
86
- * settles.
83
+ * Sends an HTTP command and reads its `{instance, run_id}` acknowledgement. done is called after the answer
84
+ * (failures too), before the Promise settles.
87
85
  */
88
86
  private send;
89
87
  }
@@ -170,29 +170,12 @@ export interface ScenarioView {
170
170
  }
171
171
  /** State of one session (one run of the launcher), as the screen sees it. */
172
172
  export interface SessionView {
173
- /** Session number the server assigned. */
174
- id: number;
175
- /** Server snapshot capture order for this run, null on older servers. */
176
- snapshotRev?: number | null;
177
- /** Capture order of the last adopted launcher projection, independent of server state. */
178
- projectionRev?: number | null;
179
- /** Highest launcher event position included in an adopted summary projection. */
180
- projectionSeq?: number;
181
- /** Highest diagnostic identifier represented in this view. */
182
- problemSeq?: number;
183
- /** Highest diagnostic delivered by the ordered WebSocket stream. */
184
- problemEventSeq?: number;
185
- /** Summary findings awaiting possible earlier buffered live events. */
186
- pendingFindings?: {
187
- through: number;
188
- keys: readonly string[];
189
- };
190
- /** Highest live or replay event observed, retained across full log replay. */
191
- observedSeq?: number;
192
- /** Last event position for each launcher projection, retained across replay. */
193
- eventSeqs?: Readonly<Record<string, number>>;
194
- /** seq of the last event received (-1 if none). On reconnect, the resend is requested from the next one. */
173
+ /** Run identifier the server assigned. */
174
+ id: string;
175
+ /** seq of the last event received (-1 if none). */
195
176
  lastSeq: number;
177
+ /** Baseline launcher t_ms at the start of the run (0 on cold runs). */
178
+ runT0Ms: number;
196
179
  /** The configuration file (relative to root). */
197
180
  file: string;
198
181
  /** Participants left out. */
@@ -297,18 +280,9 @@ export declare function sessionFromSummary(summary: SessionSummary): SessionView
297
280
  */
298
281
  export declare function addDropped(session: SessionView, dropped: Dropped): SessionView;
299
282
  /**
300
- * Applies a summary. The local log is kept.
301
- *
302
- * - force (WebSocket hello and session): arrives in the same order as events, so everything is taken as correct at
303
- * the time it arrives.
304
- * - Without force (an HTTP answer): its order relative to notifications is unknown. Whether the launcher runs and the
305
- * stop requests are taken, but a launcher that has ended in the same run is never set back to running. Server
306
- * notices are taken only when there are no fewer than held locally (the server only adds, so a summary with fewer is
307
- * old). Phase, check, participants, findings, result and virtual time are taken only when the summary is newer than
308
- * the local events, and not at all with controlOnly (the WebSocket is connected and the same things arrive in
309
- * notifications), so findings do not appear twice, once from the summary and once from a notification.
283
+ * Applies an authoritative summary from the WebSocket stream (hello or session). The local log is kept.
310
284
  */
311
- export declare function applySummary(session: SessionView, summary: SessionSummary, force?: boolean, controlOnly?: boolean): SessionView;
285
+ export declare function applySummary(session: SessionView, summary: SessionSummary): SessionView;
312
286
  /**
313
287
  * Adds a server notice (later summaries carry the same one and replace it). Beyond the limit, only the number is
314
288
  * counted.
@@ -322,5 +296,3 @@ export declare function phaseIndex(phase: Phase | null): number;
322
296
  * staleEvents (seq went back). The log array is rebuilt once per batch (not copied for every event).
323
297
  */
324
298
  export declare function applyEvents(session: SessionView, events: readonly LauncherEvent[], countStale?: boolean): SessionView;
325
- /** Combines a same-run full replay with lines only the client still holds. */
326
- export declare function recoverReplayLogs(session: SessionView, recovered: readonly LogLine[], notKept: ReadonlyMap<string, number>): SessionView;