donobu 2.3.0 → 2.4.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/README.md +14 -0
- package/dist/apis/SpecialFlowsApi.d.ts +7 -1
- package/dist/apis/SpecialFlowsApi.js +41 -29
- package/dist/apis/SpecialFlowsApi.js.map +1 -1
- package/dist/apis/ToolsApi.d.ts +1 -1
- package/dist/apis/ToolsApi.js +1 -1
- package/dist/apis/ToolsApi.js.map +1 -1
- package/dist/assets/control-panel.js +3 -3
- package/dist/assets/generated/parameter-schemas.json +4 -4
- package/dist/assets/generated/version +1 -1
- package/dist/clients/AnthropicAwsBedrockGptClient.js +1 -1
- package/dist/clients/AnthropicAwsBedrockGptClient.js.map +1 -1
- package/dist/clients/AnthropicGptClient.js +1 -1
- package/dist/clients/AnthropicGptClient.js.map +1 -1
- package/dist/clients/GoogleGptClient.js +3 -3
- package/dist/clients/GoogleGptClient.js.map +1 -1
- package/dist/clients/GptClient.d.ts +1 -1
- package/dist/clients/OpenAiGptClient.js +1 -1
- package/dist/clients/OpenAiGptClient.js.map +1 -1
- package/dist/clients/VercelAiGptClient.js +1 -1
- package/dist/clients/VercelAiGptClient.js.map +1 -1
- package/dist/esm/apis/SpecialFlowsApi.d.ts +7 -1
- package/dist/esm/apis/SpecialFlowsApi.js +41 -29
- package/dist/esm/apis/SpecialFlowsApi.js.map +1 -1
- package/dist/esm/apis/ToolsApi.d.ts +1 -1
- package/dist/esm/apis/ToolsApi.js +1 -1
- package/dist/esm/apis/ToolsApi.js.map +1 -1
- package/dist/esm/assets/control-panel.js +3 -3
- package/dist/esm/assets/generated/parameter-schemas.json +4 -4
- package/dist/esm/assets/generated/version +1 -1
- package/dist/esm/clients/AnthropicAwsBedrockGptClient.js +1 -1
- package/dist/esm/clients/AnthropicAwsBedrockGptClient.js.map +1 -1
- package/dist/esm/clients/AnthropicGptClient.js +1 -1
- package/dist/esm/clients/AnthropicGptClient.js.map +1 -1
- package/dist/esm/clients/GoogleGptClient.js +3 -3
- package/dist/esm/clients/GoogleGptClient.js.map +1 -1
- package/dist/esm/clients/GptClient.d.ts +1 -1
- package/dist/esm/clients/OpenAiGptClient.js +1 -1
- package/dist/esm/clients/OpenAiGptClient.js.map +1 -1
- package/dist/esm/clients/VercelAiGptClient.js +1 -1
- package/dist/esm/clients/VercelAiGptClient.js.map +1 -1
- package/dist/esm/main.d.ts +6 -6
- package/dist/esm/main.js +50 -39
- package/dist/esm/main.js.map +1 -1
- package/dist/esm/managers/AdminApiController.js +12 -25
- package/dist/esm/managers/AdminApiController.js.map +1 -1
- package/dist/esm/managers/CodeGenerator.d.ts +8 -0
- package/dist/esm/managers/CodeGenerator.js +25 -9
- package/dist/esm/managers/CodeGenerator.js.map +1 -1
- package/dist/esm/managers/DonobuFlow.js +4 -2
- package/dist/esm/managers/DonobuFlow.js.map +1 -1
- package/dist/esm/managers/DonobuFlowsManager.js +16 -7
- package/dist/esm/managers/DonobuFlowsManager.js.map +1 -1
- package/dist/esm/managers/DonobuMcpServer.d.ts +24 -0
- package/dist/esm/managers/DonobuMcpServer.js +146 -0
- package/dist/esm/managers/DonobuMcpServer.js.map +1 -0
- package/dist/esm/managers/DonobuStack.d.ts +19 -0
- package/dist/esm/managers/DonobuStack.js +29 -0
- package/dist/esm/managers/DonobuStack.js.map +1 -0
- package/dist/esm/managers/ToolManager.d.ts +1 -2
- package/dist/esm/managers/ToolManager.js +14 -14
- package/dist/esm/managers/ToolManager.js.map +1 -1
- package/dist/esm/models/BrowserFramework.d.ts +8 -15
- package/dist/esm/models/BrowserFramework.js +74 -96
- package/dist/esm/models/BrowserFramework.js.map +1 -1
- package/dist/esm/models/CustomTool.d.ts +1 -1
- package/dist/esm/persistence/DonobuSqliteDb.js +3 -2
- package/dist/esm/persistence/DonobuSqliteDb.js.map +1 -1
- package/dist/esm/test.d.ts +2 -15
- package/dist/esm/test.js +37 -54
- package/dist/esm/test.js.map +1 -1
- package/dist/esm/tools/CustomToolRunnerTool.js +5 -5
- package/dist/esm/tools/CustomToolRunnerTool.js.map +1 -1
- package/dist/esm/tools/GoToGoogleMapsStreetViewTool.js +9 -11
- package/dist/esm/tools/GoToGoogleMapsStreetViewTool.js.map +1 -1
- package/dist/esm/tools/Tool.d.ts +2 -2
- package/dist/esm/tools/Tool.js +4 -4
- package/dist/esm/tools/Tool.js.map +1 -1
- package/dist/esm/utils/PlaywrightUtils.js +0 -2
- package/dist/esm/utils/PlaywrightUtils.js.map +1 -1
- package/dist/main.d.ts +6 -6
- package/dist/main.js +50 -39
- package/dist/main.js.map +1 -1
- package/dist/managers/AdminApiController.js +12 -25
- package/dist/managers/AdminApiController.js.map +1 -1
- package/dist/managers/CodeGenerator.d.ts +8 -0
- package/dist/managers/CodeGenerator.js +25 -9
- package/dist/managers/CodeGenerator.js.map +1 -1
- package/dist/managers/DonobuFlow.js +4 -2
- package/dist/managers/DonobuFlow.js.map +1 -1
- package/dist/managers/DonobuFlowsManager.js +16 -7
- package/dist/managers/DonobuFlowsManager.js.map +1 -1
- package/dist/managers/DonobuMcpServer.d.ts +24 -0
- package/dist/managers/DonobuMcpServer.js +146 -0
- package/dist/managers/DonobuMcpServer.js.map +1 -0
- package/dist/managers/DonobuStack.d.ts +19 -0
- package/dist/managers/DonobuStack.js +29 -0
- package/dist/managers/DonobuStack.js.map +1 -0
- package/dist/managers/ToolManager.d.ts +1 -2
- package/dist/managers/ToolManager.js +14 -14
- package/dist/managers/ToolManager.js.map +1 -1
- package/dist/models/BrowserFramework.d.ts +8 -15
- package/dist/models/BrowserFramework.js +74 -96
- package/dist/models/BrowserFramework.js.map +1 -1
- package/dist/models/CustomTool.d.ts +1 -1
- package/dist/persistence/DonobuSqliteDb.js +3 -2
- package/dist/persistence/DonobuSqliteDb.js.map +1 -1
- package/dist/test.d.ts +2 -15
- package/dist/test.js +37 -54
- package/dist/test.js.map +1 -1
- package/dist/tools/CustomToolRunnerTool.js +5 -5
- package/dist/tools/CustomToolRunnerTool.js.map +1 -1
- package/dist/tools/GoToGoogleMapsStreetViewTool.js +9 -11
- package/dist/tools/GoToGoogleMapsStreetViewTool.js.map +1 -1
- package/dist/tools/Tool.d.ts +2 -2
- package/dist/tools/Tool.js +4 -4
- package/dist/tools/Tool.js.map +1 -1
- package/dist/utils/PlaywrightUtils.js +0 -2
- package/dist/utils/PlaywrightUtils.js.map +1 -1
- package/package.json +1 -1
- package/dist/apis/GptResourcesApi.d.ts +0 -20
- package/dist/apis/GptResourcesApi.js +0 -53
- package/dist/apis/GptResourcesApi.js.map +0 -1
- package/dist/apis/KeysApi.d.ts +0 -25
- package/dist/apis/KeysApi.js +0 -64
- package/dist/apis/KeysApi.js.map +0 -1
- package/dist/assets/Donobu.entitlements.plist +0 -28
- package/dist/clients/GoogleGptClient2.d.ts +0 -18
- package/dist/clients/GoogleGptClient2.js +0 -237
- package/dist/clients/GoogleGptClient2.js.map +0 -1
- package/dist/donobu.fixtures.d.ts +0 -57
- package/dist/donobu.fixtures.js +0 -167
- package/dist/donobu.fixtures.js.map +0 -1
- package/dist/esm/apis/GptResourcesApi.d.ts +0 -20
- package/dist/esm/apis/GptResourcesApi.js +0 -53
- package/dist/esm/apis/GptResourcesApi.js.map +0 -1
- package/dist/esm/apis/KeysApi.d.ts +0 -25
- package/dist/esm/apis/KeysApi.js +0 -64
- package/dist/esm/apis/KeysApi.js.map +0 -1
- package/dist/esm/assets/Donobu.entitlements.plist +0 -28
- package/dist/esm/donobu.fixtures.d.ts +0 -57
- package/dist/esm/donobu.fixtures.js +0 -167
- package/dist/esm/donobu.fixtures.js.map +0 -1
- package/dist/esm/exceptions/GptResourceNotFoundException.d.ts +0 -8
- package/dist/esm/exceptions/GptResourceNotFoundException.js +0 -16
- package/dist/esm/exceptions/GptResourceNotFoundException.js.map +0 -1
- package/dist/esm/managers/FlowsPersistence.d.ts +0 -79
- package/dist/esm/managers/FlowsPersistence.js +0 -3
- package/dist/esm/managers/FlowsPersistence.js.map +0 -1
- package/dist/esm/managers/FlowsPersistenceAwsS3.d.ts +0 -48
- package/dist/esm/managers/FlowsPersistenceAwsS3.js +0 -284
- package/dist/esm/managers/FlowsPersistenceAwsS3.js.map +0 -1
- package/dist/esm/managers/FlowsPersistenceFactory.d.ts +0 -9
- package/dist/esm/managers/FlowsPersistenceFactory.js +0 -3
- package/dist/esm/managers/FlowsPersistenceFactory.js.map +0 -1
- package/dist/esm/managers/FlowsPersistenceFactoryImpl.d.ts +0 -57
- package/dist/esm/managers/FlowsPersistenceFactoryImpl.js +0 -119
- package/dist/esm/managers/FlowsPersistenceFactoryImpl.js.map +0 -1
- package/dist/esm/managers/FlowsPersistenceFactoryPreset.d.ts +0 -12
- package/dist/esm/managers/FlowsPersistenceFactoryPreset.js +0 -25
- package/dist/esm/managers/FlowsPersistenceFactoryPreset.js.map +0 -1
- package/dist/esm/managers/FlowsPersistenceFilesystem.d.ts +0 -33
- package/dist/esm/managers/FlowsPersistenceFilesystem.js +0 -180
- package/dist/esm/managers/FlowsPersistenceFilesystem.js.map +0 -1
- package/dist/esm/managers/FlowsPersistenceGoogleCloudStorage.d.ts +0 -40
- package/dist/esm/managers/FlowsPersistenceGoogleCloudStorage.js +0 -209
- package/dist/esm/managers/FlowsPersistenceGoogleCloudStorage.js.map +0 -1
- package/dist/esm/managers/FlowsPersistenceSupabase.d.ts +0 -33
- package/dist/esm/managers/FlowsPersistenceSupabase.js +0 -152
- package/dist/esm/managers/FlowsPersistenceSupabase.js.map +0 -1
- package/dist/esm/managers/FlowsPersistenceVolatile.d.ts +0 -30
- package/dist/esm/managers/FlowsPersistenceVolatile.js +0 -103
- package/dist/esm/managers/FlowsPersistenceVolatile.js.map +0 -1
- package/dist/esm/managers/GptPlatformApiKeysManager.d.ts +0 -36
- package/dist/esm/managers/GptPlatformApiKeysManager.js +0 -3
- package/dist/esm/managers/GptPlatformApiKeysManager.js.map +0 -1
- package/dist/esm/managers/GptPlatformApiKeysManagerFilesystem.d.ts +0 -29
- package/dist/esm/managers/GptPlatformApiKeysManagerFilesystem.js +0 -136
- package/dist/esm/managers/GptPlatformApiKeysManagerFilesystem.js.map +0 -1
- package/dist/esm/managers/GptPlatformApiKeysManagerVolatile.d.ts +0 -35
- package/dist/esm/managers/GptPlatformApiKeysManagerVolatile.js +0 -51
- package/dist/esm/managers/GptPlatformApiKeysManagerVolatile.js.map +0 -1
- package/dist/esm/managers/GptResourcesManager.d.ts +0 -39
- package/dist/esm/managers/GptResourcesManager.js +0 -130
- package/dist/esm/managers/GptResourcesManager.js.map +0 -1
- package/dist/esm/managers/SelectorGenerator.d.ts +0 -8
- package/dist/esm/managers/SelectorGenerator.js +0 -15
- package/dist/esm/managers/SelectorGenerator.js.map +0 -1
- package/dist/esm/models/ElementSelectorForReplay.d.ts +0 -14
- package/dist/esm/models/ElementSelectorForReplay.js +0 -3
- package/dist/esm/models/ElementSelectorForReplay.js.map +0 -1
- package/dist/esm/models/GptResource.d.ts +0 -33
- package/dist/esm/models/GptResource.js +0 -3
- package/dist/esm/models/GptResource.js.map +0 -1
- package/dist/esm/persistence/AgentsPersistenceFilesystem.d.ts +0 -15
- package/dist/esm/persistence/AgentsPersistenceFilesystem.js +0 -48
- package/dist/esm/persistence/AgentsPersistenceFilesystem.js.map +0 -1
- package/dist/esm/persistence/GptConfigsPersistenceFilesystem.d.ts +0 -16
- package/dist/esm/persistence/GptConfigsPersistenceFilesystem.js +0 -54
- package/dist/esm/persistence/GptConfigsPersistenceFilesystem.js.map +0 -1
- package/dist/esm/persistence/GptResourcesPersistence.d.ts +0 -11
- package/dist/esm/persistence/GptResourcesPersistence.js +0 -3
- package/dist/esm/persistence/GptResourcesPersistence.js.map +0 -1
- package/dist/esm/persistence/GptResourcesPersistenceFilesystem.d.ts +0 -20
- package/dist/esm/persistence/GptResourcesPersistenceFilesystem.js +0 -79
- package/dist/esm/persistence/GptResourcesPersistenceFilesystem.js.map +0 -1
- package/dist/esm/persistence/GptResourcesPersistenceVolatile.d.ts +0 -14
- package/dist/esm/persistence/GptResourcesPersistenceVolatile.js +0 -32
- package/dist/esm/persistence/GptResourcesPersistenceVolatile.js.map +0 -1
- package/dist/esm/testfixtures.d.ts +0 -66
- package/dist/esm/testfixtures.js +0 -288
- package/dist/esm/testfixtures.js.map +0 -1
- package/dist/esm/tools/AssertTextVisibility.d.ts +0 -19
- package/dist/esm/tools/AssertTextVisibility.js +0 -32
- package/dist/esm/tools/AssertTextVisibility.js.map +0 -1
- package/dist/esm/tools/ClickButtonTool.d.ts +0 -14
- package/dist/esm/tools/ClickButtonTool.js +0 -36
- package/dist/esm/tools/ClickButtonTool.js.map +0 -1
- package/dist/esm/tools/NavigateToWebpageTool.d.ts +0 -20
- package/dist/esm/tools/NavigateToWebpageTool.js +0 -40
- package/dist/esm/tools/NavigateToWebpageTool.js.map +0 -1
- package/dist/esm/utils/DirectoryUtils.d.ts +0 -11
- package/dist/esm/utils/DirectoryUtils.js +0 -37
- package/dist/esm/utils/DirectoryUtils.js.map +0 -1
- package/dist/exceptions/GptResourceNotFoundException.d.ts +0 -8
- package/dist/exceptions/GptResourceNotFoundException.js +0 -16
- package/dist/exceptions/GptResourceNotFoundException.js.map +0 -1
- package/dist/managers/FlowsPersistence.d.ts +0 -79
- package/dist/managers/FlowsPersistence.js +0 -3
- package/dist/managers/FlowsPersistence.js.map +0 -1
- package/dist/managers/FlowsPersistenceAwsS3.d.ts +0 -48
- package/dist/managers/FlowsPersistenceAwsS3.js +0 -284
- package/dist/managers/FlowsPersistenceAwsS3.js.map +0 -1
- package/dist/managers/FlowsPersistenceFactory.d.ts +0 -9
- package/dist/managers/FlowsPersistenceFactory.js +0 -3
- package/dist/managers/FlowsPersistenceFactory.js.map +0 -1
- package/dist/managers/FlowsPersistenceFactoryImpl.d.ts +0 -57
- package/dist/managers/FlowsPersistenceFactoryImpl.js +0 -119
- package/dist/managers/FlowsPersistenceFactoryImpl.js.map +0 -1
- package/dist/managers/FlowsPersistenceFactoryPreset.d.ts +0 -12
- package/dist/managers/FlowsPersistenceFactoryPreset.js +0 -25
- package/dist/managers/FlowsPersistenceFactoryPreset.js.map +0 -1
- package/dist/managers/FlowsPersistenceFilesystem.d.ts +0 -33
- package/dist/managers/FlowsPersistenceFilesystem.js +0 -180
- package/dist/managers/FlowsPersistenceFilesystem.js.map +0 -1
- package/dist/managers/FlowsPersistenceGoogleCloudStorage.d.ts +0 -40
- package/dist/managers/FlowsPersistenceGoogleCloudStorage.js +0 -209
- package/dist/managers/FlowsPersistenceGoogleCloudStorage.js.map +0 -1
- package/dist/managers/FlowsPersistenceSupabase.d.ts +0 -33
- package/dist/managers/FlowsPersistenceSupabase.js +0 -152
- package/dist/managers/FlowsPersistenceSupabase.js.map +0 -1
- package/dist/managers/FlowsPersistenceVolatile.d.ts +0 -30
- package/dist/managers/FlowsPersistenceVolatile.js +0 -103
- package/dist/managers/FlowsPersistenceVolatile.js.map +0 -1
- package/dist/managers/GptPlatformApiKeysManager.d.ts +0 -36
- package/dist/managers/GptPlatformApiKeysManager.js +0 -3
- package/dist/managers/GptPlatformApiKeysManager.js.map +0 -1
- package/dist/managers/GptPlatformApiKeysManagerFilesystem.d.ts +0 -29
- package/dist/managers/GptPlatformApiKeysManagerFilesystem.js +0 -136
- package/dist/managers/GptPlatformApiKeysManagerFilesystem.js.map +0 -1
- package/dist/managers/GptPlatformApiKeysManagerVolatile.d.ts +0 -35
- package/dist/managers/GptPlatformApiKeysManagerVolatile.js +0 -51
- package/dist/managers/GptPlatformApiKeysManagerVolatile.js.map +0 -1
- package/dist/managers/GptResourcesManager.d.ts +0 -44
- package/dist/managers/GptResourcesManager.js +0 -180
- package/dist/managers/GptResourcesManager.js.map +0 -1
- package/dist/managers/SelectorGenerator.d.ts +0 -8
- package/dist/managers/SelectorGenerator.js +0 -15
- package/dist/managers/SelectorGenerator.js.map +0 -1
- package/dist/models/BaseToolParam.d.ts +0 -9
- package/dist/models/BaseToolParam.js +0 -3
- package/dist/models/BaseToolParam.js.map +0 -1
- package/dist/models/BaseToolParameters.d.ts +0 -9
- package/dist/models/BaseToolParameters.js +0 -3
- package/dist/models/BaseToolParameters.js.map +0 -1
- package/dist/models/DonobuAnnotated.d.ts +0 -23
- package/dist/models/DonobuAnnotated.js +0 -12
- package/dist/models/DonobuAnnotated.js.map +0 -1
- package/dist/models/ElementSelectorForReplay.d.ts +0 -14
- package/dist/models/ElementSelectorForReplay.js +0 -3
- package/dist/models/ElementSelectorForReplay.js.map +0 -1
- package/dist/models/GptResource.d.ts +0 -33
- package/dist/models/GptResource.js +0 -3
- package/dist/models/GptResource.js.map +0 -1
- package/dist/persistence/AgentsPersistenceFilesystem.d.ts +0 -15
- package/dist/persistence/AgentsPersistenceFilesystem.js +0 -48
- package/dist/persistence/AgentsPersistenceFilesystem.js.map +0 -1
- package/dist/persistence/GptConfigsPersistenceFilesystem.d.ts +0 -16
- package/dist/persistence/GptConfigsPersistenceFilesystem.js +0 -54
- package/dist/persistence/GptConfigsPersistenceFilesystem.js.map +0 -1
- package/dist/persistence/GptResourcesPersistence.d.ts +0 -11
- package/dist/persistence/GptResourcesPersistence.js +0 -3
- package/dist/persistence/GptResourcesPersistence.js.map +0 -1
- package/dist/persistence/GptResourcesPersistenceFilesystem.d.ts +0 -20
- package/dist/persistence/GptResourcesPersistenceFilesystem.js +0 -79
- package/dist/persistence/GptResourcesPersistenceFilesystem.js.map +0 -1
- package/dist/persistence/GptResourcesPersistenceVolatile.d.ts +0 -14
- package/dist/persistence/GptResourcesPersistenceVolatile.js +0 -32
- package/dist/persistence/GptResourcesPersistenceVolatile.js.map +0 -1
- package/dist/testfixtures.d.ts +0 -66
- package/dist/testfixtures.js +0 -288
- package/dist/testfixtures.js.map +0 -1
- package/dist/tools/AssertTextVisibility.d.ts +0 -19
- package/dist/tools/AssertTextVisibility.js +0 -32
- package/dist/tools/AssertTextVisibility.js.map +0 -1
- package/dist/tools/ClickButtonTool.d.ts +0 -14
- package/dist/tools/ClickButtonTool.js +0 -36
- package/dist/tools/ClickButtonTool.js.map +0 -1
- package/dist/tools/NavigateToWebpage.d.ts +0 -19
- package/dist/tools/NavigateToWebpage.js +0 -25
- package/dist/tools/NavigateToWebpage.js.map +0 -1
- package/dist/tools/NavigateToWebpageTool.d.ts +0 -20
- package/dist/tools/NavigateToWebpageTool.js +0 -40
- package/dist/tools/NavigateToWebpageTool.js.map +0 -1
- package/dist/utils/DirectoryUtils.d.ts +0 -11
- package/dist/utils/DirectoryUtils.js +0 -37
- package/dist/utils/DirectoryUtils.js.map +0 -1
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { FlowMetadata } from '../models/FlowMetadata';
|
|
2
|
-
import { ToolCall } from '../models/ToolCall';
|
|
3
|
-
import { VideoSegment } from '../models/VideoSegment';
|
|
4
|
-
import { FlowsPersistence } from './FlowsPersistence';
|
|
5
|
-
import { BrowserStorageState } from '../models/BrowserState';
|
|
6
|
-
/**
|
|
7
|
-
* A volatile (in-memory) implementation of FlowsPersistence.
|
|
8
|
-
*/
|
|
9
|
-
export declare class FlowsPersistenceVolatile implements FlowsPersistence {
|
|
10
|
-
private readonly flows;
|
|
11
|
-
private readonly screenshots;
|
|
12
|
-
private readonly toolCalls;
|
|
13
|
-
private readonly videos;
|
|
14
|
-
private readonly files;
|
|
15
|
-
private readonly browserStates;
|
|
16
|
-
saveMetadata(flowMetadata: FlowMetadata): Promise<void>;
|
|
17
|
-
getMetadataByFlowId(flowId: string): Promise<FlowMetadata>;
|
|
18
|
-
getMetadataByFlowName(flowName: string): Promise<FlowMetadata>;
|
|
19
|
-
savePngScreenShot(flowId: string, bytes: Buffer): Promise<string>;
|
|
20
|
-
saveToolCall(flowId: string, toolCall: ToolCall): Promise<void>;
|
|
21
|
-
getToolCalls(flowId: string): Promise<ToolCall[]>;
|
|
22
|
-
getFlows(): Promise<FlowMetadata[]>;
|
|
23
|
-
setVideo(flowId: string, bytes: Buffer): Promise<void>;
|
|
24
|
-
getVideoSegment(flowId: string, startOffset: number, length: number): Promise<VideoSegment | null>;
|
|
25
|
-
getFlowFile(flowId: string, fileId: string): Promise<Buffer | null>;
|
|
26
|
-
setFlowFile(flowId: string, fileId: string, fileBytes: Buffer): Promise<void>;
|
|
27
|
-
setBrowserState(flowId: string, browserState: BrowserStorageState): Promise<void>;
|
|
28
|
-
getBrowserState(flowId: string): Promise<BrowserStorageState | null>;
|
|
29
|
-
deleteFlow(flowId: string): Promise<void>;
|
|
30
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowsPersistenceVolatile = void 0;
|
|
4
|
-
const FlowNotFoundException_1 = require("../exceptions/FlowNotFoundException");
|
|
5
|
-
/**
|
|
6
|
-
* A volatile (in-memory) implementation of FlowsPersistence.
|
|
7
|
-
*/
|
|
8
|
-
class FlowsPersistenceVolatile {
|
|
9
|
-
flows = new Map();
|
|
10
|
-
screenshots = new Map();
|
|
11
|
-
toolCalls = new Map();
|
|
12
|
-
videos = new Map();
|
|
13
|
-
files = new Map();
|
|
14
|
-
browserStates = new Map();
|
|
15
|
-
async saveMetadata(flowMetadata) {
|
|
16
|
-
this.flows.set(flowMetadata.id, { ...flowMetadata });
|
|
17
|
-
}
|
|
18
|
-
async getMetadataByFlowId(flowId) {
|
|
19
|
-
const metadata = this.flows.get(flowId);
|
|
20
|
-
if (!metadata) {
|
|
21
|
-
throw FlowNotFoundException_1.FlowNotFoundException.forId(flowId);
|
|
22
|
-
}
|
|
23
|
-
return { ...metadata };
|
|
24
|
-
}
|
|
25
|
-
async getMetadataByFlowName(flowName) {
|
|
26
|
-
const flows = Array.from(this.flows.values()).filter((flow) => flow.name === flowName);
|
|
27
|
-
if (flows.length > 0) {
|
|
28
|
-
return { ...flows[0] };
|
|
29
|
-
}
|
|
30
|
-
throw FlowNotFoundException_1.FlowNotFoundException.forName(flowName);
|
|
31
|
-
}
|
|
32
|
-
async savePngScreenShot(flowId, bytes) {
|
|
33
|
-
if (!this.screenshots.has(flowId)) {
|
|
34
|
-
this.screenshots.set(flowId, new Map());
|
|
35
|
-
}
|
|
36
|
-
const filename = `${new Date().toISOString()}.screenshot.png`;
|
|
37
|
-
this.screenshots.get(flowId).set(filename, Buffer.from(bytes));
|
|
38
|
-
return filename;
|
|
39
|
-
}
|
|
40
|
-
async saveToolCall(flowId, toolCall) {
|
|
41
|
-
if (!this.toolCalls.has(flowId)) {
|
|
42
|
-
this.toolCalls.set(flowId, []);
|
|
43
|
-
}
|
|
44
|
-
this.toolCalls.get(flowId).push({ ...toolCall });
|
|
45
|
-
}
|
|
46
|
-
async getToolCalls(flowId) {
|
|
47
|
-
if (!this.flows.has(flowId)) {
|
|
48
|
-
throw FlowNotFoundException_1.FlowNotFoundException.forId(flowId);
|
|
49
|
-
}
|
|
50
|
-
const calls = this.toolCalls.get(flowId) || [];
|
|
51
|
-
return [...calls].sort((a, b) => a.startedAt.localeCompare(b.startedAt));
|
|
52
|
-
}
|
|
53
|
-
async getFlows() {
|
|
54
|
-
return Array.from(this.flows.values()).map((flow) => ({ ...flow }));
|
|
55
|
-
}
|
|
56
|
-
async setVideo(flowId, bytes) {
|
|
57
|
-
this.videos.set(flowId, Buffer.from(bytes));
|
|
58
|
-
}
|
|
59
|
-
async getVideoSegment(flowId, startOffset, length) {
|
|
60
|
-
const video = this.videos.get(flowId);
|
|
61
|
-
if (!video) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
const totalLength = video.length;
|
|
65
|
-
const adjustedLength = Math.min(length, totalLength - startOffset);
|
|
66
|
-
return {
|
|
67
|
-
bytes: video.slice(startOffset, startOffset + adjustedLength),
|
|
68
|
-
totalLength,
|
|
69
|
-
startOffset,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
async getFlowFile(flowId, fileId) {
|
|
73
|
-
const flowFiles = this.files.get(flowId);
|
|
74
|
-
if (!flowFiles) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
const file = flowFiles.get(fileId);
|
|
78
|
-
return file ? Buffer.from(file) : null;
|
|
79
|
-
}
|
|
80
|
-
async setFlowFile(flowId, fileId, fileBytes) {
|
|
81
|
-
if (!this.files.has(flowId)) {
|
|
82
|
-
this.files.set(flowId, new Map());
|
|
83
|
-
}
|
|
84
|
-
this.files.get(flowId).set(fileId, Buffer.from(fileBytes));
|
|
85
|
-
}
|
|
86
|
-
async setBrowserState(flowId, browserState) {
|
|
87
|
-
this.browserStates.set(flowId, { ...browserState });
|
|
88
|
-
}
|
|
89
|
-
async getBrowserState(flowId) {
|
|
90
|
-
const state = this.browserStates.get(flowId);
|
|
91
|
-
return state ? { ...state } : null;
|
|
92
|
-
}
|
|
93
|
-
async deleteFlow(flowId) {
|
|
94
|
-
this.flows.delete(flowId);
|
|
95
|
-
this.screenshots.delete(flowId);
|
|
96
|
-
this.toolCalls.delete(flowId);
|
|
97
|
-
this.videos.delete(flowId);
|
|
98
|
-
this.files.delete(flowId);
|
|
99
|
-
this.browserStates.delete(flowId);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.FlowsPersistenceVolatile = FlowsPersistenceVolatile;
|
|
103
|
-
//# sourceMappingURL=FlowsPersistenceVolatile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FlowsPersistenceVolatile.js","sourceRoot":"","sources":["../../src/managers/FlowsPersistenceVolatile.ts"],"names":[],"mappings":";;;AAIA,+EAA4E;AAG5E;;GAEG;AACH,MAAa,wBAAwB;IAClB,KAAK,GAA8B,IAAI,GAAG,EAAE,CAAC;IAC7C,WAAW,GAAqC,IAAI,GAAG,EAAE,CAAC;IAC1D,SAAS,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC/C,MAAM,GAAwB,IAAI,GAAG,EAAE,CAAC;IACxC,KAAK,GAAqC,IAAI,GAAG,EAAE,CAAC;IACpD,aAAa,GAAqC,IAAI,GAAG,EAAE,CAAC;IAEtE,KAAK,CAAC,YAAY,CAAC,YAA0B;QAClD,IAAI,CAAC,KAAK,CAAC,G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AAc,EACd,YAAiC;QAEjC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;IACtD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC1B,MAAc;QAEd,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,MAAc;QACpC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF;AArID,4DAqIC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Platform } from '../models/FlowMetadata';
|
|
2
|
-
/**
|
|
3
|
-
* Interface for setting and getting Platform-specific API keys.
|
|
4
|
-
*/
|
|
5
|
-
export interface GptPlatformApiKeysManager {
|
|
6
|
-
/**
|
|
7
|
-
* Sets the given API key with the given GPT platform.
|
|
8
|
-
*
|
|
9
|
-
* @param gptPlatform - The GPT platform to set the key for
|
|
10
|
-
* @param apiKey - The API key to set
|
|
11
|
-
* @throws {GptPlatformAuthenticationFailedException} If the API key is invalid
|
|
12
|
-
* @throws {GptPlatformNotReachableException} If the GPT platform cannot be connected to
|
|
13
|
-
* @throws {GptPlatformInternalErrorException} If there's an internal error with the GPT platform
|
|
14
|
-
*/
|
|
15
|
-
setKey(gptPlatform: Platform, apiKey: string): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Returns the API key for the given Platform in plaintext.
|
|
18
|
-
*
|
|
19
|
-
* @param gptPlatform - The GPT platform to get the key for
|
|
20
|
-
* @returns The API key in plaintext
|
|
21
|
-
* @throws {ApiKeyNotSetUpException} If no API key is set up for the platform
|
|
22
|
-
*/
|
|
23
|
-
getKey(gptPlatform: Platform): Promise<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Returns the list of platforms that have API keys available.
|
|
26
|
-
*
|
|
27
|
-
* @returns Array of platforms that have API keys set up
|
|
28
|
-
*/
|
|
29
|
-
getGptPlatformsWithKeys(): Promise<Platform[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Deletes the API key for the given platform.
|
|
32
|
-
*
|
|
33
|
-
* @param gptPlatform - The GPT platform to delete the key for
|
|
34
|
-
*/
|
|
35
|
-
deleteKey(gptPlatform: Platform): Promise<void>;
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GptPlatformApiKeysManager.js","sourceRoot":"","sources":["../../src/managers/GptPlatformApiKeysManager.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Platform } from '../models/FlowMetadata';
|
|
2
|
-
import { GptPlatformApiKeysManager } from './GptPlatformApiKeysManager';
|
|
3
|
-
/**
|
|
4
|
-
* An implementation of the GptPlatformApiKeysManager that uses the local filesystem for
|
|
5
|
-
* persistence.
|
|
6
|
-
*/
|
|
7
|
-
export declare class GptPlatformApiKeysManagerFilesystem implements GptPlatformApiKeysManager {
|
|
8
|
-
private static readonly API_KEYS_FILENAME;
|
|
9
|
-
private static readonly LEGACY_API_KEY_FILENAME_TEMPLATE;
|
|
10
|
-
private readonly apiKeysFilepath;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new instance, initializing keys using the following rules:
|
|
13
|
-
* 1. If there are API keys specified in environment variables, save those.
|
|
14
|
-
* 2. Use the given directory to persist data.
|
|
15
|
-
*
|
|
16
|
-
* @param storageDirectory - The directory to store API keys
|
|
17
|
-
*/
|
|
18
|
-
static create(storageDirectory: string): Promise<GptPlatformApiKeysManagerFilesystem>;
|
|
19
|
-
private constructor();
|
|
20
|
-
private initialize;
|
|
21
|
-
setKey(gptPlatform: Platform, apiKey: string): Promise<void>;
|
|
22
|
-
getKey(gptPlatform: Platform): Promise<string>;
|
|
23
|
-
getGptPlatformsWithKeys(): Promise<Platform[]>;
|
|
24
|
-
deleteKey(gptPlatform: Platform): Promise<void>;
|
|
25
|
-
private setKeyWithNoValidation;
|
|
26
|
-
private getGptModelToValidateKeyWith;
|
|
27
|
-
private migrateLegacyKeys;
|
|
28
|
-
private setApiKeysFromEnvironmentVariables;
|
|
29
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GptPlatformApiKeysManagerFilesystem = void 0;
|
|
7
|
-
const FlowMetadata_1 = require("../models/FlowMetadata");
|
|
8
|
-
const ApiKeyNotSetUpException_1 = require("../exceptions/ApiKeyNotSetUpException");
|
|
9
|
-
const GptClientFactory_1 = require("../clients/GptClientFactory");
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const Logger_1 = require("../utils/Logger");
|
|
13
|
-
/**
|
|
14
|
-
* An implementation of the GptPlatformApiKeysManager that uses the local filesystem for
|
|
15
|
-
* persistence.
|
|
16
|
-
*/
|
|
17
|
-
class GptPlatformApiKeysManagerFilesystem {
|
|
18
|
-
static API_KEYS_FILENAME = '.gptplatforms';
|
|
19
|
-
static LEGACY_API_KEY_FILENAME_TEMPLATE = '.%skey';
|
|
20
|
-
apiKeysFilepath;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new instance, initializing keys using the following rules:
|
|
23
|
-
* 1. If there are API keys specified in environment variables, save those.
|
|
24
|
-
* 2. Use the given directory to persist data.
|
|
25
|
-
*
|
|
26
|
-
* @param storageDirectory - The directory to store API keys
|
|
27
|
-
*/
|
|
28
|
-
static async create(storageDirectory) {
|
|
29
|
-
const instance = new GptPlatformApiKeysManagerFilesystem(storageDirectory);
|
|
30
|
-
await instance.initialize(storageDirectory);
|
|
31
|
-
return instance;
|
|
32
|
-
}
|
|
33
|
-
constructor(storageDirectory) {
|
|
34
|
-
this.apiKeysFilepath = path_1.default.join(storageDirectory, GptPlatformApiKeysManagerFilesystem.API_KEYS_FILENAME);
|
|
35
|
-
}
|
|
36
|
-
async initialize(storageDirectory) {
|
|
37
|
-
await this.migrateLegacyKeys(storageDirectory);
|
|
38
|
-
await this.setApiKeysFromEnvironmentVariables();
|
|
39
|
-
}
|
|
40
|
-
async setKey(gptPlatform, apiKey) {
|
|
41
|
-
const gptModel = this.getGptModelToValidateKeyWith(gptPlatform);
|
|
42
|
-
// Attempt to create a GPT client using the given key
|
|
43
|
-
await GptClientFactory_1.GptClientFactory.create(gptPlatform, gptModel, apiKey);
|
|
44
|
-
await this.setKeyWithNoValidation(gptPlatform, apiKey);
|
|
45
|
-
}
|
|
46
|
-
async getKey(gptPlatform) {
|
|
47
|
-
try {
|
|
48
|
-
const content = await fs_1.promises.readFile(this.apiKeysFilepath, 'utf-8');
|
|
49
|
-
const apiKeys = JSON.parse(content);
|
|
50
|
-
if (apiKeys[gptPlatform]) {
|
|
51
|
-
return apiKeys[gptPlatform];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
Logger_1.Logger.appLogger.error('Error reading API keys file', error);
|
|
56
|
-
}
|
|
57
|
-
throw new ApiKeyNotSetUpException_1.ApiKeyNotSetUpException(gptPlatform.toLowerCase());
|
|
58
|
-
}
|
|
59
|
-
async getGptPlatformsWithKeys() {
|
|
60
|
-
const platforms = Object.values(FlowMetadata_1.Platform);
|
|
61
|
-
const results = await Promise.all(platforms.map(async (platform) => {
|
|
62
|
-
try {
|
|
63
|
-
await this.getKey(platform);
|
|
64
|
-
return platform;
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
if (error instanceof ApiKeyNotSetUpException_1.ApiKeyNotSetUpException) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
}));
|
|
73
|
-
return results.filter((platform) => platform !== null);
|
|
74
|
-
}
|
|
75
|
-
async deleteKey(gptPlatform) {
|
|
76
|
-
await this.setKeyWithNoValidation(gptPlatform, null);
|
|
77
|
-
}
|
|
78
|
-
async setKeyWithNoValidation(gptPlatform, apiKey) {
|
|
79
|
-
let apiKeys = {};
|
|
80
|
-
try {
|
|
81
|
-
const content = await fs_1.promises.readFile(this.apiKeysFilepath, 'utf-8');
|
|
82
|
-
apiKeys = JSON.parse(content);
|
|
83
|
-
}
|
|
84
|
-
catch (_e) {
|
|
85
|
-
// File doesn't exist or is invalid, start with empty object
|
|
86
|
-
}
|
|
87
|
-
apiKeys[gptPlatform] = apiKey;
|
|
88
|
-
await fs_1.promises.writeFile(this.apiKeysFilepath, JSON.stringify(apiKeys));
|
|
89
|
-
}
|
|
90
|
-
getGptModelToValidateKeyWith(gptPlatform) {
|
|
91
|
-
switch (gptPlatform) {
|
|
92
|
-
case FlowMetadata_1.Platform.OPENAI:
|
|
93
|
-
return 'gpt-4o-mini';
|
|
94
|
-
case FlowMetadata_1.Platform.ANTHROPIC:
|
|
95
|
-
return 'claude-3-haiku-20240307';
|
|
96
|
-
case FlowMetadata_1.Platform.GOOGLE:
|
|
97
|
-
return 'gemini-1.5-flash';
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async migrateLegacyKeys(storageDirectory) {
|
|
101
|
-
for (const platform of Object.values(FlowMetadata_1.Platform)) {
|
|
102
|
-
const legacyPath = path_1.default.join(storageDirectory, GptPlatformApiKeysManagerFilesystem.LEGACY_API_KEY_FILENAME_TEMPLATE.replace('%s', platform.toLowerCase()));
|
|
103
|
-
try {
|
|
104
|
-
const exists = await fs_1.promises
|
|
105
|
-
.access(legacyPath)
|
|
106
|
-
.then(() => true)
|
|
107
|
-
.catch(() => false);
|
|
108
|
-
if (exists) {
|
|
109
|
-
const apiKey = await fs_1.promises.readFile(legacyPath, 'utf-8');
|
|
110
|
-
await this.setKeyWithNoValidation(platform, apiKey);
|
|
111
|
-
await fs_1.promises.unlink(legacyPath);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
Logger_1.Logger.appLogger.error(`Error migrating legacy API key file for ${platform}`, error);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async setApiKeysFromEnvironmentVariables() {
|
|
120
|
-
for (const platform of Object.values(FlowMetadata_1.Platform)) {
|
|
121
|
-
const keyName = `${platform}_KEY`;
|
|
122
|
-
const keyValue = process.env[keyName];
|
|
123
|
-
if (keyValue) {
|
|
124
|
-
try {
|
|
125
|
-
Logger_1.Logger.appLogger.info(`Setting ${platform} API key using the ${keyName} environment variable.`);
|
|
126
|
-
await this.setKeyWithNoValidation(platform, keyValue);
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
Logger_1.Logger.appLogger.error(`Failed to set API key for ${platform} using the ${keyName} environment variable.`, error);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.GptPlatformApiKeysManagerFilesystem = GptPlatformApiKeysManagerFilesystem;
|
|
136
|
-
//# sourceMappingURL=GptPlatformApiKeysManagerFilesystem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GptPlatformApiKeysManagerFilesystem.js","sourceRoot":"","sources":["../../src/managers/GptPlatformApiKeysManagerFilesyst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C;oBACtD,MAAM,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;oBACpD,MAAM,aAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,eAAM,CAAC,SAAS,CAAC,KAAK,CACpB,2CAA2C,QAAQ,EAAE,EACrD,KAAK,CACN,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,kCAAkC;QAC9C,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,uBAAQ,CAAC,EAAE,CAAC;YAC/C,MAAM,OAAO,GAAG,GAAG,QAAQ,MAAM,CAAC;YAClC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAEtC,IAAI,QAAQ,EAAE,CAAC;gBACb,IAAI,CAAC;oBACH,eAAM,CAAC,SAAS,CAAC,IAAI,CACnB,WAAW,QAAQ,sBAAsB,OAAO,wBAAwB,CACzE,CAAC;oBACF,MAAM,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;gBACxD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,eAAM,CAAC,SAAS,CAAC,KAAK,CACpB,6BAA6B,QAAQ,cAAc,OAAO,wBAAwB,EAClF,KAAK,CACN,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;;AA5JH,kFA6JC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Platform } from '../models/FlowMetadata';
|
|
2
|
-
import { GptPlatformApiKeysManager } from './GptPlatformApiKeysManager';
|
|
3
|
-
/**
|
|
4
|
-
* A volatile (in-memory) implementation of GptPlatformApiKeysManager.
|
|
5
|
-
*/
|
|
6
|
-
export declare class GptPlatformApiKeysManagerVolatile implements GptPlatformApiKeysManager {
|
|
7
|
-
private readonly apiKeys;
|
|
8
|
-
/**
|
|
9
|
-
* Sets the given API key with the given GPT platform.
|
|
10
|
-
*
|
|
11
|
-
* @param gptPlatform - The GPT platform to set the key for
|
|
12
|
-
* @param apiKey - The API key to set
|
|
13
|
-
*/
|
|
14
|
-
setKey(gptPlatform: Platform, apiKey: string): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Returns the API key for the given Platform in plaintext.
|
|
17
|
-
*
|
|
18
|
-
* @param gptPlatform - The GPT platform to get the key for
|
|
19
|
-
* @returns The API key in plaintext
|
|
20
|
-
* @throws {ApiKeyNotSetUpException} If no API key is set up for the platform
|
|
21
|
-
*/
|
|
22
|
-
getKey(gptPlatform: Platform): Promise<string>;
|
|
23
|
-
/**
|
|
24
|
-
* Returns the list of platforms that have API keys available.
|
|
25
|
-
*
|
|
26
|
-
* @returns Array of platforms that have API keys set up
|
|
27
|
-
*/
|
|
28
|
-
getGptPlatformsWithKeys(): Promise<Platform[]>;
|
|
29
|
-
/**
|
|
30
|
-
* Deletes the API key for the given platform.
|
|
31
|
-
*
|
|
32
|
-
* @param gptPlatform - The GPT platform to delete the key for
|
|
33
|
-
*/
|
|
34
|
-
deleteKey(gptPlatform: Platform): Promise<void>;
|
|
35
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GptPlatformApiKeysManagerVolatile = void 0;
|
|
4
|
-
const ApiKeyNotSetUpException_1 = require("../exceptions/ApiKeyNotSetUpException");
|
|
5
|
-
/**
|
|
6
|
-
* A volatile (in-memory) implementation of GptPlatformApiKeysManager.
|
|
7
|
-
*/
|
|
8
|
-
class GptPlatformApiKeysManagerVolatile {
|
|
9
|
-
apiKeys = new Map();
|
|
10
|
-
/**
|
|
11
|
-
* Sets the given API key with the given GPT platform.
|
|
12
|
-
*
|
|
13
|
-
* @param gptPlatform - The GPT platform to set the key for
|
|
14
|
-
* @param apiKey - The API key to set
|
|
15
|
-
*/
|
|
16
|
-
async setKey(gptPlatform, apiKey) {
|
|
17
|
-
this.apiKeys.set(gptPlatform, apiKey);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Returns the API key for the given Platform in plaintext.
|
|
21
|
-
*
|
|
22
|
-
* @param gptPlatform - The GPT platform to get the key for
|
|
23
|
-
* @returns The API key in plaintext
|
|
24
|
-
* @throws {ApiKeyNotSetUpException} If no API key is set up for the platform
|
|
25
|
-
*/
|
|
26
|
-
async getKey(gptPlatform) {
|
|
27
|
-
const apiKey = this.apiKeys.get(gptPlatform);
|
|
28
|
-
if (!apiKey) {
|
|
29
|
-
throw new ApiKeyNotSetUpException_1.ApiKeyNotSetUpException(gptPlatform);
|
|
30
|
-
}
|
|
31
|
-
return apiKey;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns the list of platforms that have API keys available.
|
|
35
|
-
*
|
|
36
|
-
* @returns Array of platforms that have API keys set up
|
|
37
|
-
*/
|
|
38
|
-
async getGptPlatformsWithKeys() {
|
|
39
|
-
return Array.from(this.apiKeys.keys());
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Deletes the API key for the given platform.
|
|
43
|
-
*
|
|
44
|
-
* @param gptPlatform - The GPT platform to delete the key for
|
|
45
|
-
*/
|
|
46
|
-
async deleteKey(gptPlatform) {
|
|
47
|
-
this.apiKeys.delete(gptPlatform);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.GptPlatformApiKeysManagerVolatile = GptPlatformApiKeysManagerVolatile;
|
|
51
|
-
//# sourceMappingURL=GptPlatformApiKeysManagerVolatile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GptPlatformApiKeysManagerVolatile.js","sourceRoot":"","sources":["../../src/managers/GptPlatformApiKeysManagerVolatile.ts"],"names":[],"mappings":";;;AAEA,mFAAgF;AAEhF;;GAEG;AACH,MAAa,iCAAiC;IAG3B,OAAO,GAA0B,IAAI,GAAG,EAAE,CAAC;IAE5D;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,WAAqB,EAAE,MAAc;QACvD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CAAC,WAAqB;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,iDAAuB,CAAC,WAAW,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,uBAAuB;QAClC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAAC,WAAqB;QAC1C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACF;AA/CD,8EA+CC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Platform } from '../models/FlowMetadata';
|
|
2
|
-
import { GptResource } from '../models/GptResource';
|
|
3
|
-
import { GptResourcesPersistence } from '../persistence/GptResourcesPersistence';
|
|
4
|
-
import { GptPlatformApiKeysManager } from './GptPlatformApiKeysManager';
|
|
5
|
-
/**
|
|
6
|
-
* This class manages GPT resources and is responsible for validation around
|
|
7
|
-
* that context.
|
|
8
|
-
*/
|
|
9
|
-
export declare class GptResourcesManager {
|
|
10
|
-
private readonly persistence;
|
|
11
|
-
private constructor();
|
|
12
|
-
static create(persistence: GptResourcesPersistence, legacyApiKeysManager?: GptPlatformApiKeysManager): Promise<GptResourcesManager>;
|
|
13
|
-
/**
|
|
14
|
-
* Attempt to save the given GPT resource. Where possible, a zero-cost
|
|
15
|
-
* request is attempted to be made with the GPT resource before saving it.
|
|
16
|
-
* If the zero-cost request is attemted and it fails, this method throws.
|
|
17
|
-
*/
|
|
18
|
-
set(name: string, resource: GptResource): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Fetch a GPT resource by name.
|
|
21
|
-
*/
|
|
22
|
-
get(name: string): Promise<GptResource>;
|
|
23
|
-
/**
|
|
24
|
-
* Fetch all GPT resources.
|
|
25
|
-
*/
|
|
26
|
-
getAll(): Promise<Map<string, GptResource>>;
|
|
27
|
-
/**
|
|
28
|
-
* Delete a GPT resource by name.
|
|
29
|
-
*/
|
|
30
|
-
delete(name: string): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Verifies the given GPT resource and name or throws if they are invalid.
|
|
33
|
-
*/
|
|
34
|
-
private verifyGptResourceOrThrow;
|
|
35
|
-
static portGptResourceFromLegacy(gptResourcesManager: GptResourcesManager, legacyApiKeysManager: GptPlatformApiKeysManager, platform: Platform | null, modelName: string | null): Promise<{
|
|
36
|
-
name: string;
|
|
37
|
-
resource: GptResource;
|
|
38
|
-
} | null>;
|
|
39
|
-
/**
|
|
40
|
-
* Ports legacy GPT platform keys to GPT resources if a corresponding GPT
|
|
41
|
-
* resource does not exist.
|
|
42
|
-
*/
|
|
43
|
-
private static portLegacyApiKeys;
|
|
44
|
-
}
|