@kapeta/local-cluster-service 0.74.0 → 0.74.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 +15 -0
- package/dist/cjs/src/storm/PageGenerator.js +12 -5
- package/dist/cjs/src/storm/codegen.js +11 -7
- package/dist/cjs/src/storm/events.d.ts +2 -0
- package/dist/cjs/src/storm/routes.js +31 -14
- package/dist/cjs/src/storm/stormClient.d.ts +4 -4
- package/dist/cjs/src/storm/stormClient.js +13 -3
- package/dist/cjs/src/storm/stream.d.ts +2 -0
- package/dist/cjs/src/stormService.d.ts +2 -2
- package/dist/cjs/src/stormService.js +8 -6
- package/dist/esm/src/storm/PageGenerator.js +12 -5
- package/dist/esm/src/storm/codegen.js +11 -7
- package/dist/esm/src/storm/events.d.ts +2 -0
- package/dist/esm/src/storm/routes.js +31 -14
- package/dist/esm/src/storm/stormClient.d.ts +4 -4
- package/dist/esm/src/storm/stormClient.js +13 -3
- package/dist/esm/src/storm/stream.d.ts +2 -0
- package/dist/esm/src/stormService.d.ts +2 -2
- package/dist/esm/src/stormService.js +8 -6
- package/package.json +1 -1
- package/src/storm/PageGenerator.ts +18 -8
- package/src/storm/codegen.ts +5 -2
- package/src/storm/events.ts +2 -0
- package/src/storm/routes.ts +42 -22
- package/src/storm/stormClient.ts +12 -7
- package/src/storm/stream.ts +2 -0
- package/src/stormService.ts +9 -7
package/src/storm/stormClient.ts
CHANGED
@@ -24,6 +24,7 @@ const fetchWithRetries = createFetch(global.fetch, { retries: 5, retryDelay: 10
|
|
24
24
|
export const STORM_ID = 'storm';
|
25
25
|
|
26
26
|
export const ConversationIdHeader = 'Conversation-Id';
|
27
|
+
export const SystemIdHeader = 'System-Id';
|
27
28
|
|
28
29
|
export interface UIShellsPrompt {
|
29
30
|
theme?: string;
|
@@ -85,11 +86,12 @@ export interface BasePromptRequest {
|
|
85
86
|
skipImprovement?: boolean;
|
86
87
|
}
|
87
88
|
|
88
|
-
class StormClient {
|
89
|
+
export class StormClient {
|
89
90
|
private readonly _baseUrl: string;
|
90
|
-
|
91
|
-
constructor() {
|
91
|
+
private readonly _systemId: string;
|
92
|
+
constructor(systemId?: string) {
|
92
93
|
this._baseUrl = getRemoteUrl('ai-service', 'https://ai.kapeta.com');
|
94
|
+
this._systemId = systemId || "";
|
93
95
|
}
|
94
96
|
|
95
97
|
private async createOptions(
|
@@ -110,7 +112,9 @@ class StormClient {
|
|
110
112
|
if (body.conversationId) {
|
111
113
|
headers[ConversationIdHeader] = body.conversationId;
|
112
114
|
}
|
113
|
-
|
115
|
+
if (this._systemId) {
|
116
|
+
headers[SystemIdHeader] = this._systemId
|
117
|
+
}
|
114
118
|
return {
|
115
119
|
url,
|
116
120
|
method: method,
|
@@ -130,7 +134,6 @@ class StormClient {
|
|
130
134
|
prompt: stringPrompt,
|
131
135
|
conversationId: body.conversationId,
|
132
136
|
});
|
133
|
-
|
134
137
|
const abort = new AbortController();
|
135
138
|
options.signal = abort.signal;
|
136
139
|
|
@@ -202,6 +205,7 @@ class StormClient {
|
|
202
205
|
public createUIShells(prompt: UIShellsPrompt, conversationId?: string) {
|
203
206
|
return this.send('/v2/ui/shells', {
|
204
207
|
prompt: JSON.stringify(prompt),
|
208
|
+
conversationId: conversationId,
|
205
209
|
});
|
206
210
|
}
|
207
211
|
|
@@ -245,6 +249,9 @@ class StormClient {
|
|
245
249
|
const response = await fetch(u, {
|
246
250
|
method: 'POST',
|
247
251
|
body: JSON.stringify(prompt.pages),
|
252
|
+
headers: {
|
253
|
+
'systemId': prompt.systemId,
|
254
|
+
},
|
248
255
|
});
|
249
256
|
return (await response.json()) as HTMLPage[];
|
250
257
|
}
|
@@ -377,5 +384,3 @@ class StormClient {
|
|
377
384
|
return response;
|
378
385
|
}
|
379
386
|
}
|
380
|
-
|
381
|
-
export const stormClient = new StormClient();
|
package/src/storm/stream.ts
CHANGED
@@ -99,6 +99,7 @@ export interface ConversationItem {
|
|
99
99
|
|
100
100
|
export interface StormContextRequest<T = string> {
|
101
101
|
conversationId?: string;
|
102
|
+
systemId?: string;
|
102
103
|
history?: ConversationItem[];
|
103
104
|
prompt: T;
|
104
105
|
}
|
@@ -150,6 +151,7 @@ export enum HTMLPageEncoding {
|
|
150
151
|
|
151
152
|
export interface ImplementAPIClients {
|
152
153
|
pages: HTMLPage[];
|
154
|
+
systemId: string;
|
153
155
|
}
|
154
156
|
|
155
157
|
export interface HTMLPage {
|
package/src/stormService.ts
CHANGED
@@ -5,7 +5,7 @@ import path from 'path';
|
|
5
5
|
import { existsSync } from 'fs';
|
6
6
|
import { StormEvent, StormEventModelResponse, StormEventPromptImprove, StormEventUIShell } from './storm/events';
|
7
7
|
import * as tar from 'tar';
|
8
|
-
import {
|
8
|
+
import { StormClient } from './storm/stormClient';
|
9
9
|
|
10
10
|
export class StormService {
|
11
11
|
private getConversationFile(conversationId: string) {
|
@@ -118,8 +118,8 @@ export class StormService {
|
|
118
118
|
}
|
119
119
|
}
|
120
120
|
|
121
|
-
async uploadConversation(handle: string,
|
122
|
-
const tarballFile = this.getConversationTarball(
|
121
|
+
async uploadConversation(handle: string, systemId: string) {
|
122
|
+
const tarballFile = this.getConversationTarball(systemId);
|
123
123
|
const destDir = path.dirname(tarballFile);
|
124
124
|
const tarballName = path.basename(tarballFile);
|
125
125
|
await tar.create(
|
@@ -131,13 +131,15 @@ export class StormService {
|
|
131
131
|
},
|
132
132
|
['.']
|
133
133
|
);
|
134
|
-
|
134
|
+
const stormClient = new StormClient(systemId);
|
135
|
+
await stormClient.uploadSystem(handle, systemId, await fs.readFile(tarballFile));
|
135
136
|
}
|
136
137
|
|
137
|
-
async installProjectById(handle: string,
|
138
|
-
const tarballFile = this.getConversationTarball(
|
138
|
+
async installProjectById(handle: string, systemId: string) {
|
139
|
+
const tarballFile = this.getConversationTarball(systemId);
|
139
140
|
const destDir = path.dirname(tarballFile);
|
140
|
-
const
|
141
|
+
const stormClient = new StormClient(systemId);
|
142
|
+
const buffer = await stormClient.downloadSystem(handle, systemId);
|
141
143
|
await fs.mkdir(destDir, { recursive: true });
|
142
144
|
await fs.writeFile(tarballFile, buffer);
|
143
145
|
await tar.extract({
|