skeleton-crew-runtime 0.1.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.
@@ -0,0 +1,127 @@
1
+ import type { RuntimeContext, ScreenDefinition, ActionDefinition, PluginDefinition } from './types.js';
2
+ import type { ScreenRegistry } from './screen-registry.js';
3
+ import type { ActionEngine } from './action-engine.js';
4
+ import type { PluginRegistry } from './plugin-registry.js';
5
+ import type { EventBus } from './event-bus.js';
6
+ import type { Runtime } from './types.js';
7
+ /**
8
+ * RuntimeContext provides a safe API facade for subsystems.
9
+ * Passed to plugins and action handlers without exposing internal mutable structures.
10
+ *
11
+ * Requirements: 1.2, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6
12
+ */
13
+ export declare class RuntimeContextImpl implements RuntimeContext {
14
+ private screenRegistry;
15
+ private actionEngine;
16
+ private pluginRegistry;
17
+ private eventBus;
18
+ private runtime;
19
+ private hostContext;
20
+ constructor(screenRegistry: ScreenRegistry, actionEngine: ActionEngine, pluginRegistry: PluginRegistry, eventBus: EventBus, runtime: Runtime, hostContext: Record<string, unknown>);
21
+ /**
22
+ * Screens API - exposes Screen Registry operations
23
+ * Requirements: 4.1, 4.2, 4.3, 4.4, 4.5, 10.1, 10.2, 10.3, 10.4, 10.5
24
+ */
25
+ get screens(): {
26
+ registerScreen: (screen: ScreenDefinition) => (() => void);
27
+ getScreen: (id: string) => ScreenDefinition | null;
28
+ getAllScreens: () => ScreenDefinition[];
29
+ };
30
+ /**
31
+ * Actions API - exposes Action Engine operations
32
+ * Requirements: 4.1, 4.2, 4.3, 4.4, 4.5
33
+ */
34
+ get actions(): {
35
+ registerAction: <P = unknown, R = unknown>(action: ActionDefinition<P, R>) => (() => void);
36
+ runAction: <P = unknown, R = unknown>(id: string, params?: P) => Promise<R>;
37
+ };
38
+ /**
39
+ * Plugins API - exposes Plugin Registry operations
40
+ * Requirements: 13.1, 13.2, 13.3, 13.4, 13.5
41
+ */
42
+ get plugins(): {
43
+ registerPlugin: (plugin: PluginDefinition) => void;
44
+ getPlugin: (name: string) => PluginDefinition | null;
45
+ getAllPlugins: () => PluginDefinition[];
46
+ getInitializedPlugins: () => string[];
47
+ };
48
+ /**
49
+ * Events API - exposes Event Bus operations
50
+ * Requirements: 12.1, 12.2, 12.3, 12.4, 12.5
51
+ */
52
+ get events(): {
53
+ emit: (event: string, data?: unknown) => void;
54
+ emitAsync: (event: string, data?: unknown) => Promise<void>;
55
+ on: (event: string, handler: (data: unknown) => void) => (() => void);
56
+ };
57
+ /**
58
+ * Returns the Runtime instance
59
+ * Requirement: 9.6
60
+ */
61
+ getRuntime(): Runtime;
62
+ /**
63
+ * Host context - readonly access to injected host services
64
+ * Requirements: 1.2, 1.3, 1.4
65
+ *
66
+ * Returns a frozen shallow copy of the host context to prevent mutation.
67
+ * This ensures plugins can access host services but cannot modify them.
68
+ */
69
+ get host(): Readonly<Record<string, unknown>>;
70
+ /**
71
+ * Introspection API - query runtime metadata
72
+ * Requirements: 3.1, 4.1, 5.1, 6.1
73
+ */
74
+ get introspect(): {
75
+ /**
76
+ * List all registered action IDs
77
+ * Requirements: 3.1
78
+ */
79
+ listActions: () => string[];
80
+ /**
81
+ * Get action metadata by ID (excludes handler function)
82
+ * Requirements: 3.2, 3.3, 3.4, 3.5
83
+ */
84
+ getActionDefinition: (id: string) => Readonly<{
85
+ id: string;
86
+ timeout: number | undefined;
87
+ }> | null;
88
+ /**
89
+ * List all registered plugin names
90
+ * Requirements: 4.1
91
+ */
92
+ listPlugins: () => string[];
93
+ /**
94
+ * Get plugin metadata by name (excludes setup/dispose functions)
95
+ * Requirements: 4.2, 4.3, 4.4, 4.5
96
+ */
97
+ getPluginDefinition: (name: string) => Readonly<{
98
+ name: string;
99
+ version: string;
100
+ }> | null;
101
+ /**
102
+ * List all registered screen IDs
103
+ * Requirements: 5.1
104
+ */
105
+ listScreens: () => string[];
106
+ /**
107
+ * Get screen definition by ID (includes all properties)
108
+ * Requirements: 5.2, 5.3, 5.4, 5.5
109
+ */
110
+ getScreenDefinition: (id: string) => Readonly<{
111
+ id: string;
112
+ title: string;
113
+ component: string;
114
+ }> | null;
115
+ /**
116
+ * Get runtime metadata with statistics
117
+ * Requirements: 6.1, 6.2, 6.3, 6.4, 6.5
118
+ */
119
+ getMetadata: () => Readonly<{
120
+ runtimeVersion: string;
121
+ totalActions: number;
122
+ totalPlugins: number;
123
+ totalScreens: number;
124
+ }>;
125
+ };
126
+ }
127
+ //# sourceMappingURL=runtime-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-context.d.ts","sourceRoot":"","sources":["../src/runtime-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAkC1C;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,WAAW,CAA0B;gBAG3C,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAUtC;;;OAGG;IACH,IAAI,OAAO;iCAEkB,gBAAgB,KAAG,CAAC,MAAM,IAAI,CAAC;wBAGxC,MAAM,KAAG,gBAAgB,GAAG,IAAI;6BAG7B,gBAAgB,EAAE;MAIxC;IAED;;;OAGG;IACH,IAAI,OAAO;yBAEU,CAAC,YAAY,CAAC,oBAAoB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAC,MAAM,IAAI,CAAC;oBAG5E,CAAC,YAAY,CAAC,gBAAgB,MAAM,WAAW,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC;MAI5E;IAED;;;OAGG;IACH,IAAI,OAAO;iCAEkB,gBAAgB,KAAG,IAAI;0BAG9B,MAAM,KAAG,gBAAgB,GAAG,IAAI;6BAG/B,gBAAgB,EAAE;qCAGV,MAAM,EAAE;MAItC;IAED;;;OAGG;IACH,IAAI,MAAM;sBAEQ,MAAM,SAAS,OAAO,KAAG,IAAI;2BAGxB,MAAM,SAAS,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;oBAG7C,MAAM,WAAW,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;MAItE;IAED;;;OAGG;IACH,UAAU,IAAI,OAAO;IAIrB;;;;;;OAMG;IACH,IAAI,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAE5C;IAED;;;OAGG;IACH,IAAI,UAAU;QAEV;;;WAGG;2BACc,MAAM,EAAE;QAIzB;;;WAGG;kCACuB,MAAM;;;;QAchC;;;WAGG;2BACc,MAAM,EAAE;QAIzB;;;WAGG;oCACyB,MAAM;;;;QAclC;;;WAGG;2BACc,MAAM,EAAE;QAIzB;;;WAGG;kCACuB,MAAM;;;;;QAehC;;;WAGG;;;;;;;MAaN;CACF"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Deep freeze utility - recursively freezes an object and all nested objects.
3
+ * Internal use only, not exported.
4
+ *
5
+ * Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
6
+ *
7
+ * @param obj - The object to deep freeze
8
+ * @returns The frozen object with proper typing
9
+ */
10
+ function deepFreeze(obj) {
11
+ // Freeze the object itself (Requirement 7.1)
12
+ Object.freeze(obj);
13
+ // Iterate over all properties (Requirement 7.2)
14
+ Object.getOwnPropertyNames(obj).forEach(prop => {
15
+ const value = obj[prop];
16
+ // Skip functions (Requirement 7.4)
17
+ if (typeof value === 'function') {
18
+ return;
19
+ }
20
+ // Skip already frozen objects (Requirement 7.5)
21
+ if (value && typeof value === 'object' && !Object.isFrozen(value)) {
22
+ // Recursively freeze nested objects and arrays (Requirements 7.2, 7.3)
23
+ deepFreeze(value);
24
+ }
25
+ });
26
+ return obj;
27
+ }
28
+ /**
29
+ * RuntimeContext provides a safe API facade for subsystems.
30
+ * Passed to plugins and action handlers without exposing internal mutable structures.
31
+ *
32
+ * Requirements: 1.2, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6
33
+ */
34
+ export class RuntimeContextImpl {
35
+ screenRegistry;
36
+ actionEngine;
37
+ pluginRegistry;
38
+ eventBus;
39
+ runtime;
40
+ hostContext;
41
+ constructor(screenRegistry, actionEngine, pluginRegistry, eventBus, runtime, hostContext) {
42
+ this.screenRegistry = screenRegistry;
43
+ this.actionEngine = actionEngine;
44
+ this.pluginRegistry = pluginRegistry;
45
+ this.eventBus = eventBus;
46
+ this.runtime = runtime;
47
+ this.hostContext = hostContext;
48
+ }
49
+ /**
50
+ * Screens API - exposes Screen Registry operations
51
+ * Requirements: 4.1, 4.2, 4.3, 4.4, 4.5, 10.1, 10.2, 10.3, 10.4, 10.5
52
+ */
53
+ get screens() {
54
+ return {
55
+ registerScreen: (screen) => {
56
+ return this.screenRegistry.registerScreen(screen);
57
+ },
58
+ getScreen: (id) => {
59
+ return this.screenRegistry.getScreen(id);
60
+ },
61
+ getAllScreens: () => {
62
+ return this.screenRegistry.getAllScreens();
63
+ }
64
+ };
65
+ }
66
+ /**
67
+ * Actions API - exposes Action Engine operations
68
+ * Requirements: 4.1, 4.2, 4.3, 4.4, 4.5
69
+ */
70
+ get actions() {
71
+ return {
72
+ registerAction: (action) => {
73
+ return this.actionEngine.registerAction(action);
74
+ },
75
+ runAction: (id, params) => {
76
+ return this.actionEngine.runAction(id, params);
77
+ }
78
+ };
79
+ }
80
+ /**
81
+ * Plugins API - exposes Plugin Registry operations
82
+ * Requirements: 13.1, 13.2, 13.3, 13.4, 13.5
83
+ */
84
+ get plugins() {
85
+ return {
86
+ registerPlugin: (plugin) => {
87
+ this.pluginRegistry.registerPlugin(plugin);
88
+ },
89
+ getPlugin: (name) => {
90
+ return this.pluginRegistry.getPlugin(name);
91
+ },
92
+ getAllPlugins: () => {
93
+ return this.pluginRegistry.getAllPlugins();
94
+ },
95
+ getInitializedPlugins: () => {
96
+ return this.pluginRegistry.getInitializedPlugins();
97
+ }
98
+ };
99
+ }
100
+ /**
101
+ * Events API - exposes Event Bus operations
102
+ * Requirements: 12.1, 12.2, 12.3, 12.4, 12.5
103
+ */
104
+ get events() {
105
+ return {
106
+ emit: (event, data) => {
107
+ this.eventBus.emit(event, data);
108
+ },
109
+ emitAsync: (event, data) => {
110
+ return this.eventBus.emitAsync(event, data);
111
+ },
112
+ on: (event, handler) => {
113
+ return this.eventBus.on(event, handler);
114
+ }
115
+ };
116
+ }
117
+ /**
118
+ * Returns the Runtime instance
119
+ * Requirement: 9.6
120
+ */
121
+ getRuntime() {
122
+ return this.runtime;
123
+ }
124
+ /**
125
+ * Host context - readonly access to injected host services
126
+ * Requirements: 1.2, 1.3, 1.4
127
+ *
128
+ * Returns a frozen shallow copy of the host context to prevent mutation.
129
+ * This ensures plugins can access host services but cannot modify them.
130
+ */
131
+ get host() {
132
+ return Object.freeze({ ...this.hostContext });
133
+ }
134
+ /**
135
+ * Introspection API - query runtime metadata
136
+ * Requirements: 3.1, 4.1, 5.1, 6.1
137
+ */
138
+ get introspect() {
139
+ return {
140
+ /**
141
+ * List all registered action IDs
142
+ * Requirements: 3.1
143
+ */
144
+ listActions: () => {
145
+ return this.actionEngine.getAllActions().map(action => action.id);
146
+ },
147
+ /**
148
+ * Get action metadata by ID (excludes handler function)
149
+ * Requirements: 3.2, 3.3, 3.4, 3.5
150
+ */
151
+ getActionDefinition: (id) => {
152
+ const action = this.actionEngine.getAction(id);
153
+ if (!action)
154
+ return null;
155
+ // Extract only id and timeout (exclude handler function)
156
+ const metadata = {
157
+ id: action.id,
158
+ timeout: action.timeout
159
+ };
160
+ // Deep freeze the metadata
161
+ return deepFreeze(metadata);
162
+ },
163
+ /**
164
+ * List all registered plugin names
165
+ * Requirements: 4.1
166
+ */
167
+ listPlugins: () => {
168
+ return this.pluginRegistry.getAllPlugins().map(plugin => plugin.name);
169
+ },
170
+ /**
171
+ * Get plugin metadata by name (excludes setup/dispose functions)
172
+ * Requirements: 4.2, 4.3, 4.4, 4.5
173
+ */
174
+ getPluginDefinition: (name) => {
175
+ const plugin = this.pluginRegistry.getPlugin(name);
176
+ if (!plugin)
177
+ return null;
178
+ // Extract only name and version (exclude setup/dispose functions)
179
+ const metadata = {
180
+ name: plugin.name,
181
+ version: plugin.version
182
+ };
183
+ // Deep freeze the metadata
184
+ return deepFreeze(metadata);
185
+ },
186
+ /**
187
+ * List all registered screen IDs
188
+ * Requirements: 5.1
189
+ */
190
+ listScreens: () => {
191
+ return this.screenRegistry.getAllScreens().map(screen => screen.id);
192
+ },
193
+ /**
194
+ * Get screen definition by ID (includes all properties)
195
+ * Requirements: 5.2, 5.3, 5.4, 5.5
196
+ */
197
+ getScreenDefinition: (id) => {
198
+ const screen = this.screenRegistry.getScreen(id);
199
+ if (!screen)
200
+ return null;
201
+ // Include all screen properties
202
+ const metadata = {
203
+ id: screen.id,
204
+ title: screen.title,
205
+ component: screen.component
206
+ };
207
+ // Deep freeze the metadata
208
+ return deepFreeze(metadata);
209
+ },
210
+ /**
211
+ * Get runtime metadata with statistics
212
+ * Requirements: 6.1, 6.2, 6.3, 6.4, 6.5
213
+ */
214
+ getMetadata: () => {
215
+ const metadata = {
216
+ runtimeVersion: '0.1.0',
217
+ totalActions: this.actionEngine.getAllActions().length,
218
+ totalPlugins: this.pluginRegistry.getAllPlugins().length,
219
+ totalScreens: this.screenRegistry.getAllScreens().length
220
+ };
221
+ // Deep freeze the metadata
222
+ return deepFreeze(metadata);
223
+ }
224
+ };
225
+ }
226
+ }
227
+ //# sourceMappingURL=runtime-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-context.js","sourceRoot":"","sources":["../src/runtime-context.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAI,GAAM;IAC3B,6CAA6C;IAC7C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAEnB,gDAAgD;IAChD,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC7C,MAAM,KAAK,GAAI,GAAW,CAAC,IAAI,CAAC,CAAC;QAEjC,mCAAmC;QACnC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QAED,gDAAgD;QAChD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAClE,uEAAuE;YACvE,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAkB,CAAC;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IACrB,cAAc,CAAiB;IAC/B,YAAY,CAAe;IAC3B,cAAc,CAAiB;IAC/B,QAAQ,CAAW;IACnB,OAAO,CAAU;IACjB,WAAW,CAA0B;IAE7C,YACE,cAA8B,EAC9B,YAA0B,EAC1B,cAA8B,EAC9B,QAAkB,EAClB,OAAgB,EAChB,WAAoC;QAEpC,IAAI,CAAC,cAAc,GAAG,cAA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AM;oBAAE,OAAO,IAAI,CAAC;gBAEzB,gCAAgC;gBAChC,MAAM,QAAQ,GAAG;oBACf,EAAE,EAAE,MAAM,CAAC,EAAE;oBACb,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,SAAS,EAAE,MAAM,CAAC,SAAS;iBAC5B,CAAC;gBAEF,2BAA2B;gBAC3B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;YAED;;;eAGG;YACH,WAAW,EAAE,GAAG,EAAE;gBAChB,MAAM,QAAQ,GAAG;oBACf,cAAc,EAAE,OAAO;oBACvB,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC,MAAM;oBACtD,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,MAAM;oBACxD,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,MAAM;iBACzD,CAAC;gBAEF,2BAA2B;gBAC3B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,125 @@
1
+ import type { RuntimeContext, UIProvider, PluginDefinition, RuntimeOptions } from './types.js';
2
+ import { RuntimeState } from './types.js';
3
+ /**
4
+ * Runtime is the main orchestrator that coordinates all subsystems.
5
+ * Handles initialization, shutdown, and lifecycle state tracking.
6
+ *
7
+ * Requirements: 1.1, 1.2, 1.3, 1.4, 1.5, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 3.1, 3.5, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 9.7, 9.9, 15.1, 15.3, 15.5, 16.1, 16.2, 16.3, 16.4, 16.5
8
+ */
9
+ export declare class Runtime {
10
+ private plugins;
11
+ private screens;
12
+ private actions;
13
+ private events;
14
+ private ui;
15
+ private context;
16
+ private initialized;
17
+ private pendingPlugins;
18
+ private logger;
19
+ private state;
20
+ private hostContext;
21
+ /**
22
+ * Creates a new Runtime instance with optional configuration.
23
+ *
24
+ * @param options - Optional configuration object
25
+ * @param options.logger - Custom logger implementation (defaults to ConsoleLogger)
26
+ * @param options.hostContext - Host application services to inject (defaults to empty object)
27
+ *
28
+ * Requirements: 1.1, 1.5, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6
29
+ */
30
+ constructor(options?: RuntimeOptions);
31
+ /**
32
+ * Validates host context and logs warnings for common mistakes.
33
+ * Does not throw errors or modify the context.
34
+ *
35
+ * @param context - The host context to validate
36
+ *
37
+ * Requirements: 2.1, 2.2, 2.3, 2.4
38
+ */
39
+ private validateHostContext;
40
+ /**
41
+ * Registers a plugin before initialization.
42
+ * Plugins registered this way will have their setup callbacks executed during initialize().
43
+ *
44
+ * @param plugin - The plugin definition to register
45
+ * @throws Error if runtime is already initialized
46
+ */
47
+ registerPlugin(plugin: PluginDefinition): void;
48
+ /**
49
+ * Initializes the runtime following the strict initialization sequence.
50
+ * Creates all subsystems in order, then executes plugin setup callbacks.
51
+ * Emits runtime:initialized event after successful initialization.
52
+ *
53
+ * @throws Error if initialize is called twice
54
+ * @throws Error if any plugin setup fails
55
+ *
56
+ * Requirements: 1.1, 1.2, 1.3, 1.4, 1.5, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 3.1, 3.5, 15.1, 15.3, 15.5, 16.1, 16.2, 16.3, 16.4, 16.5, 17.1, 17.2, 17.3
57
+ */
58
+ initialize(): Promise<void>;
59
+ /**
60
+ * Shuts down the runtime following the strict shutdown sequence.
61
+ * Emits runtime:shutdown event at start of shutdown.
62
+ * Disposes initialized plugins, shuts down UI provider, clears all registries, and releases resources.
63
+ * Safe to call multiple times (idempotent).
64
+ *
65
+ * Requirements: 4.1, 4.2, 4.3, 4.4, 4.5, 9.5, 15.2, 15.4, 15.6, 16.1, 16.2, 16.3, 16.4, 16.5, 17.4, 17.5
66
+ */
67
+ shutdown(): Promise<void>;
68
+ /**
69
+ * Returns the RuntimeContext for this runtime instance.
70
+ *
71
+ * @returns The RuntimeContext
72
+ * @throws Error if runtime is not initialized
73
+ *
74
+ * Requirement: 9.1
75
+ */
76
+ getContext(): RuntimeContext;
77
+ /**
78
+ * Returns whether the runtime has been initialized.
79
+ *
80
+ * @returns true if runtime is initialized, false otherwise
81
+ *
82
+ * Requirements: 16.1, 16.2, 16.3
83
+ */
84
+ isInitialized(): boolean;
85
+ /**
86
+ * Returns the current lifecycle state of the runtime.
87
+ *
88
+ * @returns The current RuntimeState
89
+ *
90
+ * Requirements: 16.1, 16.2, 16.3, 16.4, 16.5
91
+ */
92
+ getState(): RuntimeState;
93
+ /**
94
+ * Registers a UI provider with the runtime.
95
+ * Delegates to UIBridge subsystem.
96
+ * Can be called after initialization completes.
97
+ *
98
+ * @param provider - The UI provider implementation
99
+ * @throws Error if provider is invalid or already registered
100
+ *
101
+ * Requirements: 10.3, 10.9
102
+ */
103
+ setUIProvider(provider: UIProvider): void;
104
+ /**
105
+ * Returns the registered UI provider.
106
+ * Delegates to UIBridge subsystem.
107
+ *
108
+ * @returns The registered UIProvider or null if none registered
109
+ *
110
+ * Requirement: 10.4
111
+ */
112
+ getUIProvider(): UIProvider | null;
113
+ /**
114
+ * Renders a screen by looking it up in the ScreenRegistry and delegating to UIBridge.
115
+ *
116
+ * @param screenId - The screen identifier to render
117
+ * @returns The result from the UI provider's render method
118
+ * @throws Error if screen is not found
119
+ * @throws Error if no UI provider is registered
120
+ *
121
+ * Requirement: 10.5
122
+ */
123
+ renderScreen(screenId: string): unknown;
124
+ }
125
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAU,MAAM,YAAY,CAAC;AACvG,OAAO,EAAiB,YAAY,EAAE,MAAM,YAAY,CAAC;AAQzD;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,O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