@vehicle-sil/gui-client 0.2.0-rc.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +14 -6
- package/README.md +14 -6
- package/dist/index.js +764 -566
- package/package.json +1 -1
- package/types/client.d.ts +3 -1
- package/types/front-actions.d.ts +8 -6
- package/types/front-types.d.ts +25 -6
- package/types/index.d.ts +4 -4
- package/types/protocol/server.d.ts +42 -5
- package/types/session-state.d.ts +17 -2
- package/types/session.d.ts +15 -9
- package/types/time.d.ts +4 -2
- package/types/variables.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vehicle-sil/gui-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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, SessionSummary } 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,6 +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
|
+
/** `POST api/prepare`: prepares a persistent launcher when eligible. */
|
|
116
|
+
prepare(request: PrepareRequest): Promise<PrepareResponse>;
|
|
115
117
|
/** `GET api/session`: summary of the current session (null if none). Also applied to the session copy. */
|
|
116
118
|
fetchSession(): Promise<SessionSummary | null>;
|
|
117
119
|
/**
|
package/types/front-actions.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import type { FrontControls, Intent, OperationName, RunState } from './front-typ
|
|
|
4
4
|
import { ActionError } from './front-types.js';
|
|
5
5
|
import type { Snapshot } from './front-compose.js';
|
|
6
6
|
import type { StopCapture } from './run.js';
|
|
7
|
-
import
|
|
7
|
+
import { type RunTarget } from './session.js';
|
|
8
|
+
import type { CheckResult, ConfigText, SavedConfig, SessionSummary } from './protocol.js';
|
|
8
9
|
import { ErrorSink, Readable } from './values.js';
|
|
9
10
|
/** A failed action, kept for `status.problem`. */
|
|
10
11
|
export interface Failure {
|
|
@@ -56,6 +57,7 @@ export declare class FrontActions {
|
|
|
56
57
|
idStart?: number);
|
|
57
58
|
start(intent?: Intent, options?: {
|
|
58
59
|
file?: string;
|
|
60
|
+
onStarted?: (session: SessionSummary) => void;
|
|
59
61
|
}): Promise<void>;
|
|
60
62
|
/**
|
|
61
63
|
* Checks what `intent` would start (`api/check`). Its failure is the caller's: it is not kept for `status.problem`.
|
|
@@ -105,11 +107,11 @@ export declare class FrontActions {
|
|
|
105
107
|
/** Repeated requests for the same run share one operation. */
|
|
106
108
|
private once;
|
|
107
109
|
private guarded;
|
|
108
|
-
pause(): Promise<void>;
|
|
109
|
-
resume(): Promise<void>;
|
|
110
|
-
step(ms: number): Promise<void>;
|
|
111
|
-
setSpeed(value: number | 'max'): Promise<void>;
|
|
112
|
-
runUntil(ms: number): Promise<void>;
|
|
110
|
+
pause(target?: RunTarget | null): Promise<void>;
|
|
111
|
+
resume(target?: RunTarget | null): Promise<void>;
|
|
112
|
+
step(ms: number, target?: RunTarget | null): Promise<void>;
|
|
113
|
+
setSpeed(value: number | 'max', target?: RunTarget | null): Promise<void>;
|
|
114
|
+
runUntil(ms: number, target?: RunTarget | null): Promise<void>;
|
|
113
115
|
private time;
|
|
114
116
|
/** Ends a waiting command: with an error, or (null) as done. A command ended twice is ended once. */
|
|
115
117
|
private settle;
|
package/types/front-types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GuiClient } from './client.js';
|
|
2
|
-
import type {
|
|
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
4
|
import type { ValueCondition, WriteBlock, WriteStatus } from './variable-state.js';
|
|
4
5
|
import type { VariableRef, VariableValue } from './variables.js';
|
|
5
6
|
import type { Readable } from './values.js';
|
|
@@ -200,6 +201,7 @@ export interface FrontRun {
|
|
|
200
201
|
/** Starts a run of `file` (default: the start-up file). Rejects with `check-failed` and the findings if the check refuses it. */
|
|
201
202
|
start(intent?: Intent, options?: {
|
|
202
203
|
file?: string;
|
|
204
|
+
onStarted?: (session: SessionSummary) => void;
|
|
203
205
|
}): Promise<void>;
|
|
204
206
|
/** Stops in order. Works whatever the state of the connection (the request is sent if the network is up). */
|
|
205
207
|
stop(): Promise<void>;
|
|
@@ -213,13 +215,14 @@ export interface FrontRun {
|
|
|
213
215
|
* Time operations. `pause`, `resume` and `setSpeed` resolve when the launcher has answered; `step` and `runUntil`
|
|
214
216
|
* resolve when time has arrived and the run is paused again (read `clock` after `await`). Another command sent before
|
|
215
217
|
* it arrives (from this page, another page or stdin) rejects it with `interrupted`.
|
|
218
|
+
* Pass the target from the rendered view to refuse the operation if the run changes before dispatch.
|
|
216
219
|
*/
|
|
217
220
|
export interface FrontTime {
|
|
218
|
-
pause(): Promise<void>;
|
|
219
|
-
resume(): Promise<void>;
|
|
220
|
-
step(ms: number): Promise<void>;
|
|
221
|
-
setSpeed(value: number | 'max'): Promise<void>;
|
|
222
|
-
runUntil(ms: number): Promise<void>;
|
|
221
|
+
pause(target?: RunTarget | null): Promise<void>;
|
|
222
|
+
resume(target?: RunTarget | null): Promise<void>;
|
|
223
|
+
step(ms: number, target?: RunTarget | null): Promise<void>;
|
|
224
|
+
setSpeed(value: number | 'max', target?: RunTarget | null): Promise<void>;
|
|
225
|
+
runUntil(ms: number, target?: RunTarget | null): Promise<void>;
|
|
223
226
|
}
|
|
224
227
|
/** What a screen shows for one variable. */
|
|
225
228
|
export interface VariableView {
|
|
@@ -269,8 +272,24 @@ export interface Front {
|
|
|
269
272
|
readonly clock: Readable<FrontClock>;
|
|
270
273
|
readonly controls: Readable<FrontControls>;
|
|
271
274
|
readonly scenario: Readable<FrontScenario | null>;
|
|
275
|
+
/** Current persistent runtime state (mode, ready/preparing/resetting/cold reason), or null until received. */
|
|
276
|
+
readonly runtime: Readable<RuntimeStatus | null>;
|
|
272
277
|
readonly run: FrontRun;
|
|
273
278
|
readonly time: FrontTime;
|
|
279
|
+
/**
|
|
280
|
+
* Prepares the persistent launcher for `options.file` (default: the start-up file) when eligible (`POST api/prepare`).
|
|
281
|
+
*/
|
|
282
|
+
prepare(options?: {
|
|
283
|
+
file?: string;
|
|
284
|
+
variant?: string;
|
|
285
|
+
disable?: string[];
|
|
286
|
+
enable?: string[];
|
|
287
|
+
manual?: string[];
|
|
288
|
+
}): Promise<RuntimeStatus>;
|
|
289
|
+
/** Lists the configuration files under the server root (`GET api/configs`). */
|
|
290
|
+
configs(): Promise<ConfigList>;
|
|
291
|
+
/** Returns applied writes recorded in the current or last run as scenario YAML (`GET api/recording`). */
|
|
292
|
+
recording(): Promise<Recording | null>;
|
|
274
293
|
/**
|
|
275
294
|
* The networks of the run that the start's `connect` connected outside (empty when there are none, when no run is
|
|
276
295
|
* 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { DEFAULT_LIMITS, createClient } from './client.js';
|
|
2
2
|
export type { ClientOptions, GuiClient } from './client.js';
|
|
3
3
|
export type { ClientConnection, CloseInfo, ConnectionState } from './connection.js';
|
|
4
|
-
export type { ClientSession, Notice } from './session.js';
|
|
4
|
+
export type { ClientSession, Notice, RunTarget } from './session.js';
|
|
5
5
|
export type { ClientRun, StopAction } from './run.js';
|
|
6
6
|
export type { ClientTime, Lateness, NotSentReason, SendResult, TimeFailure, TimeState, } from './time.js';
|
|
7
7
|
export { ANSWER_TIMEOUT_MS } from './time.js';
|
|
@@ -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, 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';
|
|
29
29
|
export { createWaveforms } from './waveforms.js';
|
|
30
30
|
export type { Waveforms, WaveformSeries } from './waveforms.js';
|
|
31
31
|
export { createVariableEditor } from './variable-editor.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
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
|
|
@@ -278,13 +278,40 @@ export interface SummaryParticipant {
|
|
|
278
278
|
/** State of the connection to the ECU's variables (the launcher's control_link event). null until it arrives. */
|
|
279
279
|
control_link: ControlLink | null;
|
|
280
280
|
}
|
|
281
|
+
export type LauncherMode = Open<'cold' | 'hot'>;
|
|
282
|
+
export type RuntimeMode = Open<'cold' | 'hot'>;
|
|
283
|
+
export type RuntimeState = Open<'idle' | 'preparing' | 'ready' | 'running' | 'resetting' | 'cold'>;
|
|
284
|
+
/** Persistent launcher status reported on `api/session`, `api/prepare`, `hello`, and `runtime` notifications. */
|
|
285
|
+
export interface RuntimeStatus {
|
|
286
|
+
mode: RuntimeMode;
|
|
287
|
+
state: RuntimeState;
|
|
288
|
+
config: string | null;
|
|
289
|
+
reason: string | null;
|
|
290
|
+
message: string | null;
|
|
291
|
+
}
|
|
292
|
+
export declare const readRuntimeStatus: Reader<RuntimeStatus>;
|
|
293
|
+
export interface PrepareRequest {
|
|
294
|
+
file: string;
|
|
295
|
+
variant?: string;
|
|
296
|
+
disable?: string[];
|
|
297
|
+
enable?: string[];
|
|
298
|
+
manual?: string[];
|
|
299
|
+
}
|
|
300
|
+
export interface PrepareResponse {
|
|
301
|
+
instance: string;
|
|
302
|
+
runtime: RuntimeStatus;
|
|
303
|
+
}
|
|
304
|
+
export declare const readPrepareResponse: (value: unknown) => PrepareResponse;
|
|
281
305
|
/** launcher of the summary: whether the launcher process is running and, if it ended, how. */
|
|
282
306
|
export interface SummaryLauncher {
|
|
283
307
|
/**
|
|
284
|
-
* Whether
|
|
285
|
-
* stopped.
|
|
308
|
+
* Whether the run is still active on its launcher (false once ended, even when a persistent launcher stays alive).
|
|
286
309
|
*/
|
|
287
310
|
running: boolean;
|
|
311
|
+
/** Persistent `'hot'` or per-run `'cold'`. Omitted on older servers. */
|
|
312
|
+
mode?: LauncherMode;
|
|
313
|
+
/** Whether the underlying launcher process itself is still alive. Omitted on older servers. */
|
|
314
|
+
process_alive?: boolean;
|
|
288
315
|
exit_code: number | null;
|
|
289
316
|
/** Number of the signal that ended it (POSIX only). */
|
|
290
317
|
signal: number | null;
|
|
@@ -355,6 +382,8 @@ export interface SessionSummary {
|
|
|
355
382
|
* that asked for `session_without_check` lack the field and read it as null (the local check result is used as is).
|
|
356
383
|
*/
|
|
357
384
|
check: CheckResult | null;
|
|
385
|
+
/** The checked stop time when the full check was too large to keep. */
|
|
386
|
+
stop_at_ms?: number | null;
|
|
358
387
|
participants: SummaryParticipant[];
|
|
359
388
|
findings: Finding[];
|
|
360
389
|
result: RunResult | null;
|
|
@@ -439,6 +468,8 @@ export declare const readSessionResponse: (value: unknown) => SessionSummary | n
|
|
|
439
468
|
export declare const readSessionInstance: (value: unknown) => string;
|
|
440
469
|
/** What the server accepts, from `allowed` of an `api/session` response: also there when there is no run. */
|
|
441
470
|
export declare const readSessionAllowed: (value: unknown) => ServerAllowed | null;
|
|
471
|
+
/** Persistent runtime status carried alongside `api/session` (undefined on older servers). */
|
|
472
|
+
export declare const readSessionRuntime: (value: unknown) => RuntimeStatus | null | undefined;
|
|
442
473
|
/**
|
|
443
474
|
* Body of POST api/stop. force: false stops in order (asking again has no further effect); true stops without waiting.
|
|
444
475
|
*/
|
|
@@ -453,8 +484,8 @@ export interface StopSessionRequestBody extends StopRequestBody {
|
|
|
453
484
|
/** Names of the time commands (the launcher's stdin commands other than stop). */
|
|
454
485
|
export type TimeCommandName = 'pause' | 'resume' | 'step' | 'run_until' | 'speed';
|
|
455
486
|
/**
|
|
456
|
-
*
|
|
457
|
-
*
|
|
487
|
+
* The command sent in POST api/time. The GUI Client adds the run's session and server instance to the request.
|
|
488
|
+
* The server passes the command to the launcher as one line. The answer arrives as a command event.
|
|
458
489
|
*/
|
|
459
490
|
export type TimeCommand = ({
|
|
460
491
|
command: 'pause';
|
|
@@ -557,8 +588,10 @@ export interface VariablesSummary {
|
|
|
557
588
|
/** Number of unsettled operations the server could not keep (normally 0). */
|
|
558
589
|
operations_open_omitted: number;
|
|
559
590
|
}
|
|
591
|
+
export declare const readOperationReport: (value: unknown, path: string, u?: Unreadable) => OperationReport;
|
|
560
592
|
/** Reads `variables` of a summary (present in `hello` and HTTP summaries, absent from `session` notifications). */
|
|
561
593
|
export declare const readVariablesSummary: (value: unknown) => VariablesSummary;
|
|
594
|
+
export declare const readVariablesReport: (value: unknown, path: string, u?: Unreadable) => VariablesSummary;
|
|
562
595
|
/** The `values` notification: the last values of the watched variables, and when they are from. */
|
|
563
596
|
export interface ValuesMessage {
|
|
564
597
|
type: 'values';
|
|
@@ -708,6 +741,10 @@ export type ServerMessage =
|
|
|
708
741
|
/** What the server accepts now; also there when `session` is null. null from a server that does not say. */
|
|
709
742
|
allowed: ServerAllowed | null;
|
|
710
743
|
replay: Replay | null;
|
|
744
|
+
runtime?: RuntimeStatus | null;
|
|
745
|
+
} | {
|
|
746
|
+
type: 'runtime';
|
|
747
|
+
runtime: RuntimeStatus;
|
|
711
748
|
}
|
|
712
749
|
/**
|
|
713
750
|
* What the server accepts changed with no `session` to carry it (a start begins or fails, the server begins to end).
|
package/types/session-state.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckResult, ControlLink, Dropped, Finding, LauncherEvent, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, ServerProblem, SessionSummary, Speed, StateReport, TimeReport } from './protocol.js';
|
|
1
|
+
import { CheckResult, ControlLink, Dropped, Finding, LauncherEvent, LauncherMode, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, ServerProblem, SessionSummary, Speed, StateReport, TimeReport } from './protocol.js';
|
|
2
2
|
/**
|
|
3
3
|
* A reason: a code that stays the same (an entry of the owner's reason codes, or one the client names) and one English
|
|
4
4
|
* sentence.
|
|
@@ -98,8 +98,12 @@ export interface ParticipantView {
|
|
|
98
98
|
}
|
|
99
99
|
/** State of the launcher process (as the server sees it). */
|
|
100
100
|
export interface LauncherView {
|
|
101
|
-
/** Whether
|
|
101
|
+
/** Whether the run is still active on its launcher (false once ended, even in hot mode). */
|
|
102
102
|
running: boolean;
|
|
103
|
+
/** Persistent `'hot'` or per-run `'cold'`. Undefined from older servers. */
|
|
104
|
+
mode?: LauncherMode;
|
|
105
|
+
/** Whether the underlying launcher process itself is still alive. Undefined from older servers. */
|
|
106
|
+
processAlive?: boolean;
|
|
103
107
|
exitCode: number | null;
|
|
104
108
|
/** Number of the signal that ended it (POSIX only). */
|
|
105
109
|
signal: number | null;
|
|
@@ -205,6 +209,8 @@ export interface SessionView {
|
|
|
205
209
|
/** Position of the last known phase received (so an unknown phase never moves the phase backwards). */
|
|
206
210
|
phaseRank: number;
|
|
207
211
|
check: CheckResult | null;
|
|
212
|
+
/** The checked stop time when the full check was too large to keep. */
|
|
213
|
+
stopAtMs?: number | null;
|
|
208
214
|
participants: readonly ParticipantView[];
|
|
209
215
|
/** Log lines (in seq order). */
|
|
210
216
|
logs: readonly LogLine[];
|
|
@@ -233,6 +239,7 @@ export interface SessionView {
|
|
|
233
239
|
*/
|
|
234
240
|
launcherState: StateReport | null;
|
|
235
241
|
result: RunResult | null;
|
|
242
|
+
state: 'running' | 'ended' | string;
|
|
236
243
|
launcher: LauncherView;
|
|
237
244
|
/** What the server noticed (shown in English, unchanged). */
|
|
238
245
|
problems: readonly ServerProblem[];
|
|
@@ -267,6 +274,14 @@ export type RunOutcome =
|
|
|
267
274
|
| 'ended'
|
|
268
275
|
/** The launcher exited without a result. */
|
|
269
276
|
| 'crashed';
|
|
277
|
+
/** Whether the session is running (`state === 'running'`). */
|
|
278
|
+
export declare function isSessionRunning(session: SessionView | SessionSummary | null | undefined): boolean;
|
|
279
|
+
/** Whether the run itself is actively executing on its launcher. */
|
|
280
|
+
export declare function isRunActive(session: SessionView | SessionSummary | null | undefined): boolean;
|
|
281
|
+
/** Whether a result has arrived while a one-shot launcher process is still finishing. */
|
|
282
|
+
export declare function isLauncherFinishing(session: SessionView | SessionSummary | null | undefined): boolean;
|
|
283
|
+
/** Whether the underlying launcher process is still alive (falls back to `launcher.running` on older servers). */
|
|
284
|
+
export declare function isLauncherAlive(session: SessionView | SessionSummary | null | undefined): boolean;
|
|
270
285
|
/**
|
|
271
286
|
* Whether the run waits before its first step (the step at time 0) for a resume or a step: the launcher's state says
|
|
272
287
|
* so (`holding`; a run started paused whose launcher has a Control Server). Meanwhile the launcher writes no time
|
package/types/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from './connection.js';
|
|
2
|
-
import { AuthMessage, ServerAllowed, ServerMessage, SessionSummary } from './protocol.js';
|
|
2
|
+
import { AuthMessage, RuntimeStatus, ServerAllowed, ServerMessage, SessionSummary } from './protocol.js';
|
|
3
3
|
import { SessionView } from './session-state.js';
|
|
4
4
|
import { ErrorSink, Readable } from './values.js';
|
|
5
5
|
/** How many kinds of notices not tied to a session are kept. */
|
|
@@ -19,15 +19,18 @@ export interface Notice {
|
|
|
19
19
|
/** How many times the same text arrived. */
|
|
20
20
|
count: number;
|
|
21
21
|
}
|
|
22
|
+
/** Identity of one run across all starts of the server. */
|
|
23
|
+
export interface RunTarget {
|
|
24
|
+
session: number;
|
|
25
|
+
instance: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function sameRunTarget(left: RunTarget | null, right: RunTarget | null): boolean;
|
|
22
28
|
/** Read side of the session copy (GuiClient.session). */
|
|
23
29
|
export interface ClientSession {
|
|
24
30
|
/** The current (or last) session. null while the server has none yet. */
|
|
25
31
|
readonly session: Readable<SessionView | null>;
|
|
26
32
|
/** Identity of the session suitable for a targeted action. */
|
|
27
|
-
currentTarget():
|
|
28
|
-
session: number;
|
|
29
|
-
instance: string;
|
|
30
|
-
} | null;
|
|
33
|
+
currentTarget(): RunTarget | null;
|
|
31
34
|
/** The last authenticated server instance, even when there is no session. */
|
|
32
35
|
currentInstance(): string | null;
|
|
33
36
|
/**
|
|
@@ -41,6 +44,8 @@ export interface ClientSession {
|
|
|
41
44
|
* does not say. What the launcher accepts is `launcherState` of the session.
|
|
42
45
|
*/
|
|
43
46
|
readonly allowed: Readable<ServerAllowed | null>;
|
|
47
|
+
/** Persistent launcher status reported on hello, runtime notifications, and prepare answers. */
|
|
48
|
+
readonly runtime: Readable<RuntimeStatus | null>;
|
|
44
49
|
/** When an event was last applied (Date.now()). The starting point for advancing elapsed time with the clock. */
|
|
45
50
|
readonly lastEventAt: Readable<number>;
|
|
46
51
|
/**
|
|
@@ -103,6 +108,7 @@ export declare class SessionFeed implements ClientSession {
|
|
|
103
108
|
private readonly current;
|
|
104
109
|
private readonly synced;
|
|
105
110
|
private readonly allowedValue;
|
|
111
|
+
private readonly runtimeValue;
|
|
106
112
|
private readonly receivedAt;
|
|
107
113
|
private readonly noticeList;
|
|
108
114
|
private readonly rejectedValue;
|
|
@@ -114,6 +120,7 @@ export declare class SessionFeed implements ClientSession {
|
|
|
114
120
|
readonly session: Readable<SessionView | null>;
|
|
115
121
|
readonly ready: Readable<boolean>;
|
|
116
122
|
readonly allowed: Readable<ServerAllowed | null>;
|
|
123
|
+
readonly runtime: Readable<RuntimeStatus | null>;
|
|
117
124
|
readonly lastEventAt: Readable<number>;
|
|
118
125
|
readonly notices: Readable<readonly Notice[]>;
|
|
119
126
|
readonly rejected: Readable<boolean>;
|
|
@@ -140,10 +147,7 @@ export declare class SessionFeed implements ClientSession {
|
|
|
140
147
|
onInstance(listener: (instance: string, current: () => boolean) => void): void;
|
|
141
148
|
/** Instance associated with the current session, or null if its origin is not known. */
|
|
142
149
|
currentInstance(): string | null;
|
|
143
|
-
currentTarget():
|
|
144
|
-
session: number;
|
|
145
|
-
instance: string;
|
|
146
|
-
} | null;
|
|
150
|
+
currentTarget(): RunTarget | null;
|
|
147
151
|
adopt(summary: SessionSummary | null, instance: string, resyncFrom?: string | null): Adoption | null;
|
|
148
152
|
sameRun(adoption: Adoption): boolean;
|
|
149
153
|
isCurrent(revision: number): boolean;
|
|
@@ -152,6 +156,8 @@ export declare class SessionFeed implements ClientSession {
|
|
|
152
156
|
* server that does not number it: the newest arrival wins). Used inside the library.
|
|
153
157
|
*/
|
|
154
158
|
adoptAllowed(allowed: ServerAllowed | null): void;
|
|
159
|
+
/** Updates the current persistent runtime status (from HTTP `prepare`/`session`). Used inside the library. */
|
|
160
|
+
adoptRuntime(runtime: RuntimeStatus | null): void;
|
|
155
161
|
report(message: string, count?: number): void;
|
|
156
162
|
dismissNotice(id: number): void;
|
|
157
163
|
/** Reads and applies a batch from the connection. */
|
package/types/time.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpTransport } from './http.js';
|
|
2
2
|
import { TimeCommand, TimeCommandName } from './protocol.js';
|
|
3
|
+
import { type RunTarget } from './session.js';
|
|
3
4
|
import { CommandView, SessionView, TimeView } from './session-state.js';
|
|
4
5
|
import { ErrorSink, Readable } from './values.js';
|
|
5
6
|
/**
|
|
@@ -98,16 +99,17 @@ export interface ClientTime {
|
|
|
98
99
|
export declare class TimeControl implements ClientTime {
|
|
99
100
|
private readonly session;
|
|
100
101
|
private readonly transport;
|
|
102
|
+
private readonly currentTarget;
|
|
101
103
|
/** How long to wait for an answer (ms). */
|
|
102
104
|
readonly answerTimeoutMs: number;
|
|
103
|
-
private readonly
|
|
105
|
+
private readonly awaitingHttp;
|
|
104
106
|
private readonly pending;
|
|
105
107
|
private readonly failureValue;
|
|
106
108
|
private answerTimer;
|
|
107
109
|
private lastLateness;
|
|
108
110
|
/** Time state. */
|
|
109
111
|
readonly state: Readable<TimeState>;
|
|
110
|
-
constructor(session: Readable<SessionView | null>, transport: HttpTransport,
|
|
112
|
+
constructor(session: Readable<SessionView | null>, transport: HttpTransport, currentTarget: () => RunTarget | null,
|
|
111
113
|
/** How long to wait for an answer (ms). */
|
|
112
114
|
answerTimeoutMs?: number, onError?: ErrorSink);
|
|
113
115
|
pause(): SendResult;
|
package/types/variables.d.ts
CHANGED
|
@@ -157,6 +157,8 @@ export interface OperationView {
|
|
|
157
157
|
}
|
|
158
158
|
/** Options of a write. */
|
|
159
159
|
export interface WriteOptions {
|
|
160
|
+
/** Optional server instance identifier to reject stale writes across server restarts. */
|
|
161
|
+
instance?: string;
|
|
160
162
|
/** Virtual time at which to apply it (ms). Omitted: the next step. */
|
|
161
163
|
atMs?: number;
|
|
162
164
|
/** If the requested time cannot be met: reject (default; not applied) or apply (applied in the next step). */
|