@nsshunt/stsrunnerframework 1.0.200 → 2.0.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.
Files changed (44) hide show
  1. package/README.md +1059 -1
  2. package/dist/stsrunnerframework.mjs +8263 -4105
  3. package/dist/stsrunnerframework.mjs.map +1 -1
  4. package/dist/stsrunnerframework.umd.js +8288 -4119
  5. package/dist/stsrunnerframework.umd.js.map +1 -1
  6. package/package.json +4 -4
  7. package/types/abstractRunnerExecutionWorker.d.ts +194 -0
  8. package/types/abstractRunnerExecutionWorker.d.ts.map +1 -0
  9. package/types/archiveManager.d.ts +172 -0
  10. package/types/archiveManager.d.ts.map +1 -0
  11. package/types/asyncRunnerInstanceManager.d.ts +108 -0
  12. package/types/asyncRunnerInstanceManager.d.ts.map +1 -0
  13. package/types/commonTypes.d.ts +115 -35
  14. package/types/commonTypes.d.ts.map +1 -1
  15. package/types/index.d.ts +1 -1
  16. package/types/index.d.ts.map +1 -1
  17. package/types/messageBroker.d.ts +324 -0
  18. package/types/messageBroker.d.ts.map +1 -0
  19. package/types/runnerInstance.d.ts +245 -0
  20. package/types/runnerInstance.d.ts.map +1 -0
  21. package/types/runnerLifecycleManager.d.ts +210 -0
  22. package/types/runnerLifecycleManager.d.ts.map +1 -0
  23. package/types/telemetryProcessor.d.ts +67 -0
  24. package/types/telemetryProcessor.d.ts.map +1 -1
  25. package/types/testing/mockedWorkerTestRunner01.d.ts +129 -2
  26. package/types/testing/mockedWorkerTestRunner01.d.ts.map +1 -1
  27. package/types/testing/testCase01.d.ts +222 -2
  28. package/types/testing/testCase01.d.ts.map +1 -1
  29. package/types/testing/testCase02.d.ts +206 -2
  30. package/types/testing/testCase02.d.ts.map +1 -1
  31. package/types/testing/wmwokerProcess.test.d.ts +1 -0
  32. package/types/testing/wmwokerProcess2.test.d.ts +1 -0
  33. package/types/workerCommandCoordinator.d.ts +152 -0
  34. package/types/workerCommandCoordinator.d.ts.map +1 -0
  35. package/types/workerInstance.d.ts +340 -16
  36. package/types/workerInstance.d.ts.map +1 -1
  37. package/types/workerInstanceMannager.d.ts +170 -0
  38. package/types/workerInstanceMannager.d.ts.map +1 -0
  39. package/types/workerManager.d.ts +335 -24
  40. package/types/workerManager.d.ts.map +1 -1
  41. package/types/workerRegistry.d.ts +251 -0
  42. package/types/workerRegistry.d.ts.map +1 -0
  43. package/types/workerStateSynchroniser.d.ts +161 -0
  44. package/types/workerStateSynchroniser.d.ts.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsrunnerframework",
3
- "version": "1.0.200",
3
+ "version": "2.0.1",
4
4
  "description": "STS Runner Framework",
5
5
  "main": "./dist/stsrunnerframework.umd.js",
6
6
  "module": "./dist/stsrunnerframework.mjs",
@@ -52,10 +52,10 @@
52
52
  "@types/lodash.merge": "^4.6.9",
53
53
  "@typescript-eslint/eslint-plugin": "^8.57.0",
54
54
  "@typescript-eslint/parser": "^8.57.0",
55
- "eslint": "^9.39.2",
55
+ "eslint": "^10.0.3",
56
56
  "globals": "^17.4.0",
57
57
  "typescript": "^5.9.3",
58
- "vite": "^7.3.1",
59
- "vitest": "^4.0.18"
58
+ "vite": "^8.0.0",
59
+ "vitest": "^4.1.0"
60
60
  }
61
61
  }
@@ -0,0 +1,194 @@
1
+
2
+ /**
3
+ * AbstractRunnerExecutionWorker
4
+ * =============================
5
+ *
6
+ * Abstract base class for the *actual execution worker runtime* that lives inside:
7
+ *
8
+ * - a browser Web Worker, or
9
+ * - a Node.js worker thread
10
+ *
11
+ * This class is the worker-side execution host for runners. It is responsible for:
12
+ *
13
+ * - receiving commands from the manager/controller side
14
+ * - creating concrete executable runner instances
15
+ * - maintaining in-worker runner runtime state
16
+ * - driving runner execution loops
17
+ * - posting unsolicited telemetry and state changes back to the manager
18
+ * - posting solicited command responses back to the manager
19
+ * - retiring/removing finished runners from the worker's live runtime collection
20
+ *
21
+ * Important architectural distinction
22
+ * -----------------------------------
23
+ * This class is **not** the same as the manager-side worker model used in your
24
+ * registry/coordinator layer.
25
+ *
26
+ * Manager side:
27
+ * - owns worker metadata
28
+ * - issues commands
29
+ * - receives telemetry/results
30
+ *
31
+ * Worker side (this class):
32
+ * - actually runs the work
33
+ * - holds concrete runner implementations
34
+ * - manages runner execution lifecycle inside the worker runtime
35
+ *
36
+ * Why abstract?
37
+ * -------------
38
+ * The runner logic can be anything:
39
+ *
40
+ * - HTTP/API execution
41
+ * - synthetic load generation
42
+ * - browser automation
43
+ * - database work
44
+ * - arbitrary domain workflows
45
+ *
46
+ * This class provides the common runtime/lifecycle/message-handling framework,
47
+ * while subclasses override `CreateAsyncRunner(...)` to create a concrete
48
+ * `IRunnerInstance` that performs the actual work.
49
+ */
50
+ import { MessagePort } from 'worker_threads';
51
+ import { IRunnerInstance, IRunner, ITestRunnerTelemetryPayload, IWorkerOptions } from './commonTypes';
52
+ import { ISTSLogger } from '@nsshunt/stsutils';
53
+ /**
54
+ * Internal runtime record stored for each runner hosted inside this worker.
55
+ *
56
+ * This combines:
57
+ * - the serialisable runner DTO/state (`runner`)
58
+ * - the concrete executable runner implementation (`runnerInstance`)
59
+ * - an archive flag used for in-worker cleanup (`archived`)
60
+ */
61
+ export interface IRunnerEx2RunState {
62
+ /**
63
+ * Concrete executable runner implementation.
64
+ *
65
+ * This is the object that performs the actual domain work.
66
+ */
67
+ runnerInstance: IRunnerInstance;
68
+ /**
69
+ * Current serialisable runner model/state.
70
+ *
71
+ * This is the object sent back to the manager for state/telemetry updates.
72
+ */
73
+ runner: IRunner;
74
+ /**
75
+ * Indicates whether the runner has already been archived/marked for removal
76
+ * from the worker's live runner collection.
77
+ */
78
+ archived: boolean;
79
+ }
80
+ /**
81
+ * Abstract worker-runtime base class.
82
+ *
83
+ * A concrete subclass is expected to:
84
+ * - run inside a real worker environment
85
+ * - override `CreateAsyncRunner(...)`
86
+ * - optionally expose its `ProcessMessage(...)` method as the worker message entry point
87
+ *
88
+ * High-level lifecycle
89
+ * --------------------
90
+ * 1. Manager bootstraps this worker by sending `MessagePort`
91
+ * 2. This class stores the manager communication port and worker options
92
+ * 3. Manager sends commands like:
93
+ * - `AddRunner`
94
+ * - `StartRunner`
95
+ * - `PauseRunner`
96
+ * - `GetRunners`
97
+ * 4. This class processes those commands and updates runner runtime state
98
+ * 5. This class sends:
99
+ * - solicited responses for commands
100
+ * - unsolicited state changes
101
+ * - unsolicited telemetry
102
+ */
103
+ export declare abstract class AbstractRunnerExecutionWorker {
104
+ #private;
105
+ /**
106
+ * Logger used by this worker runtime.
107
+ *
108
+ * Returns the shared default logger by default, but exposing this as a getter
109
+ * allows subclasses to override/customise logging behaviour if desired.
110
+ */
111
+ get logger(): ISTSLogger;
112
+ /**
113
+ * Construct the worker runtime host and start the background cleanup loop.
114
+ */
115
+ constructor();
116
+ /**
117
+ * Return a random integer between `0` and `max - 1`.
118
+ *
119
+ * Utility helper available to subclasses/runner logic.
120
+ *
121
+ * @param max Exclusive upper bound.
122
+ * @returns Random integer.
123
+ */
124
+ GetRandomInt: (max: number) => number;
125
+ /**
126
+ * Post unsolicited telemetry for a runner back to the manager.
127
+ *
128
+ * Uses the runner's current live serialisable state.
129
+ *
130
+ * @param id Runner id.
131
+ */
132
+ PostTelemetryById: (id: string) => void;
133
+ /**
134
+ * Get the manager communication port.
135
+ *
136
+ * @returns Manager communication port, or `null` if bootstrap is not complete.
137
+ */
138
+ get CollectorCollectorPort(): MessagePort | null;
139
+ /**
140
+ * Get the worker runtime options.
141
+ *
142
+ * @returns Worker options, or `null` if bootstrap is not complete.
143
+ */
144
+ get Options(): IWorkerOptions | null;
145
+ /**
146
+ * Factory method to create a concrete executable runner instance.
147
+ *
148
+ * This is the main extension point for subclasses.
149
+ *
150
+ * Subclasses should override this and return an `IRunnerInstance` that knows
151
+ * how to execute the actual domain work.
152
+ *
153
+ * Possible concrete runner behaviours:
154
+ * - REST/API load generation
155
+ * - browser automation
156
+ * - database execution
157
+ * - synthetic workflow orchestration
158
+ * - any arbitrary executable task
159
+ *
160
+ * Base implementation returns `null`.
161
+ *
162
+ * @param testRunnerTelemetryPayload Runner creation payload.
163
+ * @returns Concrete runner instance, or `null` if not implemented.
164
+ */
165
+ CreateAsyncRunner: (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload) => Promise<IRunnerInstance | null>;
166
+ /**
167
+ * Main inbound message dispatcher for this worker runtime.
168
+ *
169
+ * This method is intended to be wired to the actual worker's message handler.
170
+ *
171
+ * Supported commands:
172
+ * - `MessagePort`
173
+ * - `AddRunner`
174
+ * - `StartRunner`
175
+ * - `StopRunner`
176
+ * - `TerminateRunner`
177
+ * - `PauseRunner`
178
+ * - `ResumeRunner`
179
+ * - `ResetRunner`
180
+ * - `ExecuteRunner`
181
+ * - `UpdateRunner`
182
+ * - `GetRunners`
183
+ *
184
+ * Behaviour:
185
+ * - interprets the inbound message
186
+ * - dispatches to the appropriate internal handler
187
+ * - bootstrap-initialises the worker on `MessagePort`
188
+ * - logs and ignores unknown commands
189
+ *
190
+ * @param data Raw inbound message payload.
191
+ */
192
+ ProcessMessage: (data: any) => Promise<void>;
193
+ }
194
+ //# sourceMappingURL=abstractRunnerExecutionWorker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstractRunnerExecutionWorker.d.ts","sourceRoot":"","sources":["../src/abstractRunnerExecutionWorker.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C,OAAO,EAIH,eAAe,EAEf,OAAO,EACP,2BAA2B,EAC3B,cAAc,EAMjB,MAAM,eAAe,CAAC;AAMvB,OAAO,EAAE,UAAU,EAAwB,MAAM,mBAAmB,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;OAIG;IACH,cAAc,EAAE,eAAe,CAAC;IAEhC;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,8BAAsB,6BAA6B;;IAqC/C;;;;;OAKG;IACH,IAAI,MAAM,IAAI,UAAU,CAEvB;IAoJD;;OAEG;;IAKH;;;;;;;OAOG;IACH,YAAY,GAAI,KAAK,MAAM,YAEzB;IAEF;;;;;;OAMG;IACH,iBAAiB,GAAI,IAAI,MAAM,UAE7B;IAEF;;;;OAIG;IACH,IAAI,sBAAsB,IAAI,WAAW,GAAG,IAAI,CAE/C;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,cAAc,GAAG,IAAI,CAEnC;IAyCD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,iBAAiB,GAAU,4BAA4B,2BAA2B,KAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAElH;IAq0BF;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,cAAc,GAAU,MAAM,GAAG,mBAuE/B;CACL"}
@@ -0,0 +1,172 @@
1
+
2
+ /**
3
+ * ArchiveManager
4
+ * --------------
5
+ * Background lifecycle manager responsible for:
6
+ *
7
+ * - scanning all live workers/runners for runners that have reached an archiveable end state
8
+ * - stopping any active telemetry/instrument publishing for those runners
9
+ * - copying eligible runners into an in-memory archive list
10
+ * - marking runners as archived so they are not processed repeatedly
11
+ * - deleting archived runners from the live worker registry after a short delay
12
+ *
13
+ * High-level behaviour:
14
+ * 1. Periodically scan all workers and their runners
15
+ * 2. Identify runners in a terminal/archiveable state:
16
+ * - completed
17
+ * - error
18
+ * - stopped
19
+ * - terminated
20
+ * 3. For each matching runner:
21
+ * - stop instrumentation publishing if active
22
+ * - archive the runner unless it was terminated
23
+ * - mark the runner as archived
24
+ * - schedule deletion from the live registry after `archiveDeleteTimeout`
25
+ * 4. Repeat on a timed loop until `Terminate()` is called
26
+ *
27
+ * Notes:
28
+ * - Terminated runners are intentionally NOT added to the archive list,
29
+ * but they are still marked as archived and later removed from the live registry.
30
+ * - The archive list is capped at `maxArchiveListLength`.
31
+ * - This class owns only the archive list and loop scheduling; live worker/runner
32
+ * ownership remains with the {@link WorkerRegistry}.
33
+ */
34
+ import { IRunner, IRunnerSearchFilters } from './commonTypes';
35
+ import { ISTSLogger } from '@nsshunt/stsutils';
36
+ import { WorkerRegistry } from './workerRegistry';
37
+ /**
38
+ * Constructor options for {@link ArchiveManager}.
39
+ */
40
+ export interface IArchiveManagerOptions {
41
+ /**
42
+ * Logger used for diagnostics and error reporting.
43
+ */
44
+ logger: ISTSLogger;
45
+ /**
46
+ * Maximum number of archived runner snapshots to keep in memory.
47
+ *
48
+ * When the archive exceeds this size, the oldest archived runner is removed.
49
+ */
50
+ maxArchiveListLength: number;
51
+ /**
52
+ * Shared live worker registry used to inspect workers/runners and delete
53
+ * archived runners from the active runtime graph.
54
+ */
55
+ workerRegistry: WorkerRegistry;
56
+ }
57
+ /**
58
+ * Archive manager for completed/stopped/failed runner instances.
59
+ */
60
+ export declare class ArchiveManager {
61
+ /**
62
+ * Immutable runtime configuration for this archive manager.
63
+ */
64
+ private readonly options;
65
+ /**
66
+ * In-memory archive of serialised runner snapshots.
67
+ *
68
+ * Important:
69
+ * - This stores serialised runner DTOs, not live `IRunnerEx` instances.
70
+ * - The list is bounded by `maxArchiveListLength`.
71
+ */
72
+ private readonly archiveList;
73
+ /**
74
+ * Delay in seconds before removing an archived runner from the live worker registry.
75
+ *
76
+ * Purpose:
77
+ * - allows a short grace period after archiving
78
+ * - avoids immediate deletion of the live runner instance
79
+ *
80
+ * A value of `0` would disable delayed deletion.
81
+ */
82
+ private readonly archiveDeleteTimeout;
83
+ /**
84
+ * Timeout handle for the recurring archive scan loop.
85
+ *
86
+ * This is stored so the loop can be stopped later via {@link Terminate}.
87
+ */
88
+ private timeout;
89
+ /**
90
+ * Construct a new archive manager.
91
+ *
92
+ * @param options Logger, archive size cap, and worker registry dependencies.
93
+ */
94
+ constructor(options: IArchiveManagerOptions);
95
+ /**
96
+ * Execute a single archive scan cycle and schedule the next cycle.
97
+ *
98
+ * Behaviour:
99
+ * - scans all live workers and all live runners
100
+ * - collects runners eligible for archiving into a temporary `removeList`
101
+ * - processes the collected runners after a short delay
102
+ * - schedules the next loop execution
103
+ *
104
+ * Archiveable runner states:
105
+ * - `IRunnerState.completed`
106
+ * - `IRunnerState.error`
107
+ * - `IRunnerState.stopped`
108
+ * - `IRunnerState.terminated`
109
+ *
110
+ * Additional behaviour per matching runner:
111
+ * - If a publish instrument controller is attached, `EndPublish()` is called
112
+ * - If the runner state is NOT `terminated`, the runner is serialised and pushed
113
+ * into the in-memory archive list
114
+ * - If the runner state IS `terminated`, it is skipped for archive storage
115
+ * - In both cases, the runner is marked `archived = true`
116
+ * - The live runner is scheduled for deletion from the worker registry after
117
+ * `archiveDeleteTimeout`
118
+ *
119
+ * Loop scheduling:
120
+ * - If one or more runners were found, processing happens after 100 ms, then the
121
+ * next scan is scheduled 1000 ms later
122
+ * - If none were found, the next scan is scheduled directly after 1000 ms
123
+ *
124
+ * Notes:
125
+ * - The short 100 ms processing delay helps separate detection and mutation phases.
126
+ * - In Node.js, delayed deletion timeouts are `unref()`'d so they do not keep the
127
+ * process alive by themselves.
128
+ *
129
+ * @throws Re-throws unexpected errors after logging.
130
+ */
131
+ ProcessLoopExecutor: () => Promise<void>;
132
+ /**
133
+ * Get archived runner snapshots filtered by optional search criteria.
134
+ *
135
+ * Supported filters:
136
+ * - `plan`
137
+ * - `planInstanceId`
138
+ * - `tag`
139
+ * - `userDataKey`
140
+ *
141
+ * Filter behaviour:
142
+ * - If a filter property is absent/blank, it is ignored
143
+ * - All supplied filters are combined using logical AND
144
+ *
145
+ * Examples:
146
+ * - by runner plan name
147
+ * - by specific plan instance id
148
+ * - by tag membership
149
+ * - by existence of a userData key
150
+ *
151
+ * Notes:
152
+ * - This method returns archived DTOs (`IRunner[]`), not live runner instances
153
+ * - The archive list is in-memory only and bounded by `maxArchiveListLength`
154
+ *
155
+ * @param runnerSearchFilters Search/filter options to apply.
156
+ * @returns Filtered archive list. Returns an empty array on error.
157
+ */
158
+ GetArchiveList: (runnerSearchFilters: IRunnerSearchFilters) => Promise<IRunner[]>;
159
+ /**
160
+ * Stop the recurring archive scan loop.
161
+ *
162
+ * Behaviour:
163
+ * - Clears the currently scheduled scan timeout if present
164
+ * - Does not clear already scheduled delayed per-runner deletion timeouts
165
+ * - Does not modify the current archive list
166
+ *
167
+ * Intended use:
168
+ * - called during overall worker-manager shutdown/termination
169
+ */
170
+ Terminate: () => void;
171
+ }
172
+ //# sourceMappingURL=archiveManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archiveManager.d.ts","sourceRoot":"","sources":["../src/archiveManager.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,OAAO,EAAgB,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAc,MAAM,mBAAmB,CAAC;AAO3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,cAAc;IACvB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;IAE7C;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAc;IAEnD;;;;OAIG;IACH,OAAO,CAAC,OAAO,CAAM;IAErB;;;;OAIG;gBACS,OAAO,EAAE,sBAAsB;IAI3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,mBAAmB,sBA+JjB;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,cAAc,GAAU,qBAAqB,oBAAoB,KAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CA+BpF;IAEF;;;;;;;;;;OAUG;IACH,SAAS,aAIP;CACL"}
@@ -0,0 +1,108 @@
1
+
2
+ /**
3
+ * AsyncRunnerInstanceManager
4
+ * --------------------------
5
+ * Factory/creation manager responsible for constructing live {@link RunnerInstance}
6
+ * objects for a given worker.
7
+ *
8
+ * Responsibilities:
9
+ * - generate a unique runner id
10
+ * - build the hierarchical {@link IAsyncRunnerContext} for the runner
11
+ * - optionally create a child publish/instrument controller for the runner
12
+ * - construct and return a new live {@link RunnerInstance}
13
+ *
14
+ * High-level role in the architecture:
15
+ * - {@link WorkerInstance} owns runners
16
+ * - {@link AsyncRunnerInstanceManager} creates runners
17
+ * - {@link RunnerInstance} executes runner behaviour and communicates through the broker
18
+ *
19
+ * Notes:
20
+ * - This class does not register the runner into a worker; it only creates it.
21
+ * - Registration is handled elsewhere, typically by the worker that owns the runner.
22
+ * - This class centralises runner identity/context construction so that every runner
23
+ * follows the same naming and instrumentation conventions.
24
+ */
25
+ import { IWorkerEx, IRunnerEx, IRunnerOptions } from './commonTypes';
26
+ import { PublishInstrumentController } from '@nsshunt/stsinstrumentmanagerclient';
27
+ import { STSMessageBroker } from './messageBroker';
28
+ /**
29
+ * Constructor options for {@link AsyncRunnerInstanceManager}.
30
+ */
31
+ export interface IAsyncRunnerInstanceManagerOptions {
32
+ /**
33
+ * Id of the top-level worker manager that owns all workers/runners created through this factory.
34
+ */
35
+ workerManagerId: string;
36
+ /**
37
+ * Optional root publish/instrument controller.
38
+ *
39
+ * When supplied, a dedicated child publish controller is created for each new runner
40
+ * using the runner's async context.
41
+ */
42
+ instrumentController?: PublishInstrumentController;
43
+ /**
44
+ * Message broker used by created runner instances to send commands to the worker.
45
+ */
46
+ messageBroker: STSMessageBroker;
47
+ }
48
+ /**
49
+ * Factory/manager used to construct new live asynchronous runner instances.
50
+ *
51
+ * This class encapsulates:
52
+ * - runner id creation
53
+ * - async runner context creation
54
+ * - optional per-runner instrumentation publisher creation
55
+ * - `RunnerInstance` construction
56
+ */
57
+ export declare class AsyncRunnerInstanceManager {
58
+ #private;
59
+ /**
60
+ * Construct a new async runner instance manager.
61
+ *
62
+ * @param options Worker-manager id, optional instrumentation controller, and message broker.
63
+ */
64
+ constructor(options: IAsyncRunnerInstanceManagerOptions);
65
+ /**
66
+ * Create a new live asynchronous runner instance for the supplied worker.
67
+ *
68
+ * Behaviour:
69
+ * - Generates a new unique runner id
70
+ * - Builds a hierarchical {@link IAsyncRunnerContext} for the runner
71
+ * - Optionally creates a child publish/instrument controller scoped to that runner
72
+ * - Constructs and returns a new {@link RunnerInstance}
73
+ *
74
+ * Async runner context structure:
75
+ *
76
+ * The generated context follows a 4-level hierarchy:
77
+ *
78
+ * 1. host
79
+ * 2. agent
80
+ * 3. worker/thread
81
+ * 4. runner
82
+ *
83
+ * The generated `nid` format is:
84
+ *
85
+ * `[level1]@[level2]^[level3]|[level4]`
86
+ *
87
+ * Concretely:
88
+ *
89
+ * `[hostName]@[agentId]-[userAgent]^[workerId]|[runnerId]`
90
+ *
91
+ * Where:
92
+ * - `hostName` identifies the host/runtime machine
93
+ * - `agentId-userAgent` identifies the logical agent/browser/session instance
94
+ * - `workerId` identifies the worker hosting the runner
95
+ * - `runnerId` identifies the runner inside that worker
96
+ *
97
+ * Notes:
98
+ * - This method only creates the runner instance; it does not add it to the worker's
99
+ * internal runner map or push it into the underlying worker runtime.
100
+ * - That registration/bootstrap step is performed elsewhere by the owning worker.
101
+ *
102
+ * @param workerEx The live worker instance that will own the new runner.
103
+ * @param runnerOptions Runtime options/configuration for the new runner.
104
+ * @returns Newly constructed live runner instance.
105
+ */
106
+ CreateAsyncRunner: (workerEx: IWorkerEx, runnerOptions: IRunnerOptions) => IRunnerEx;
107
+ }
108
+ //# sourceMappingURL=asyncRunnerInstanceManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncRunnerInstanceManager.d.ts","sourceRoot":"","sources":["../src/asyncRunnerInstanceManager.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAuB,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI1F,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAOlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAInD;;GAEG;AACH,MAAM,WAAW,kCAAkC;IAC/C;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,2BAA2B,CAAC;IAEnD;;OAEG;IACH,aAAa,EAAE,gBAAgB,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,qBAAa,0BAA0B;;IAMnC;;;;OAIG;gBACS,OAAO,EAAE,kCAAkC;IAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,iBAAiB,GAAI,UAAU,SAAS,EAAE,eAAe,cAAc,KAAG,SAAS,CAsFjF;CACL"}