@vehicle-sil/gui-client 0.2.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.2.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, 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';
@@ -112,8 +112,8 @@ export interface GuiClient {
112
112
  * the user opens the choice. Waits in the queue of the checks, as long as `check`.
113
113
  */
114
114
  connections(request: ConnectionsRequest): Promise<Connections>;
115
- /** `GET api/session`: summary of the current session (null if none). Also applied to the session copy. */
116
- fetchSession(): Promise<SessionSummary | null>;
115
+ /** `POST api/prepare`: prepares a persistent launcher when eligible. */
116
+ prepare(request: PrepareRequest): Promise<PrepareResponse>;
117
117
  /**
118
118
  * `GET api/dashboard`: reads the dashboard file next to the configuration file (relative to root) in the form the
119
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 } 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,12 +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;
64
+ onStarted?: (started: RunAck) => void;
60
65
  }): Promise<void>;
66
+ isAwaitingRunSession(): boolean;
67
+ isStopConfirmed(): boolean;
61
68
  /**
62
69
  * Checks what `intent` would start (`api/check`). Its failure is the caller's: it is not kept for `status.problem`.
63
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
@@ -96,10 +103,7 @@ export declare class FrontActions {
96
103
  /** What the client refuses before it sends a start: the connection, and a start of this page still on its way. */
97
104
  private refusalOfStart;
98
105
  stop(): Promise<void>;
99
- forceStop(target?: {
100
- session: number;
101
- instance: string;
102
- }): Promise<void>;
106
+ forceStop(target?: RunTarget): Promise<void>;
103
107
  /** Pending stop only affects controls of the run it was sent for. */
104
108
  busyForCurrent(): ReadonlySet<OperationName>;
105
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, ConfigText, SavedConfig, Finding, OutsideState, RunEnd, ScenarioFile, ScenarioStatus, ScenarioStep } 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,14 +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?: (started: RunAck) => void;
204
205
  }): Promise<void>;
205
206
  /** Stops in order. Works whatever the state of the connection (the request is sent if the network is up). */
206
207
  stop(): Promise<void>;
207
208
  /** Stops without waiting for the participants. */
208
- forceStop(target?: {
209
- session: number;
210
- instance: string;
211
- }): Promise<void>;
209
+ forceStop(target?: RunTarget): Promise<void>;
212
210
  }
213
211
  /**
214
212
  * Time operations. `pause`, `resume` and `setSpeed` resolve when the launcher has answered; `step` and `runUntil`
@@ -271,8 +269,24 @@ export interface Front {
271
269
  readonly clock: Readable<FrontClock>;
272
270
  readonly controls: Readable<FrontControls>;
273
271
  readonly scenario: Readable<FrontScenario | null>;
272
+ /** Current persistent runtime state (mode, ready/preparing/resetting/cold reason), or null until received. */
273
+ readonly runtime: Readable<RuntimeStatus | null>;
274
274
  readonly run: FrontRun;
275
275
  readonly time: FrontTime;
276
+ /**
277
+ * Prepares the persistent launcher for `options.file` (default: the start-up file) when eligible (`POST api/prepare`).
278
+ */
279
+ prepare(options?: {
280
+ file?: string;
281
+ variant?: string;
282
+ disable?: string[];
283
+ enable?: string[];
284
+ manual?: string[];
285
+ }): Promise<RuntimeStatus | null>;
286
+ /** Lists the configuration files under the server root (`GET api/configs`). */
287
+ configs(): Promise<ConfigList>;
288
+ /** Returns applied writes recorded in the current or last run as scenario YAML (`GET api/recording`). */
289
+ recording(): Promise<Recording | null>;
276
290
  /**
277
291
  * The networks of the run that the start's `connect` connected outside (empty when there are none, when no run is
278
292
  * going, and in a run that a `role: bridge` participant of the file connects: do not read "connected or not" from it).
package/types/index.d.ts CHANGED
@@ -22,10 +22,10 @@ export { BATCH_MS, TRY_AGAIN_LATER, webSocketFactory } from './connection.js';
22
22
  export type { SocketFactory, SocketHandlers, SocketLike } from './connection.js';
23
23
  export { DEFAULT_TIMEOUT_MS, HttpError, errorMessage, fetchTransport } from './http.js';
24
24
  export type { FetchTransportOptions, HttpOutcome, HttpRequest, HttpTransport } from './http.js';
25
- export { isHolding, launcherAnswer, phaseIndex, runOutcome } from './session-state.js';
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, readRecording, readScenarioList, readServerMessage, readSessionAllowed, readSessionResponse, 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, LogCounts, Open, OutsideState, ParticipantRole, ParticipantState, Phase, Recording, Replay, RunParticipant, RunRequest, RunResult, RunEnd, RunResultName, RunTiming, RunTraffic, 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;
@@ -2,20 +2,18 @@
2
2
  * The shapes the GUI server decides: the HTTP API (`api/*`), the WebSocket messages and the dashboard files. Parts that
3
3
  * come from the launcher (check, result, events) have the shapes of launcher.ts. Rules of the parsers: read.ts.
4
4
  */
5
- import { Open, Reader } from './read.js';
5
+ import { Open, Reader, Unreadable } from './read.js';
6
6
  import { CheckResult, ControlLink, Finding, LauncherEvent, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, Speed, SummaryCommand, SummaryState, TimeReport, Caution } from './launcher.js';
7
7
  /**
8
8
  * The version of the GUI server's API that this library reads (`vehicle_sil_gui` of `api/app` and `hello`). It does not
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'>;
@@ -278,13 +276,40 @@ export interface SummaryParticipant {
278
276
  /** State of the connection to the ECU's variables (the launcher's control_link event). null until it arrives. */
279
277
  control_link: ControlLink | null;
280
278
  }
279
+ export type LauncherMode = Open<'cold' | 'hot'>;
280
+ export type RuntimeMode = Open<'cold' | 'hot'>;
281
+ export type RuntimeState = Open<'idle' | 'preparing' | 'ready' | 'running' | 'resetting' | 'cold'>;
282
+ /** Persistent launcher status reported on `api/session`, `api/prepare`, `hello`, and `runtime` notifications. */
283
+ export interface RuntimeStatus {
284
+ mode: RuntimeMode;
285
+ state: RuntimeState;
286
+ config: string | null;
287
+ reason: string | null;
288
+ message: string | null;
289
+ }
290
+ export declare const readRuntimeStatus: Reader<RuntimeStatus>;
291
+ export interface PrepareRequest {
292
+ file: string;
293
+ variant?: string;
294
+ disable?: string[];
295
+ enable?: string[];
296
+ manual?: string[];
297
+ }
298
+ export interface PrepareResponse {
299
+ instance: string;
300
+ runtime?: RuntimeStatus;
301
+ }
302
+ export declare const readPrepareResponse: (value: unknown) => PrepareResponse;
281
303
  /** launcher of the summary: whether the launcher process is running and, if it ended, how. */
282
304
  export interface SummaryLauncher {
283
305
  /**
284
- * Whether it is running. Stays true after it printed the result, until the process exits. Decides whether it can be
285
- * stopped.
306
+ * Whether the run is still active on its launcher (false once ended, even when a persistent launcher stays alive).
286
307
  */
287
308
  running: boolean;
309
+ /** Persistent `'hot'` or per-run `'cold'`. Omitted on older servers. */
310
+ mode?: LauncherMode;
311
+ /** Whether the underlying launcher process itself is still alive. Omitted on older servers. */
312
+ process_alive?: boolean;
288
313
  exit_code: number | null;
289
314
  /** Number of the signal that ended it (POSIX only). */
290
315
  signal: number | null;
@@ -309,9 +334,9 @@ export interface LogCounts {
309
334
  * authoritative).
310
335
  */
311
336
  export interface SessionSummary {
312
- id: number;
313
- /** Server capture order within this instance and run; absent on older servers. */
314
- 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;
315
340
  /** Path relative to root. */
316
341
  file: string;
317
342
  disable: string[];
@@ -351,8 +376,7 @@ export interface SessionSummary {
351
376
  */
352
377
  allowed?: ServerAllowed | null;
353
378
  /**
354
- * The check result of this run (the check event). null until it arrives. The `session` notifications of a connection
355
- * 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.
356
380
  */
357
381
  check: CheckResult | null;
358
382
  /** The checked stop time when the full check was too large to keep. */
@@ -364,8 +388,6 @@ export interface SessionSummary {
364
388
  log: Record<string, LogCounts>;
365
389
  problems: ServerProblem[];
366
390
  problems_omitted: number;
367
- /** Highest diagnostic identifier allocated by the server, including omitted diagnostics. */
368
- problem_seq?: number | null;
369
391
  /** Progress of the scenario run (`scenario` of `api/run`). null for a run without a scenario. */
370
392
  scenario: SummaryScenario | null;
371
393
  /**
@@ -422,12 +444,6 @@ export interface ServerSaveItem extends ServerAllowedItem {
422
444
  * `launcher_state.allowed`.
423
445
  */
424
446
  export interface ServerAllowed {
425
- /**
426
- * Goes up by one each time what `allowed` says changes, the same in every place that carries it (`hello`,
427
- * `api/session`, the summary, the `allowed` message): keep the one with the larger rev. 0 from a server that does not
428
- * number it.
429
- */
430
- rev: number;
431
447
  start: ServerAllowedItem;
432
448
  stop: ServerAllowedItem;
433
449
  force: ServerAllowedItem;
@@ -435,27 +451,33 @@ export interface ServerAllowed {
435
451
  save: ServerSaveItem;
436
452
  }
437
453
  export declare const readServerAllowed: Reader<ServerAllowed>;
438
- /** 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). */
439
455
  export declare const readSessionResponse: (value: unknown) => SessionSummary | null;
440
- /** 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. */
441
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;
442
464
  /** What the server accepts, from `allowed` of an `api/session` response: also there when there is no run. */
443
465
  export declare const readSessionAllowed: (value: unknown) => ServerAllowed | null;
466
+ /** Persistent runtime status carried alongside `api/session` (undefined on older servers). */
467
+ export declare const readSessionRuntime: (value: unknown) => RuntimeStatus | null | undefined;
444
468
  /**
445
- * 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.
446
471
  */
447
- export interface StopRequestBody {
472
+ export interface StopSessionRequestBody {
448
473
  force: boolean;
449
- }
450
- /** POST api/stop-session: the server stops only this session. */
451
- export interface StopSessionRequestBody extends StopRequestBody {
452
- session: number;
474
+ run_id: string;
453
475
  instance: string;
454
476
  }
455
477
  /** Names of the time commands (the launcher's stdin commands other than stop). */
456
478
  export type TimeCommandName = 'pause' | 'resume' | 'step' | 'run_until' | 'speed';
457
479
  /**
458
- * 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.
459
481
  * The server passes the command to the launcher as one line. The answer arrives as a command event.
460
482
  */
461
483
  export type TimeCommand = ({
@@ -483,9 +505,9 @@ export type TimeCommand = ({
483
505
  */
484
506
  id?: number;
485
507
  };
486
- /** 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. */
487
509
  export interface TimeAnswer {
488
- session_id: number;
510
+ run_id: string;
489
511
  command: TimeCommandName;
490
512
  /** The `id` the request had (null if none). */
491
513
  id: number | null;
@@ -541,8 +563,6 @@ export interface OperationReport {
541
563
  }
542
564
  /** `variables` of the summary: state of the variable API, variables per participant, recent operations. */
543
565
  export interface VariablesSummary {
544
- /** Server capture order for variable snapshots and availability deltas; absent on older servers. */
545
- rev?: number | null;
546
566
  state: Open<'off' | 'connecting' | 'ready' | 'failed' | 'ended'>;
547
567
  reason: string | null;
548
568
  peers: {
@@ -559,14 +579,17 @@ export interface VariablesSummary {
559
579
  /** Number of unsettled operations the server could not keep (normally 0). */
560
580
  operations_open_omitted: number;
561
581
  }
582
+ export declare const readOperationReport: (value: unknown, path: string, u?: Unreadable) => OperationReport;
562
583
  /** Reads `variables` of a summary (present in `hello` and HTTP summaries, absent from `session` notifications). */
563
584
  export declare const readVariablesSummary: (value: unknown) => VariablesSummary;
585
+ export declare const readVariablesReport: (value: unknown, path: string, u?: Unreadable) => VariablesSummary;
564
586
  /** The `values` notification: the last values of the watched variables, and when they are from. */
565
587
  export interface ValuesMessage {
566
588
  type: 'values';
567
589
  /** id of the watch. */
568
590
  id: number;
569
- session: number;
591
+ watch_id: number;
592
+ run_id: string;
570
593
  /** The controller's virtual time (ms; null if unknown). */
571
594
  sim_ms: number | null;
572
595
  /** true: paused, and the values include every step that began before sim_ms. */
@@ -581,7 +604,7 @@ export interface ValuesMessage {
581
604
  }
582
605
  /** Answer of `api/write`. */
583
606
  export interface WriteAnswer {
584
- session_id: number;
607
+ run_id: string;
585
608
  /** Operation number. The result arrives in `operation` notifications. */
586
609
  operation: number;
587
610
  }
@@ -670,22 +693,19 @@ export type WatchMessage = {
670
693
  export interface AuthMessage {
671
694
  type: 'auth';
672
695
  token: string;
673
- session?: number;
674
- from_seq?: number;
675
- /**
676
- * If true, the summaries in this connection's `session` notifications leave out `check` (it arrives in the `hello`
677
- * summary and the `check` event), because the check result is large and does not change during the run.
678
- */
679
- session_without_check?: boolean;
696
+ instance?: string;
697
+ run_id?: string;
698
+ after_stream_seq?: number;
680
699
  }
681
700
  /** replay of hello: where the resend starts (null: from the beginning). */
682
701
  export interface Replay {
683
- from_seq: number | null;
702
+ after_stream_seq: number | null;
684
703
  }
685
704
  /** dropped: how much was not sent to this screen. */
686
705
  export interface Dropped {
687
706
  type: 'dropped';
688
- session: number | null;
707
+ stream_seq?: number;
708
+ run_id: string | null;
689
709
  /**
690
710
  * not-kept: the server no longer holds it (before the resend); slow-client: the screen read too slowly and the server
691
711
  * dropped some of what it was to send.
@@ -706,35 +726,45 @@ export type ServerMessage =
706
726
  {
707
727
  type: 'hello';
708
728
  instance: string;
729
+ stream_seq?: number;
709
730
  session: SessionSummary | null;
710
731
  /** What the server accepts now; also there when `session` is null. null from a server that does not say. */
711
732
  allowed: ServerAllowed | null;
712
733
  replay: Replay | null;
734
+ runtime?: RuntimeStatus | null;
735
+ } | {
736
+ type: 'runtime';
737
+ stream_seq?: number;
738
+ runtime: RuntimeStatus;
713
739
  }
714
740
  /**
715
741
  * What the server accepts changed with no `session` to carry it (a start begins or fails, the server begins to end).
716
- * 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.
717
743
  */
718
744
  | {
719
745
  type: 'allowed';
720
- session: number | null;
746
+ stream_seq?: number;
747
+ run_id: string | null;
721
748
  allowed: ServerAllowed;
722
749
  }
723
750
  /** A launcher event (resent log lines as well as new events). */
724
751
  | {
725
752
  type: 'event';
726
- session: number;
753
+ stream_seq?: number;
754
+ run_id: string;
727
755
  event: LauncherEvent;
728
756
  }
729
757
  /** The resend has finished. */
730
758
  | {
731
759
  type: 'synced';
732
- session: number | null;
760
+ stream_seq?: number;
761
+ run_id: string | null;
733
762
  last_seq: number | null;
734
763
  }
735
764
  /** The session summary changed (started, stop requested, the launcher exited, the run ended). */
736
765
  | {
737
766
  type: 'session';
767
+ stream_seq?: number;
738
768
  session: SessionSummary;
739
769
  }
740
770
  /**
@@ -743,7 +773,8 @@ export type ServerMessage =
743
773
  */
744
774
  | ({
745
775
  type: 'error';
746
- session: number | null;
776
+ stream_seq?: number;
777
+ run_id: string | null;
747
778
  } & ServerProblem)
748
779
  /** How much was not sent. */
749
780
  | Dropped
@@ -755,7 +786,8 @@ export type ServerMessage =
755
786
  /** The state or the list of the variable API changed (also once right after a run starts). */
756
787
  | {
757
788
  type: 'variables';
758
- session: number;
789
+ stream_seq?: number;
790
+ run_id: string;
759
791
  variables: VariablesSummary;
760
792
  }
761
793
  /** Values of the watched variables. */
@@ -763,7 +795,8 @@ export type ServerMessage =
763
795
  /** The result of a write changed. */
764
796
  | ({
765
797
  type: 'operation';
766
- session: number;
798
+ stream_seq?: number;
799
+ run_id: string;
767
800
  } & OperationReport)
768
801
  /**
769
802
  * Whether ECUs use their variables changed. For each participant listed, the state of every variable it reports
@@ -771,8 +804,8 @@ export type ServerMessage =
771
804
  */
772
805
  | {
773
806
  type: 'availability';
774
- session: number;
775
- rev?: number | null;
807
+ stream_seq?: number;
808
+ run_id: string;
776
809
  peers: Record<string, Record<string, VariableAvailability>>;
777
810
  };
778
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
  }