@haibun/web-server-express 1.65.3 → 1.65.4

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@haibun/web-server-express",
3
3
  "type": "module",
4
- "version": "1.65.3",
4
+ "version": "1.65.4",
5
5
  "description": "",
6
6
  "main": "build/web-server-stepper.js",
7
7
  "files": ["build/**"],
@@ -1,32 +0,0 @@
1
- import { AStepper, IHasOptions } from '@haibun/core/build/lib/astepper.js';
2
- import { TNamed, IStepperCycles } from '@haibun/core/build/lib/defs.js';
3
- export declare class ExecutorApiStepper extends AStepper implements IHasOptions {
4
- private executionContexts;
5
- private httpPrompters;
6
- options: {
7
- EXECUTOR_API_PATH: {
8
- desc: string;
9
- parse: (path: string) => {
10
- result: string;
11
- };
12
- };
13
- CONTEXT_TIMEOUT: {
14
- desc: string;
15
- parse: (timeout: string) => {
16
- result: number;
17
- };
18
- };
19
- };
20
- cycles: IStepperCycles;
21
- steps: {
22
- setupExecutorApi: {
23
- gwta: string;
24
- action: ({ path }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TNotOKActionResult> | Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult>;
25
- };
26
- };
27
- private startContextCleanup;
28
- private cleanupContext;
29
- private setupExecutorRoutes;
30
- }
31
- export default ExecutorApiStepper;
32
- //# sourceMappingURL=executor-api-stepper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executor-api-stepper.d.ts","sourceRoot":"","sources":["../src/executor-api-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAmG,MAAM,gCAAgC,CAAC;AAmFzK,qBAAa,kBAAmB,SAAQ,QAAS,YAAW,WAAW;IACtE,OAAO,CAAC,iBAAiB,CAA6C;IACtE,OAAO,CAAC,aAAa,CAAwC;IAE7D,OAAO;;;0BAGS,MAAM;;;;;;6BAIH,MAAM;;;;MAEvB;IAEF,MAAM,EAAE,cAAc,CA8CpB;IAEF,KAAK;;;+BAGgB,MAAM;;MAiBzB;IAEF,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,mBAAmB;CAsQ3B;AAED,eAAe,kBAAkB,CAAC"}
@@ -1,391 +0,0 @@
1
- import { AStepper } from '@haibun/core/build/lib/astepper.js';
2
- import { actionNotOK, actionOK, getFromRuntime, getStepperOption } from '@haibun/core/build/lib/util/index.js';
3
- import { WEBSERVER } from './defs.js';
4
- import { Executor } from '@haibun/core/build/phases/Executor.js';
5
- import { asFeatures } from '@haibun/core/build/lib/resolver-features.js';
6
- import { createSteppers, setStepperWorlds } from '@haibun/core/build/lib/util/index.js';
7
- import { Resolver } from '@haibun/core/build/phases/Resolver.js';
8
- import { expand } from '@haibun/core/build/lib/features.js';
9
- import { applyEffectFeatures } from '@haibun/core/build/applyEffectFeatures.js';
10
- // HTTP Prompter for web-based debugging
11
- class HttpPrompter {
12
- contexts;
13
- contextId;
14
- pendingPrompts = new Map();
15
- constructor(contexts, contextId) {
16
- this.contexts = contexts;
17
- this.contextId = contextId;
18
- }
19
- async prompt(prompt) {
20
- const promptId = `${this.contextId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
21
- return new Promise((resolve) => {
22
- this.pendingPrompts.set(promptId, { resolve, prompt });
23
- // Store prompt in context for HTTP retrieval
24
- const context = this.contexts.get(this.contextId);
25
- if (context) {
26
- context.isPaused = true;
27
- context.lastActivity = Date.now();
28
- }
29
- });
30
- }
31
- resolvePrompt(promptId, response) {
32
- const pending = this.pendingPrompts.get(promptId);
33
- if (pending) {
34
- pending.resolve(response);
35
- this.pendingPrompts.delete(promptId);
36
- const context = this.contexts.get(this.contextId);
37
- if (context) {
38
- context.isPaused = false;
39
- context.lastActivity = Date.now();
40
- }
41
- }
42
- }
43
- getPendingPrompts() {
44
- return Array.from(this.pendingPrompts.entries()).map(([id, { prompt }]) => ({
45
- id,
46
- ...prompt
47
- }));
48
- }
49
- cancel() {
50
- // Cancel all pending prompts
51
- this.pendingPrompts.forEach(({ resolve }) => resolve(undefined));
52
- this.pendingPrompts.clear();
53
- }
54
- }
55
- export class ExecutorApiStepper extends AStepper {
56
- executionContexts = new Map();
57
- httpPrompters = new Map();
58
- options = {
59
- EXECUTOR_API_PATH: {
60
- desc: 'API path for executor endpoints (default: /api/executor)',
61
- parse: (path) => ({ result: path }),
62
- },
63
- CONTEXT_TIMEOUT: {
64
- desc: 'Execution context timeout in minutes (default: 60)',
65
- parse: (timeout) => ({ result: parseInt(timeout) || 60 }),
66
- },
67
- };
68
- cycles = {
69
- beforeStep: async ({ featureStep, action }) => {
70
- // Track step execution in active contexts
71
- for (const context of this.executionContexts.values()) {
72
- if (context.isRunning) {
73
- context.currentStep = { featureStep, action, timestamp: Date.now() };
74
- context.stepHistory.push(context.currentStep);
75
- context.lastActivity = Date.now();
76
- // Check for breakpoints
77
- if (context.breakpoints.has(action.actionName) || context.breakpoints.has('*')) {
78
- context.isPaused = true;
79
- const prompter = this.httpPrompters.get(context.id);
80
- if (prompter) {
81
- await prompter.prompt({
82
- message: `Breakpoint hit at ${action.actionName}`,
83
- options: ['continue', 'step', 'abort']
84
- });
85
- }
86
- }
87
- }
88
- }
89
- },
90
- afterStep: ({ actionResult }) => {
91
- // Update step results in active contexts
92
- for (const context of this.executionContexts.values()) {
93
- if (context.isRunning && context.currentStep) {
94
- context.currentStep.result = actionResult;
95
- context.currentStep.completed = Date.now();
96
- context.lastActivity = Date.now();
97
- }
98
- }
99
- return Promise.resolve({});
100
- },
101
- onFailure: () => {
102
- // Handle failures in active contexts
103
- for (const context of this.executionContexts.values()) {
104
- if (context.isRunning) {
105
- context.isPaused = true;
106
- context.lastActivity = Date.now();
107
- }
108
- }
109
- return Promise.resolve();
110
- }
111
- };
112
- steps = {
113
- setupExecutorApi: {
114
- gwta: 'setup executor API at {path}',
115
- action: ({ path }) => {
116
- try {
117
- const apiPath = path || getStepperOption(this, 'EXECUTOR_API_PATH', this.getWorld().moduleOptions) || '/api/executor';
118
- const webserver = getFromRuntime(this.getWorld().runtime, WEBSERVER);
119
- if (!webserver) {
120
- return Promise.resolve(actionNotOK('Web server not available. Ensure web-server-stepper is configured.'));
121
- }
122
- this.setupExecutorRoutes(webserver, apiPath);
123
- this.startContextCleanup();
124
- return Promise.resolve(actionOK());
125
- }
126
- catch (error) {
127
- return Promise.resolve(actionNotOK(`Failed to setup executor API: ${error.message}`));
128
- }
129
- },
130
- },
131
- };
132
- startContextCleanup() {
133
- const timeoutMinutes = parseInt(getStepperOption(this, 'CONTEXT_TIMEOUT', this.getWorld().moduleOptions) || '60');
134
- const timeoutMs = timeoutMinutes * 60 * 1000;
135
- setInterval(() => {
136
- const now = Date.now();
137
- for (const [id, context] of this.executionContexts.entries()) {
138
- if (now - context.lastActivity > timeoutMs) {
139
- this.cleanupContext(id);
140
- }
141
- }
142
- }, 5 * 60 * 1000); // Check every 5 minutes
143
- }
144
- cleanupContext(contextId) {
145
- const context = this.executionContexts.get(contextId);
146
- if (context) {
147
- // Cancel any pending prompts
148
- const prompter = this.httpPrompters.get(contextId);
149
- if (prompter) {
150
- prompter.cancel();
151
- this.httpPrompters.delete(contextId);
152
- }
153
- // Remove from world prompter if subscribed
154
- if (context.world?.prompter) {
155
- context.world.prompter.unsubscribe(prompter);
156
- }
157
- this.executionContexts.delete(contextId);
158
- this.getWorld().logger.debug(`Cleaned up execution context ${contextId}`);
159
- }
160
- }
161
- setupExecutorRoutes(webserver, basePath) {
162
- const world = this.getWorld();
163
- // POST /api/executor/features - Execute features with context
164
- webserver.addRoute('post', `${basePath}/features`, (req, res) => {
165
- void (async () => {
166
- try {
167
- const { features, steppers, options, contextId, debug = false } = req.body;
168
- if (!features || !Array.isArray(features)) {
169
- res.status(400).json({
170
- error: 'Invalid request: features array is required'
171
- });
172
- return;
173
- }
174
- // Create or reuse execution context
175
- const execContextId = contextId || `ctx-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
176
- let context = this.executionContexts.get(execContextId);
177
- if (!context) {
178
- // Create steppers first
179
- const stepperClasses = steppers || [];
180
- const createdSteppers = await createSteppers(stepperClasses);
181
- // Create execution world
182
- const executionWorld = {
183
- ...world,
184
- ...(options || {}),
185
- tag: { ...world.tag, source: 'api', contextId: execContextId }
186
- };
187
- // Set up debugging if requested
188
- if (debug) {
189
- const httpPrompter = new HttpPrompter(this.executionContexts, execContextId);
190
- this.httpPrompters.set(execContextId, httpPrompter);
191
- executionWorld.prompter.subscribe(httpPrompter);
192
- }
193
- await setStepperWorlds(createdSteppers, executionWorld);
194
- // Create context
195
- context = {
196
- id: execContextId,
197
- steppers: createdSteppers,
198
- world: executionWorld,
199
- isRunning: false,
200
- isPaused: false,
201
- breakpoints: new Set(),
202
- stepHistory: [],
203
- createdAt: Date.now(),
204
- lastActivity: Date.now()
205
- };
206
- this.executionContexts.set(execContextId, context);
207
- }
208
- // Mark as running
209
- context.isRunning = true;
210
- context.lastActivity = Date.now();
211
- // Resolve and execute features
212
- const featureObjects = asFeatures(features.map(f => ({
213
- path: f.path || '/api/feature',
214
- content: f.content
215
- })));
216
- const expandedFeatures = await expand({ features: featureObjects, backgrounds: [] });
217
- const resolver = new Resolver(context.steppers);
218
- const resolvedFeatures = await resolver.resolveStepsFromFeatures(expandedFeatures);
219
- const appliedFeatures = await applyEffectFeatures(context.world, resolvedFeatures, context.steppers);
220
- const result = await Executor.executeFeatures(context.steppers, context.world, appliedFeatures);
221
- // Mark as completed
222
- context.isRunning = false;
223
- context.lastActivity = Date.now();
224
- res.json({
225
- success: true,
226
- contextId: execContextId,
227
- result: {
228
- ok: result.ok,
229
- featureResults: result.featureResults?.map(fr => ({
230
- path: fr.path,
231
- ok: fr.ok,
232
- stepCount: fr.stepResults.length,
233
- failedSteps: fr.stepResults.filter(sr => !sr.ok).length
234
- })),
235
- summary: {
236
- totalFeatures: result.featureResults?.length || 0,
237
- passedFeatures: result.featureResults?.filter(fr => fr.ok).length || 0,
238
- failedFeatures: result.featureResults?.filter(fr => !fr.ok).length || 0
239
- }
240
- }
241
- });
242
- }
243
- catch (error) {
244
- world.logger.error('API execution error:', error);
245
- res.status(500).json({
246
- error: 'Execution failed',
247
- message: error.message
248
- });
249
- }
250
- })();
251
- });
252
- // GET /api/executor/contexts - List execution contexts
253
- webserver.addRoute('get', `${basePath}/contexts`, (req, res) => {
254
- const contexts = Array.from(this.executionContexts.values()).map(ctx => ({
255
- id: ctx.id,
256
- isRunning: ctx.isRunning,
257
- isPaused: ctx.isPaused,
258
- createdAt: ctx.createdAt,
259
- lastActivity: ctx.lastActivity,
260
- stepCount: ctx.stepHistory.length,
261
- breakpointCount: ctx.breakpoints.size
262
- }));
263
- res.json({ contexts });
264
- });
265
- // GET /api/executor/contexts/:id - Get context details
266
- webserver.addRoute('get', `${basePath}/contexts/:id`, (req, res) => {
267
- const contextId = req.params?.id;
268
- const context = this.executionContexts.get(contextId);
269
- if (!context) {
270
- res.status(404).json({ error: 'Context not found' });
271
- return;
272
- }
273
- const prompter = this.httpPrompters.get(contextId);
274
- res.json({
275
- id: context.id,
276
- isRunning: context.isRunning,
277
- isPaused: context.isPaused,
278
- currentStep: context.currentStep,
279
- stepHistory: context.stepHistory.slice(-20), // Last 20 steps
280
- breakpoints: Array.from(context.breakpoints),
281
- pendingPrompts: prompter ? prompter.getPendingPrompts() : [],
282
- createdAt: context.createdAt,
283
- lastActivity: context.lastActivity
284
- });
285
- });
286
- // POST /api/executor/contexts/:id/breakpoints - Manage breakpoints
287
- webserver.addRoute('post', `${basePath}/contexts/:id/breakpoints`, (req, res) => {
288
- const contextId = req.params?.id;
289
- const context = this.executionContexts.get(contextId);
290
- if (!context) {
291
- res.status(404).json({ error: 'Context not found' });
292
- return;
293
- }
294
- const { action, stepperName } = req.body;
295
- const breakpoint = stepperName ? `${stepperName}.${action}` : action;
296
- if (req.body.operation === 'add') {
297
- context.breakpoints.add(breakpoint);
298
- }
299
- else if (req.body.operation === 'remove') {
300
- context.breakpoints.delete(breakpoint);
301
- }
302
- context.lastActivity = Date.now();
303
- res.json({ breakpoints: Array.from(context.breakpoints) });
304
- });
305
- // POST /api/executor/contexts/:id/prompts/:promptId - Respond to prompts
306
- webserver.addRoute('post', `${basePath}/contexts/:id/prompts/:promptId`, (req, res) => {
307
- const contextId = req.params?.id;
308
- const promptId = req.params?.promptId;
309
- const context = this.executionContexts.get(contextId);
310
- if (!context) {
311
- res.status(404).json({ error: 'Context not found' });
312
- return;
313
- }
314
- const prompter = this.httpPrompters.get(contextId);
315
- if (!prompter) {
316
- res.status(400).json({ error: 'No prompter available for this context' });
317
- return;
318
- }
319
- prompter.resolvePrompt(promptId, req.body.response);
320
- context.lastActivity = Date.now();
321
- res.json({ success: true });
322
- });
323
- // DELETE /api/executor/contexts/:id - Clean up context
324
- webserver.addRoute('delete', `${basePath}/contexts/:id`, (req, res) => {
325
- const contextId = req.params?.id;
326
- if (this.executionContexts.has(contextId)) {
327
- this.cleanupContext(contextId);
328
- res.json({ success: true });
329
- }
330
- else {
331
- res.status(404).json({ error: 'Context not found' });
332
- }
333
- });
334
- // GET /api/executor/status - Get executor status
335
- webserver.addRoute('get', `${basePath}/status`, (req, res) => {
336
- res.json({
337
- status: 'ready',
338
- timestamp: new Date().toISOString(),
339
- version: '1.0.0',
340
- activeContexts: this.executionContexts.size,
341
- runningContexts: Array.from(this.executionContexts.values()).filter(ctx => ctx.isRunning).length
342
- });
343
- });
344
- // POST /api/executor/validate - Validate features without execution
345
- webserver.addRoute('post', `${basePath}/validate`, (req, res) => {
346
- void (async () => {
347
- try {
348
- const { features, steppers } = req.body;
349
- if (!features || !Array.isArray(features)) {
350
- res.status(400).json({
351
- error: 'Invalid request: features array is required'
352
- });
353
- return;
354
- }
355
- const featureObjects = asFeatures(features.map(f => ({
356
- path: f.path || '/api/feature',
357
- content: f.content
358
- })));
359
- const stepperClasses = steppers || [];
360
- const createdSteppers = await createSteppers(stepperClasses);
361
- await setStepperWorlds(createdSteppers, world);
362
- const expandedFeatures = await expand({ features: featureObjects, backgrounds: [] });
363
- const resolver = new Resolver(createdSteppers);
364
- const resolvedFeatures = await resolver.resolveStepsFromFeatures(expandedFeatures);
365
- res.json({
366
- success: true,
367
- validation: {
368
- featuresCount: resolvedFeatures.length,
369
- totalSteps: resolvedFeatures.reduce((sum, f) => sum + f.featureSteps.length, 0),
370
- features: resolvedFeatures.map(f => ({
371
- path: f.path,
372
- stepCount: f.featureSteps.length,
373
- valid: true
374
- }))
375
- }
376
- });
377
- }
378
- catch (error) {
379
- world.logger.error('API validation error:', error);
380
- res.status(500).json({
381
- error: 'Validation failed',
382
- message: error.message
383
- });
384
- }
385
- })();
386
- });
387
- world.logger.log(`Executor API routes configured at ${basePath}`);
388
- }
389
- }
390
- export default ExecutorApiStepper;
391
- //# sourceMappingURL=executor-api-stepper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executor-api-stepper.js","sourceRoot":"","sources":["../src/executor-api-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC/G,OAAO,EAAc,SAAS,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AA0BhF,wCAAwC;AACxC,MA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I,CAAC;wBACpB,KAAK,EAAE,mBAAmB;wBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;qBACtB,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC,CAAC,EAAE,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,qCAAqC,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;CACD;AAED,eAAe,kBAAkB,CAAC"}
@@ -1,30 +0,0 @@
1
- import { AStepper, IHasOptions } from '@haibun/core/build/lib/astepper.js';
2
- import { TWorld } from '@haibun/core/build/lib/defs.js';
3
- export default class RemoteExecutorStepper extends AStepper implements IHasOptions {
4
- options: {
5
- REMOTE_PORT: {
6
- desc: string;
7
- parse: (port: string) => {
8
- result: number;
9
- };
10
- };
11
- ACCESS_TOKEN: {
12
- desc: string;
13
- parse: (token: string) => {
14
- result: string;
15
- };
16
- };
17
- };
18
- private routeAdded;
19
- private steppers;
20
- configuredToken: string;
21
- setWorld(world: TWorld, steppers: AStepper[]): Promise<void>;
22
- addRemoteExecutorRoute(): void;
23
- steps: {
24
- enableRemoteExecutor: {
25
- gwta: string;
26
- action: () => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult>;
27
- };
28
- };
29
- }
30
- //# sourceMappingURL=remote-executor-stepper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-executor-stepper.d.ts","sourceRoot":"","sources":["../src/remote-executor-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAe,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAOrE,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,QAAS,YAAW,WAAW;IACjF,OAAO;;;0BAGS,MAAM;;;;;;2BAIL,MAAM;;;;MAErB;IAEF,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAkB;IAClC,eAAe,EAAE,MAAM,CAAC;IAElB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAelD,sBAAsB;IA2DtB,KAAK;;;;;MAQH;CACF"}
@@ -1,90 +0,0 @@
1
- import { AStepper } from '@haibun/core/build/lib/astepper.js';
2
- import { FeatureExecutor } from '@haibun/core/build/phases/Executor.js';
3
- import { actionOK, getFromRuntime, getStepperOption } from '@haibun/core/build/lib/util/index.js';
4
- import { WEBSERVER } from './defs.js';
5
- import WebServerStepper from './web-server-stepper.js';
6
- import { getActionableStatement } from '@haibun/core/build/phases/Resolver.js';
7
- export default class RemoteExecutorStepper extends AStepper {
8
- options = {
9
- REMOTE_PORT: {
10
- desc: 'Port for remote execution API (DANGEROUS - development only)',
11
- parse: (port) => ({ result: parseInt(port, 10) }),
12
- },
13
- ACCESS_TOKEN: {
14
- desc: 'Access token for remote execution API authentication',
15
- parse: (token) => ({ result: token }),
16
- },
17
- };
18
- routeAdded = false;
19
- steppers = [];
20
- configuredToken;
21
- async setWorld(world, steppers) {
22
- await super.setWorld(world, steppers);
23
- this.configuredToken = getStepperOption(this, 'ACCESS_TOKEN', this.getWorld().moduleOptions);
24
- this.steppers = steppers;
25
- const port = getStepperOption(this, 'REMOTE_PORT', world.moduleOptions);
26
- if (port && typeof port === 'number') {
27
- // Configure the web server to use the same port
28
- const webServerStepper = steppers.find(s => s instanceof WebServerStepper);
29
- if (webServerStepper) {
30
- webServerStepper.port = port;
31
- }
32
- // Add route after world is set and webserver should be available
33
- setTimeout(() => void this.addRemoteExecutorRoute(), 100);
34
- }
35
- }
36
- addRemoteExecutorRoute() {
37
- if (this.routeAdded) {
38
- return;
39
- }
40
- const webserver = getFromRuntime(this.getWorld().runtime, WEBSERVER);
41
- if (!webserver) {
42
- throw new Error('WebServer not available - ensure web-server-stepper is loaded');
43
- }
44
- // Add the remote execution route
45
- webserver.addRoute('post', '/execute-step', (req, res) => {
46
- void (async () => {
47
- try {
48
- if (this.configuredToken) {
49
- const authHeader = req.headers.authorization;
50
- const providedToken = authHeader?.startsWith('Bearer ') ? authHeader.slice(7) : null;
51
- if (!providedToken || providedToken !== this.configuredToken) {
52
- res.status(401).json({ error: 'Invalid or missing access token' });
53
- return;
54
- }
55
- }
56
- if (!['statement', 'source'].every(key => typeof req.body[key] === 'string')) {
57
- res.status(400).json({ error: 'statement and source are required' });
58
- return;
59
- }
60
- const { statement, source } = req.body;
61
- const world = this.getWorld();
62
- const steppers = this.steppers;
63
- const { featureStep } = await getActionableStatement(steppers, statement, source);
64
- const result = await FeatureExecutor.doFeatureStep(steppers, featureStep, world);
65
- res.json(result);
66
- }
67
- catch (error) {
68
- const errorMessage = error instanceof Error ? error.message : String(error);
69
- res.status(500).json({
70
- error: errorMessage,
71
- success: false
72
- });
73
- }
74
- })();
75
- });
76
- this.routeAdded = true;
77
- this.getWorld().logger.warn('⚠️ DANGEROUS: Remote executor route added at /execute-step');
78
- this.getWorld().logger.warn('⚠️ This exposes execution context - use only in secure environments');
79
- }
80
- steps = {
81
- enableRemoteExecutor: {
82
- gwta: 'enable remote executor',
83
- action: () => {
84
- this.addRemoteExecutorRoute();
85
- return Promise.resolve(actionOK());
86
- },
87
- },
88
- };
89
- }
90
- //# sourceMappingURL=remote-executor-stepper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-executor-stepper.js","sourceRoot":"","sources":["../src/remote-executor-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAClG,OAAO,EAAmC,SAAS,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,MAAM,CA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