@kapeta/local-cluster-service 0.64.2 → 0.65.0

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.65.0](https://github.com/kapetacom/local-cluster-service/compare/v0.64.3...v0.65.0) (2024-08-26)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add votes endpoints ([82c1ee7](https://github.com/kapetacom/local-cluster-service/commit/82c1ee7a959f61475a7403845f8037b11fdd5084))
7
+
8
+ ## [0.64.3](https://github.com/kapetacom/local-cluster-service/compare/v0.64.2...v0.64.3) (2024-08-23)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Handle new prompt payload format in edit ([#223](https://github.com/kapetacom/local-cluster-service/issues/223)) ([bf06e8a](https://github.com/kapetacom/local-cluster-service/commit/bf06e8a9d82833fcaf076c254e46cc94f945a23c))
14
+
1
15
  ## [0.64.2](https://github.com/kapetacom/local-cluster-service/compare/v0.64.1...v0.64.2) (2024-08-22)
2
16
 
3
17
 
@@ -321,7 +321,9 @@ router.post('/ui/edit', async (req, res) => {
321
321
  })
322
322
  .filter((page) => !!page);
323
323
  const editStream = await stormClient_1.stormClient.editPages({
324
- ...aiRequest.prompt,
324
+ prompt: aiRequest.prompt.prompt.prompt,
325
+ blockDescription: aiRequest.prompt.blockDescription,
326
+ planDescription: aiRequest.prompt.planDescription,
325
327
  pages,
326
328
  }, conversationId);
327
329
  onRequestAborted(req, res, () => {
@@ -358,6 +360,18 @@ router.post('/ui/edit', async (req, res) => {
358
360
  }
359
361
  }
360
362
  });
363
+ router.post('/ui/vote', async (req, res) => {
364
+ const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()] || '';
365
+ const aiRequest = JSON.parse(req.stringBody ?? '{}');
366
+ const { topic, vote, mainConversationId } = aiRequest;
367
+ return stormClient_1.stormClient.voteUIPage(topic, conversationId, vote, mainConversationId);
368
+ });
369
+ router.post('/ui/get-vote', async (req, res) => {
370
+ const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()] || '';
371
+ const aiRequest = JSON.parse(req.stringBody ?? '{}');
372
+ const { topic, mainConversationId } = aiRequest;
373
+ return stormClient_1.stormClient.getVoteUIPage(topic, conversationId, mainConversationId);
374
+ });
361
375
  router.post('/:handle/all', async (req, res) => {
362
376
  const handle = req.params.handle;
363
377
  try {
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { ConversationItem, StormFileImplementationPrompt, StormStream, StormUIImplementationPrompt, StormUIListPrompt } from './stream';
2
3
  import { Page, StormEventPageUrl } from './events';
3
4
  export declare const STORM_ID = "storm";
@@ -36,7 +37,16 @@ export interface UIPageEditRequest {
36
37
  planDescription: string;
37
38
  blockDescription: string;
38
39
  pages: StormEventPageUrl['payload'][];
39
- prompt: string;
40
+ prompt: BasePromptRequest;
41
+ }
42
+ export interface UIPageVoteRequest {
43
+ topic: string;
44
+ vote: -1 | 0 | 1;
45
+ mainConversationId: string;
46
+ }
47
+ export interface UIPageGetVoteRequest {
48
+ topic: string;
49
+ mainConversationId: string;
40
50
  }
41
51
  export interface BasePromptRequest {
42
52
  prompt: string;
@@ -53,6 +63,10 @@ declare class StormClient {
53
63
  createUIShells(prompt: UIShellsPrompt, conversationId?: string): Promise<StormStream>;
54
64
  createUILandingPages(prompt: BasePromptRequest, conversationId?: string): Promise<StormStream>;
55
65
  createUIPage(prompt: UIPagePrompt, conversationId?: string, history?: ConversationItem[]): Promise<StormStream>;
66
+ voteUIPage(topic: string, conversationId: string, vote: -1 | 0 | 1, mainConversationId?: string): Promise<Response>;
67
+ getVoteUIPage(topic: string, conversationId: string, mainConversationId?: string): Promise<{
68
+ vote: -1 | 0 | 1;
69
+ }>;
56
70
  classifyUIReferences(prompt: string, conversationId?: string): Promise<StormStream>;
57
71
  editPages(prompt: UIPageEditPrompt, conversationId?: string): Promise<StormStream>;
58
72
  listScreens(prompt: StormUIListPrompt, conversationId?: string): Promise<StormStream>;
@@ -110,6 +110,27 @@ class StormClient {
110
110
  history,
111
111
  });
112
112
  }
113
+ async voteUIPage(topic, conversationId, vote, mainConversationId) {
114
+ const options = await this.createOptions('/v2/ui/vote', 'POST', {
115
+ prompt: JSON.stringify({ topic, vote, mainConversationId }),
116
+ conversationId,
117
+ });
118
+ return fetch(options.url, {
119
+ method: options.method,
120
+ headers: options.headers,
121
+ });
122
+ }
123
+ async getVoteUIPage(topic, conversationId, mainConversationId) {
124
+ const options = await this.createOptions('/v2/ui/get-vote', 'POST', {
125
+ prompt: JSON.stringify({ topic, mainConversationId }),
126
+ conversationId,
127
+ });
128
+ const response = await fetch(options.url, {
129
+ method: options.method,
130
+ headers: options.headers,
131
+ });
132
+ return response.json();
133
+ }
113
134
  classifyUIReferences(prompt, conversationId) {
114
135
  return this.send('/v2/ui/references', {
115
136
  prompt: prompt,
@@ -321,7 +321,9 @@ router.post('/ui/edit', async (req, res) => {
321
321
  })
322
322
  .filter((page) => !!page);
323
323
  const editStream = await stormClient_1.stormClient.editPages({
324
- ...aiRequest.prompt,
324
+ prompt: aiRequest.prompt.prompt.prompt,
325
+ blockDescription: aiRequest.prompt.blockDescription,
326
+ planDescription: aiRequest.prompt.planDescription,
325
327
  pages,
326
328
  }, conversationId);
327
329
  onRequestAborted(req, res, () => {
@@ -358,6 +360,18 @@ router.post('/ui/edit', async (req, res) => {
358
360
  }
359
361
  }
360
362
  });
363
+ router.post('/ui/vote', async (req, res) => {
364
+ const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()] || '';
365
+ const aiRequest = JSON.parse(req.stringBody ?? '{}');
366
+ const { topic, vote, mainConversationId } = aiRequest;
367
+ return stormClient_1.stormClient.voteUIPage(topic, conversationId, vote, mainConversationId);
368
+ });
369
+ router.post('/ui/get-vote', async (req, res) => {
370
+ const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()] || '';
371
+ const aiRequest = JSON.parse(req.stringBody ?? '{}');
372
+ const { topic, mainConversationId } = aiRequest;
373
+ return stormClient_1.stormClient.getVoteUIPage(topic, conversationId, mainConversationId);
374
+ });
361
375
  router.post('/:handle/all', async (req, res) => {
362
376
  const handle = req.params.handle;
363
377
  try {
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { ConversationItem, StormFileImplementationPrompt, StormStream, StormUIImplementationPrompt, StormUIListPrompt } from './stream';
2
3
  import { Page, StormEventPageUrl } from './events';
3
4
  export declare const STORM_ID = "storm";
@@ -36,7 +37,16 @@ export interface UIPageEditRequest {
36
37
  planDescription: string;
37
38
  blockDescription: string;
38
39
  pages: StormEventPageUrl['payload'][];
39
- prompt: string;
40
+ prompt: BasePromptRequest;
41
+ }
42
+ export interface UIPageVoteRequest {
43
+ topic: string;
44
+ vote: -1 | 0 | 1;
45
+ mainConversationId: string;
46
+ }
47
+ export interface UIPageGetVoteRequest {
48
+ topic: string;
49
+ mainConversationId: string;
40
50
  }
41
51
  export interface BasePromptRequest {
42
52
  prompt: string;
@@ -53,6 +63,10 @@ declare class StormClient {
53
63
  createUIShells(prompt: UIShellsPrompt, conversationId?: string): Promise<StormStream>;
54
64
  createUILandingPages(prompt: BasePromptRequest, conversationId?: string): Promise<StormStream>;
55
65
  createUIPage(prompt: UIPagePrompt, conversationId?: string, history?: ConversationItem[]): Promise<StormStream>;
66
+ voteUIPage(topic: string, conversationId: string, vote: -1 | 0 | 1, mainConversationId?: string): Promise<Response>;
67
+ getVoteUIPage(topic: string, conversationId: string, mainConversationId?: string): Promise<{
68
+ vote: -1 | 0 | 1;
69
+ }>;
56
70
  classifyUIReferences(prompt: string, conversationId?: string): Promise<StormStream>;
57
71
  editPages(prompt: UIPageEditPrompt, conversationId?: string): Promise<StormStream>;
58
72
  listScreens(prompt: StormUIListPrompt, conversationId?: string): Promise<StormStream>;
@@ -110,6 +110,27 @@ class StormClient {
110
110
  history,
111
111
  });
112
112
  }
113
+ async voteUIPage(topic, conversationId, vote, mainConversationId) {
114
+ const options = await this.createOptions('/v2/ui/vote', 'POST', {
115
+ prompt: JSON.stringify({ topic, vote, mainConversationId }),
116
+ conversationId,
117
+ });
118
+ return fetch(options.url, {
119
+ method: options.method,
120
+ headers: options.headers,
121
+ });
122
+ }
123
+ async getVoteUIPage(topic, conversationId, mainConversationId) {
124
+ const options = await this.createOptions('/v2/ui/get-vote', 'POST', {
125
+ prompt: JSON.stringify({ topic, mainConversationId }),
126
+ conversationId,
127
+ });
128
+ const response = await fetch(options.url, {
129
+ method: options.method,
130
+ headers: options.headers,
131
+ });
132
+ return response.json();
133
+ }
113
134
  classifyUIReferences(prompt, conversationId) {
114
135
  return this.send('/v2/ui/references', {
115
136
  prompt: prompt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.64.2",
3
+ "version": "0.65.0",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -20,6 +20,8 @@ import {
20
20
  UIPageEditPrompt,
21
21
  UIPageEditRequest,
22
22
  BasePromptRequest,
23
+ UIPageVoteRequest,
24
+ UIPageGetVoteRequest,
23
25
  } from './stormClient';
24
26
  import { Page, StormEvent, StormEventPage, StormEventPhaseType, UserJourneyScreen } from './events';
25
27
 
@@ -405,7 +407,9 @@ router.post('/ui/edit', async (req: KapetaBodyRequest, res: Response) => {
405
407
 
406
408
  const editStream = await stormClient.editPages(
407
409
  {
408
- ...aiRequest.prompt,
410
+ prompt: aiRequest.prompt.prompt.prompt,
411
+ blockDescription: aiRequest.prompt.blockDescription,
412
+ planDescription: aiRequest.prompt.planDescription,
409
413
  pages,
410
414
  },
411
415
  conversationId
@@ -447,6 +451,20 @@ router.post('/ui/edit', async (req: KapetaBodyRequest, res: Response) => {
447
451
  }
448
452
  });
449
453
 
454
+ router.post('/ui/vote', async (req: KapetaBodyRequest, res: Response) => {
455
+ const conversationId = (req.headers[ConversationIdHeader.toLowerCase()] as string | undefined) || '';
456
+ const aiRequest: UIPageVoteRequest = JSON.parse(req.stringBody ?? '{}');
457
+ const { topic, vote, mainConversationId } = aiRequest;
458
+ return stormClient.voteUIPage(topic, conversationId, vote, mainConversationId);
459
+ });
460
+
461
+ router.post('/ui/get-vote', async (req: KapetaBodyRequest, res: Response) => {
462
+ const conversationId = (req.headers[ConversationIdHeader.toLowerCase()] as string | undefined) || '';
463
+ const aiRequest: UIPageGetVoteRequest = JSON.parse(req.stringBody ?? '{}');
464
+ const { topic, mainConversationId } = aiRequest;
465
+ return stormClient.getVoteUIPage(topic, conversationId, mainConversationId);
466
+ });
467
+
450
468
  router.post('/:handle/all', async (req: KapetaBodyRequest, res: Response) => {
451
469
  const handle = req.params.handle as string;
452
470
 
@@ -59,7 +59,18 @@ export interface UIPageEditRequest {
59
59
  planDescription: string;
60
60
  blockDescription: string;
61
61
  pages: StormEventPageUrl['payload'][];
62
- prompt: string;
62
+ prompt: BasePromptRequest;
63
+ }
64
+
65
+ export interface UIPageVoteRequest {
66
+ topic: string;
67
+ vote: -1 | 0 | 1;
68
+ mainConversationId: string;
69
+ }
70
+
71
+ export interface UIPageGetVoteRequest {
72
+ topic: string;
73
+ mainConversationId: string;
63
74
  }
64
75
 
65
76
  export interface BasePromptRequest {
@@ -195,6 +206,32 @@ class StormClient {
195
206
  });
196
207
  }
197
208
 
209
+ public async voteUIPage(topic: string, conversationId: string, vote: -1 | 0 | 1, mainConversationId?: string) {
210
+ const options = await this.createOptions('/v2/ui/vote', 'POST', {
211
+ prompt: JSON.stringify({ topic, vote, mainConversationId }),
212
+ conversationId,
213
+ });
214
+
215
+ return fetch(options.url, {
216
+ method: options.method,
217
+ headers: options.headers,
218
+ });
219
+ }
220
+
221
+ public async getVoteUIPage(topic: string, conversationId: string, mainConversationId?: string) {
222
+ const options = await this.createOptions('/v2/ui/get-vote', 'POST', {
223
+ prompt: JSON.stringify({ topic, mainConversationId }),
224
+ conversationId,
225
+ });
226
+
227
+ const response = await fetch(options.url, {
228
+ method: options.method,
229
+ headers: options.headers,
230
+ });
231
+
232
+ return response.json() as Promise<{ vote: -1 | 0 | 1 }>;
233
+ }
234
+
198
235
  public classifyUIReferences(prompt: string, conversationId?: string) {
199
236
  return this.send('/v2/ui/references', {
200
237
  prompt: prompt,