@kapeta/local-cluster-service 0.54.7 → 0.54.9

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [0.54.9](https://github.com/kapetacom/local-cluster-service/compare/v0.54.8...v0.54.9) (2024-07-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * filter out INVALID_RESPONSE events ([abc1ca3](https://github.com/kapetacom/local-cluster-service/commit/abc1ca371f3f88e339e4ec6e6204efd333c2c771))
7
+
8
+ ## [0.54.8](https://github.com/kapetacom/local-cluster-service/compare/v0.54.7...v0.54.8) (2024-06-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update webrouter handling after template change ([#187](https://github.com/kapetacom/local-cluster-service/issues/187)) ([1c3dffa](https://github.com/kapetacom/local-cluster-service/commit/1c3dffa0f8e44680e9dbdee0acd97bde9a3e42b8))
14
+
1
15
  ## [0.54.7](https://github.com/kapetacom/local-cluster-service/compare/v0.54.6...v0.54.7) (2024-06-21)
2
16
 
3
17
 
@@ -282,7 +282,9 @@ class StormCodegen {
282
282
  }
283
283
  // TODO: remove this when we have a better way to handle failed events
284
284
  // Skip failed events - they are not relevant to the materializer
285
- filteredEvents = filteredEvents.filter((event) => !event.type.endsWith('_FAILED') && !event.type.endsWith('ERROR_INTERNAL'));
285
+ filteredEvents = filteredEvents.filter((event) => !event.type.endsWith('_FAILED') &&
286
+ !event.type.endsWith('ERROR_INTERNAL') &&
287
+ !event.type.endsWith('INVALID_RESPONSE'));
286
288
  const screenEvents = [];
287
289
  const getScreenEventsFile = () => ({
288
290
  content: JSON.stringify(screenEvents),
@@ -355,23 +357,8 @@ class StormCodegen {
355
357
  };
356
358
  });
357
359
  allFiles.push(...screenFilesConverted);
358
- const webRouters = allFiles.filter((file) => file.type === codegen_1.AIFileTypes.WEB_ROUTER);
359
- await Promise.all(webRouters.map(async (webRouter) => {
360
- const payload = {
361
- filename: webRouter.filename,
362
- template: webRouter,
363
- context: screenFilesConverted.concat([getScreenEventsFile()]),
364
- prompt: this.userPrompt,
365
- };
366
- const stream = await stormClient_1.stormClient.generateCode(payload);
367
- stream.on('data', (evt) => {
368
- this.handleTemplateFileOutput(blockUri, block.aiName, evt);
369
- });
370
- this.out.on('aborted', () => {
371
- stream.abort();
372
- });
373
- await stream.waitForDone();
374
- }));
360
+ let webRouters = allFiles.filter((file) => file.type === codegen_1.AIFileTypes.WEB_ROUTER);
361
+ webRouters = await this.processTemplates(blockUri, block.aiName, stormClient_1.stormClient.generateCode.bind(stormClient_1.stormClient), webRouters, screenFilesConverted.concat([getScreenEventsFile()]));
375
362
  // Gather the context files for implementation. These will be all be passed to the AI
376
363
  const contextFiles = relevantFiles.filter((file) => ![codegen_1.AIFileTypes.SERVICE, codegen_1.AIFileTypes.WEB_SCREEN, codegen_1.AIFileTypes.WEB_ROUTER].includes(file.type));
377
364
  // Send the service and UI templates to the AI. These will be sent one-by-one in addition to the context files
@@ -395,7 +382,6 @@ class StormCodegen {
395
382
  const filePath = (0, path_2.join)(basePath, serviceFile.filename);
396
383
  await (0, promises_1.writeFile)(filePath, serviceFile.content);
397
384
  }
398
- // Write again after modifications
399
385
  for (const webRouterFile of webRouters) {
400
386
  const filePath = (0, path_2.join)(basePath, webRouterFile.filename);
401
387
  await (0, promises_1.writeFile)(filePath, webRouterFile.content);
@@ -13,7 +13,7 @@ declare class StormClient {
13
13
  createErrorClassification(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
14
14
  createCodeFix(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
15
15
  createErrorDetails(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
16
- generateCode(prompt: StormFileImplementationPrompt, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
16
+ generateCode(prompt: StormFileImplementationPrompt, conversationId?: string): Promise<StormStream>;
17
17
  }
18
18
  export declare const stormClient: StormClient;
19
19
  export {};
@@ -116,10 +116,10 @@ class StormClient {
116
116
  prompt,
117
117
  });
118
118
  }
119
- generateCode(prompt, history, conversationId) {
119
+ generateCode(prompt, conversationId) {
120
120
  return this.send('/v2/code/generate', {
121
- conversationId: conversationId,
122
121
  prompt,
122
+ conversationId: conversationId,
123
123
  });
124
124
  }
125
125
  }
@@ -282,7 +282,9 @@ class StormCodegen {
282
282
  }
283
283
  // TODO: remove this when we have a better way to handle failed events
284
284
  // Skip failed events - they are not relevant to the materializer
285
- filteredEvents = filteredEvents.filter((event) => !event.type.endsWith('_FAILED') && !event.type.endsWith('ERROR_INTERNAL'));
285
+ filteredEvents = filteredEvents.filter((event) => !event.type.endsWith('_FAILED') &&
286
+ !event.type.endsWith('ERROR_INTERNAL') &&
287
+ !event.type.endsWith('INVALID_RESPONSE'));
286
288
  const screenEvents = [];
287
289
  const getScreenEventsFile = () => ({
288
290
  content: JSON.stringify(screenEvents),
@@ -355,23 +357,8 @@ class StormCodegen {
355
357
  };
356
358
  });
357
359
  allFiles.push(...screenFilesConverted);
358
- const webRouters = allFiles.filter((file) => file.type === codegen_1.AIFileTypes.WEB_ROUTER);
359
- await Promise.all(webRouters.map(async (webRouter) => {
360
- const payload = {
361
- filename: webRouter.filename,
362
- template: webRouter,
363
- context: screenFilesConverted.concat([getScreenEventsFile()]),
364
- prompt: this.userPrompt,
365
- };
366
- const stream = await stormClient_1.stormClient.generateCode(payload);
367
- stream.on('data', (evt) => {
368
- this.handleTemplateFileOutput(blockUri, block.aiName, evt);
369
- });
370
- this.out.on('aborted', () => {
371
- stream.abort();
372
- });
373
- await stream.waitForDone();
374
- }));
360
+ let webRouters = allFiles.filter((file) => file.type === codegen_1.AIFileTypes.WEB_ROUTER);
361
+ webRouters = await this.processTemplates(blockUri, block.aiName, stormClient_1.stormClient.generateCode.bind(stormClient_1.stormClient), webRouters, screenFilesConverted.concat([getScreenEventsFile()]));
375
362
  // Gather the context files for implementation. These will be all be passed to the AI
376
363
  const contextFiles = relevantFiles.filter((file) => ![codegen_1.AIFileTypes.SERVICE, codegen_1.AIFileTypes.WEB_SCREEN, codegen_1.AIFileTypes.WEB_ROUTER].includes(file.type));
377
364
  // Send the service and UI templates to the AI. These will be sent one-by-one in addition to the context files
@@ -395,7 +382,6 @@ class StormCodegen {
395
382
  const filePath = (0, path_2.join)(basePath, serviceFile.filename);
396
383
  await (0, promises_1.writeFile)(filePath, serviceFile.content);
397
384
  }
398
- // Write again after modifications
399
385
  for (const webRouterFile of webRouters) {
400
386
  const filePath = (0, path_2.join)(basePath, webRouterFile.filename);
401
387
  await (0, promises_1.writeFile)(filePath, webRouterFile.content);
@@ -13,7 +13,7 @@ declare class StormClient {
13
13
  createErrorClassification(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
14
14
  createCodeFix(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
15
15
  createErrorDetails(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
16
- generateCode(prompt: StormFileImplementationPrompt, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
16
+ generateCode(prompt: StormFileImplementationPrompt, conversationId?: string): Promise<StormStream>;
17
17
  }
18
18
  export declare const stormClient: StormClient;
19
19
  export {};
@@ -116,10 +116,10 @@ class StormClient {
116
116
  prompt,
117
117
  });
118
118
  }
119
- generateCode(prompt, history, conversationId) {
119
+ generateCode(prompt, conversationId) {
120
120
  return this.send('/v2/code/generate', {
121
- conversationId: conversationId,
122
121
  prompt,
122
+ conversationId: conversationId,
123
123
  });
124
124
  }
125
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.54.7",
3
+ "version": "0.54.9",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -330,7 +330,10 @@ export class StormCodegen {
330
330
  // TODO: remove this when we have a better way to handle failed events
331
331
  // Skip failed events - they are not relevant to the materializer
332
332
  filteredEvents = filteredEvents.filter(
333
- (event) => !event.type.endsWith('_FAILED') && !event.type.endsWith('ERROR_INTERNAL')
333
+ (event) =>
334
+ !event.type.endsWith('_FAILED') &&
335
+ !event.type.endsWith('ERROR_INTERNAL') &&
336
+ !event.type.endsWith('INVALID_RESPONSE')
334
337
  );
335
338
 
336
339
  const screenEvents: StormEventScreen[] = [];
@@ -419,28 +422,13 @@ export class StormCodegen {
419
422
  });
420
423
  allFiles.push(...screenFilesConverted);
421
424
 
422
- const webRouters = allFiles.filter((file) => file.type === AIFileTypes.WEB_ROUTER);
423
- await Promise.all(
424
- webRouters.map(async (webRouter) => {
425
- const payload = {
426
- filename: webRouter.filename,
427
- template: webRouter,
428
- context: screenFilesConverted.concat([getScreenEventsFile()]),
429
- prompt: this.userPrompt,
430
- };
431
-
432
- const stream = await stormClient.generateCode(payload);
433
-
434
- stream.on('data', (evt) => {
435
- this.handleTemplateFileOutput(blockUri, block.aiName, evt);
436
- });
437
-
438
- this.out.on('aborted', () => {
439
- stream.abort();
440
- });
441
-
442
- await stream.waitForDone();
443
- })
425
+ let webRouters = allFiles.filter((file) => file.type === AIFileTypes.WEB_ROUTER);
426
+ webRouters = await this.processTemplates(
427
+ blockUri,
428
+ block.aiName,
429
+ stormClient.generateCode.bind(stormClient),
430
+ webRouters,
431
+ screenFilesConverted.concat([getScreenEventsFile()])
444
432
  );
445
433
 
446
434
  // Gather the context files for implementation. These will be all be passed to the AI
@@ -480,7 +468,6 @@ export class StormCodegen {
480
468
  await writeFile(filePath, serviceFile.content);
481
469
  }
482
470
 
483
- // Write again after modifications
484
471
  for (const webRouterFile of webRouters) {
485
472
  const filePath = join(basePath, webRouterFile.filename);
486
473
  await writeFile(filePath, webRouterFile.content);
@@ -155,10 +155,10 @@ class StormClient {
155
155
  });
156
156
  }
157
157
 
158
- public generateCode(prompt: StormFileImplementationPrompt, history?: ConversationItem[], conversationId?: string) {
158
+ public generateCode(prompt: StormFileImplementationPrompt, conversationId?: string) {
159
159
  return this.send('/v2/code/generate', {
160
- conversationId: conversationId,
161
160
  prompt,
161
+ conversationId: conversationId,
162
162
  });
163
163
  }
164
164
  }