@kapeta/local-cluster-service 0.58.0 → 0.58.2

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.58.2](https://github.com/kapetacom/local-cluster-service/compare/v0.58.1...v0.58.2) (2024-07-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Include title in journeys and pages ([16def8d](https://github.com/kapetacom/local-cluster-service/commit/16def8d726fb3b922ffc6934ce59c981996c3523))
7
+
8
+ ## [0.58.1](https://github.com/kapetacom/local-cluster-service/compare/v0.58.0...v0.58.1) (2024-07-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Make each page its own conversation ([#201](https://github.com/kapetacom/local-cluster-service/issues/201)) ([13173a8](https://github.com/kapetacom/local-cluster-service/commit/13173a8871178dc9c0e00075e829a86095709f8f))
14
+
1
15
  # [0.58.0](https://github.com/kapetacom/local-cluster-service/compare/v0.57.0...v0.58.0) (2024-07-24)
2
16
 
3
17
 
@@ -268,10 +268,12 @@ export interface StormEventPhases {
268
268
  }
269
269
  export interface Page {
270
270
  name: string;
271
+ title: string;
271
272
  description: string;
272
273
  content: string;
273
274
  path: string;
274
275
  method: string;
276
+ conversationId: string;
275
277
  }
276
278
  export interface StormEventPage {
277
279
  type: 'PAGE';
@@ -281,6 +283,7 @@ export interface StormEventPage {
281
283
  }
282
284
  export interface UserJourneyScreen {
283
285
  name: string;
286
+ title: string;
284
287
  filename: string;
285
288
  requirements: string;
286
289
  path: string;
@@ -18,9 +18,36 @@ const events_1 = require("./events");
18
18
  const event_parser_1 = require("./event-parser");
19
19
  const codegen_1 = require("./codegen");
20
20
  const assetManager_1 = require("../assetManager");
21
+ const node_uuid_1 = __importDefault(require("node-uuid"));
21
22
  const router = (0, express_promise_router_1.default)();
22
23
  router.use('/', cors_1.corsHandler);
23
24
  router.use('/', stringBody_1.stringBody);
25
+ router.post('/:handle/ui/screen', async (req, res) => {
26
+ const handle = req.params.handle;
27
+ try {
28
+ const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()];
29
+ const aiRequest = JSON.parse(req.stringBody ?? '{}');
30
+ const screenStream = await stormClient_1.stormClient.createUIPage(aiRequest, conversationId);
31
+ onRequestAborted(req, res, () => {
32
+ screenStream.abort();
33
+ });
34
+ res.set('Content-Type', 'application/x-ndjson');
35
+ res.set('Access-Control-Expose-Headers', stormClient_1.ConversationIdHeader);
36
+ res.set(stormClient_1.ConversationIdHeader, screenStream.getConversationId());
37
+ screenStream.on('data', (data) => {
38
+ console.log('Processing screen event', data);
39
+ sendEvent(res, data);
40
+ });
41
+ await waitForStormStream(screenStream);
42
+ sendDone(res);
43
+ }
44
+ catch (err) {
45
+ sendError(err, res);
46
+ if (!res.closed) {
47
+ res.end();
48
+ }
49
+ }
50
+ });
24
51
  router.post('/:handle/ui', async (req, res) => {
25
52
  const handle = req.params.handle;
26
53
  try {
@@ -47,15 +74,20 @@ router.post('/:handle/ui', async (req, res) => {
47
74
  }
48
75
  promises[screen.name] = new Promise(async (resolve, reject) => {
49
76
  try {
77
+ const innerConversationId = node_uuid_1.default.v4();
50
78
  const screenStream = await stormClient_1.stormClient.createUIPage({
51
79
  prompt: screen.requirements,
52
80
  method: screen.method,
53
81
  path: screen.path,
54
82
  description: screen.requirements,
55
83
  name: screen.name,
84
+ title: screen.title,
56
85
  filename: screen.filename,
57
- }, conversationId);
86
+ }, innerConversationId);
58
87
  screenStream.on('data', (screenData) => {
88
+ if (screenData.type === 'PAGE') {
89
+ screenData.payload.conversationId = innerConversationId;
90
+ }
59
91
  console.log('Processing screen event', screenData);
60
92
  sendEvent(res, screenData);
61
93
  });
@@ -1,8 +1,9 @@
1
1
  import { ConversationItem, StormFileImplementationPrompt, StormStream, StormUIImplementationPrompt, StormUIListPrompt } from './stream';
2
2
  export declare const STORM_ID = "storm";
3
3
  export declare const ConversationIdHeader = "Conversation-Id";
4
- interface UIPagePrompt {
4
+ export interface UIPagePrompt {
5
5
  name: string;
6
+ title: string;
6
7
  filename: string;
7
8
  prompt: string;
8
9
  path: string;
@@ -268,10 +268,12 @@ export interface StormEventPhases {
268
268
  }
269
269
  export interface Page {
270
270
  name: string;
271
+ title: string;
271
272
  description: string;
272
273
  content: string;
273
274
  path: string;
274
275
  method: string;
276
+ conversationId: string;
275
277
  }
276
278
  export interface StormEventPage {
277
279
  type: 'PAGE';
@@ -281,6 +283,7 @@ export interface StormEventPage {
281
283
  }
282
284
  export interface UserJourneyScreen {
283
285
  name: string;
286
+ title: string;
284
287
  filename: string;
285
288
  requirements: string;
286
289
  path: string;
@@ -18,9 +18,36 @@ const events_1 = require("./events");
18
18
  const event_parser_1 = require("./event-parser");
19
19
  const codegen_1 = require("./codegen");
20
20
  const assetManager_1 = require("../assetManager");
21
+ const node_uuid_1 = __importDefault(require("node-uuid"));
21
22
  const router = (0, express_promise_router_1.default)();
22
23
  router.use('/', cors_1.corsHandler);
23
24
  router.use('/', stringBody_1.stringBody);
25
+ router.post('/:handle/ui/screen', async (req, res) => {
26
+ const handle = req.params.handle;
27
+ try {
28
+ const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()];
29
+ const aiRequest = JSON.parse(req.stringBody ?? '{}');
30
+ const screenStream = await stormClient_1.stormClient.createUIPage(aiRequest, conversationId);
31
+ onRequestAborted(req, res, () => {
32
+ screenStream.abort();
33
+ });
34
+ res.set('Content-Type', 'application/x-ndjson');
35
+ res.set('Access-Control-Expose-Headers', stormClient_1.ConversationIdHeader);
36
+ res.set(stormClient_1.ConversationIdHeader, screenStream.getConversationId());
37
+ screenStream.on('data', (data) => {
38
+ console.log('Processing screen event', data);
39
+ sendEvent(res, data);
40
+ });
41
+ await waitForStormStream(screenStream);
42
+ sendDone(res);
43
+ }
44
+ catch (err) {
45
+ sendError(err, res);
46
+ if (!res.closed) {
47
+ res.end();
48
+ }
49
+ }
50
+ });
24
51
  router.post('/:handle/ui', async (req, res) => {
25
52
  const handle = req.params.handle;
26
53
  try {
@@ -47,15 +74,20 @@ router.post('/:handle/ui', async (req, res) => {
47
74
  }
48
75
  promises[screen.name] = new Promise(async (resolve, reject) => {
49
76
  try {
77
+ const innerConversationId = node_uuid_1.default.v4();
50
78
  const screenStream = await stormClient_1.stormClient.createUIPage({
51
79
  prompt: screen.requirements,
52
80
  method: screen.method,
53
81
  path: screen.path,
54
82
  description: screen.requirements,
55
83
  name: screen.name,
84
+ title: screen.title,
56
85
  filename: screen.filename,
57
- }, conversationId);
86
+ }, innerConversationId);
58
87
  screenStream.on('data', (screenData) => {
88
+ if (screenData.type === 'PAGE') {
89
+ screenData.payload.conversationId = innerConversationId;
90
+ }
59
91
  console.log('Processing screen event', screenData);
60
92
  sendEvent(res, screenData);
61
93
  });
@@ -1,8 +1,9 @@
1
1
  import { ConversationItem, StormFileImplementationPrompt, StormStream, StormUIImplementationPrompt, StormUIListPrompt } from './stream';
2
2
  export declare const STORM_ID = "storm";
3
3
  export declare const ConversationIdHeader = "Conversation-Id";
4
- interface UIPagePrompt {
4
+ export interface UIPagePrompt {
5
5
  name: string;
6
+ title: string;
6
7
  filename: string;
7
8
  prompt: string;
8
9
  path: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.58.0",
3
+ "version": "0.58.2",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -318,10 +318,12 @@ export interface StormEventPhases {
318
318
 
319
319
  export interface Page {
320
320
  name: string;
321
+ title: string;
321
322
  description: string;
322
323
  content: string;
323
324
  path: string;
324
325
  method: string;
326
+ conversationId: string;
325
327
  }
326
328
 
327
329
  // Event for creating a page
@@ -334,6 +336,7 @@ export interface StormEventPage {
334
336
 
335
337
  export interface UserJourneyScreen {
336
338
  name: string;
339
+ title: string;
337
340
  filename: string;
338
341
  requirements: string;
339
342
  path: string;
@@ -12,7 +12,7 @@ import { corsHandler } from '../middleware/cors';
12
12
  import { stringBody } from '../middleware/stringBody';
13
13
  import { KapetaBodyRequest } from '../types';
14
14
  import { StormCodegenRequest, StormContextRequest, StormCreateBlockRequest, StormStream } from './stream';
15
- import { ConversationIdHeader, stormClient, UIPageEditPrompt } from './stormClient';
15
+ import { ConversationIdHeader, stormClient, UIPagePrompt, UIPageEditPrompt } from './stormClient';
16
16
  import { StormEvent, StormEventPhaseType } from './events';
17
17
  import {
18
18
  createPhaseEndEvent,
@@ -23,12 +23,46 @@ import {
23
23
  } from './event-parser';
24
24
  import { StormCodegen } from './codegen';
25
25
  import { assetManager } from '../assetManager';
26
+ import uuid from 'node-uuid';
26
27
 
27
28
  const router = Router();
28
29
 
29
30
  router.use('/', corsHandler);
30
31
  router.use('/', stringBody);
31
32
 
33
+ router.post('/:handle/ui/screen', async (req: KapetaBodyRequest, res: Response) => {
34
+ const handle = req.params.handle as string;
35
+ try {
36
+ const conversationId = req.headers[ConversationIdHeader.toLowerCase()] as string | undefined;
37
+
38
+ const aiRequest: UIPagePrompt = JSON.parse(req.stringBody ?? '{}');
39
+
40
+ const screenStream = await stormClient.createUIPage(aiRequest, conversationId);
41
+
42
+ onRequestAborted(req, res, () => {
43
+ screenStream.abort();
44
+ });
45
+
46
+ res.set('Content-Type', 'application/x-ndjson');
47
+ res.set('Access-Control-Expose-Headers', ConversationIdHeader);
48
+ res.set(ConversationIdHeader, screenStream.getConversationId());
49
+
50
+ screenStream.on('data', (data: StormEvent) => {
51
+ console.log('Processing screen event', data);
52
+ sendEvent(res, data);
53
+ });
54
+
55
+ await waitForStormStream(screenStream);
56
+
57
+ sendDone(res);
58
+ } catch (err: any) {
59
+ sendError(err, res);
60
+ if (!res.closed) {
61
+ res.end();
62
+ }
63
+ }
64
+ });
65
+
32
66
  router.post('/:handle/ui', async (req: KapetaBodyRequest, res: Response) => {
33
67
  const handle = req.params.handle as string;
34
68
  try {
@@ -62,6 +96,7 @@ router.post('/:handle/ui', async (req: KapetaBodyRequest, res: Response) => {
62
96
  }
63
97
  promises[screen.name] = new Promise(async (resolve, reject) => {
64
98
  try {
99
+ const innerConversationId = uuid.v4();
65
100
  const screenStream = await stormClient.createUIPage(
66
101
  {
67
102
  prompt: screen.requirements,
@@ -69,11 +104,15 @@ router.post('/:handle/ui', async (req: KapetaBodyRequest, res: Response) => {
69
104
  path: screen.path,
70
105
  description: screen.requirements,
71
106
  name: screen.name,
107
+ title: screen.title,
72
108
  filename: screen.filename,
73
109
  },
74
- conversationId
110
+ innerConversationId
75
111
  );
76
112
  screenStream.on('data', (screenData: StormEvent) => {
113
+ if (screenData.type === 'PAGE') {
114
+ screenData.payload.conversationId = innerConversationId;
115
+ }
77
116
  console.log('Processing screen event', screenData);
78
117
  sendEvent(res, screenData);
79
118
  });
@@ -20,8 +20,9 @@ export const STORM_ID = 'storm';
20
20
 
21
21
  export const ConversationIdHeader = 'Conversation-Id';
22
22
 
23
- interface UIPagePrompt {
23
+ export interface UIPagePrompt {
24
24
  name: string;
25
+ title: string;
25
26
  filename: string;
26
27
  prompt: string;
27
28
  path: string;