@vertesia/client 1.1.1-dev.20260505.163000Z → 1.3.0-dev.20260620.061059Z
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 +29 -0
- package/lib/{types/AccountApi.d.ts → AccountApi.d.ts} +5 -10
- package/lib/AccountApi.d.ts.map +1 -0
- package/lib/{esm/AccountApi.js → AccountApi.js} +5 -13
- package/lib/AccountApi.js.map +1 -0
- package/lib/{types/AccountsApi.d.ts → AccountsApi.d.ts} +3 -2
- package/lib/AccountsApi.d.ts.map +1 -0
- package/lib/{esm/AccountsApi.js → AccountsApi.js} +2 -2
- package/lib/AccountsApi.js.map +1 -0
- package/lib/{types/AnalyticsApi.d.ts → AnalyticsApi.d.ts} +3 -2
- package/lib/AnalyticsApi.d.ts.map +1 -0
- package/lib/{esm/AnalyticsApi.js → AnalyticsApi.js} +5 -5
- package/lib/AnalyticsApi.js.map +1 -0
- package/lib/{types/ApiKeysApi.d.ts → ApiKeysApi.d.ts} +3 -2
- package/lib/ApiKeysApi.d.ts.map +1 -0
- package/lib/ApiKeysApi.js.map +1 -0
- package/lib/{types/AppsApi.d.ts → AppsApi.d.ts} +40 -2
- package/lib/AppsApi.d.ts.map +1 -0
- package/lib/{esm/AppsApi.js → AppsApi.js} +87 -14
- package/lib/AppsApi.js.map +1 -0
- package/lib/{types/AuditTrailApi.d.ts → AuditTrailApi.d.ts} +2 -1
- package/lib/AuditTrailApi.d.ts.map +1 -0
- package/lib/{esm/AuditTrailApi.js → AuditTrailApi.js} +1 -1
- package/lib/AuditTrailApi.js.map +1 -0
- package/lib/{types/CommandsApi.d.ts → CommandsApi.d.ts} +3 -2
- package/lib/CommandsApi.d.ts.map +1 -0
- package/lib/{esm/CommandsApi.js → CommandsApi.js} +3 -3
- package/lib/CommandsApi.js.map +1 -0
- package/lib/{types/EnvironmentsApi.d.ts → EnvironmentsApi.d.ts} +5 -4
- package/lib/EnvironmentsApi.d.ts.map +1 -0
- package/lib/{esm/EnvironmentsApi.js → EnvironmentsApi.js} +13 -13
- package/lib/EnvironmentsApi.js.map +1 -0
- package/lib/{types/GroupsApi.d.ts → GroupsApi.d.ts} +3 -2
- package/lib/GroupsApi.d.ts.map +1 -0
- package/lib/{esm/GroupsApi.js → GroupsApi.js} +8 -8
- package/lib/GroupsApi.js.map +1 -0
- package/lib/IamApi.d.ts +58 -0
- package/lib/IamApi.d.ts.map +1 -0
- package/lib/IamApi.js +76 -0
- package/lib/IamApi.js.map +1 -0
- package/lib/{types/InteractionBase.d.ts → InteractionBase.d.ts} +6 -5
- package/lib/InteractionBase.d.ts.map +1 -0
- package/lib/{esm/InteractionBase.js → InteractionBase.js} +4 -4
- package/lib/InteractionBase.js.map +1 -0
- package/lib/{types/InteractionCatalogApi.d.ts → InteractionCatalogApi.d.ts} +3 -2
- package/lib/InteractionCatalogApi.d.ts.map +1 -0
- package/lib/{esm/InteractionCatalogApi.js → InteractionCatalogApi.js} +12 -12
- package/lib/InteractionCatalogApi.js.map +1 -0
- package/lib/{types/InteractionOutput.d.ts → InteractionOutput.d.ts} +13 -12
- package/lib/InteractionOutput.d.ts.map +1 -0
- package/lib/{esm/InteractionOutput.js → InteractionOutput.js} +22 -25
- package/lib/InteractionOutput.js.map +1 -0
- package/lib/{types/InteractionResult.example.d.ts → InteractionResult.example.d.ts} +1 -0
- package/lib/InteractionResult.example.d.ts.map +1 -0
- package/lib/{esm/InteractionResult.example.js → InteractionResult.example.js} +4 -4
- package/lib/InteractionResult.example.js.map +1 -0
- package/lib/{types/InteractionsApi.d.ts → InteractionsApi.d.ts} +17 -6
- package/lib/InteractionsApi.d.ts.map +1 -0
- package/lib/{esm/InteractionsApi.js → InteractionsApi.js} +45 -28
- package/lib/InteractionsApi.js.map +1 -0
- package/lib/{types/OAuthClientsApi.d.ts → OAuthClientsApi.d.ts} +4 -2
- package/lib/OAuthClientsApi.d.ts.map +1 -0
- package/lib/{esm/OAuthClientsApi.js → OAuthClientsApi.js} +3 -0
- package/lib/OAuthClientsApi.js.map +1 -0
- package/lib/{types/OAuthGrantsApi.d.ts → OAuthGrantsApi.d.ts} +2 -1
- package/lib/OAuthGrantsApi.d.ts.map +1 -0
- package/lib/OAuthGrantsApi.js.map +1 -0
- package/lib/{types/OAuthProvidersApi.d.ts → OAuthProvidersApi.d.ts} +3 -2
- package/lib/OAuthProvidersApi.d.ts.map +1 -0
- package/lib/OAuthProvidersApi.js.map +1 -0
- package/lib/OAuthServerApi.d.ts +19 -0
- package/lib/OAuthServerApi.d.ts.map +1 -0
- package/lib/OAuthServerApi.js +48 -0
- package/lib/OAuthServerApi.js.map +1 -0
- package/lib/{types/ProjectsApi.d.ts → ProjectsApi.d.ts} +8 -5
- package/lib/ProjectsApi.d.ts.map +1 -0
- package/lib/{esm/ProjectsApi.js → ProjectsApi.js} +21 -12
- package/lib/ProjectsApi.js.map +1 -0
- package/lib/{types/PromptsApi.d.ts → PromptsApi.d.ts} +17 -9
- package/lib/PromptsApi.d.ts.map +1 -0
- package/lib/{esm/PromptsApi.js → PromptsApi.js} +16 -18
- package/lib/PromptsApi.js.map +1 -0
- package/lib/RefsApi.d.ts +7 -0
- package/lib/RefsApi.d.ts.map +1 -0
- package/lib/{esm/RefsApi.js → RefsApi.js} +2 -2
- package/lib/RefsApi.js.map +1 -0
- package/lib/{types/RemoteMcpConnectionsApi.d.ts → RemoteMcpConnectionsApi.d.ts} +3 -2
- package/lib/RemoteMcpConnectionsApi.d.ts.map +1 -0
- package/lib/{esm/RemoteMcpConnectionsApi.js → RemoteMcpConnectionsApi.js} +3 -3
- package/lib/RemoteMcpConnectionsApi.js.map +1 -0
- package/lib/{types/RunsApi.d.ts → RunsApi.d.ts} +11 -7
- package/lib/RunsApi.d.ts.map +1 -0
- package/lib/{esm/RunsApi.js → RunsApi.js} +14 -12
- package/lib/RunsApi.js.map +1 -0
- package/lib/SecretsApi.d.ts +18 -0
- package/lib/SecretsApi.d.ts.map +1 -0
- package/lib/SecretsApi.js +30 -0
- package/lib/SecretsApi.js.map +1 -0
- package/lib/{types/SkillsApi.d.ts → SkillsApi.d.ts} +3 -2
- package/lib/SkillsApi.d.ts.map +1 -0
- package/lib/{esm/SkillsApi.js → SkillsApi.js} +3 -3
- package/lib/SkillsApi.js.map +1 -0
- package/lib/{types/StreamSource.d.ts → StreamSource.d.ts} +1 -0
- package/lib/StreamSource.d.ts.map +1 -0
- package/lib/StreamSource.js.map +1 -0
- package/lib/ToolsApi.d.ts +36 -0
- package/lib/ToolsApi.d.ts.map +1 -0
- package/lib/ToolsApi.js +46 -0
- package/lib/ToolsApi.js.map +1 -0
- package/lib/{types/TrainingApi.d.ts → TrainingApi.d.ts} +7 -6
- package/lib/TrainingApi.d.ts.map +1 -0
- package/lib/TrainingApi.js +51 -0
- package/lib/TrainingApi.js.map +1 -0
- package/lib/{types/UsersApi.d.ts → UsersApi.d.ts} +3 -2
- package/lib/UsersApi.d.ts.map +1 -0
- package/lib/{esm/UsersApi.js → UsersApi.js} +3 -3
- package/lib/UsersApi.js.map +1 -0
- package/lib/{types/client.d.ts → client.d.ts} +55 -27
- package/lib/client.d.ts.map +1 -0
- package/lib/{esm/client.js → client.js} +113 -61
- package/lib/client.js.map +1 -0
- package/lib/{types/execute.d.ts → execute.d.ts} +5 -4
- package/lib/execute.d.ts.map +1 -0
- package/lib/{esm/execute.js → execute.js} +29 -11
- package/lib/execute.js.map +1 -0
- package/lib/{types/index.d.ts → index.d.ts} +9 -8
- package/lib/index.d.ts.map +1 -0
- package/lib/{esm/index.js → index.js} +4 -2
- package/lib/index.js.map +1 -0
- package/lib/{types/nodejs → nodejs}/NodeStreamSource.d.ts +3 -2
- package/lib/nodejs/NodeStreamSource.d.ts.map +1 -0
- package/lib/{esm/nodejs → nodejs}/NodeStreamSource.js +3 -3
- package/lib/nodejs/NodeStreamSource.js.map +1 -0
- package/lib/nodejs/index.d.ts +2 -0
- package/lib/nodejs/index.d.ts.map +1 -0
- package/lib/nodejs/index.js +2 -0
- package/lib/nodejs/index.js.map +1 -0
- package/lib/{types/store → store}/AgentsApi.d.ts +60 -9
- package/lib/store/AgentsApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/AgentsApi.js +174 -53
- package/lib/store/AgentsApi.js.map +1 -0
- package/lib/{types/store → store}/AnalyzeDocApi.d.ts +3 -2
- package/lib/store/AnalyzeDocApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/AnalyzeDocApi.js +10 -10
- package/lib/store/AnalyzeDocApi.js.map +1 -0
- package/lib/{types/store → store}/CollectionsApi.d.ts +6 -5
- package/lib/store/CollectionsApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/CollectionsApi.js +22 -22
- package/lib/store/CollectionsApi.js.map +1 -0
- package/lib/{types/store → store}/CostApi.d.ts +3 -2
- package/lib/store/CostApi.d.ts.map +1 -0
- package/lib/store/CostApi.js.map +1 -0
- package/lib/{types/store → store}/DashboardApi.d.ts +3 -2
- package/lib/store/DashboardApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/DashboardApi.js +7 -4
- package/lib/store/DashboardApi.js.map +1 -0
- package/lib/{types/store → store}/DataApi.d.ts +4 -3
- package/lib/store/DataApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/DataApi.js +6 -6
- package/lib/store/DataApi.js.map +1 -0
- package/lib/{types/store → store}/EmailApi.d.ts +3 -2
- package/lib/store/EmailApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/EmailApi.js +5 -5
- package/lib/store/EmailApi.js.map +1 -0
- package/lib/store/EmbeddingsApi.d.ts +13 -0
- package/lib/store/EmbeddingsApi.d.ts.map +1 -0
- package/lib/store/EmbeddingsApi.js +25 -0
- package/lib/store/EmbeddingsApi.js.map +1 -0
- package/lib/{types/store → store}/FilesApi.d.ts +22 -7
- package/lib/store/FilesApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/FilesApi.js +56 -51
- package/lib/store/FilesApi.js.map +1 -0
- package/lib/{types/store → store}/HiveMemoryApi.d.ts +3 -2
- package/lib/store/HiveMemoryApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/HiveMemoryApi.js +11 -11
- package/lib/{esm/store → store}/HiveMemoryApi.js.map +1 -1
- package/lib/{types/store → store}/IndexingApi.d.ts +16 -10
- package/lib/store/IndexingApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/IndexingApi.js +57 -45
- package/lib/store/IndexingApi.js.map +1 -0
- package/lib/{types/store → store}/ObjectsApi.d.ts +16 -11
- package/lib/store/ObjectsApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/ObjectsApi.js +46 -63
- package/lib/store/ObjectsApi.js.map +1 -0
- package/lib/{types/store → store}/PendingAsksApi.d.ts +5 -2
- package/lib/store/PendingAsksApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/PendingAsksApi.js +4 -4
- package/lib/store/PendingAsksApi.js.map +1 -0
- package/lib/store/ProcessApi.d.ts +25 -0
- package/lib/store/ProcessApi.d.ts.map +1 -0
- package/lib/store/ProcessApi.js +42 -0
- package/lib/store/ProcessApi.js.map +1 -0
- package/lib/{types/store → store}/QueryApi.d.ts +2 -1
- package/lib/store/QueryApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/QueryApi.js +3 -3
- package/lib/store/QueryApi.js.map +1 -0
- package/lib/{types/store → store}/RenderingApi.d.ts +3 -2
- package/lib/store/RenderingApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/RenderingApi.js +8 -8
- package/lib/store/RenderingApi.js.map +1 -0
- package/lib/{types/store → store}/SchedulesApi.d.ts +3 -2
- package/lib/store/SchedulesApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/SchedulesApi.js +4 -4
- package/lib/store/SchedulesApi.js.map +1 -0
- package/lib/store/TaskApi.d.ts +16 -0
- package/lib/store/TaskApi.d.ts.map +1 -0
- package/lib/store/TaskApi.js +42 -0
- package/lib/store/TaskApi.js.map +1 -0
- package/lib/{types/store → store}/ToolsApi.d.ts +3 -2
- package/lib/store/ToolsApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/ToolsApi.js +2 -2
- package/lib/store/ToolsApi.js.map +1 -0
- package/lib/{types/store → store}/TypeCatalogApi.d.ts +4 -3
- package/lib/store/TypeCatalogApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/TypeCatalogApi.js +5 -5
- package/lib/store/TypeCatalogApi.js.map +1 -0
- package/lib/{types/store → store}/TypesApi.d.ts +5 -4
- package/lib/store/TypesApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/TypesApi.js +12 -12
- package/lib/store/TypesApi.js.map +1 -0
- package/lib/{types/store → store}/WorkflowsApi.d.ts +11 -9
- package/lib/store/WorkflowsApi.d.ts.map +1 -0
- package/lib/{esm/store → store}/WorkflowsApi.js +62 -52
- package/lib/store/WorkflowsApi.js.map +1 -0
- package/lib/store/client.d.ts +62 -0
- package/lib/store/client.d.ts.map +1 -0
- package/lib/store/client.js +106 -0
- package/lib/store/client.js.map +1 -0
- package/lib/{types/store → store}/errors.d.ts +2 -1
- package/lib/store/errors.d.ts.map +1 -0
- package/lib/store/errors.js +7 -0
- package/lib/store/errors.js.map +1 -0
- package/lib/store/index.d.ts +21 -0
- package/lib/store/index.d.ts.map +1 -0
- package/lib/store/index.js +21 -0
- package/lib/store/index.js.map +1 -0
- package/lib/store/signed-url.d.ts +39 -0
- package/lib/store/signed-url.d.ts.map +1 -0
- package/lib/store/signed-url.js +153 -0
- package/lib/store/signed-url.js.map +1 -0
- package/lib/store/stream-termination.d.ts +4 -0
- package/lib/store/stream-termination.d.ts.map +1 -0
- package/lib/store/stream-termination.js +31 -0
- package/lib/store/stream-termination.js.map +1 -0
- package/lib/{types/store → store}/version.d.ts +2 -0
- package/lib/store/version.d.ts.map +1 -0
- package/lib/{esm/store → store}/version.js +1 -0
- package/lib/store/version.js.map +1 -0
- package/lib/vertesia-client.js +1 -1
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +26 -38
- package/src/AccountApi.ts +10 -22
- package/src/AccountsApi.ts +3 -9
- package/src/AnalyticsApi.ts +6 -8
- package/src/ApiKeysApi.ts +10 -2
- package/src/AppsApi.ts +131 -27
- package/src/AuditTrailApi.ts +4 -4
- package/src/CommandsApi.ts +7 -8
- package/src/EnvironmentsApi.ts +27 -23
- package/src/GroupsApi.ts +15 -10
- package/src/IamApi.ts +56 -22
- package/src/InteractionBase.ts +18 -9
- package/src/InteractionCatalogApi.ts +15 -20
- package/src/InteractionOutput.test.ts +40 -57
- package/src/InteractionOutput.ts +55 -47
- package/src/InteractionResult.example.ts +30 -18
- package/src/InteractionsApi.ts +113 -59
- package/src/OAuthClientsApi.ts +6 -1
- package/src/OAuthGrantsApi.ts +1 -1
- package/src/OAuthProvidersApi.ts +3 -4
- package/src/OAuthServerApi.ts +53 -6
- package/src/ProjectsApi.ts +70 -31
- package/src/PromptsApi.ts +44 -29
- package/src/RefsApi.ts +4 -10
- package/src/RemoteMcpConnectionsApi.ts +6 -7
- package/src/RunsApi.ts +25 -20
- package/src/SecretsApi.ts +56 -0
- package/src/SkillsApi.ts +5 -12
- package/src/StreamSource.ts +6 -1
- package/src/ToolsApi.ts +52 -0
- package/src/TrainingApi.ts +27 -25
- package/src/UsersApi.ts +6 -8
- package/src/client.test.ts +68 -2
- package/src/client.ts +160 -103
- package/src/execute.ts +60 -20
- package/src/index.ts +8 -8
- package/src/nodejs/NodeStreamSource.ts +4 -5
- package/src/nodejs/index.ts +1 -1
- package/src/store/AgentsApi.ts +308 -148
- package/src/store/AnalyzeDocApi.ts +39 -21
- package/src/store/CollectionsApi.ts +40 -38
- package/src/store/CostApi.ts +14 -19
- package/src/store/DashboardApi.ts +24 -27
- package/src/store/DataApi.ts +29 -32
- package/src/store/EmailApi.ts +6 -6
- package/src/store/EmbeddingsApi.ts +15 -15
- package/src/store/FilesApi.ts +80 -85
- package/src/store/HiveMemoryApi.ts +17 -28
- package/src/store/IndexingApi.ts +113 -76
- package/src/store/ObjectsApi.ts +100 -131
- package/src/store/PendingAsksApi.ts +7 -5
- package/src/store/ProcessApi.ts +61 -0
- package/src/store/QueryApi.ts +3 -4
- package/src/store/RenderingApi.ts +14 -17
- package/src/store/SchedulesApi.ts +6 -6
- package/src/store/TaskApi.ts +45 -0
- package/src/store/ToolsApi.ts +3 -3
- package/src/store/TypeCatalogApi.ts +56 -53
- package/src/store/TypesApi.ts +26 -18
- package/src/store/WorkflowsApi.ts +158 -152
- package/src/store/client.ts +58 -39
- package/src/store/errors.ts +3 -3
- package/src/store/index.ts +20 -18
- package/src/store/signed-url.test.ts +182 -0
- package/src/store/signed-url.ts +184 -0
- package/src/store/stream-gap.test.ts +230 -0
- package/src/store/stream-termination.test.ts +58 -0
- package/src/store/stream-termination.ts +40 -0
- package/src/store/version.ts +2 -1
- package/lib/cjs/AccountApi.js +0 -85
- package/lib/cjs/AccountApi.js.map +0 -1
- package/lib/cjs/AccountsApi.js +0 -16
- package/lib/cjs/AccountsApi.js.map +0 -1
- package/lib/cjs/AnalyticsApi.js +0 -43
- package/lib/cjs/AnalyticsApi.js.map +0 -1
- package/lib/cjs/ApiKeysApi.js +0 -61
- package/lib/cjs/ApiKeysApi.js.map +0 -1
- package/lib/cjs/AppsApi.js +0 -137
- package/lib/cjs/AppsApi.js.map +0 -1
- package/lib/cjs/AuditTrailApi.js +0 -39
- package/lib/cjs/AuditTrailApi.js.map +0 -1
- package/lib/cjs/CommandsApi.js +0 -19
- package/lib/cjs/CommandsApi.js.map +0 -1
- package/lib/cjs/EnvironmentsApi.js +0 -72
- package/lib/cjs/EnvironmentsApi.js.map +0 -1
- package/lib/cjs/GroupsApi.js +0 -86
- package/lib/cjs/GroupsApi.js.map +0 -1
- package/lib/cjs/IamApi.js +0 -53
- package/lib/cjs/IamApi.js.map +0 -1
- package/lib/cjs/InteractionBase.js +0 -44
- package/lib/cjs/InteractionBase.js.map +0 -1
- package/lib/cjs/InteractionCatalogApi.js +0 -64
- package/lib/cjs/InteractionCatalogApi.js.map +0 -1
- package/lib/cjs/InteractionOutput.js +0 -300
- package/lib/cjs/InteractionOutput.js.map +0 -1
- package/lib/cjs/InteractionResult.example.js +0 -57
- package/lib/cjs/InteractionResult.example.js.map +0 -1
- package/lib/cjs/InteractionsApi.js +0 -260
- package/lib/cjs/InteractionsApi.js.map +0 -1
- package/lib/cjs/OAuthClientsApi.js +0 -25
- package/lib/cjs/OAuthClientsApi.js.map +0 -1
- package/lib/cjs/OAuthGrantsApi.js +0 -30
- package/lib/cjs/OAuthGrantsApi.js.map +0 -1
- package/lib/cjs/OAuthProvidersApi.js +0 -43
- package/lib/cjs/OAuthProvidersApi.js.map +0 -1
- package/lib/cjs/OAuthServerApi.js +0 -22
- package/lib/cjs/OAuthServerApi.js.map +0 -1
- package/lib/cjs/ProjectsApi.js +0 -105
- package/lib/cjs/ProjectsApi.js.map +0 -1
- package/lib/cjs/PromptsApi.js +0 -135
- package/lib/cjs/PromptsApi.js.map +0 -1
- package/lib/cjs/RefsApi.js +0 -14
- package/lib/cjs/RefsApi.js.map +0 -1
- package/lib/cjs/RemoteMcpConnectionsApi.js +0 -38
- package/lib/cjs/RemoteMcpConnectionsApi.js.map +0 -1
- package/lib/cjs/RunsApi.js +0 -115
- package/lib/cjs/RunsApi.js.map +0 -1
- package/lib/cjs/SkillsApi.js +0 -39
- package/lib/cjs/SkillsApi.js.map +0 -1
- package/lib/cjs/StreamSource.js +0 -17
- package/lib/cjs/StreamSource.js.map +0 -1
- package/lib/cjs/TrainingApi.js +0 -54
- package/lib/cjs/TrainingApi.js.map +0 -1
- package/lib/cjs/UsersApi.js +0 -19
- package/lib/cjs/UsersApi.js.map +0 -1
- package/lib/cjs/client.js +0 -375
- package/lib/cjs/client.js.map +0 -1
- package/lib/cjs/execute.js +0 -160
- package/lib/cjs/execute.js.map +0 -1
- package/lib/cjs/index.js +0 -36
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/nodejs/NodeStreamSource.js +0 -45
- package/lib/cjs/nodejs/NodeStreamSource.js.map +0 -1
- package/lib/cjs/nodejs/index.js +0 -18
- package/lib/cjs/nodejs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/store/AgentsApi.js +0 -663
- package/lib/cjs/store/AgentsApi.js.map +0 -1
- package/lib/cjs/store/AnalyzeDocApi.js +0 -56
- package/lib/cjs/store/AnalyzeDocApi.js.map +0 -1
- package/lib/cjs/store/CollectionsApi.js +0 -131
- package/lib/cjs/store/CollectionsApi.js.map +0 -1
- package/lib/cjs/store/CommandsApi.js +0 -17
- package/lib/cjs/store/CommandsApi.js.map +0 -1
- package/lib/cjs/store/CostApi.js +0 -62
- package/lib/cjs/store/CostApi.js.map +0 -1
- package/lib/cjs/store/DashboardApi.js +0 -182
- package/lib/cjs/store/DashboardApi.js.map +0 -1
- package/lib/cjs/store/DataApi.js +0 -436
- package/lib/cjs/store/DataApi.js.map +0 -1
- package/lib/cjs/store/EmailApi.js +0 -103
- package/lib/cjs/store/EmailApi.js.map +0 -1
- package/lib/cjs/store/EmbeddingsApi.js +0 -29
- package/lib/cjs/store/EmbeddingsApi.js.map +0 -1
- package/lib/cjs/store/FilesApi.js +0 -286
- package/lib/cjs/store/FilesApi.js.map +0 -1
- package/lib/cjs/store/HiveMemoryApi.js +0 -174
- package/lib/cjs/store/HiveMemoryApi.js.map +0 -1
- package/lib/cjs/store/IndexingApi.js +0 -308
- package/lib/cjs/store/IndexingApi.js.map +0 -1
- package/lib/cjs/store/ObjectsApi.js +0 -340
- package/lib/cjs/store/ObjectsApi.js.map +0 -1
- package/lib/cjs/store/PendingAsksApi.js +0 -43
- package/lib/cjs/store/PendingAsksApi.js.map +0 -1
- package/lib/cjs/store/QueryApi.js +0 -67
- package/lib/cjs/store/QueryApi.js.map +0 -1
- package/lib/cjs/store/RenderingApi.js +0 -84
- package/lib/cjs/store/RenderingApi.js.map +0 -1
- package/lib/cjs/store/SchedulesApi.js +0 -103
- package/lib/cjs/store/SchedulesApi.js.map +0 -1
- package/lib/cjs/store/ToolsApi.js +0 -21
- package/lib/cjs/store/ToolsApi.js.map +0 -1
- package/lib/cjs/store/TypeCatalogApi.js +0 -50
- package/lib/cjs/store/TypeCatalogApi.js.map +0 -1
- package/lib/cjs/store/TypesApi.js +0 -60
- package/lib/cjs/store/TypesApi.js.map +0 -1
- package/lib/cjs/store/WorkersApi.js +0 -16
- package/lib/cjs/store/WorkersApi.js.map +0 -1
- package/lib/cjs/store/WorkflowsApi.js +0 -621
- package/lib/cjs/store/WorkflowsApi.js.map +0 -1
- package/lib/cjs/store/client.js +0 -93
- package/lib/cjs/store/client.js.map +0 -1
- package/lib/cjs/store/errors.js +0 -11
- package/lib/cjs/store/errors.js.map +0 -1
- package/lib/cjs/store/index.js +0 -34
- package/lib/cjs/store/index.js.map +0 -1
- package/lib/cjs/store/version.js +0 -6
- package/lib/cjs/store/version.js.map +0 -1
- package/lib/esm/AccountApi.js.map +0 -1
- package/lib/esm/AccountsApi.js.map +0 -1
- package/lib/esm/AnalyticsApi.js.map +0 -1
- package/lib/esm/ApiKeysApi.js.map +0 -1
- package/lib/esm/AppsApi.js.map +0 -1
- package/lib/esm/AuditTrailApi.js.map +0 -1
- package/lib/esm/CommandsApi.js.map +0 -1
- package/lib/esm/EnvironmentsApi.js.map +0 -1
- package/lib/esm/GroupsApi.js.map +0 -1
- package/lib/esm/IamApi.js +0 -47
- package/lib/esm/IamApi.js.map +0 -1
- package/lib/esm/InteractionBase.js.map +0 -1
- package/lib/esm/InteractionCatalogApi.js.map +0 -1
- package/lib/esm/InteractionOutput.js.map +0 -1
- package/lib/esm/InteractionResult.example.js.map +0 -1
- package/lib/esm/InteractionsApi.js.map +0 -1
- package/lib/esm/OAuthClientsApi.js.map +0 -1
- package/lib/esm/OAuthGrantsApi.js.map +0 -1
- package/lib/esm/OAuthProvidersApi.js.map +0 -1
- package/lib/esm/OAuthServerApi.js +0 -19
- package/lib/esm/OAuthServerApi.js.map +0 -1
- package/lib/esm/ProjectsApi.js.map +0 -1
- package/lib/esm/PromptsApi.js.map +0 -1
- package/lib/esm/RefsApi.js.map +0 -1
- package/lib/esm/RemoteMcpConnectionsApi.js.map +0 -1
- package/lib/esm/RunsApi.js.map +0 -1
- package/lib/esm/SkillsApi.js.map +0 -1
- package/lib/esm/StreamSource.js.map +0 -1
- package/lib/esm/TrainingApi.js +0 -51
- package/lib/esm/TrainingApi.js.map +0 -1
- package/lib/esm/UsersApi.js.map +0 -1
- package/lib/esm/client.js.map +0 -1
- package/lib/esm/execute.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/nodejs/NodeStreamSource.js.map +0 -1
- package/lib/esm/nodejs/index.js +0 -2
- package/lib/esm/nodejs/index.js.map +0 -1
- package/lib/esm/store/AgentsApi.js.map +0 -1
- package/lib/esm/store/AnalyzeDocApi.js.map +0 -1
- package/lib/esm/store/CollectionsApi.js.map +0 -1
- package/lib/esm/store/CommandsApi.js +0 -13
- package/lib/esm/store/CommandsApi.js.map +0 -1
- package/lib/esm/store/CostApi.js.map +0 -1
- package/lib/esm/store/DashboardApi.js.map +0 -1
- package/lib/esm/store/DataApi.js.map +0 -1
- package/lib/esm/store/EmailApi.js.map +0 -1
- package/lib/esm/store/EmbeddingsApi.js +0 -25
- package/lib/esm/store/EmbeddingsApi.js.map +0 -1
- package/lib/esm/store/FilesApi.js.map +0 -1
- package/lib/esm/store/IndexingApi.js.map +0 -1
- package/lib/esm/store/ObjectsApi.js.map +0 -1
- package/lib/esm/store/PendingAsksApi.js.map +0 -1
- package/lib/esm/store/QueryApi.js.map +0 -1
- package/lib/esm/store/RenderingApi.js.map +0 -1
- package/lib/esm/store/SchedulesApi.js.map +0 -1
- package/lib/esm/store/ToolsApi.js.map +0 -1
- package/lib/esm/store/TypeCatalogApi.js.map +0 -1
- package/lib/esm/store/TypesApi.js.map +0 -1
- package/lib/esm/store/WorkersApi.js +0 -12
- package/lib/esm/store/WorkersApi.js.map +0 -1
- package/lib/esm/store/WorkflowsApi.js.map +0 -1
- package/lib/esm/store/client.js +0 -89
- package/lib/esm/store/client.js.map +0 -1
- package/lib/esm/store/errors.js +0 -7
- package/lib/esm/store/errors.js.map +0 -1
- package/lib/esm/store/index.js +0 -18
- package/lib/esm/store/index.js.map +0 -1
- package/lib/esm/store/version.js.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types/AccountApi.d.ts.map +0 -1
- package/lib/types/AccountsApi.d.ts.map +0 -1
- package/lib/types/AnalyticsApi.d.ts.map +0 -1
- package/lib/types/ApiKeysApi.d.ts.map +0 -1
- package/lib/types/AppsApi.d.ts.map +0 -1
- package/lib/types/AuditTrailApi.d.ts.map +0 -1
- package/lib/types/CommandsApi.d.ts.map +0 -1
- package/lib/types/EnvironmentsApi.d.ts.map +0 -1
- package/lib/types/GroupsApi.d.ts.map +0 -1
- package/lib/types/IamApi.d.ts +0 -36
- package/lib/types/IamApi.d.ts.map +0 -1
- package/lib/types/InteractionBase.d.ts.map +0 -1
- package/lib/types/InteractionCatalogApi.d.ts.map +0 -1
- package/lib/types/InteractionOutput.d.ts.map +0 -1
- package/lib/types/InteractionResult.example.d.ts.map +0 -1
- package/lib/types/InteractionsApi.d.ts.map +0 -1
- package/lib/types/OAuthClientsApi.d.ts.map +0 -1
- package/lib/types/OAuthGrantsApi.d.ts.map +0 -1
- package/lib/types/OAuthProvidersApi.d.ts.map +0 -1
- package/lib/types/OAuthServerApi.d.ts +0 -10
- package/lib/types/OAuthServerApi.d.ts.map +0 -1
- package/lib/types/ProjectsApi.d.ts.map +0 -1
- package/lib/types/PromptsApi.d.ts.map +0 -1
- package/lib/types/RefsApi.d.ts +0 -6
- package/lib/types/RefsApi.d.ts.map +0 -1
- package/lib/types/RemoteMcpConnectionsApi.d.ts.map +0 -1
- package/lib/types/RunsApi.d.ts.map +0 -1
- package/lib/types/SkillsApi.d.ts.map +0 -1
- package/lib/types/StreamSource.d.ts.map +0 -1
- package/lib/types/TrainingApi.d.ts.map +0 -1
- package/lib/types/UsersApi.d.ts.map +0 -1
- package/lib/types/client.d.ts.map +0 -1
- package/lib/types/execute.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/nodejs/NodeStreamSource.d.ts.map +0 -1
- package/lib/types/nodejs/index.d.ts +0 -1
- package/lib/types/nodejs/index.d.ts.map +0 -1
- package/lib/types/store/AgentsApi.d.ts.map +0 -1
- package/lib/types/store/AnalyzeDocApi.d.ts.map +0 -1
- package/lib/types/store/CollectionsApi.d.ts.map +0 -1
- package/lib/types/store/CommandsApi.d.ts +0 -10
- package/lib/types/store/CommandsApi.d.ts.map +0 -1
- package/lib/types/store/CostApi.d.ts.map +0 -1
- package/lib/types/store/DashboardApi.d.ts.map +0 -1
- package/lib/types/store/DataApi.d.ts.map +0 -1
- package/lib/types/store/EmailApi.d.ts.map +0 -1
- package/lib/types/store/EmbeddingsApi.d.ts +0 -12
- package/lib/types/store/EmbeddingsApi.d.ts.map +0 -1
- package/lib/types/store/FilesApi.d.ts.map +0 -1
- package/lib/types/store/HiveMemoryApi.d.ts.map +0 -1
- package/lib/types/store/IndexingApi.d.ts.map +0 -1
- package/lib/types/store/ObjectsApi.d.ts.map +0 -1
- package/lib/types/store/PendingAsksApi.d.ts.map +0 -1
- package/lib/types/store/QueryApi.d.ts.map +0 -1
- package/lib/types/store/RenderingApi.d.ts.map +0 -1
- package/lib/types/store/SchedulesApi.d.ts.map +0 -1
- package/lib/types/store/ToolsApi.d.ts.map +0 -1
- package/lib/types/store/TypeCatalogApi.d.ts.map +0 -1
- package/lib/types/store/TypesApi.d.ts.map +0 -1
- package/lib/types/store/WorkersApi.d.ts +0 -6
- package/lib/types/store/WorkersApi.d.ts.map +0 -1
- package/lib/types/store/WorkflowsApi.d.ts.map +0 -1
- package/lib/types/store/client.d.ts +0 -57
- package/lib/types/store/client.d.ts.map +0 -1
- package/lib/types/store/errors.d.ts.map +0 -1
- package/lib/types/store/index.d.ts +0 -17
- package/lib/types/store/index.d.ts.map +0 -1
- package/lib/types/store/version.d.ts.map +0 -1
- package/src/store/CommandsApi.ts +0 -15
- package/src/store/WorkersApi.ts +0 -17
- /package/lib/{esm/ApiKeysApi.js → ApiKeysApi.js} +0 -0
- /package/lib/{esm/OAuthGrantsApi.js → OAuthGrantsApi.js} +0 -0
- /package/lib/{esm/OAuthProvidersApi.js → OAuthProvidersApi.js} +0 -0
- /package/lib/{esm/StreamSource.js → StreamSource.js} +0 -0
- /package/lib/{esm/store → store}/CostApi.js +0 -0
package/lib/vertesia-client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ExecutionRunStatus as t,toAgentMessage as e,AgentMessageType as s,parseMessage as r,DataStoreApiHeaders as n,ContentObjectApiHeaders as a,canGenerateRendition as o,WorkflowExecutionStatus as i,isWorkflowTerminalStatus as l}from"@vertesia/common";export{canGenerateRendition,getSupportedRenditionFormats,supportsVisualRendition}from"@vertesia/common";class u extends Error{status;payload;request;request_info;displayDetails;original_message;constructor(t,e,s,r,n=!0){super(function(t,e,s,r,n){let a=t;if(n){a+="\nRequest: "+e.method+" "+e.url+" => "+s;const t=r?.details||r?.error?.details;if(t){const e=typeof t;"string"===e?a+="\nDetails: "+t:"object"===e&&(a+="\nDetails: "+JSON.stringify(t,void 0,2))}a+="\nStack Trace: "}return a}(t,e,s,r,n)),this.original_message=t,this.request=e,this.status=s,this.payload=r,this.request_info=e.method+" "+e.url+" => "+s,this.displayDetails=n}get details(){return this.payload?.details||this.payload?.error?.details}}class c extends u{constructor(t,e,s,r,n=!0){super(t,e,s,r,n)}updateDetails(t){return t!==this.details?new c(this.original_message,this.request,this.status,{...this.payload,details:t},this.displayDetails):this}}class p extends u{constructor(t,e){super("Failed to connect to server: "+e.message,t,0,e)}}let d;if(globalThis.TextDecoderStream&&"function"==typeof globalThis.TextDecoderStream)d=globalThis.TextDecoderStream;else{class t extends TransformStream{_options;constructor(t="utf-8",{fatal:s=!1,ignoreBOM:r=!1}={}){super(new e(new TextDecoder(t,{fatal:s,ignoreBOM:r}))),this._options={fatal:s,ignoreBOM:r,encoding:t}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class e{decoder;constructor(t){this.decoder=t}transform(t,e){if(!(t instanceof ArrayBuffer||ArrayBuffer.isView(t)))throw new TypeError("Input must be a compatible with: ArrayBuffer | Uint8Array");const s=this.decoder.decode(t,{stream:!0});0!==s.length&&e.enqueue(s)}flush(t){const e=this.decoder.decode();0!==e.length&&t.enqueue(e)}}d=t}const h=[239,187,191];class y extends TransformStream{constructor(){let t;super({start(e){t=function(t){let e,s,r,n,a,o,i;return l(),{feed:function(t){s=s?s+t:t,e&&function(t){return h.every((e,s)=>t.charCodeAt(s)===e)}(s)&&(s=s.slice(h.length)),e=!1;const a=s.length;let o=0,i=!1;for(;o<a;){i&&("\n"===s[o]&&++o,i=!1);let t,e=-1,l=n;for(let n=r;e<0&&n<a;++n)t=s[n],":"===t&&l<0?l=n-o:"\r"===t?(i=!0,e=n-o):"\n"===t&&(e=n-o);if(e<0){r=a-o,n=l;break}r=0,n=-1,u(s,o,l,e),o+=e+1}o===a?s="":o>0&&(s=s.slice(o))},reset:l};function l(){e=!0,s="",r=0,n=-1,a=void 0,o=void 0,i=""}function u(e,s,r,n){if(0===n)return i.length>0&&(t({type:"event",id:a,event:o||void 0,data:i.slice(0,-1)}),i="",a=void 0),void(o=void 0);const l=r<0,u=e.slice(s,s+(l?n:r));let c=0;c=l?n:" "===e[s+r+1]?r+2:r+1;const p=s+c,d=n-c,h=e.slice(p,p+d).toString();if("data"===u)i+=h?"".concat(h,"\n"):"\n";else if("event"===u)o=h;else if("id"!==u||h.includes("\0")){if("retry"===u){const e=parseInt(h,10);Number.isNaN(e)||t({type:"reconnect-interval",value:e})}}else a=h}}(t=>{"event"===t.type&&e.enqueue(t)})},transform(e){t.feed(e)}})}}function g(t){return"/"===t[t.length-1]?t.slice(0,-1):t}class m{_fetch;baseUrl;errorFactory=t=>t;verboseErrors=!0;constructor(t,e){this.baseUrl=g(t),this._fetch=function(t){return t?Promise.resolve(t):"function"==typeof globalThis.fetch?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw new Error("No Fetch implementation found")})}(e)}throwError(t){throw this.errorFactory(t)}getUrl(t){return t.startsWith("http://")||t.startsWith("https://")?g(t):g((e=this.baseUrl,s=t,e.endsWith("/")?s.startsWith("/")?e+s.substring(1):e+s:s.startsWith("/")?e+s:e+"/"+s));var e,s}get(t,e){return this.request("GET",t,e)}del(t,e){return this.request("DELETE",t,e)}delete(t,e){return this.request("DELETE",t,e)}post(t,e){return this.request("POST",t,e)}put(t,e){return this.request("PUT",t,e)}jsonParse(t){return JSON.parse(t)}createRequest(t,e){return Promise.resolve(new Request(t,e))}createServerError(t,e,s){let r="Server Error: "+e.status;return s&&(!function(t){return"Not a valid JSON payload"===t?.error&&"string"==typeof t.text}(s)?s.message?r=String(s.message):s.error&&("string"==typeof s.error?r=String(s.error):"string"==typeof s.error.message&&(r=String(s.error.message))):(r+=e.statusText?" "+e.statusText:"",r+=": non-JSON response")),new c(r,t,e.status,s,this.verboseErrors)}async readJSONPayload(t){return t.text().then(e=>{if(e)try{return this.jsonParse(e)}catch(s){return{status:t.status,error:"Not a valid JSON payload",message:s.message,text:e}}}).catch(e=>({status:t.status,error:"Unable to load response content",message:e.message}))}handleResponse(t,e,s){return s&&s.reader?"sse"===s.reader?async function(t){if(!t.ok){const e=await t.text(),s=new Error("SSE error: "+t.status+". Content:\n"+e);throw s.status=t.status,s}if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(new d).pipeThrough(new y)}(e):s.reader.call(this,e):this.readJSONPayload(e).then(s=>{if(e.ok)return s;this.throwError(this.createServerError(t,e,s))})}async request(t,e,s){let r=this.getUrl(e);s?.query&&(r+="?"+function(t){const e=[];for(const s of Object.keys(t)){const r=t[s];null!=r&&e.push(encodeURIComponent(s)+"="+encodeURIComponent(String(r)))}return e.join("&")}(s.query));const n=this.headers?Object.assign({},this.headers):{},a=s?.headers;if(a)for(const t in a)n[t.toLowerCase()]=a[t];let o;const i=s?.payload;i&&(s&&!1===s.jsonPayload?o=i:(o="string"!=typeof i?JSON.stringify(i):i,"content-type"in n||(n["content-type"]="application/json"))),"sse"!==s?.reader||"accept"in n||(n.accept="text/event-stream");const l={method:t,headers:n,body:o},u=await this.createRequest(r,l);return this._fetch.then(t=>t(u).catch(t=>{console.error(`Failed to connect to ${r}`,t),this.throwError(new p(u,t))}).then(t=>this.handleResponse(u,t,s)))}async sseRequest(t,e,s,r){const n=(await this.request(t,e,{...s,reader:"sse"})).getReader();let a;try{for(;;){const{done:t,value:e}=await n.read();if(t)break;a=e,r(e)}}finally{n.releaseLock()}return a}fetch(t,e){return this._fetch.then(s=>s(t,e))}}class f extends m{headers;_auth;onRequest;onResponse;response;constructor(t,e){super(t,e),this.baseUrl="/"===t[t.length-1]?t.substring(0,t.length-1):t,this.headers=this.initialHeaders}get initialHeaders(){return{accept:"application/json"}}withAuthCallback(t){return this._auth=t||void 0,this}withErrorFactory(t){return this.errorFactory=t,this}withLang(t){return t?this.headers["accept-language"]=t:delete this.headers["accept-language"],this}withHeaders(t){const e=this.headers;for(const s in t){const r=t[s];null!=r&&(e[s.toLowerCase()]=r)}return this}setHeader(t,e){e?this.headers[t.toLowerCase()]=e:delete this.headers[t.toLowerCase()]}async createRequest(t,e){if(this._auth&&(!(s=e.headers)||!("authorization"in s))){const t=e.headers?e.headers:{};e.headers=t;const s=await this._auth();s&&(e.headers.authorization=s)}var s;this.response=void 0;const r=await super.createRequest(t,e);return this.onRequest&&this.onRequest(r),r}async handleResponse(t,e,s){return this.response=e,this.onResponse&&this.onResponse(e,t),super.handleResponse(t,e,s)}}class w extends m{client;constructor(t,e){super(t.getUrl(e),t._fetch),this.client=t,this.createServerError=t.createServerError,this.errorFactory=t.errorFactory,this.verboseErrors=t.verboseErrors}createRequest(t,e){return this.client.createRequest(t,e)}handleResponse(t,e,s){return this.client.handleResponse(t,e,s)}get headers(){return this.client.headers}}class v extends w{constructor(t){super(t,"/api/v1/account")}info(){return this.get("/")}update(t){return this.put("/",{payload:t})}projects(){return this.get("/projects").then(t=>t.data)}members(){return this.get("/members")}inviteUser(t){return this.post("/invites",{payload:t})}listInvites(){return this.get("/invites")}listInvitation(t="project"){return this.get(`/invites/${t}`)}acceptInvite(t){return this.put(`/invites/${t}`)}rejectInvite(t){return this.delete(`/invites/${t}`)}onboardingProgress(){return this.get("/onboarding")}getGoogleToken(){return this.get("/google-token")}getStripeBillingStatus(){return this.get("/stripe-billing-status")}}class $ extends w{constructor(t){super(t,"/api/v1/accounts")}create(t){return this.post("/",{payload:{name:t}})}list(){return this.get("/")}}class b extends w{constructor(t){super(t,"/api/v1/analytics")}runsSummary(t,e){const s=new URLSearchParams;t?.start&&s.set("start",t.start),t?.end&&s.set("end",t.end),e&&s.set("environment",e);const r=s.toString();return this.get("/runs/summary"+(r?"?"+r:""))}runsTimeSeries(t,e){const s=new URLSearchParams;t?.start&&s.set("start",t.start),t?.end&&s.set("end",t.end),e&&s.set("environment",e);const r=s.toString();return this.get("/runs/time-series"+(r?"?"+r:""))}runsTokenUsage(t,e){const s=new URLSearchParams;t?.start&&s.set("start",t.start),t?.end&&s.set("end",t.end),e&&s.set("environment",e);const r=s.toString();return this.get("/runs/token-usage"+(r?"?"+r:""))}}class S extends w{constructor(t){super(t,"/api/v1/apikeys")}list(t="account"){return this.get("/",{query:{level:t}})}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}retrieve(t,e=!1){return e?this.get(`/${t}`,{query:{withValue:!0}}):this.get(`/${t}`)}delete(t){return this.del(`/${t}`)}getToken(t){return this.get(`/${t}/token`)}requestPublicKey(t={}){return this.get("/pk",{query:t})}}class k extends w{constructor(t){super(t,"/api/v1/apps")}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}listAppInstallationTools(t){return this.get(`/installations/${t}/tools`)}list(){return this.get("/")}install(t,e,s,r){return this.post("/install",{payload:{app_id:t,settings:e,oauth_params:s,oauth_provider_params:r}})}uninstall(t){return this.del(`/install/${t}`)}getAppInstallationByName(t){return this.get(`/installations/name/${t}`).catch(t=>{if(404===t.status)return null;throw t})}getAppInstallationProjects(t){if(!t.id&&!t.name)throw new Error("Invalid arguments: appId or appName must be specified");const e=t.id?{id:t.id}:{name:t.name};return this.get("/installations/projects",{query:e})}getInstalledApps(t){return this.get("/installations",{query:{kind:t}})}getAllAppInstallations(){return this.get("/installations/all")}listInstallations(){return this.get("/installations/refs")}updateInstallationSettings(t){return this.put(`/installations/settings/${t.app_id}`,{payload:{app_id:t.app_id,settings:t.settings}})}updateToolAllowlist(t,e){return this.put(`/installations/${t}/tool-allowlist`,{payload:{tool_allowlist:e}})}validateUrl(t){return this.post("/validate-url",{payload:{url:t}})}}class x extends w{constructor(t){super(t,"/api/v1/audit-trail")}list(t){const e=new URLSearchParams;t?.actions?.length&&e.set("actions",t.actions.join(",")),t?.resourceTypes?.length&&e.set("resourceTypes",t.resourceTypes.join(",")),t?.resourceId&&e.set("resourceId",t.resourceId),t?.principalId&&e.set("principalId",t.principalId),t?.principalType&&e.set("principalType",t.principalType),t?.effectivePrincipalId&&e.set("effectivePrincipalId",t.effectivePrincipalId),void 0!==t?.hasEffectivePrincipal&&e.set("hasEffectivePrincipal",String(t.hasEffectivePrincipal)),t?.projectId&&e.set("projectId",t.projectId),t?.from&&e.set("from",t.from),t?.to&&e.set("to",t.to),t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset));const s=e.toString();return this.get("/"+(s?"?"+s:""))}}let _=class extends w{constructor(t){super(t,"/api/v1/commands")}async isNamespaceAvailable(t){return this.get(`/namespaces/${t}/is_available`).then(t=>t.available)}async initSamples(){return this.post("/onboarding/init-samples")}};class T extends w{constructor(t){super(t,"/api/v1/environments")}list(t=!1){const e=t?{all:!0}:void 0;return this.get("/",{query:e})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}updateConfig(t,e){return this.put("/"+t+"/config",{payload:e})}listModels(t,e){return this.get("/"+t+"/models",{query:e?{...e}:void 0})}listTrainableModels(t){return this.get(`/${t}/trainable-models`)}embeddings(t,e){return this.post("/"+t+"/embeddings",{payload:e})}migrateInteractions(t){return this.post("/migrate-interactions",{payload:t})}}class E extends w{constructor(t){super(t,"/groups")}list(t){return this.get("/",{query:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}delete(t){return this.del("/"+t)}listMembers(t){return this.get("/"+t+"/members")}addMember(t,e){return this.post("/"+t+"/members/"+e)}removeMember(t,e){return this.del("/"+t+"/members/"+e)}syncMembers(){return this.post("/sync-members")}}class q extends w{constructor(t){super(t,"/api/v1/iam")}aces=new A(this);roles=new R(this);groups=new E(this)}class R extends w{constructor(t){super(t,"/roles")}list(){return this.get("/")}}class A extends w{constructor(t){super(t,"/aces")}list(t){return this.get("/",{query:{...t}})}retrieve(t){return this.get("/"+t)}create(t){return this.post("/",{payload:t})}delete(t){return this.del("/"+t)}}async function U(){return"function"==typeof globalThis.EventSource?globalThis.EventSource:(await import("eventsource")).EventSource}async function P(e,s,r={},n){const a=!!n,o=await e.runs.create({...r,interaction:s,stream:a});if(a){if(o.status===t.failed)return o;await I(e,o.id,n)}return o}function I(t,e,s){return new Promise((r,n)=>{(async()=>{try{const a=await U(),o=new URL(t.runs.baseUrl+"/"+e+"/stream"),i=t._auth?await t._auth():void 0;if(!i)throw new Error("No auth token available");{const t=i.split(" ")[1];o.searchParams.set("access_token",t)}const l=new a(o.href);l.addEventListener("message",t=>{try{const e=JSON.parse(t.data);e&&s&&s(e)}catch(t){n(t)}}),l.addEventListener("close",t=>{try{l.close();const e=JSON.parse(t.data);r(e)}catch(t){n(t)}})}catch(t){n(t)}})()})}class O extends w{constructor(t){super(t,"/api/v1/interactions/catalog")}list(t={}){return this.get("/",{query:t})}listStoredInteractions(t={}){return this.get("/stored",{query:t})}listSysInteractions(t){return this.get("/sys",{query:{tag:t}})}listAppInteractions(t,e){return this.get(`/apps/${t}`,{query:{tag:e}})}listAllAppInteractions(t){return this.get("/apps",{query:{tag:t}})}resolve(t){return this.get(`/resolve/${t}`)}}const j=Symbol("InteractionOutput");function C(t){return t.result=D.from(t.result),t}function M(t){return t.result=D.from(t.result),t}class D{results;constructor(t){this.results=t}static from(t){return t?t[j]?t:Array.isArray(t)?F(t):F("object"==typeof t?[{type:"json",value:t}]:[{type:"text",value:String(t)}]):F([])}static isInteractionOutputArray(t){return t&&!0===t[j]}get isEmpty(){return 0===this.results.length}hasObject(){return this.results.some(t=>"json"===t.type)}hasText(){return this.results.some(t=>"text"===t.type)}hasImage(){return this.results.some(t=>"image"===t.type)}text(t="\n"){return this.results.filter(t=>"text"===t.type).map(t=>t.value).join(t)}texts(){return this.results.filter(t=>"text"===t.type).map(t=>t.value)}object(){const t=this.results.find(t=>"json"===t.type);return t?t.value:function(t){let e;for(const s of t)if("text"===s.type){const t=s.value.trim();try{return JSON.parse(t)}catch(t){e=t}}e||(e=new Error("No JSON result found and no text available to parse"));throw e}(this.results)}objects(){return this.results.filter(t=>"json"===t.type).map(t=>t.value)}objectAt(t){let e=0;for(const s of this.results)if("json"===s.type){if(e===t)return s.value;e++}throw new Error(`Object at index ${t} not found`)}image(){const t=this.results.find(t=>"image"===t.type);if(!t)throw new Error("No image result found");return t.value}images(){return this.results.filter(t=>"image"===t.type).map(t=>t.value)}stringify(t="\n",e=2){return this.results.map(t=>"json"===t.type?JSON.stringify(t.value,null,e):String(t.value)).join(t)}toString(){return this.text()}toJSON(){return this.results}}function F(t){const e=new D(t);return new Proxy(t,{get(t,s,r){if(s===j)return!0;if(s in e){const t=e[s];return"function"==typeof t?t.bind(e):t}return Reflect.get(t,s,r)}})}class N extends w{catalog;constructor(t){super(t,"/api/v1/interactions"),this.catalog=new O(t)}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}listEndpoints(t){return this.post("/endpoints",{payload:t})}listVersionsByName(t){return this.get(`/versions/${t}`)}listTags(t){return this.get("/tags",{query:{...t}})}computeFacets(t){return this.post("/facets",{payload:t})}listNames(){return this.get("/names")}export(t){return this.post("/export",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}async execute(t,e={},s){return C(await P(this.client,t,e,s).catch(t=>{throw t instanceof c&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t}))}async executeByName(e,s={},r){const n=await async function(e,s,r={},n){const a=!!n,o=await e.post("/api/v1/execute",{payload:{...r,interaction:s,stream:a}});if(a){if(o.status===t.failed)return o;await I(e,o.id,n)}return o}(this.client,e,s,r).catch(t=>{throw t instanceof c&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t});return C(n)}executeAsync(t){return async function(t,e){return await t.post("/api/v1/execute/async",{payload:e})}(this.client,t)}publish(t,e){return this.post(`/${t}/publish`,{payload:e})}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}generateInteraction(t,e){return this.post(`${t}/generate-interaction`,{payload:e})}generateTestData(t,e){return this.post(`${t}/generate-test-data`,{payload:e})}suggestImprovements(t,e){return this.post(`${t}/suggest-prompt-improvements`,{payload:e})}suggestPromptImprovements(t){return this.post("/improve",{payload:t})}listVersions(t){return this.get(`/${t}/versions`)}listForks(t){return this.get(`/${t}/forks`)}requestSlot(t){return async function(t,e){return await t.post("/api/v1/execute/rate-limit/request",{payload:e})}(this.client,t)}resolve(t,e){return this.get(`/resolve/${encodeURIComponent(t)}`,{query:e})}}class L extends w{constructor(t){super(t,"/api/v1/oauth-clients")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}remove(t){return this.del(`/${t}`)}}function H(t){if(t)return Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t).map(([t,e])=>[t,String(e)]))}class B extends w{constructor(t){super(t,"/api/v1/oauth-grants")}list(t){return this.get("/",{query:H(t)})}retrieve(t){return this.get(`/${t}`)}revoke(t,e){return this.del(`/${t}`,{query:e})}revokeBulk(t){return this.post("/revoke",{payload:t})}}class W extends w{constructor(t){super(t,"/api/v1/oauth-providers")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}remove(t){return this.del(`/${t}`)}authorize(t){return this.get(`/${t}/authorize`)}exchange(t,e){return this.post("/exchange",{payload:{code:t,state:e}})}getStatus(t){return this.get(`/${t}/status`)}connect(t){return this.post(`/${t}/connect`,{payload:{}})}getToken(t){return this.post(`/${t}/token`,{payload:{}})}disconnect(t){return this.del(`/${t}/disconnect`)}}class z extends w{constructor(t){super(t,"/oauth")}createAuthorizationRequest(t){return this.post("/requests",{payload:t})}retrieveRequest(t){return this.get(`/requests/${t}`)}approveRequest(t,e){return this.post(`/requests/${t}/approve`,{payload:e})}denyRequest(t){return this.post(`/requests/${t}/deny`,{payload:{}})}}class J extends w{constructor(t){super(t,"/api/v1/projects")}list(t){return this.get("/",{query:{account:t}})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}updateConfiguration(t,e){return this.put(`/${t}/configuration`,{payload:e})}integrations=new V(this);getTools(t){return this.get(`/${t}/tools`)}getToolByName(t,e){return this.get(`/${t}/tools/${e}`).catch(t=>{if(404===t.status)return null;throw t})}listAppContentTypes(t,e){return this.get(`/${t}/app-types`,{query:{tag:e}})}getAppContentType(t,e){return this.get(`/${t}/app-types/${e}`)}listAppRenderingTemplates(t,e){return this.get(`/${t}/app-templates`,{query:{tag:e}})}getAppRenderingTemplate(t,e){return this.get(`/${t}/app-templates/${e}`)}getCompositeAppConfiguration(t){return this.get(`/${t}/composite-app`)}updateCompositeAppConfiguration(t,e){return this.put(`/${t}/composite-app`,{payload:e})}}class V extends w{constructor(t){super(t,"/")}list(t){return this.get(`/${t}/integrations`).then(t=>t.integrations)}retrieve(t,e){return this.get(`/${t}/integrations/${e}`).catch(t=>{if(404!==t.status)throw t})}update(t,e,s){return this.put(`/${t}/integrations/${e}`,{payload:s})}updatePlugins(t,e){return this.post(`/${t}/plugins`,{payload:{plugins:e}})}listPlugins(t){return this.get(`/${t}/plugins`)}}class G extends w{constructor(t){super(t,"/api/v1/prompts")}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}computeFacets(t){return this.post("/facets",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}render(t,e){return this.post(`/${t}/render`,{payload:e})}options(t){return this.get(`/options/${t}`)}listVersions(t){return this.get(`/${t}/versions`)}listInteractions(t){return this.get(`/${t}/interactions`)}listForks(t){return this.get(`/${t}/forks`)}}class K extends w{constructor(t){super(t,"/api/v1/refs")}resolve(t){return this.post("/resolve",{payload:{refs:t}})}}class Q extends w{constructor(t){super(t,"/api/v1/remote-mcp-connections")}getStatus(t){return this.get(`/status/${t}`)}getCollectionStatus(t,e){return this.get(`/status/${t}/${e}`)}getMetadata(t,e){return this.get(`/metadata/${t}/${e}`)}authorize(t,e){return this.get(`/authorize/${t}/${e}`)}connect(t,e){return this.post(`/connect/${t}/${e}`,{})}disconnect(t,e){return this.del(`/disconnect/${t}/${e}`)}getCollectionToken(t,e){return this.post("/token",{payload:{app_install_id:t,collection_id:e}})}getToken(t){return this.post("/token",{payload:{mcp_server_url:t}})}}class Y extends w{constructor(t){super(t,"/api/v1/runs")}list({limit:t,offset:e,filters:s}){const r={limit:t,offset:e,...s};return this.get("/",{query:r})}find(t){return this.post("/find",{payload:t})}async retrieve(t){return M(await this.get("/"+t))}retrievePopulated(t){return this.get("/"+t,{query:{populate:"true"}})}filterOptions(t,e){const s={...e};return this.get(`/filter-options/${t}`,{query:s})}async create(t){const e=this.client.sessionTags;if(e){let s=Array.isArray(e)?e:[e];Array.isArray(t.tags)?s=s.concat(t.tags):t.tags&&(s=s.concat([t.tags])),t={...t,tags:s}}return M(await this.post("/",{payload:t}))}sendToolResults(t){return this.post("/tool-results",{payload:t})}sendUserMessage(t){return this.post("/user-message",{payload:t})}computeFacets(t){return this.post("/facets",{payload:t})}search(t){return this.post("/search",{payload:t})}clone(t){return this.post("/clone",{payload:t})}}class X extends w{constructor(t){super(t,"/api/v1/skills")}findRelevant(t,e){const s={context:t,limit:e};return this.post("/find-relevant",{payload:s})}findRelevantForTask(t,e){return this.findRelevant({task_description:t,tool_names:e})}}class Z extends w{constructor(t){super(t,"/api/v1/agents")}start(t){return this.post("/",{payload:t})}createRecord(t){return this.post("/record",{payload:t})}retrieve(t){return this.get(`/${t}`)}list(t){const e={};return t?.id&&(e.id=t.id),t?.status&&(e.status=Array.isArray(t.status)?t.status.join(","):t.status),t?.interaction&&(e.interaction=t.interaction),t?.started_by&&(e.started_by=t.started_by),t?.since&&(e.since=t.since.toISOString()),t?.until&&(e.until=t.until.toISOString()),t?.schedule_id&&(e.schedule_id=t.schedule_id),t?.type&&(e.type=t.type),t?.limit&&(e.limit=String(t.limit)),t?.offset&&(e.offset=String(t.offset)),t?.cursor&&(e.cursor=t.cursor),t?.sort&&(e.sort=t.sort),t?.order&&(e.order=t.order),this.get("/",{query:e})}search(t){const e={};return t?.query&&(e.query=t.query),t?.status&&(e.status=Array.isArray(t.status)?t.status.join(","):t.status),t?.interaction&&(e.interaction=t.interaction),t?.started_by&&(e.started_by=t.started_by),t?.categories?.length&&(e.categories=t.categories.join(",")),t?.tags?.length&&(e.tags=t.tags.join(",")),t?.content_type_name&&(e.content_type_name=t.content_type_name),t?.since&&(e.since=t.since.toISOString()),t?.until&&(e.until=t.until.toISOString()),t?.limit&&(e.limit=String(t.limit)),t?.offset&&(e.offset=String(t.offset)),this.get("/search",{query:e})}terminate(t,e){const s=e?{reason:e}:void 0;return this.del(`/${t}`,{query:s})}restart(t){return this.post(`/${t}/restart`,{})}fork(t){return this.post(`/${t}/fork`,{})}updateStatus(t,e){return this.post(`/${t}/status`,{payload:e})}sendSignal(t,e,s){return this.post(`/${t}/signal/${e}`,{payload:s})}query(t,e){return this.get(`/${t}/query/${e}`)}getActiveWorkstreams(t){return this.query(t,"ActiveWorkstreams")}async retrieveMessages(t,s){const r=s?{since:s}:void 0;return(await this.get(`/${t}/updates`,{query:r})).messages.map(s=>e(s,t))}postMessage(t,e){return this.post(`/${t}/updates`,{payload:e})}async streamMessages(t,n,a,o){let i=()=>{},l=()=>{};const u=new Promise((t,e)=>{i=t,l=e});let c=0,p=a||0,d=!1,h=null,y=null,g=null,m=null;const f=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},w=()=>{g&&(clearTimeout(g),g=null),y&&(clearInterval(y),y=null),h&&(h.close(),h=null),o&&m&&(o.removeEventListener("abort",m),m=null)},v=t=>{d||(d=!0,w(),i(t))};if(o){if(o.aborted)return d=!0,w(),i(null),u;m=()=>{v(null)},o.addEventListener("abort",m,{once:!0})}try{if(!d){const e=await this.retrieveMessages(t,a);for(const t of e){if(d)break;if(p=Math.max(p,t.timestamp||0),n&&n(t,v),d)break;const e=t.workstream_id||"main";if(t.type===s.TERMINATED||t.type===s.COMPLETE&&"main"===e)return v(null),u}}}catch(t){d||console.warn("Failed to fetch historical messages, continuing with SSE:",t)}const $=async(a=!1)=>{if(!d)try{const o=await U();if(d)return;const i=this.client,u=new URL(i.agents.baseUrl+`/${t}/stream`);p>0&&u.searchParams.set("since",p.toString()),u.searchParams.set("skipHistory","true");const m=i._auth?await i._auth():void 0;if(d)return;if(!m)return d=!0,w(),void l(new Error("No auth token available"));const b=m.split(" ")[1];if(u.searchParams.set("access_token",b),a&&console.log(`Reconnecting to agent stream ${t} (attempt ${c+1}/10)`),d)return;const S=new o(u.href);h=S,y=setInterval(()=>{},1e3);let k=0;S.onopen=()=>{a&&console.log(`Reconnected to agent stream ${t}`),k=Date.now()},S.onmessage=a=>{if(!d&&a.data&&!a.data.startsWith(":"))try{const o=r(a.data);if(p=o.ts?Math.max(p,o.ts):Date.now(),n){const s=e(o,t);n(s,v)}const i=o.w||"main";(o.t===s.TERMINATED||o.t===s.COMPLETE&&"main"===i)&&v(null)}catch(t){console.error("Failed to parse SSE message:",t,a.data)}},S.onerror=t=>{if(d)return;w();if((k?Date.now()-k:0)>5e3&&(c=0),c<10){const t=f(c);c++,g=setTimeout(()=>{g=null,d||$(!0)},t)}else d=!0,w(),l(new Error("SSE connection failed after 10 reconnection attempts"))}}catch(t){if(d)return;if(c<10){const t=f(c);c++,g=setTimeout(()=>{g=null,d||$(!0)},t)}else d=!0,w(),l(t)}};return $(!1),u}getInternals(t){return this.get(`/${t}/internals`)}getRunDetails(t,e){const s={};return e?.includeHistory&&(s.include_history="true"),this.get(`/${t}/details`,{query:s})}async streamRunDetails(t,e,s){const r=await U(),n=this.client,a=new URL(n.agents.baseUrl+`/${t}/details/stream`),o=n._auth?await n._auth():void 0;if(!o)throw new Error("No auth token available");const i=o.split(" ")[1];return a.searchParams.set("access_token",i),new Promise((t,n)=>{const o=new r(a.href);let i=null;const l=()=>{o.close(),s&&i&&(s.removeEventListener("abort",i),i=null)};if(s){if(s.aborted)return l(),void t();i=()=>{l(),t()},s.addEventListener("abort",i,{once:!0})}o.addEventListener("history",t=>{try{const s=JSON.parse(t.data);e&&e({type:"history",data:s})}catch(t){}}),o.addEventListener("control",s=>{try{const r=JSON.parse(s.data);e&&e({type:"control",data:r}),"type"in r&&"done"===r.type&&(l(),t())}catch(t){}}),o.addEventListener("error",t=>{try{const s=JSON.parse(t.data);e&&e({type:"error",data:s})}catch(t){}}),o.onerror=t=>{l(),n(new Error("SSE connection failed for details stream"))}})}listChildren(t){return this.get(`/${t}/children`)}getChildDetails(t,e,s){const r={};return s?.includeHistory&&(r.include_history="true"),this.get(`/${t}/children/${e}/details`,{query:r})}listArtifacts(t,e){const s=e?.visibility?{visibility:e.visibility}:void 0;return this.get(`/${t}/artifacts`,{query:s})}getArtifactUrl(t,e,s,r){const n={url:"1"};return s&&(n.disposition=s),r&&(n.filename=r),this.get(`/${t}/artifacts/${e}`,{query:n})}async uploadArtifact(t,e,s,r){const n=r||"application/octet-stream",a=await this.put(`/${t}/artifacts/${e}`,{headers:{"Content-Type":n}}),o=await fetch(a.url,{method:"PUT",body:s,headers:{"Content-Type":n}});if(!o.ok)throw new Error(`Failed to upload artifact: ${o.statusText}`);return a}async downloadArtifact(t,e){const{url:s}=await this.getArtifactUrl(t,e,"attachment"),r=await fetch(s);if(!r.ok)throw new Error(`Failed to download artifact: ${r.statusText}`);if(!r.body)throw new Error("No body in artifact download response");return r.body}ingestEvents(t,e){const s={events:e};return this.post(`/${t}/events`,{payload:s})}getAnalyticsSummary(t={}){return this.post("/analytics/summary",{payload:t})}getTokenUsageAnalytics(t={}){return this.post("/analytics/tokens",{payload:t})}getLlmLatencyAnalytics(t={}){return this.post("/analytics/latency/llm",{payload:t})}getToolLatencyAnalytics(t={}){return this.post("/analytics/latency/tools",{payload:t})}getAgentLatencyAnalytics(t={}){return this.post("/analytics/latency/agents",{payload:t})}getErrorAnalytics(t={}){return this.post("/analytics/errors",{payload:t})}getToolAnalytics(t={}){return this.post("/analytics/tools",{payload:t})}getToolParameterAnalytics(t){return this.post("/analytics/tools/parameters",{payload:t})}getAnalyticsFilterOptions(t={}){return this.post("/analytics/filter-options",{payload:t})}getPromptSizeAnalytics(t={}){return this.post("/analytics/prompt-size",{payload:t})}getTopPrincipalsAnalytics(t={}){return this.post("/analytics/top-principals",{payload:t})}getRunsByAgentAnalytics(t={}){return this.post("/analytics/runs-by-agent",{payload:t})}getTimeToFirstResponseAnalytics(t={}){return this.post("/analytics/time-to-first-response",{payload:t})}getFirstResponseBehaviorAnalytics(t={}){return this.post("/analytics/first-response-behavior",{payload:t})}}class tt extends w{constructor(t){super(t,"/api/v1/collections")}search(t){return this.post("/search",{payload:t})}computeListFacets(t){return this.post("/facets",{payload:t})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}addMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"add",members:e}})}listMembers(t,e){return this.get(`/${t}/members`,{query:{...e}})}computeFacets(t,e){return this.post(`/${t}/facets`,{payload:e})}searchMembers(t,e){return this.post(`/${t}/search`,{payload:e})}deleteMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"delete",members:e}})}addChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"add",children:e}})}deleteChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"delete",children:e}})}searchChildren(t,e={}){return this.post(`/${t}/children/search`,{payload:e})}delete(t){return this.del(`/${t}`)}updatePermissions(t,e){return this.put(`/${t}/permissions`,{payload:e})}propagatePermissions(t){return this.post(`/${t}/propagate-permissions`)}propagateSharedProperties(t){return this.post(`/${t}/propagate-shared-props`)}}class et extends w{constructor(t){super(t,"/api/v1/cost")}getAnalytics(t={}){return this.post("/analytics",{payload:t})}getGlobalAnalytics(t={}){return this.post("/analytics/global",{payload:t})}getModelPrices(t={}){return this.get("/model-prices",{query:{...t}})}getRunPrice(t){return this.post("/run-price",{payload:t})}getRunPriceComparison(t){return this.post("/run-price",{payload:{...t,include_comparison_pricing:!0}})}getExportUrl(t){const e=new URLSearchParams;t?.from&&e.set("from","number"==typeof t.from?new Date(t.from).toISOString():t.from),t?.to&&e.set("to","number"==typeof t.to?new Date(t.to).toISOString():t.to),t?.scope&&e.set("scope",t.scope),t?.project_id&&e.set("project_id",t.project_id),t?.workflow_id&&e.set("workflow_id",t.workflow_id);const s=e.toString();return`${this.baseUrl}/export${s?`?${s}`:""}`}}class st extends w{constructor(t,e="/api/v1/embeddings"){super(t,e)}async status(t){return this.get(t+"/status")}async activate(t,e){if(!e.environment)throw new Error("Invalid configuration: select environment");return this.post(t+"/enable",{payload:e})}async disable(t){return this.post(t+"/disable")}async recalculate(t){return this.post(t+"/recalculate")}}class rt extends w{constructor(t){super(t,"/api/v1/commands")}embeddings=new st(this,"/embeddings")}class nt extends w{storeId;constructor(t,e){super(t,`/api/v1/data/${e}/dashboards`),this.storeId=e}storeHeaders(){return{[n.DATA_STORE_ID]:this.storeId}}list(t){const e=t?`?status=${t}`:"";return this.get(`/${e}`,{headers:this.storeHeaders()})}create(t){return this.post("/",{payload:t,headers:this.storeHeaders()})}retrieve(t){return this.get(`/${t}`,{headers:this.storeHeaders()})}update(t,e){return this.put(`/${t}`,{payload:e,headers:this.storeHeaders()})}delete(t){return this.del(`/${t}`,{headers:this.storeHeaders()})}bulkArchive(t){return this.post("/bulk/archive",{payload:{ids:t},headers:this.storeHeaders()})}bulkDelete(t){return this.post("/bulk/delete",{payload:{ids:t},headers:this.storeHeaders()})}listVersions(t,e){const s=new URLSearchParams;e?.snapshotsOnly&&s.set("snapshots_only","true"),e?.limit&&s.set("limit",String(e.limit));const r=s.toString()?`?${s}`:"";return this.get(`/${t}/versions${r}`,{headers:this.storeHeaders()})}getVersion(t,e){return this.get(`/${t}/versions/${e}`,{headers:this.storeHeaders()})}createSnapshot(t,e){return this.post(`/${t}/versions`,{payload:e,headers:this.storeHeaders()})}promoteVersion(t,e,s){return this.post(`/${t}/versions/${e}/promote`,{payload:s||{},headers:this.storeHeaders()})}setVersioningEnabled(t,e){return this.put(`/${t}/versioning`,{payload:{enabled:e},headers:this.storeHeaders()})}}class at extends w{constructor(t){super(t,"/api/v1/data")}storeHeaders(t){return{[n.DATA_STORE_ID]:t}}list(){return this.get("/")}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`,{headers:this.storeHeaders(t)})}delete(t){return this.del(`/${t}`,{headers:this.storeHeaders(t)})}getSchema(t,e){const s=e?`?format=${e}`:"";return this.get(`/${t}/schema${s}`,{headers:this.storeHeaders(t)})}updateSchema(t,e){return this.put(`/${t}/schema`,{payload:e,headers:this.storeHeaders(t)})}getSchemaHistory(t){return this.get(`/${t}/schema/history`,{headers:this.storeHeaders(t)})}listTables(t){return this.get(`/${t}/tables`,{headers:this.storeHeaders(t)})}createTables(t,e){return this.post(`/${t}/tables`,{payload:e,headers:this.storeHeaders(t)})}getTable(t,e,s){const r=s?"?sample=true":"";return this.get(`/${t}/tables/${e}${r}`,{headers:this.storeHeaders(t)})}alterTable(t,e,s){return this.put(`/${t}/tables/${e}`,{payload:s,headers:this.storeHeaders(t)})}dropTable(t,e){return this.del(`/${t}/tables/${e}`,{headers:this.storeHeaders(t)})}import(t,e){return this.post(`/${t}/import`,{payload:e,headers:this.storeHeaders(t)})}getImportStatus(t,e){return this.get(`/${t}/import/${e}`,{headers:this.storeHeaders(t)})}listVersions(t,e){const s=e?"?snapshots_only=true":"";return this.get(`/${t}/versions${s}`,{headers:this.storeHeaders(t)})}createSnapshot(t,e){return this.post(`/${t}/versions`,{payload:e,headers:this.storeHeaders(t)})}rollback(t,e){return this.post(`/${t}/versions/${e}/rollback`,{headers:this.storeHeaders(t)})}queryVersion(t,e,s){return this.post(`/${t}/versions/${e}/query`,{payload:s,headers:this.storeHeaders(t)})}query(t,e){return this.post(`/${t}/query`,{payload:e,headers:this.storeHeaders(t)})}queryBatch(t,e){return this.post(`/${t}/query/batch`,{payload:{queries:e},headers:this.storeHeaders(t)})}validateQueries(t,e){return this.post(`/${t}/query/validate`,{payload:{queries:e},headers:this.storeHeaders(t)})}getDownloadInfo(t,e){const s=e?`?version_id=${e}`:"";return this.get(`/${t}/download${s}`,{headers:this.storeHeaders(t)})}dashboards(t){return new nt(this.client,t)}}class ot extends w{constructor(t){super(t,"/api/v1/email")}send(t){return this.post("/send",{payload:t})}resolveRoute(t){return this.post("/resolve-route",{payload:{route_key:t}})}createRoute(t){return this.post("/routes",{payload:t})}getRoute(t){return this.get(`/routes/${t}`)}updateRoute(t,e){return this.put(`/routes/${t}`,{payload:e})}forwardEmail(t,e){return this.post(`/routes/${t}/forward`,{payload:e})}}class it extends w{constructor(t,e="/api/v1/indexing"){super(t,e)}async status(){return this.get("/status")}async reindex(t){return this.post("/reindex",{payload:t})}async analyzeDrift(){return this.post("/analyze-drift",{payload:{}})}async getDriftAnalysis(){return this.get("/drift-analysis")}async enableIndexing(){return this.post("/enable-indexing")}async disableIndexing(){return this.post("/disable-indexing")}async enableQueries(){return this.post("/enable-queries")}async disableQueries(){return this.post("/disable-queries")}index(t,e){return this.post("/internal/index",{payload:{object_id:t,document:e}})}delete(t){return this.post("/internal/delete",{payload:{object_id:t}})}bulkIndex(t,e){return this.post("/internal/bulk-index",{payload:{documents:t,target_index:e}})}ensureIndex(t){return this.post("/internal/ensure-index",{payload:{recreate:t}})}createReindexTarget(){return this.post("/internal/create-reindex-target",{payload:{}})}getStats(){return this.post("/internal/stats",{payload:{}})}getReindexRange(){return this.post("/internal/reindex-range",{payload:{}})}fetchBatch(t,e){return this.post("/internal/fetch-batch",{payload:{cursor:t,limit:e}})}getNextIndexCursor(t,e,s){return this.post("/internal/next-cursor",{payload:{cursor:t,limit:e,count:s}})}analyzeDriftBatch(t,e){return this.post("/internal/analyze-drift-batch",{payload:{cursor:t,limit:e}})}triggerReindex(t){return this.post("/internal/trigger-reindex",{payload:t?{full_reindex:t.fullReindex,object_ids:t.objectIds,recreate_index:t.recreateIndex}:{}})}fetchDocumentsByIds(t){return this.post("/internal/fetch-by-ids",{payload:{object_ids:t}})}bulkDelete(t){return this.post("/internal/bulk-delete",{payload:{object_ids:t}})}getConfiguration(){return this.post("/internal/configuration",{payload:{}})}get zenoBulkBaseUrl(){const t=this.client.baseUrl;return t.includes("zeno-server")?t.replace(/zeno-server/,"zeno-bulk"):t}zenoBulkPost(t,e){return this.client.post(this.zenoBulkBaseUrl+t,{payload:e})}computeShards(t,e){return this.zenoBulkPost("/reindex/compute-shards",{tenant_id:t,shard_size:e??5e4})}indexShard(t){return this.zenoBulkPost("/reindex/shard",{params:t})}swapAlias(t,e,s){return this.zenoBulkPost("/reindex/swap-alias",{tenant_id:t,target_index:e,alias:s})}async reindexViaBulk(t,e,s){const r=this.zenoBulkBaseUrl+"/reindex",n={tenant_id:t,dry_run:s??!1};if(!e)return this.client.post(r,{payload:n});let a;if(await this.client.sseRequest("POST",r,{payload:n},t=>{if(e(t),"event"===t.type&&"done"===t.event)try{a=JSON.parse(t.data)}catch{}}),!a)throw new Error("zeno-bulk SSE stream ended without a done event");return a}}class lt extends u{constructor(t,e){super("Resource not found: "+e.message,t,404,e.payload)}}class ut{stream;name;type;id;constructor(t,e,s,r){this.stream=t,this.name=e,this.type=s,this.id=r}}const ct="memories",pt="agents";function dt(t){const e=t.endsWith(".tar.gz")?t:t+".tar.gz";return`${ct}/${e}`}function ht(t,e){return`${pt}/${t}/${e}`}class yt extends w{constructor(t){super(t,"/api/v1/files")}async deleteFile(t,e){return this.delete(`/${t}`,{query:{prefix:e}})}getMetadata(t){return this.get("/metadata",{query:{file:t}})}setFileMetadata(t,e){const s={file:t,metadata:e};return this.put("/metadata",{payload:s})}getOrCreateBucket(){return this.post("/bucket")}list(t){return this.get("/list",{query:{prefix:t}})}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){const r={file:t,name:e,disposition:s};return this.post("/download-url",{payload:r})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}bulkGetUploadUrls(t){return this.post("/bulk-upload-urls",{payload:t})}async bulkUpload(t,e=10){const s=t.map(t=>({name:t.name,mime_type:t.type,id:t instanceof ut?t.id:void 0})),{files:r}=await this.bulkGetUploadUrls({files:s}),n=new Array(t.length);for(let s=0;s<t.length;s+=e){const a=t.slice(s,s+e);await Promise.all(a.map(async(t,e)=>{const a=s+e,{url:o,id:i,mime_type:l}=r[a],u=t instanceof ut,c=t.type||l,p=await fetch(o,{method:"PUT",body:u?t.stream:t,duplex:u?"half":void 0,headers:c?{"Content-Type":c}:void 0});if(!p.ok)throw new Error(`Failed to upload file ${t.name}: ${p.statusText}`);const d=p.headers.get("etag")?.replace(/^"(.*)"$/,"$1");n[a]={source:i,name:t.name,type:c,etag:d}}))}return n}async uploadFile(t){const e=t instanceof ut,{url:s,id:r,path:n}=await this.getUploadUrl(t);return await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:{"Content-Type":t.type||"application/gzip"}}).then(t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)}).catch(t=>{throw console.error("Failed to upload file",{err:t,url:s,id:r,path:n}),t}),r}async downloadFile(t){const e=!t.startsWith("https:"),{url:s}=e?await this.getDownloadUrl(t):{url:t},r=await fetch(s,{method:"GET"}).then(e=>{if(e.ok)return e;throw 404===e.status?new Error(`File at ${s} not found`):403===e.status?new Error(`File at ${s} is forbidden`):(console.log(e),new Error(`Failed to download file ${t}: ${e.statusText}`))}).catch(e=>{throw console.error(`Failed to download file ${t}.`,e),e});if(!r.body)throw new Error(`No body in response while downloading file ${t}`);return r.body}async copyFile(t,e){return(await this.post("/copy",{payload:{source:t,dest:e}})).dest}async uploadMemoryPack(t){const e=dt(t.name),s=t.name.endsWith(".tar.gz")?t.name:t.name+".tar.gz";if(t instanceof File){const r=t;return this.uploadFile(new ut(r.stream(),s,r.type,e))}return this.uploadFile(new ut(t.stream,s,t.type,e))}async downloadMemoryPack(t,e=!1){let s=await this.downloadFile(dt(t));if(e){const t=new DecompressionStream("gzip");s=s.pipeThrough(t)}return s}listByPrefix(t){return this.get("/list",{query:{prefix:t}})}async uploadArtifact(t,e,s){const r=ht(t,e);if(s instanceof File){const t=s;return this.uploadFile(new ut(t.stream(),e,t.type,r))}return this.uploadFile(new ut(s.stream,e,s.type,r))}async downloadArtifact(t,e){const s=ht(t,e);return this.downloadFile(s)}getArtifactDownloadUrl(t,e,s){const r=ht(t,e);return this.getDownloadUrl(r,e,s)}async listArtifacts(t){const e=`${pt}/${t}/`;return(await this.listByPrefix(e)).files}}class gt extends w{constructor(t){super(t,"/api/v1/hive-memory")}list(t){const e=new URLSearchParams;t?.category&&e.set("category",t.category),t?.scope&&e.set("scope",t.scope),t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset));const s=e.toString();return this.get(s?`/?${s}`:"/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}search(t){return this.post("/search",{payload:t})}recall(t,e){return this.post("/recall",{payload:{task_description:t,tools:e?.tools,category:e?.category,max_results:e?.maxResults}})}getFormatted(t){return this.get(`/${t}/formatted`)}recordUsage(t){return this.post(`/${t}/usage`,{})}getByCategory(t,e){const s=new URLSearchParams;e?.limit&&s.set("limit",String(e.limit)),e?.offset&&s.set("offset",String(e.offset));const r=s.toString();return this.get(`/category/${t}${r?`?${r}`:""}`)}getStats(){return this.get("/stats")}applyDecay(t){return this.post("/admin/decay",{payload:{days_threshold:t?.daysThreshold,decay_rate:t?.decayRate}})}archiveLowConfidence(t){return this.post("/admin/archive",{payload:{threshold:t}})}}class mt extends w{objectId;constructor(t,e){super(t,`/${e}/analyze`),this.objectId=e}async start(t){return this.post("/",{payload:t})}async getStatus(){return this.get("/status")}async getResults(){return this.get("/results")}async adaptTables(t){return this.post("/adapt_tables",{payload:t})}async getAdaptedTables(t,e){const s=t?`/adapt_tables/${t}`:"/adapt_tables",r={};e?.format&&(r.format=e.format),void 0!==e?.raw&&(r.raw=e.raw);const n={query:r};return"csv"===e?.format&&(n.responseType="text"),this.get(s,n)}async getXml(){return this.get("/xml")}async getTables(t){const e={};return t&&(e.query={format:t}),this.get("/tables",e)}async getImages(){return this.get("/images")}async getAnnotated(){return this.get("/annotated")}}class ft extends w{constructor(t){super(t,"/api/v1/objects")}analyze(t){return new mt(this,t)}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){return this.post("/download-url",{payload:{file:t,name:e,disposition:s}})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}getContentSource(t){return this.get(`/${t}/content-source`)}list(t={}){const e=t.limit||100,s=t.offset||0,r=t.query||{};return this.get("/",{query:{limit:e,offset:s,select:t.select,...r,all_revisions:t.all_revisions,from_root:t.from_root||void 0}})}computeFacets(t){return this.post("/facets",{payload:t})}listFolders(t="/"){throw new Error("Not implemented yet")}find(t){return this.post("/find",{payload:t})}count(t){return this.post("/count",{payload:t})}search(t){return this.post("/search",{payload:t})}retrieve(t,e){return this.get(`/${t}`,{query:{select:e}})}getObjectText(t){return this.get(`/${t}/text`)}async upload(t){const e=t instanceof ut,{url:s,id:r,mime_type:n}=await this.getUploadUrl({id:e?t.id:void 0,name:t.name,mime_type:t.type}),a=t.type||n,o=await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:a?{"Content-Type":a}:void 0}).then(t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)}).catch(t=>{throw console.error("Failed to upload file",t),t}),i=o.headers.get("etag")?.replace(/^"(.*)"$/,"$1");return{source:r,name:t.name,type:a,etag:i}}async create(t,e){const s={...t};(t.content instanceof ut||t.content instanceof File)&&(s.content=await this.upload(t.content));const r={};return e?.processing_priority&&(r[a.PROCESSING_PRIORITY]=e.processing_priority),e?.collection_id&&(r[a.COLLECTION_ID]=e.collection_id),await this.post("/",{payload:s,headers:r})}async createFromExternalSource(t,e={},s){const r=await this.client.files.getMetadata(t),n={...e,content:{source:t,name:r.name,type:r.contentType,etag:r.etag}},o={};return s?.processing_priority&&(o[a.PROCESSING_PRIORITY]=s.processing_priority),s?.collection_id&&(o[a.COLLECTION_ID]=s.collection_id),await this.post("/",{payload:n,headers:o})}async update(t,e,s){const r={...e};(e.content instanceof ut||e.content instanceof File)&&(r.content=await this.upload(e.content));const n={};return s?.ifMatch&&(n["if-match"]=s.ifMatch),s?.processing_priority&&(n[a.PROCESSING_PRIORITY]=s.processing_priority),s?.createRevision&&(n[a.CREATE_REVISION]="true",s.revisionLabel&&(n[a.REVISION_LABEL]=s.revisionLabel)),s?.suppressWorkflows&&(n[a.SUPPRESS_WORKFLOWS]="true"),this.put(`/${t}`,{payload:r,headers:n})}getRevisions(t){return this.get(`/${t}/revisions`)}getCollections(t){return this.get(`/${t}/collections`)}delete(t){return Array.isArray(t)?this.client.runOperation({name:"delete",ids:t,params:{}}):this.del(`/${t}`)}bulkUpdate(t){const e=Object.keys(t);return this.client.runOperation({name:"update",ids:e,params:t})}bulkCreate(t,e){return this.client.runOperation({name:"create",ids:[],params:{objects:t,...e}})}listWorkflowRuns(t){return this.get(`/${t}/workflow-runs`)}listRenditions(t){return this.get(`/${t}/renditions`)}getRendition(t,e){const s={max_hw:e.max_hw,generate_if_missing:e.generate_if_missing,sign_url:e.sign_url,block_on_generation:e.block_on_generation};return this.get(`/${t}/renditions/${e.format}`,{query:s})}getRenditionSafe(t,e,s){return o(e,s.format)?this.getRendition(t,s):Promise.resolve(null)}exportProperties(t){return this.post("/export",{payload:t})}setEmbedding(t,e,s){return this.put(`/${t}/embeddings/${e}`,{payload:s})}}class wt extends w{constructor(t){super(t,"/api/v1/pending-asks")}register(t){return this.post("/",{payload:t})}resolve(t,e){return this.post(`/${t}/resolve`,{payload:e})}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}}class vt extends w{constructor(t,e="/api/v1/query"){super(t,e)}async execute(t){return this.post("/",{payload:t})}async sql(t){return this.execute({sql:t})}async esql(t){return this.execute({esql:t})}async dsl(t){return this.execute({dsl:t})}}class $t extends w{constructor(t){super(t,"/api/v1/rendering")}start(t){return this.post("/jobs",{payload:t})}getStatus(t,e){return this.get("/jobs/status",{query:{workflow_id:t,workflow_run_id:e}})}async render(t,e={}){const s=e.pollIntervalMs??1500,r=e.timeoutMs??6e5,n=await this.start(t);if(!n.workflow_id||!n.workflow_run_id)throw new Error("Failed to start rendering workflow");const a=Date.now();for(;;){const e=await this.getStatus(n.workflow_id,n.workflow_run_id);if(e.status===i.COMPLETED){if(!e.download_url&&!e.file_uri)throw new Error(e.error||"Rendering completed but no output file was produced");return{status:"success",format:t.format,download_url:e.download_url,file_uri:e.file_uri}}if(l(e.status)){const t=i[e.status]||String(e.status);throw new Error(e.error||`Rendering failed with status: ${t}`)}if(Date.now()-a>=r)throw new Error(`Rendering timed out after ${r}ms`);await bt(s)}}}function bt(t){return new Promise(e=>setTimeout(e,t))}class St extends w{constructor(t){super(t,"/api/v1/schedules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}trigger(t){return this.post(`/${t}/trigger`,{})}pause(t,e){return this.post(`/${t}/pause`,{payload:{note:e}})}resume(t,e){return this.post(`/${t}/resume`,{payload:{note:e}})}}class kt extends w{constructor(t){super(t,"/api/v1/tools")}getBuiltinCatalog(){return this.get("/")}}class xt extends w{constructor(t){super(t,"/api/v1/types/catalog")}list(t={}){return this.get("/",{query:t})}listSysTypes(t){return this.get("/sys",{query:{tag:t}})}listAppTypes(t){return this.get("/apps",{query:{tag:t}})}listStoredTypes(t={}){return this.get("/stored",{query:t})}resolve(t){const e="string"==typeof t?t:t.code||t.id;return this.get(`/resolve/${e}`)}}class _t extends w{catalog;constructor(t){super(t,"/api/v1/types"),this.catalog=new xt(t)}list(t={},e){const s=t.limit||2e3,r=t.offset||0,n=t.query||{};return this.get("/",{query:{limit:s,offset:r,layout:!!e?.layout,schema:!!e?.schema,...n}})}find(t){return this.post("/find",{payload:t})}retrieve(t){return this.get(`/${t}`)}getTypeByName(t){return this.get(`/name/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}const Tt="20260319",Et="x-api-version";class qt extends w{constructor(t){super(t,"/api/v1/workers")}async deploy(t){return this.post("/",{payload:t})}}class Rt extends w{constructor(t){super(t,"/api/v1/workflows")}getActivityCatalog(){return this.get("/activity-catalog")}listRuns(t,e,s){return this.post("/runs",{payload:{documentId:t,eventName:e,ruleId:s}})}listConversations(t){return this.post("/conversations",{payload:t})}searchRuns(t){return this.post("/runs",{payload:t})}sendSignal(t,e,s,r){return this.post(`/runs/${t}/${e}/signal/${s}`,{payload:r})}getRunDetails(t,e,s){const r={};return void 0!==s?.includeHistory&&(r.include_history=s.includeHistory),void 0!==s?.historyFormat&&(r.history_format=s.historyFormat),this.get(`/runs/${e}/${t}`,{query:r})}getRunInteraction(t,e){return this.get(`/runs/${t}/${e}/interaction`)}terminate(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/terminate`,{payload:r})}cancel(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/cancel`,{payload:r})}query(t,e,s){return this.get(`/runs/${t}/${e}/query/${s}`)}execute(t,e={}){return this.post(`/execute/${t}`,{payload:e})}postMessage(t,e){if(!t)throw new Error("runId is required");return this.post(`/runs/${t}/updates`,{payload:e})}async retrieveMessages(t,s,r){const n={since:r};return(await this.get(`/runs/${t}/${s}/updates`,{query:n})).messages.map(t=>e(t,s))}async streamMessages(t,n,a,o,i){return new Promise((l,u)=>{let c=0,p=o||0,d=!1,h=null,y=null,g=null,m=null;const f=10,w=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},v=()=>{g&&(clearTimeout(g),g=null),y&&(clearInterval(y),y=null),h&&(h.close(),h=null),i&&m&&(i.removeEventListener("abort",m),m=null)},$=t=>{d||(d=!0,v(),l(t))};if(i){if(i.aborted)return void $(null);m=()=>$(null),i.addEventListener("abort",m,{once:!0})}const b=async(o=!1)=>{if(!d)try{const i=await U(),m=this.client,S=new URL(m.workflows.baseUrl+`/runs/${t}/${n}/stream`);p>0&&S.searchParams.set("since",p.toString()),S.searchParams.set("skipHistory","true");const k=m._auth?await m._auth():void 0;if(d)return;if(!k)return d=!0,v(),void u(new Error("No auth token available"));const x=k.split(" ")[1];S.searchParams.set("access_token",x),o&&console.log(`Reconnecting to SSE stream for run ${n} (attempt ${c+1}/10)`);const _=new i(S.href);h=_,y=setInterval(()=>{},1e3),_.onopen=()=>{o&&console.log(`Successfully reconnected to SSE stream for run ${n}`),c=0},_.onmessage=t=>{if(t.data&&!t.data.startsWith(":"))try{const o=r(t.data);if(p=o.ts?Math.max(p,o.ts):Date.now(),a){const t=e(o,n);a(t,$)}const i=o.w||"main";o.t===s.TERMINATED||o.t===s.COMPLETE&&"main"===i?(console.log("Closing stream due to COMPLETE message from main workstream"),d||(d=!0,v(),l(null))):o.t===s.COMPLETE&&console.log(`Received COMPLETE message from non-main workstream: ${i}, keeping stream open`)}catch(e){console.error("Failed to parse SSE message:",e,t.data)}else console.log("Received comment or heartbeat; ignoring it.: ",t.data)},_.onerror=t=>{if(!d)if(console.warn(`SSE stream error for run ${n}:`,t),v(),c<f){const t=w(c);console.log(`Attempting to reconnect in ${t}ms (attempt ${c+1}/10)`),c++,g=setTimeout(()=>{g=null,d||b(!0)},t)}else console.error(`Failed to reconnect to SSE stream for run ${n} after 10 attempts`),d=!0,u(new Error("SSE connection failed after 10 reconnection attempts"))}}catch(t){if(console.error("Error setting up SSE stream:",t),c<f){const t=w(c);c++,g=setTimeout(()=>{g=null,d||b(!0)},t)}else u(t)}};(async()=>{try{const e=await this.retrieveMessages(t,n,o);for(const t of e){p=Math.max(p,t.timestamp||0),a&&a(t,$);const e=t.workstream_id||"main";if(t.type===s.TERMINATED||t.type===s.COMPLETE&&"main"===e)return void $(null)}}catch(t){console.warn("Failed to fetch historical messages, continuing with SSE:",t)}b(!1)})().catch(u)})}async streamMessagesWS(t,e,n,a){return new Promise((o,i)=>{let l=0;const u=10;let c=null,p=a||0,d=!1;const h=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},y=async()=>{if(!d)try{const a=this.client,g=new URL(a.workflows.baseUrl+`/runs/${t}/${e}/ws`);g.protocol=g.protocol.replace("http","ws"),p>0&&g.searchParams.set("since",p.toString());const m=a._auth?await a._auth():void 0;if(!m)return void i(new Error("No auth token available"));const f=m.split(" ")[1];g.searchParams.set("access_token",f),l>0&&console.log(`Reconnecting to WebSocket for run ${e} (attempt ${l+1}/10)`),c=new WebSocket(g.href),c.onopen=()=>{l>0&&console.log(`Successfully reconnected to WebSocket for run ${e}`),l=0,d||o({cleanup:()=>{d=!0,c&&(c.close(),c=null)},sendSignal:(t,e)=>{if(c?.readyState===WebSocket.OPEN){const s={type:"signal",signalName:t,data:e,requestId:Date.now()};c.send(JSON.stringify(s))}else console.warn("WebSocket not open, cannot send signal")}})},c.onmessage=t=>{try{const e=JSON.parse(t.data);if("type"in e&&"string"==typeof e.type){if("pong"===e.type)return void console.debug("Received pong");if("ack"===e.type)return void console.debug("Signal acknowledged",e);if("error"===e.type)return void console.error("WebSocket error message",e)}const a=r(e);p=a.ts?Math.max(p,a.ts):Date.now(),n&&n(a);const o=a.w||"main";(a.t===s.TERMINATED||a.t===s.COMPLETE&&"main"===o)&&(console.log("Closing WebSocket due to workflow completion"),d=!0,c&&(c.close(),c=null))}catch(t){console.error("Failed to parse WebSocket message",t)}},c.onerror=t=>{console.error("WebSocket error",t)},c.onclose=()=>{if(!d&&l<u){const t=h(l);console.log(`WebSocket closed, reconnecting in ${t}ms (attempt ${l+1}/10)`),l++,setTimeout(y,t)}else l>=u&&i(new Error("WebSocket connection failed after 10 attempts"))}}catch(t){if(console.error("Error setting up WebSocket",t),l<u){const t=h(l);l++,setTimeout(y,t)}else i(t)}};y()})}ingestEvents(t,e,s){return this.post(`/runs/${t}/${e}/events`,{payload:{events:s}})}getAnalyticsSummary(t={}){return this.post("/analytics/summary",{payload:t})}getTokenUsageAnalytics(t={}){return this.post("/analytics/tokens",{payload:t})}getLlmLatencyAnalytics(t={}){return this.post("/analytics/latency/llm",{payload:t})}getToolLatencyAnalytics(t={}){return this.post("/analytics/latency/tools",{payload:t})}getAgentLatencyAnalytics(t={}){return this.post("/analytics/latency/agents",{payload:t})}getErrorAnalytics(t={}){return this.post("/analytics/errors",{payload:t})}getToolAnalytics(t={}){return this.post("/analytics/tools",{payload:t})}getToolParameterAnalytics(t){return this.post("/analytics/tools/parameters",{payload:t})}getAnalyticsFilterOptions(t={}){return this.post("/analytics/filter-options",{payload:t})}getPromptSizeAnalytics(t={}){return this.post("/analytics/prompt-size",{payload:t})}getTopPrincipalsAnalytics(t={}){return this.post("/analytics/top-principals",{payload:t})}getRunsByAgentAnalytics(t={}){return this.post("/analytics/runs-by-agent",{payload:t})}getTimeToFirstResponseAnalytics(t={}){return this.post("/analytics/time-to-first-response",{payload:t})}getFirstResponseBehaviorAnalytics(t={}){return this.post("/analytics/first-response-behavior",{payload:t})}rules=new At(this);definitions=new Ut(this)}class At extends w{constructor(t){super(t,"/rules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}execute(t,e,s){const r={objectIds:e,vars:s};return this.post(`/${t}/execute`,{payload:r})}}class Ut extends w{constructor(t){super(t,"/definitions")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}class Pt extends f{constructor(t={}){super(function(t){if(!t)throw new Error("zeno client serverUrl is required");return t}(t.serverUrl)),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.errorFactory=t=>404===t.status?new lt(t.request,t):t}withApiVersion(t){return t?this.headers[Et]=String(t):delete this.headers[Et],this}withApiKey(t){return this.withAuthCallback(t?()=>Promise.resolve(`Bearer ${t}`):void 0)}runOperation(t){return this.post("/api/v1/operations",{payload:t})}get initialHeaders(){return{...super.initialHeaders,[Et]:Tt}}agents=new Z(this);cost=new et(this);objects=new ft(this);types=new _t(this);workflows=new Rt(this);schedules=new St(this);files=new yt(this);commands=new rt(this);workers=new qt(this);collections=new tt(this);embeddings=new st(this);email=new ot(this);pendingAsks=new wt(this);data=new at(this);tools=new kt(this);indexing=new it(this);query=new vt(this);hiveMemory=new gt(this);rendering=new $t(this)}class It extends w{constructor(t){super(t,"/api/v1/training")}listSessions(t={}){return this.get("/",{query:t})}listSessionNames(t={}){return this.get("/names",{query:t})}createSession(t){return this.post("/",{payload:t})}getSession(t){return this.get("/"+t)}addToSession(t,e){return this.post("/"+t+"/add",{payload:{runs:e}})}listSessionRuns(t,e=100,s=0){return this.get("/"+t+"/runs",{query:{limit:e,offset:s}})}buildSession(t){return this.post("/"+t+"/build")}getDataUrl(t){return this.get("/"+t+"/url")}getDataUploadUrl(t,e=!1){return this.get("/"+t+"/upload-url",e?{query:{resumable:"true"}}:{})}startTraining(t){return this.post("/"+t+"/start")}cancelTraining(t){return this.post("/"+t+"/cancel")}getTrainingJob(t){return this.get(`/job/${t}`)}getAndSyncTrainingJob(t){return this.get(`/job/${t}`,{query:{sync:"true"}})}setDataset(t,e="default"){return this.post("/"+t+"/dataset",{payload:{dataset:e}})}}class Ot extends w{constructor(t){super(t,"/api/v1/users")}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}delete(t){return this.del("/"+t)}}class jt extends f{_jwt=null;store;sessionTags;tokenServerUrl;oauthClients;oauthGrants;oauthServer;oauthProviders;remoteMcpConnections;static async fromAuthToken(t,e,s){e||(e=Ct(t));const r=s||Dt(e.endpoints);return await new jt({serverUrl:r.studio,storeUrl:r.store,tokenServerUrl:r.token||e.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(t={site:"api.vertesia.io"}){let e,s;if(t.serverUrl)e=t.serverUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'serverUrl' is required for VertesiaClient");e=`https://${t.site}`}if(t.storeUrl)s=t.storeUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'storeUrl' is required for VertesiaClient");s=`https://${t.site}`}if(super(e),t.tokenServerUrl)this.tokenServerUrl=t.tokenServerUrl;else if(t.site){const e=t.site.replace("api-preview.","api.").replace(/^api/,"sts");this.tokenServerUrl=`https://${e}`}else if(t.serverUrl||t.storeUrl){const e=t.serverUrl||t.storeUrl||"";try{const t=new URL(e);if(t.hostname.startsWith("api")){const e=t.hostname.replace("api-preview.","api.").replace(/^api/,"sts");this.tokenServerUrl=`https://${e}`}else this.tokenServerUrl="https://sts.dev1.vertesia.io"}catch(t){this.tokenServerUrl="https://sts.dev1.vertesia.io"}}else this.tokenServerUrl="https://sts.dev1.vertesia.io";this.store=new Pt({serverUrl:s,tokenServerUrl:this.tokenServerUrl,apikey:t.apikey,onRequest:t.onRequest,onResponse:t.onResponse}),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.sessionTags=t.sessionTags,this.oauthClients=new L(this),this.oauthGrants=new B(this),this.oauthServer=new z(this),this.oauthProviders=new W(this),this.remoteMcpConnections=new Q(this)}withApiVersion(t){return t?this.headers[Et]=String(t):delete this.headers[Et],this}withAuthCallback(t){return this.store.withAuthCallback(t),super.withAuthCallback(t)}async withApiKey(t){return this.withAuthCallback(t?async()=>{if(!function(t){return t.startsWith("pk-")||t.startsWith("sk-")}(t))return`Bearer ${t}`;if(function(t){if(!t)return!0;const e=Ct(t).exp;return Date.now()<=1e3*e-6e4}(this._jwt)){const e=await this.getAuthToken(t);this._jwt=e.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){const t=await this._auth();this._jwt||(this._jwt=t.trim().split(" ")[1])}return this._jwt||null}async getDecodedJWT(){const t=await this.getRawJWT();return t?Ct(t):null}async getProject(){const t=await this.getDecodedJWT();return t?.project||null}async getAccount(){const t=await this.getDecodedJWT();return t?.account||null}get agents(){return this.store.agents}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get types(){return this.store.types}get data(){return this.store.data}get storeUrl(){return this.store.baseUrl}async getAuthToken(t){return fetch(`${this.tokenServerUrl}/token/issue`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}}).then(t=>t.json()).then(t=>t).catch(t=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:t}),t})}get initialHeaders(){return{...super.initialHeaders,[Et]:Tt}}projects=new J(this);environments=new T(this);interactions=new N(this);skills=new X(this);prompts=new G(this);runs=new Y(this);account=new v(this);accounts=new $(this);apikeys=new S(this);analytics=new b(this);auditTrail=new x(this);training=new It(this);users=new Ot(this);iam=new q(this);refs=new K(this);commands=new _(this);apps=new k(this)}function Ct(t){const e=function(t){const e=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(4*Math.ceil(t.length/4),"="),s=globalThis.Buffer;if(s)return s.from(e,"base64").toString("utf-8");if("undefined"!=typeof atob&&"undefined"!=typeof TextDecoder){const t=atob(e),s=Uint8Array.from(t,t=>t.charCodeAt(0));return(new TextDecoder).decode(s)}throw new Error("No base64 decoder available")}(t.split(".")[1]);return JSON.parse(e)}function Mt(){const t=globalThis.process;return t?.env?.STS_URL}function Dt(t){return t?"string"==typeof t?Ft(t):t:Ft("api.vertesia.io")}function Ft(t){if("local"===t)return{studio:"http://localhost:8091",store:"http://localhost:8092",token:Mt()??"https://sts.dev1.vertesia.io"};{const e=`https://${t}`;return{studio:e,store:e,token:e.replace("api","sts")}}}class Nt{id;client;constructor(t,e){this.id=t,this.client=e instanceof jt?e:new jt(e)}retrieve(){return this.client.interactions.retrieve(this.id)}update(t){return this.client.interactions.update(this.id,t)}render(t){throw new Error("Not implemented")}async execute(t={},e){return P(this.client,this.id,t,e)}}export{pt as ARTIFACTS_PREFIX,Z as AgentsApi,rt as CommandsApi,at as DataApi,ot as EmailApi,yt as FilesApi,gt as HiveMemoryApi,j as IS_INTERACTION_OUTPUT,it as IndexingApi,Nt as InteractionBase,D as InteractionOutput,ct as MEMORIES_PREFIX,L as OAuthClientsApi,B as OAuthGrantsApi,W as OAuthProvidersApi,z as OAuthServerApi,ft as ObjectsApi,wt as PendingAsksApi,vt as QueryApi,Q as RemoteMcpConnectionsApi,$t as RenderingApi,St as SchedulesApi,ut as StreamSource,xt as TypeCatalogApi,_t as TypesApi,jt as VertesiaClient,Rt as WorkflowsApi,Ut as WorkflowsDefinitionApi,At as WorkflowsRulesApi,Pt as ZenoClient,lt as ZenoClientNotFoundError,F as createInteractionOutput,Dt as decodeEndpoints,Ct as decodeJWT,M as enhanceExecutionRun,C as enhanceInteractionExecutionResult,ht as getAgentArtifactPath,dt as getMemoryFilePath};
|
|
1
|
+
import{ExecutionRunStatus as t,AgentMessageType as e,toAgentMessage as r,parseMessage as s,DataStoreApiHeaders as n,ContentObjectApiHeaders as i,canGenerateRendition as o,WorkflowExecutionStatus as a,isWorkflowTerminalStatus as u,APP_VERSION_HEADER as l}from"@vertesia/common";export{APP_VERSION_HEADER,Permission,canGenerateRendition,getOAuthPermissionScopes,getSupportedRenditionFormats,supportsVisualRendition}from"@vertesia/common";function c(t){return null!==t&&"object"==typeof t}function d(t){if(c(t))return t.details?t.details:c(t.error)?t.error.details:void 0}class h extends Error{status;payload;request;request_info;displayDetails;original_message;constructor(t,e,r,s,n=!0){super(function(t,e,r,s,n){let i=t;if(n){i+=`\nRequest: ${e.method} ${e.url} => ${r}`;const t=d(s);if(t){const e=typeof t;"string"===e?i+=`\nDetails: ${t}`:"object"===e&&(i+=`\nDetails: ${JSON.stringify(t,void 0,2)}`)}i+="\nStack Trace: "}return i}(t,e,r,s,n)),this.original_message=t,this.request=e,this.status=r,this.payload=s,this.request_info=`${e.method} ${e.url} => ${r}`,this.displayDetails=n}get details(){return d(this.payload)}}class p extends h{constructor(t,e,r,s,n=!0){super(t,e,r,s,n)}updateDetails(t){if(t!==this.details){const e=c(this.payload)?{...this.payload,details:t}:{details:t};return new p(this.original_message,this.request,this.status,e,this.displayDetails)}return this}}class y extends h{constructor(t,e){super(`Failed to connect to server: ${e.message}`,t,0,e)}}class g extends Error{constructor(t,e){super(t),this.name="ParseError",this.type=e.type,this.field=e.field,this.value=e.value,this.line=e.line}}const f=32;function m(t){}function w(t){if("function"==typeof t)throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=m,onError:r=m,onRetry:s=m,onComment:n,maxBufferSize:i}=t,o=[];let a,u,l=0,c=!0,d="",h=0,p=!1;function y(){void 0!==i&&(l+d.length<=i||(p=!0,o.length=0,l=0,a=void 0,d="",h=0,u=void 0,r(new g(`Buffered data exceeded max buffer size of ${i} characters`,{type:"max-buffer-size-exceeded"}))))}function w(t){let r=0;if(-1===t.indexOf("\r")){let s=t.indexOf("\n",r);for(;-1!==s;){if(r===s){h>0&&e({id:a,event:u,data:d}),a=void 0,d="",h=0,u=void 0,r=s+1,s=t.indexOf("\n",r);continue}const n=t.charCodeAt(r);if(v(t,r,n)){const n=t.charCodeAt(r+5)===f?r+6:r+5,i=t.slice(n,s);if(0===h&&10===t.charCodeAt(s+1)){e({id:a,event:u,data:i}),a=void 0,d="",u=void 0,r=s+2,s=t.indexOf("\n",r);continue}d=0===h?i:`${d}\n${i}`,h++}else $(t,r,n)?u=t.slice(t.charCodeAt(r+6)===f?r+7:r+6,s)||void 0:b(t,r,s);r=s+1,s=t.indexOf("\n",r)}return t.slice(r)}for(;r<t.length;){const e=t.indexOf("\r",r),s=t.indexOf("\n",r);let n=-1;if(-1!==e&&-1!==s?n=e<s?e:s:-1!==e?n=e===t.length-1?-1:e:-1!==s&&(n=s),-1===n)break;b(t,r,n),r=n+1,13===t.charCodeAt(r-1)&&10===t.charCodeAt(r)&&r++}return t.slice(r)}function b(t,r,s){if(r===s)return h>0&&e({id:a,event:u,data:d}),a=void 0,d="",h=0,void(u=void 0);const i=t.charCodeAt(r);if(v(t,r,i)){const e=t.charCodeAt(r+5)===f?r+6:r+5,n=t.slice(e,s);return d=0===h?n:`${d}\n${n}`,void h++}if($(t,r,i))return void(u=t.slice(t.charCodeAt(r+6)===f?r+7:r+6,s)||void 0);if(105===i&&100===t.charCodeAt(r+1)&&58===t.charCodeAt(r+2)){const e=t.slice(t.charCodeAt(r+3)===f?r+4:r+3,s);return void(a=e.includes("\0")?void 0:e)}if(58===i){if(n){const e=t.slice(r,s);n(e.slice(t.charCodeAt(r+1)===f?2:1))}return}const o=t.slice(r,s),l=o.indexOf(":");if(-1===l)return void S(o,"",o);const c=o.slice(0,l),p=o.charCodeAt(l+1)===f?2:1;S(c,o.slice(l+p),o)}function S(t,e,n){switch(t){case"event":u=e||void 0;break;case"data":d=0===h?e:`${d}\n${e}`,h++;break;case"id":a=e.includes("\0")?void 0:e;break;case"retry":/^\d+$/.test(e)?s(parseInt(e,10)):r(new g(`Invalid \`retry\` value: "${e}"`,{type:"invalid-retry",value:e,line:n}));break;default:r(new g(`Unknown field "${t.length>20?`${t.slice(0,20)}…`:t}"`,{type:"unknown-field",field:t,value:e,line:n}))}}return{feed:function(t){if(p)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,239===t.charCodeAt(0)&&187===t.charCodeAt(1)&&191===t.charCodeAt(2)&&(t=t.slice(3))),0===o.length){const e=w(t);return""!==e&&(o.push(e),l=e.length),void y()}if(-1===t.indexOf("\n")&&-1===t.indexOf("\r"))return o.push(t),l+=t.length,void y();o.push(t);const e=o.join("");o.length=0,l=0;const r=w(e);""!==r&&(o.push(r),l=r.length),y()},reset:function(t={}){if(t.consume&&o.length>0){const t=o.join("");b(t,0,t.length)}c=!0,a=void 0,d="",h=0,u=void 0,o.length=0,l=0,p=!1}}}function v(t,e,r){return 100===r&&97===t.charCodeAt(e+1)&&116===t.charCodeAt(e+2)&&97===t.charCodeAt(e+3)&&58===t.charCodeAt(e+4)}function $(t,e,r){return 101===r&&118===t.charCodeAt(e+1)&&101===t.charCodeAt(e+2)&&110===t.charCodeAt(e+3)&&116===t.charCodeAt(e+4)&&58===t.charCodeAt(e+5)}class b extends TransformStream{constructor(){let t;super({start(e){t=w({onEvent(t){const r={type:"event",...t};e.enqueue(r)}})},transform(e){t.feed(e)}})}}let S;if(globalThis.TextDecoderStream&&"function"==typeof globalThis.TextDecoderStream)S=globalThis.TextDecoderStream;else{class t extends TransformStream{_options;constructor(t="utf-8",{fatal:r=!1,ignoreBOM:s=!1}={}){super(new e(new TextDecoder(t,{fatal:r,ignoreBOM:s}))),this._options={fatal:r,ignoreBOM:s,encoding:t}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class e{decoder;constructor(t){this.decoder=t}transform(t,e){if(!(t instanceof ArrayBuffer||ArrayBuffer.isView(t)))throw new TypeError("Input must be a compatible with: ArrayBuffer | Uint8Array");const r=this.decoder.decode(t,{stream:!0});0!==r.length&&e.enqueue(r)}flush(t){const e=this.decoder.decode();0!==e.length&&t.enqueue(e)}}S=t}function _(t){return"/"===t[t.length-1]?t.slice(0,-1):t}const k=["GET","HEAD","OPTIONS","PUT","DELETE"],x=[502,503,504];function E(t){return null!==t&&"object"==typeof t}function R(t,e,r){const s=r?function(t){const e=t.headers.get("retry-after");if(!e)return;const r=Number(e);if(Number.isFinite(r)&&r>=0)return 1e3*r;const s=Date.parse(e);return Number.isNaN(s)?void 0:Math.max(0,s-Date.now())}(r):void 0,n=s??Math.min(t.maxDelayMs,t.baseDelayMs*2**e);return t.jitter?Math.floor(Math.random()*n):n}function T(t){return t instanceof Error?t:new Error(String(t))}function A(t){const e=AbortSignal.timeout;if("function"==typeof e)return e(t);const r=new AbortController;return setTimeout(()=>r.abort(new DOMException("The operation timed out","TimeoutError")),t),r.signal}async function q(t){try{await(t.body?.cancel())}catch{}}class P{_fetch;baseUrl;errorFactory=t=>t;verboseErrors=!0;retryPolicy;defaultTimeoutMs;constructor(t,e){this.baseUrl=_(t),this._fetch=function(t){return t?Promise.resolve(t):"function"==typeof globalThis.fetch?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw new Error("No Fetch implementation found")})}(e)}throwError(t){throw this.errorFactory(t)}withRetryPolicy(t){return this.retryPolicy=t||void 0,this}getRetryPolicy(){return this.retryPolicy}withTimeout(t){return this.defaultTimeoutMs="number"==typeof t&&t>0?t:void 0,this}getTimeout(){return this.defaultTimeoutMs}resolveTimeout(t){if("sse"===t?.reader)return;const e=t?.timeoutMs;if(!1===e||null===e)return;if("number"==typeof e)return e>0?e:void 0;const r=this.getTimeout();return r&&r>0?r:void 0}getUrl(t){return t.startsWith("http://")||t.startsWith("https://")?_(t):_((e=this.baseUrl,r=t,e.endsWith("/")?r.startsWith("/")?e+r.substring(1):e+r:r.startsWith("/")?e+r:`${e}/${r}`));var e,r}get(t,e){return this.request("GET",t,e)}del(t,e){return this.request("DELETE",t,e)}delete(t,e){return this.request("DELETE",t,e)}post(t,e){return this.request("POST",t,e)}put(t,e){return this.request("PUT",t,e)}jsonParse(t){return JSON.parse(t)}createRequest(t,e){return Promise.resolve(new Request(t,e))}handleFetchResponse(t,e){}createServerError(t,e,r){let s=`Server Error: ${e.status}`;return r&&(!function(t){return E(t)&&"Not a valid JSON payload"===t.error&&"string"==typeof t.text}(r)?E(r)&&r.message?s=String(r.message):E(r)&&r.error&&("string"==typeof r.error?s=String(r.error):E(r.error)&&"string"==typeof r.error.message&&(s=r.error.message)):(s+=e.statusText?` ${e.statusText}`:"",s+=": non-JSON response")),new p(s,t,e.status,r,this.verboseErrors)}async readJSONPayload(t){return t.text().then(e=>{if(e)try{return this.jsonParse(e)}catch(r){return{status:t.status,error:"Not a valid JSON payload",message:r instanceof Error?r.message:String(r),text:e}}}).catch(e=>{if(function(t){return"object"==typeof t&&null!==t&&"name"in t&&("TimeoutError"===t.name||"AbortError"===t.name)}(e))throw e;return{status:t.status,error:"Unable to load response content",message:e instanceof Error?e.message:String(e)}})}handleResponse(t,e,r){return r?.reader?"sse"===r.reader?async function(t){if(!t.ok){const e=await t.text(),r=new Error(`SSE error: ${t.status}. Content:\n${e}`);throw r.status=t.status,r}if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(new S).pipeThrough(new b)}(e):r.reader.call(this,e):this.readJSONPayload(e).then(r=>{if(e.ok)return r;this.throwError(this.createServerError(t,e,r))})}async request(t,e,r){let s=this.getUrl(e);r?.query&&(s+=`?${function(t){const e=[];for(const r of Object.keys(t)){const s=t[r];null!=s&&e.push(`${encodeURIComponent(r)}=${encodeURIComponent(String(s))}`)}return e.join("&")}(r.query)}`);const n=this.headers?Object.assign({},this.headers):{},i=r?.headers;if(i)for(const t in i)n[t.toLowerCase()]=i[t];let o;const a=r?.payload;a&&(r&&!1===r.jsonPayload?o=a:(o="string"!=typeof a?JSON.stringify(a):a,"content-type"in n||(n["content-type"]="application/json"))),"sse"===r?.reader&&(n.accept="text/event-stream");const u=t.toUpperCase(),l=this.resolveTimeout(r),c=()=>{const t=function(t){const e=t.filter(t=>!!t);if(0===e.length)return;if(1===e.length)return e[0];const r=AbortSignal.any;if("function"==typeof r)return r(e);const s=new AbortController;for(const t of e){if(t.aborted){s.abort(t.reason);break}t.addEventListener("abort",()=>s.abort(t.reason),{once:!0})}return s.signal}([r?.signal,l?A(l):void 0]),e={method:u,headers:Object.assign({},n),body:o};return t&&(e.signal=t),e},d=this.resolveRetryPolicy(r),h=await this._fetch;if(!d){const t=await this.createRequest(s,c());let e;try{e=await h(t)}catch(e){console.error(`Failed to connect to ${s}`,e),this.throwError(new y(t,T(e)))}return this.handleFetchResponse(t,e),this.handleResponse(t,e,r)}const p=function(t){return!(t&&"undefined"!=typeof ReadableStream&&t instanceof ReadableStream)}(o);let g;for(let t=0;t<d.attempts;t++){const e=await this.createRequest(s,c());let n;g=e;try{n=await h(e)}catch(r){this.shouldRetryConnectionError(d,u,t,p)||(console.error(`Failed to connect to ${s}`,r),this.throwError(new y(e,T(r)))),await this.waitBeforeRetry(d,t);continue}if(this.handleFetchResponse(e,n),!this.shouldRetryResponse(d,u,t,p,n))return this.handleResponse(e,n,r);await q(n),await this.waitBeforeRetry(d,t,n)}throw g&&this.throwError(new y(g,new Error(`Retry attempts exhausted for ${u} ${s}`))),new Error(`Retry attempts exhausted for ${u} ${s}`)}resolveRetryPolicy(t){if("sse"===t?.reader||!1===t?.retryPolicy||null===t?.retryPolicy)return;const e=t?.retryPolicy,r=this.getRetryPolicy();if(!e&&!r)return;const s=function(t){const e=Math.max(1,Math.floor(t.attempts??3)),r=Math.max(0,t.baseDelayMs??250),s=Math.max(r,t.maxDelayMs??4e3);return{attempts:e,methods:new Set((t.methods??k).map(t=>t.toUpperCase())),statuses:new Set(t.statuses??x),retryNonJsonServerErrors:t.retryNonJsonServerErrors??!0,retryOnConnectionError:t.retryOnConnectionError??!0,baseDelayMs:r,maxDelayMs:s,jitter:t.jitter??!0}}({...r,...e});return s.attempts>1?s:void 0}shouldRetryResponse(t,e,r,s,n){const i=t.statuses.has(n.status)||t.retryNonJsonServerErrors&&function(t){return!(t.status<500)&&!(t.headers.get("content-type")??"").toLowerCase().includes("json")}(n);return r<t.attempts-1&&s&&t.methods.has(e)&&i}shouldRetryConnectionError(t,e,r,s){return r<t.attempts-1&&s&&t.retryOnConnectionError&&t.methods.has(e)}waitBeforeRetry(t,e,r){const s=R(t,e,r);return new Promise(t=>setTimeout(t,s))}async sseRequest(t,e,r,s){const n=(await this.request(t,e,{...r,reader:"sse"})).getReader();let i;try{for(;;){const{done:t,value:e}=await n.read();if(t)break;i=e,s(e)}}finally{n.releaseLock()}return i}fetch(t,e){return this._fetch.then(r=>r(t,e))}}class U extends P{headers;_auth;onRequest;onResponse;response;constructor(t,e){super(t,e),this.baseUrl="/"===t[t.length-1]?t.substring(0,t.length-1):t,this.headers=this.initialHeaders}get initialHeaders(){const t={accept:"application/json"};return function(){const t=globalThis;return void 0===t.window&&("string"==typeof t.process?.versions?.node||"string"==typeof t.process?.versions?.bun||void 0!==t.Bun)}()&&(t["accept-encoding"]="br, gzip, deflate"),t}withAuthCallback(t){return this._auth=t||void 0,this}withErrorFactory(t){return this.errorFactory=t,this}withLang(t){return t?this.headers["accept-language"]=t:delete this.headers["accept-language"],this}withHeaders(t){const e=this.headers;for(const r in t){const s=t[r];null!=s&&(e[r.toLowerCase()]=s)}return this}setHeader(t,e){e?this.headers[t.toLowerCase()]=e:delete this.headers[t.toLowerCase()]}async createRequest(t,e){if(this._auth&&(!(r=e.headers)||!("authorization"in r))){const t=e.headers?e.headers:{};e.headers=t;const r=await this._auth();r&&(e.headers.authorization=r)}var r;this.response=void 0;const s=await super.createRequest(t,e);return this.onRequest?.(s),s}handleFetchResponse(t,e){this.response=e,this.onResponse?.(e,t)}}class C extends P{client;constructor(t,e){super(t.getUrl(e),t._fetch),this.client=t,this.createServerError=t.createServerError,this.errorFactory=t.errorFactory,this.verboseErrors=t.verboseErrors}createRequest(t,e){return this.client.createRequest(t,e)}handleResponse(t,e,r){return this.client.handleResponse(t,e,r)}handleFetchResponse(t,e){this.client.handleFetchResponse(t,e)}getRetryPolicy(){return this.client.getRetryPolicy()}getTimeout(){return this.client.getTimeout()}get headers(){return this.client.headers}}class I extends C{constructor(t){super(t,"/api/v1/account")}info(){return this.get("/")}update(t){return this.put("/",{payload:t})}projects(){return this.get("/projects").then(t=>t.data)}members(){return this.get("/members")}inviteUser(t){return this.post("/invites",{payload:t})}listInvites(){return this.get("/invites")}listInvitation(t="project"){return this.get(`/invites/${t}`)}acceptInvite(t){return this.put(`/invites/${t}`)}rejectInvite(t){return this.del(`/invites/${t}`)}onboardingProgress(){return this.get("/onboarding")}getStripeBillingStatus(){return this.get("/stripe-billing-status")}}class j extends C{constructor(t){super(t,"/api/v1/accounts")}create(t){return this.post("/",{payload:{name:t}})}list(){return this.get("/")}}class O extends C{constructor(t){super(t,"/api/v1/analytics")}runsSummary(t,e){const r=new URLSearchParams;t?.start&&r.set("start",t.start),t?.end&&r.set("end",t.end),e&&r.set("environment",e);const s=r.toString();return this.get("/runs/summary"+(s?`?${s}`:""))}runsTimeSeries(t,e){const r=new URLSearchParams;t?.start&&r.set("start",t.start),t?.end&&r.set("end",t.end),e&&r.set("environment",e);const s=r.toString();return this.get("/runs/time-series"+(s?`?${s}`:""))}runsTokenUsage(t,e){const r=new URLSearchParams;t?.start&&r.set("start",t.start),t?.end&&r.set("end",t.end),e&&r.set("environment",e);const s=r.toString();return this.get("/runs/token-usage"+(s?`?${s}`:""))}}class M extends C{constructor(t){super(t,"/api/v1/apikeys")}list(t="account"){return this.get("/",{query:{level:t}})}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}retrieve(t,e=!1){return e?this.get(`/${t}`,{query:{withValue:!0}}):this.get(`/${t}`)}delete(t){return this.del(`/${t}`)}getToken(t){return this.get(`/${t}/token`)}requestPublicKey(t={}){return this.get("/pk",{query:t})}}class D extends C{constructor(t){super(t,"/api/v1/apps")}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}previewDelete(t){return this.del(`/${t}`)}deleteApp(t){return this.del(`/${t}`,{query:{confirm:"true"}})}listVersions(t){return this.get("/versions",{query:{...t?.app_id&&{app_id:t.app_id},...t?.kind&&{kind:t.kind},...void 0!==t?.include_expired&&{include_expired:t.include_expired},...void 0!==t?.limit&&{limit:t.limit}}})}upsertVersion(t){return this.post("/versions",{payload:t})}getVersion(t){return this.get(`/versions/${t}`)}activateVersion(t){return this.post(`/versions/${t}/activate`)}startBuild(t,e){return this.post(`/${encodeURIComponent(t)}/builds`,{payload:e})}getBuildProgress(t,e,r){return this.get(`/${encodeURIComponent(t)}/builds/${encodeURIComponent(e)}/${encodeURIComponent(r)}/progress`)}listAppInstallationTools(t){return this.get(`/installations/${t}/tools`)}inspect(t){return this.get(`/${t}/inspect`)}getAppInstallationPackage(t,e="all"){return this.get(`/installations/${t}/package`,{query:{scope:Array.isArray(e)?e.join(","):e}})}getSystemToolsPackage(t="tools"){return this.get("/studio-tools/package",{query:{scope:t}})}list(){return this.get("/")}install(t,e,r,s){return this.post("/install",{payload:{app_id:t,settings:e,oauth_params:r,oauth_provider_params:s}})}uninstall(t){return this.del(`/install/${t}`)}getAppInstallationByName(t){return this.get(`/installations/name/${t}`).catch(t=>{if(404===t.status)return null;throw t})}getAppInstallationProjects(t){if(!t.id&&!t.name)throw new Error("Invalid arguments: appId or appName must be specified");const e=t.id?{id:t.id}:{name:t.name};return this.get("/installations/projects",{query:e})}getInstalledApps(t){return this.get("/installations",{query:{kind:t}})}getAllAppInstallations(){return this.get("/installations/all")}listInstallations(){return this.get("/installations/refs")}updateInstallationSettings(t){return this.put(`/installations/settings/${t.app_id}`,{payload:{app_id:t.app_id,settings:t.settings,..."access_control"in t?{access_control:t.access_control}:{}}})}updateToolAllowlist(t,e){return this.put(`/installations/${t}/tool-allowlist`,{payload:{tool_allowlist:e}})}validateUrl(t){return this.post("/validate-url",{payload:{url:t}})}}class F extends C{constructor(t){super(t,"/api/v1/audit-trail")}list(t){const e=new URLSearchParams;t?.actions?.length&&e.set("actions",t.actions.join(",")),t?.resourceTypes?.length&&e.set("resourceTypes",t.resourceTypes.join(",")),t?.resourceId&&e.set("resourceId",t.resourceId),t?.principalId&&e.set("principalId",t.principalId),t?.principalType&&e.set("principalType",t.principalType),t?.effectivePrincipalId&&e.set("effectivePrincipalId",t.effectivePrincipalId),void 0!==t?.hasEffectivePrincipal&&e.set("hasEffectivePrincipal",String(t.hasEffectivePrincipal)),t?.projectId&&e.set("projectId",t.projectId),t?.from&&e.set("from",t.from),t?.to&&e.set("to",t.to),t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset));const r=e.toString();return this.get("/"+(r?`?${r}`:""))}}class N extends C{constructor(t){super(t,"/api/v1/commands")}async isNamespaceAvailable(t){return this.get(`/namespaces/${t}/is_available`).then(t=>t.available)}async initSamples(){return this.post("/onboarding/init-samples")}}class L extends C{constructor(t){super(t,"/api/v1/environments")}list(t=!1){const e=t?{all:!0}:void 0;return this.get("/",{query:e})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}updateConfig(t,e){return this.put(`/${t}/config`,{payload:e})}listModels(t,e){return this.get(`/${t}/models`,{query:e?{...e}:void 0})}listTrainableModels(t){return this.get(`/${t}/trainable-models`)}embeddings(t,e){return this.post(`/${t}/embeddings`,{payload:e})}migrateInteractions(t){return this.post("/migrate-interactions",{payload:t})}}class B extends C{constructor(t){super(t,"/groups")}list(t){return this.get("/",{query:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}listMembers(t){return this.get(`/${t}/members`)}addMember(t,e){return this.post(`/${t}/members/${e}`)}removeMember(t,e){return this.del(`/${t}/members/${e}`)}syncMembers(){return this.post("/sync-members")}}class H extends C{constructor(t){super(t,"/api/v1/iam")}aces=new W(this);roles=new z(this);groups=new B(this);getPrincipalIdentity(){return this.get("/users/identity")}}class z extends C{constructor(t){super(t,"/roles")}list(){return this.get("/")}listSystem(){return this.get("/system")}}class W extends C{constructor(t){super(t,"/aces")}list(t){return this.get("/",{query:{...t}})}listProjectAces(){return this.get("/project")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}}const J=(()=>{const t="undefined"!=typeof process?process.env?.VERTESIA_INTERACTION_TIMEOUT_MS:void 0,e=t?Number.parseInt(t,10):NaN;return Number.isFinite(e)&&e>0?e:18e5})();async function V(){return"function"==typeof globalThis.EventSource?globalThis.EventSource:(await import("eventsource")).EventSource}async function G(e,r,s={},n){const i=!!n,o=await e.runs.create({...s,interaction:r,stream:i},{timeoutMs:i?void 0:J});if(i){if(o.status===t.failed)return o;await K(e,o.id,n)}return o}function K(t,e,r){return new Promise((s,n)=>{(async()=>{try{const i=await V(),o=new URL(`${t.runs.baseUrl}/${e}/stream`),a=t._auth?await t._auth():void 0;if(!a)throw new Error("No auth token available");{const t=a.split(" ")[1];o.searchParams.set("access_token",t)}const u=new i(o.href);u.addEventListener("message",t=>{try{const e=JSON.parse(t.data);e&&r?.(e)}catch(t){n(t)}}),u.addEventListener("close",t=>{try{u.close();const e=JSON.parse(t.data);s(e)}catch(t){n(t)}})}catch(t){n(t)}})()})}class Q extends C{constructor(t){super(t,"/api/v1/interactions/catalog")}list(t={}){return this.get("/",{query:t})}listStoredInteractions(t={}){return this.get("/stored",{query:t})}listSysInteractions(t){return this.get("/sys",{query:{tag:t}})}listAppInteractions(t,e){return this.get(`/apps/${t}`,{query:{tag:e}})}listAllAppInteractions(t){return this.get("/apps",{query:{tag:t}})}resolve(t){return this.get(`/resolve/${t}`)}}const Y=Symbol("InteractionOutput");function X(t){return t.result=tt.from(t.result),t}function Z(t){return t.result=tt.from(t.result),t}class tt{results;constructor(t){this.results=t}static from(t){return t?et(t)?t:Array.isArray(t)?rt(t):rt("object"==typeof t?[{type:"json",value:t}]:[{type:"text",value:String(t)}]):rt([])}static isInteractionOutputArray(t){return et(t)}get isEmpty(){return 0===this.results.length}hasObject(){return this.results.some(t=>"json"===t.type)}hasText(){return this.results.some(t=>"text"===t.type)}hasImage(){return this.results.some(t=>"image"===t.type)}text(t="\n"){return this.results.filter(t=>"text"===t.type).map(t=>t.value).join(t)}texts(){return this.results.filter(t=>"text"===t.type).map(t=>t.value)}object(){const t=this.results.find(t=>"json"===t.type);return t?t.value:function(t){let e;for(const r of t)if("text"===r.type){const t=r.value.trim();try{return JSON.parse(t)}catch(t){e=t instanceof Error?t:new Error(String(t))}}e||(e=new Error("No JSON result found and no text available to parse"));throw e}(this.results)}objects(){return this.results.filter(t=>"json"===t.type).map(t=>t.value)}objectAt(t){let e=0;for(const r of this.results)if("json"===r.type){if(e===t)return r.value;e++}throw new Error(`Object at index ${t} not found`)}image(){const t=this.results.find(t=>"image"===t.type);if(!t)throw new Error("No image result found");return t.value}images(){return this.results.filter(t=>"image"===t.type).map(t=>t.value)}stringify(t="\n",e=2){return this.results.map(t=>"json"===t.type?JSON.stringify(t.value,null,e):String(t.value)).join(t)}toString(){return this.text()}toJSON(){return this.results}}function et(t){return!!t&&"object"==typeof t&&!0===t[Y]}function rt(t){const e=new tt(t);return new Proxy(t,{get(t,r,s){if(r===Y)return!0;if(r in e){const t=Reflect.get(e,r,e);return"function"==typeof t?t.bind(e):t}return Reflect.get(t,r,s)}})}function st(t){return!!t&&"object"==typeof t&&"id"in t&&"string"==typeof t.id}class nt extends C{catalog;constructor(t){super(t,"/api/v1/interactions"),this.catalog=new Q(t)}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}listEndpoints(t){return this.post("/endpoints",{payload:t})}listVersionsByName(t){return this.get(`/versions/${t}`)}listTags(t){return this.get("/tags",{query:{...t}})}computeFacets(t){return this.post("/facets",{payload:t})}listNames(){return this.get("/names")}export(t){return this.post("/export",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t,e){const{cascade:r,query:s,...n}=e??{},i=r?{...s??{},cascade:"true"}:s??void 0;return super.delete(`/${t}`,{...n,query:i})}async execute(t,e={},r){return X(await G(this.client,t,e,r).catch(t=>{throw t instanceof p&&st(t.payload)?t.updateDetails({run_id:t.payload.id}):t}))}async executeByName(e,r={},s){const n=await async function(e,r,s={},n){const i=!!n,o=await e.post("/api/v1/execute",{payload:{...s,interaction:r,stream:i},timeoutMs:i?void 0:J});if(i){if(o.status===t.failed)return o;await K(e,o.id,n)}return o}(this.client,e,r,s).catch(t=>{throw t instanceof p&&st(t.payload)?t.updateDetails({run_id:t.payload.id}):t});return X(n)}executeAsync(t){return async function(t,e){return await t.post("/api/v1/execute/async",{payload:e})}(this.client,t)}publish(t,e){return this.post(`/${t}/publish`,{payload:e})}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}generateInteraction(t,e){return this.post(`${t}/generate-interaction`,{payload:e})}generateTestData(t,e){return this.post(`${t}/generate-test-data`,{payload:e})}suggestImprovements(t,e){return this.post(`${t}/suggest-prompt-improvements`,{payload:e})}suggestPromptImprovements(t){return this.post("/improve",{payload:t})}listVersions(t){return this.get(`/${t}/versions`)}listForks(t){return this.get(`/${t}/forks`)}requestSlot(t){return async function(t,e){return await t.post("/api/v1/execute/rate-limit/request",{payload:e})}(this.client,t)}resolve(t,e){return this.get(`/resolve/${encodeURIComponent(t)}`,{query:e})}}class it extends C{constructor(t){super(t,"/api/v1/oauth-clients")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}scopeMetadata(){return this.get("/scope-metadata")}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}remove(t){return this.del(`/${t}`)}}function ot(t){if(t)return Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t).map(([t,e])=>[t,String(e)]))}class at extends C{constructor(t){super(t,"/api/v1/oauth-grants")}list(t){return this.get("/",{query:ot(t)})}retrieve(t){return this.get(`/${t}`)}revoke(t,e){return this.del(`/${t}`,{query:e})}revokeBulk(t){return this.post("/revoke",{payload:t})}}class ut extends C{constructor(t){super(t,"/api/v1/oauth-providers")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}remove(t){return this.del(`/${t}`)}authorize(t){return this.get(`/${t}/authorize`)}exchange(t,e){return this.post("/exchange",{payload:{code:t,state:e}})}getStatus(t){return this.get(`/${t}/status`)}connect(t){return this.post(`/${t}/connect`,{payload:{}})}getToken(t){return this.post(`/${t}/token`,{payload:{}})}disconnect(t){return this.del(`/${t}/disconnect`)}}class lt extends P{parent;constructor(t,e){super(new URL("/oauth",`${e||t.baseUrl}/`).toString(),t._fetch),this.parent=t,this.createServerError=t.createServerError,this.errorFactory=t.errorFactory,this.verboseErrors=t.verboseErrors}get headers(){return this.parent.headers}createRequest(t,e){return this.parent.createRequest(t,e)}handleResponse(t,e,r){return this.parent.handleResponse(t,e,r)}handleFetchResponse(t,e){this.parent.handleFetchResponse(t,e)}getRetryPolicy(){return this.parent.getRetryPolicy()}createAuthorizationRequest(t){return this.post("/requests",{payload:t})}createDeviceAuthorization(t){return this.post("/device_authorization",{payload:t})}retrieveDeviceRequest(t){return this.get(`/device/${encodeURIComponent(t)}`)}retrieveRequest(t){return this.get(`/requests/${t}`)}retrieveGrantableScopes(t,e){return this.get(`/requests/${t}/grantable-scopes`,{query:{project_id:e}})}approveRequest(t,e){return this.post(`/requests/${t}/approve`,{payload:e})}denyRequest(t){return this.post(`/requests/${t}/deny`,{payload:{}})}}class ct extends C{integrations;constructor(t){super(t,"/api/v1/projects"),this.integrations=new dt(this)}list(t){return this.get("/",{query:{account:t}})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}updateConfiguration(t,e){return this.put(`/${t}/configuration`,{payload:e})}getTools(t){return this.get(`/${t}/tools`)}getToolByName(t,e){return this.get(`/${t}/tools/${e}`).catch(t=>{if(404===t.status)return null;throw t})}listAppContentTypes(t,e){return this.get(`/${t}/app-types`,{query:{tag:e}})}getAppContentType(t,e){return this.get(`/${t}/app-types/${e}`)}listAppProcesses(t,e){return this.get(`/${t}/app-processes`,{query:{tag:e}})}getAppProcess(t,e){return this.get(`/${t}/app-processes/${e}`)}listAppRenderingTemplates(t,e){return this.get(`/${t}/app-templates`,{query:{tag:e}})}getAppRenderingTemplate(t,e){return this.get(`/${t}/app-templates/${e}`)}getCompositeAppConfiguration(t){return this.get(`/${t}/composite-app`)}updateCompositeAppConfiguration(t,e){return this.put(`/${t}/composite-app`,{payload:e})}}class dt extends C{constructor(t){super(t,"/")}list(t){return this.get(`/${t}/integrations`).then(t=>t.integrations)}retrieve(t,e){return this.get(`/${t}/integrations/${e}`).catch(t=>{if(404!==t.status)throw t})}update(t,e,r){return this.put(`/${t}/integrations/${e}`,{payload:r})}updatePlugins(t,e){return this.post(`/${t}/plugins`,{payload:{plugins:e}})}listPlugins(t){return this.get(`/${t}/plugins`)}}class ht extends C{constructor(t){super(t,"/api/v1/prompts")}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}computeFacets(t){return this.post("/facets",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}render(t,e){return this.post(`/${t}/render`,{payload:e})}options(t){return this.get(`/options/${t}`)}listVersions(t){return this.get(`/${t}/versions`)}listInteractions(t){return this.get(`/${t}/interactions`)}listForks(t){return this.get(`/${t}/forks`)}}class pt extends C{constructor(t){super(t,"/api/v1/refs")}resolve(t){return this.post("/resolve",{payload:{refs:t}})}}class yt extends C{constructor(t){super(t,"/api/v1/remote-mcp-connections")}getStatus(t){return this.get(`/status/${t}`)}getCollectionStatus(t,e){return this.get(`/status/${t}/${e}`)}getMetadata(t,e){return this.get(`/metadata/${t}/${e}`)}authorize(t,e){return this.get(`/authorize/${t}/${e}`)}connect(t,e){return this.post(`/connect/${t}/${e}`,{})}disconnect(t,e){return this.del(`/disconnect/${t}/${e}`)}getCollectionToken(t,e){return this.post("/token",{payload:{app_install_id:t,collection_id:e}})}getToken(t){return this.post("/token",{payload:{mcp_server_url:t}})}}class gt extends C{constructor(t){super(t,"/api/v1/runs")}list({limit:t,offset:e,filters:r}){const s={limit:t,offset:e,...r};return this.get("/",{query:s})}find(t){return this.post("/find",{payload:t})}async retrieve(t){return Z(await this.get(`/${t}`))}retrievePopulated(t){return this.get(`/${t}`,{query:{populate:"true"}})}filterOptions(t,e){const r={...e};return this.get(`/filter-options/${t}`,{query:r})}async create(t,e){const r=this.client.sessionTags;if(r){let e=Array.isArray(r)?r:[r];Array.isArray(t.tags)?e=e.concat(t.tags):t.tags&&(e=e.concat([t.tags])),t={...t,tags:e}}return Z(await this.post("/",{payload:t,timeoutMs:e?.timeoutMs,signal:e?.signal}))}sendToolResults(t){return this.post("/tool-results",{payload:t})}sendUserMessage(t){return this.post("/user-message",{payload:t})}computeFacets(t){return this.post("/facets",{payload:t})}search(t){return this.post("/search",{payload:t})}clone(t){return this.post("/clone",{payload:t})}}class ft extends C{constructor(t){super(t,"/api/v1/secrets")}list(t,e){return this.get("/",{query:{...e,project_id:t}}).then(t=>t.secrets)}retrieve(t,e,r){return this.get(`/${e}`,{query:{...r,project_id:t}}).catch(t=>{if(404!==t.status)throw t})}create(t,e){return this.post("/",{query:{project_id:t},payload:e})}update(t,e,r,s){return this.put(`/${e}`,{query:{...s,project_id:t},payload:r})}remove(t,e,r){return this.del(`/${e}`,{query:{...r,project_id:t}})}fillWebsiteCredential(t,e,r){return this.post(`/${e}/actions/fill-browser`,{query:{project_id:t},payload:r})}}class mt extends C{constructor(t){super(t,"/api/v1/skills")}findRelevant(t,e){const r={context:t,limit:e};return this.post("/find-relevant",{payload:r})}findRelevantForTask(t,e){return this.findRelevant({task_description:t,tool_names:e})}}const wt=new Set([429,500,502,503,504]),vt=4,$t=500,bt=8e3;function St(t){return new Promise(e=>setTimeout(e,t))}function _t(t,e,r,s){const n=s?function(t){const e=t.headers.get("retry-after");if(!e)return;const r=Number(e);if(Number.isFinite(r)&&r>=0)return 1e3*r;const s=Date.parse(e);return Number.isNaN(s)?void 0:Math.max(0,s-Date.now())}(s):void 0;if(void 0!==n)return Math.min(r,n);const i=Math.min(r,e*2**t);return Math.floor(Math.random()*i)}const kt=new TextEncoder;function xt(t){if("string"==typeof t)return kt.encode(t);if(t instanceof Blob)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new TypeError(`Unsupported signed-URL upload chunk of type "${typeof t}"; body streams must yield string or binary (Uint8Array/ArrayBuffer/DataView/Blob) chunks.`)}async function Et(t,e={}){const{method:r="GET",headers:s,attempts:n=vt,baseDelayMs:i=$t,maxDelayMs:o=bt,retryableStatuses:a=wt}=e,u=await async function(t){if(null!=t){if("undefined"!=typeof ReadableStream&&t instanceof ReadableStream){const e=t.getReader(),r=[];try{for(;;){const{done:t,value:s}=await e.read();if(t)break;r.push(xt(s))}}catch(t){throw await e.cancel(t).catch(()=>{}),t}finally{e.releaseLock()}return new Blob(r)}return t}}(e.body);let l;for(let e=0;e<n;e++){const c=e===n-1;try{const n=await fetch(t,{method:r,headers:s,body:u});if(n.ok||!a.has(n.status)||c)return n;await(n.body?.cancel().catch(()=>{})),await St(_t(e,i,o,n))}catch(t){if(l=t,c)throw t;await St(_t(e,i,o))}}throw l instanceof Error?l:new Error(`Failed to fetch signed URL: ${t}`)}function Rt(t,e){const r=function(t){if(!t||"object"!=typeof t)return;const e=t.process_run_id;return"string"==typeof e?e:void 0}(t);return!r||r===e}function Tt(t,r){return(t.type===e.TERMINATED||t.type===e.COMPLETE&&"main"===(t.workstream_id??"main"))&&Rt(t.details,r)}function At(t,r){return(t.t===e.TERMINATED||t.t===e.COMPLETE&&"main"===(t.w??"main"))&&Rt(t.d,r)}class qt extends C{constructor(t){super(t,"/api/v1/agents")}start(t){return this.post("/",{payload:t})}recordRun(t){return this.post("/record",{payload:t})}createRecord(t){return this.recordRun(t)}retrieve(t){return this.get(`/${t}`)}retrieveRun(t){return this.get(`/${t}`)}retrieveProcess(t){return this.get(`/${t}`)}list(t){return this.get("/",{query:this.buildListQueryParams(t)})}async listProcessRuns(t){return(await this.get("/",{query:this.buildListQueryParams({...t,run_kind:"process"})})).items.filter(Pt)}buildListQueryParams(t){const e={};return t?.id&&(e.id=t.id),t?.status&&(e.status=Array.isArray(t.status)?t.status.join(","):t.status),t?.interaction&&(e.interaction=t.interaction),t?.started_by&&(e.started_by=t.started_by),t?.since&&(e.since=t.since.toISOString()),t?.until&&(e.until=t.until.toISOString()),t?.schedule_id&&(e.schedule_id=t.schedule_id),t?.type&&(e.type=t.type),t?.run_type&&(e.run_type=Array.isArray(t.run_type)?t.run_type.join(","):t.run_type),t?.run_kind&&(e.run_kind=t.run_kind),t?.limit&&(e.limit=String(t.limit)),t?.offset&&(e.offset=String(t.offset)),t?.cursor&&(e.cursor=t.cursor),t?.sort&&(e.sort=t.sort),t?.order&&(e.order=t.order),e}search(t){const e={};return t?.query&&(e.query=t.query),t?.status&&(e.status=Array.isArray(t.status)?t.status.join(","):t.status),t?.interaction&&(e.interaction=t.interaction),t?.started_by&&(e.started_by=t.started_by),t?.categories?.length&&(e.categories=t.categories.join(",")),t?.tags?.length&&(e.tags=t.tags.join(",")),t?.content_type_name&&(e.content_type_name=t.content_type_name),t?.since&&(e.since=t.since.toISOString()),t?.until&&(e.until=t.until.toISOString()),t?.limit&&(e.limit=String(t.limit)),t?.offset&&(e.offset=String(t.offset)),t?.sort?.length&&(e.sort=t.sort.join(",")),this.get("/search",{query:e})}terminate(t,e){const r=e?{reason:e}:void 0;return this.del(`/${t}`,{query:r})}restart(t){return this.post(`/${t}/restart`,{})}fork(t){return this.post(`/${t}/fork`,{})}getContext(t){return this.get(`/${t}/context`)}getHistory(t){return this.get(`/${t}/history`)}advance(t,e){return this.post(`/${t}/advance`,{payload:e??{}})}retryNode(t,e){return this.post(`/${t}/retry-node`,{payload:e??{}})}answerTask(t,e,r){return this.post(`/${t}/answer-task`,{payload:{task_id:e,result:r}})}updateStatus(t,e){return this.post(`/${t}/status`,{payload:e})}bindWorkflowRun(t,e){return this.post(`/${t}/workflow`,{payload:e})}sendSignal(t,e,r){return this.post(`/${t}/signal/${e}`,{payload:r})}query(t,e){return this.get(`/${t}/query/${e}`)}getActiveWorkstreams(t){return this.query(t,"ActiveWorkstreams")}async retrieveMessages(t,e){const n=e?{since:e}:void 0;return(await this.get(`/${t}/updates`,{query:n})).messages.map(e=>r(s(e),t))}postMessage(t,e){return this.post(`/${t}/updates`,{payload:e})}async streamMessages(t,e,n,i,o){let a=()=>{},u=()=>{};const l=new Promise((t,e)=>{a=t,u=e});let c=0,d=n||0;const h=Date.now();let p=!1,y=null,g=null,f=null,m=null;const w=t=>{const e=Math.min(1e3*2**t,3e4);return e+.1*Math.random()*e},v=()=>{f&&(clearTimeout(f),f=null),g&&(clearInterval(g),g=null),y&&(y.close(),y=null),i&&m&&(i.removeEventListener("abort",m),m=null)},$=t=>{p||(p=!0,v(),a(t))},b=r=>{if(p)return;v(),console.warn(`Agent stream ${t}: SSE unavailable after 10 attempts; falling back to /updates polling.`,r instanceof Error?r.message:r);const s=async()=>{if(!p){try{const r=await this.retrieveMessages(t,d||void 0);for(const s of r){if(p)return;if(!((s.timestamp||0)<=d)){if(d=s.timestamp||d,e&&e(s,$),p)return;if(Tt(s,t))return void $(null)}}}catch{}if(!p){try{const e=await this.get(`/${t}`);if(r=e?.status,"string"==typeof r&&["completed","failed","cancelled"].includes(r))return void $(null)}catch{}var r;p||(f=setTimeout(()=>{f=null,s()},5e3))}}};s()};if(i){if(i.aborted)return p=!0,v(),a(null),l;m=()=>{$(null)},i.addEventListener("abort",m,{once:!0})}try{if(!p){const r=await this.retrieveMessages(t,n);o?.onHistoryLoaded?.(r);let s=!1;for(let n=0;n<r.length;n++){const i=r[n];if(p)break;if(d=Math.max(d,i.timestamp||0),e&&e(i,$),p)break;s=n===r.length-1&&Tt(i,t)}if(s)return $(null),l}}catch(t){p||(o?.onHistoryError?.(t),console.warn("Failed to fetch historical messages, continuing with SSE:",t))}!p&&d<=0&&(d=Math.max(1,h-1));const S=async(n=!1)=>{if(!p)try{const i=await V();if(p)return;const o=this.client,a=new URL(`${o.agents.baseUrl}/${t}/stream`);d>0&&a.searchParams.set("since",d.toString()),a.searchParams.set("skipHistory","true");const l=o._auth?await o._auth():void 0;if(p)return;if(!l)return p=!0,v(),void u(new Error("No auth token available"));const h=l.split(" ")[1];if(a.searchParams.set("access_token",h),n&&console.log(`Reconnecting to agent stream ${t} (attempt ${c+1}/10)`),p)return;const m=new i(a.href);y=m,g=setInterval(()=>{},1e3);let _=0;m.onopen=()=>{n&&console.log(`Reconnected to agent stream ${t}`),_=Date.now()},m.onmessage=n=>{if(!p&&n.data&&!n.data.startsWith(":"))try{const i=s(n.data);if(d=i.ts?Math.max(d,i.ts):Date.now(),e){const s=r(i,t);e(s,$)}At(i,t)&&$(null)}catch(t){console.error("Failed to parse SSE message:",t,n.data)}},m.onerror=t=>{if(p)return;v();if((_?Date.now()-_:0)>5e3&&(c=0),c<10){const t=w(c);c++,f=setTimeout(()=>{f=null,p||S(!0)},t)}else b(new Error("SSE connection failed after 10 reconnection attempts"))}}catch(t){if(p)return;if(c<10){const t=w(c);c++,f=setTimeout(()=>{f=null,p||S(!0)},t)}else b(t)}};return S(!1),l}getInternals(t){return this.get(`/${t}/internals`)}getRunDetails(t,e){const r={};return e?.includeHistory&&(r.include_history="true"),e?.hydratePayloads&&(r.hydrate_payloads="true"),this.get(`/${t}/details`,{query:r})}async streamRunDetails(t,e,r){const s=await V(),n=this.client,i=new URL(`${n.agents.baseUrl}/${t}/details/stream`),o=n._auth?await n._auth():void 0;if(!o)throw new Error("No auth token available");const a=o.split(" ")[1];return i.searchParams.set("access_token",a),new Promise((t,n)=>{const o=new s(i.href);let a=null;const u=()=>{o.close(),r&&a&&(r.removeEventListener("abort",a),a=null)};if(r){if(r.aborted)return u(),void t();a=()=>{u(),t()},r.addEventListener("abort",a,{once:!0})}o.addEventListener("history",t=>{try{const r=JSON.parse(t.data);e&&e({type:"history",data:r})}catch(t){}}),o.addEventListener("control",r=>{try{const s=JSON.parse(r.data);e&&e({type:"control",data:s}),"type"in s&&"done"===s.type&&(u(),t())}catch(t){}}),o.addEventListener("error",t=>{try{const r=JSON.parse(t.data);e&&e({type:"error",data:r})}catch(t){}}),o.onerror=t=>{u(),n(new Error("SSE connection failed for details stream"))}})}listChildren(t){return this.get(`/${t}/children`)}getChildDetails(t,e,r){const s={};return r?.includeHistory&&(s.include_history="true"),r?.hydratePayloads&&(s.hydrate_payloads="true"),this.get(`/${t}/children/${e}/details`,{query:s})}listArtifacts(t,e){const r=e?.visibility?{visibility:e.visibility}:void 0;return this.get(`/${t}/artifacts`,{query:r})}getArtifactUrl(t,e,r,s){const n={url:"1"};return r&&(n.disposition=r),s&&(n.filename=s),this.get(`/${t}/artifacts/${e}`,{query:n})}async uploadArtifact(t,e,r,s){const n=s||"application/octet-stream",i=await this.put(`/${t}/artifacts/${e}`,{headers:{"Content-Type":n}}),o=await Et(i.url,{method:"PUT",body:r,headers:{"Content-Type":n}});if(!o.ok)throw new Error(`Failed to upload artifact: ${o.statusText}`);return i}async downloadArtifact(t,e){const{url:r}=await this.getArtifactUrl(t,e,"attachment"),s=await Et(r);if(!s.ok)throw new Error(`Failed to download artifact: ${s.statusText}`);if(!s.body)throw new Error("No body in artifact download response");return s.body}ingestEvents(t,e){const r={events:e};return this.post(`/${t}/events`,{payload:r})}getAnalyticsSummary(t={}){return this.post("/analytics/summary",{payload:t})}getTokenUsageAnalytics(t={}){return this.post("/analytics/tokens",{payload:t})}getLlmLatencyAnalytics(t={}){return this.post("/analytics/latency/llm",{payload:t})}getToolLatencyAnalytics(t={}){return this.post("/analytics/latency/tools",{payload:t})}getAgentLatencyAnalytics(t={}){return this.post("/analytics/latency/agents",{payload:t})}getErrorAnalytics(t={}){return this.post("/analytics/errors",{payload:t})}getToolAnalytics(t={}){return this.post("/analytics/tools",{payload:t})}getToolParameterAnalytics(t){return this.post("/analytics/tools/parameters",{payload:t})}getAnalyticsFilterOptions(t={}){return this.post("/analytics/filter-options",{payload:t})}getPromptSizeAnalytics(t={}){return this.post("/analytics/prompt-size",{payload:t})}getTopPrincipalsAnalytics(t={}){return this.post("/analytics/top-principals",{payload:t})}getRunsByAgentAnalytics(t={}){return this.post("/analytics/runs-by-agent",{payload:t})}getTimeToFirstResponseAnalytics(t={}){return this.post("/analytics/time-to-first-response",{payload:t})}getFirstResponseBehaviorAnalytics(t={}){return this.post("/analytics/first-response-behavior",{payload:t})}}function Pt(t){return"process"===t.run_kind}class Ut extends C{constructor(t){super(t,"/api/v1/collections")}search(t){return this.post("/search",{payload:t})}computeListFacets(t){return this.post("/facets",{payload:t})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}addMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"add",members:e}})}listMembers(t,e){return this.get(`/${t}/members`,{query:{...e}})}computeFacets(t,e){return this.post(`/${t}/facets`,{payload:e})}searchMembers(t,e){return this.post(`/${t}/search`,{payload:e})}deleteMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"delete",members:e}})}addChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"add",children:e}})}deleteChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"delete",children:e}})}searchChildren(t,e={}){return this.post(`/${t}/children/search`,{payload:e})}delete(t){return this.del(`/${t}`)}updatePermissions(t,e){return this.put(`/${t}/permissions`,{payload:e})}propagatePermissions(t){return this.post(`/${t}/propagate-permissions`)}propagateSharedProperties(t){return this.post(`/${t}/propagate-shared-props`)}}class Ct extends C{constructor(t){super(t,"/api/v1/cost")}getAnalytics(t={}){return this.post("/analytics",{payload:t})}getGlobalAnalytics(t={}){return this.post("/analytics/global",{payload:t})}getModelPrices(t={}){return this.get("/model-prices",{query:{...t}})}getRunPrice(t){return this.post("/run-price",{payload:t})}getRunPriceComparison(t){return this.post("/run-price",{payload:{...t,include_comparison_pricing:!0}})}getExportUrl(t){const e=new URLSearchParams;t?.from&&e.set("from","number"==typeof t.from?new Date(t.from).toISOString():t.from),t?.to&&e.set("to","number"==typeof t.to?new Date(t.to).toISOString():t.to),t?.scope&&e.set("scope",t.scope),t?.project_id&&e.set("project_id",t.project_id),t?.workflow_id&&e.set("workflow_id",t.workflow_id);const r=e.toString();return`${this.baseUrl}/export${r?`?${r}`:""}`}}class It extends C{storeId;constructor(t,e){super(t,`/api/v1/data/${e}/dashboards`),this.storeId=e}storeHeaders(){return{[n.DATA_STORE_ID]:this.storeId}}list(t){const e=t?`?status=${t}`:"";return this.get(`/${e}`,{headers:this.storeHeaders()})}create(t){return this.post("/",{payload:t,headers:this.storeHeaders()})}retrieve(t){return this.get(`/${t}`,{headers:this.storeHeaders()})}update(t,e){return this.put(`/${t}`,{payload:e,headers:this.storeHeaders()})}delete(t){return this.del(`/${t}`,{headers:this.storeHeaders()})}bulkArchive(t){return this.post("/bulk/archive",{payload:{ids:t},headers:this.storeHeaders()})}bulkDelete(t){return this.post("/bulk/delete",{payload:{ids:t},headers:this.storeHeaders()})}listVersions(t,e){const r=new URLSearchParams;e?.snapshotsOnly&&r.set("snapshots_only","true"),e?.limit&&r.set("limit",String(e.limit));const s=r.toString()?`?${r}`:"";return this.get(`/${t}/versions${s}`,{headers:this.storeHeaders()})}getVersion(t,e){return this.get(`/${t}/versions/${e}`,{headers:this.storeHeaders()})}createSnapshot(t,e){return this.post(`/${t}/versions`,{payload:e,headers:this.storeHeaders()})}promoteVersion(t,e,r){return this.post(`/${t}/versions/${e}/promote`,{payload:r||{},headers:this.storeHeaders()})}setVersioningEnabled(t,e){return this.put(`/${t}/versioning`,{payload:{enabled:e},headers:this.storeHeaders()})}}class jt extends C{constructor(t){super(t,"/api/v1/data")}storeHeaders(t){return{[n.DATA_STORE_ID]:t}}list(){return this.get("/")}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`,{headers:this.storeHeaders(t)})}delete(t){return this.del(`/${t}`,{headers:this.storeHeaders(t)})}getSchema(t,e){const r=e?`?format=${e}`:"";return this.get(`/${t}/schema${r}`,{headers:this.storeHeaders(t)})}updateSchema(t,e){return this.put(`/${t}/schema`,{payload:e,headers:this.storeHeaders(t)})}getSchemaHistory(t){return this.get(`/${t}/schema/history`,{headers:this.storeHeaders(t)})}listTables(t){return this.get(`/${t}/tables`,{headers:this.storeHeaders(t)})}createTables(t,e){return this.post(`/${t}/tables`,{payload:e,headers:this.storeHeaders(t)})}getTable(t,e,r){const s=r?"?sample=true":"";return this.get(`/${t}/tables/${e}${s}`,{headers:this.storeHeaders(t)})}alterTable(t,e,r){return this.put(`/${t}/tables/${e}`,{payload:r,headers:this.storeHeaders(t)})}dropTable(t,e){return this.del(`/${t}/tables/${e}`,{headers:this.storeHeaders(t)})}import(t,e){return this.post(`/${t}/import`,{payload:e,headers:this.storeHeaders(t)})}getImportStatus(t,e){return this.get(`/${t}/import/${e}`,{headers:this.storeHeaders(t)})}listVersions(t,e){const r=e?"?snapshots_only=true":"";return this.get(`/${t}/versions${r}`,{headers:this.storeHeaders(t)})}createSnapshot(t,e){return this.post(`/${t}/versions`,{payload:e,headers:this.storeHeaders(t)})}rollback(t,e){return this.post(`/${t}/versions/${e}/rollback`,{headers:this.storeHeaders(t)})}queryVersion(t,e,r){return this.post(`/${t}/versions/${e}/query`,{payload:r,headers:this.storeHeaders(t)})}query(t,e){return this.post(`/${t}/query`,{payload:e,headers:this.storeHeaders(t)})}queryBatch(t,e){return this.post(`/${t}/query/batch`,{payload:{queries:e},headers:this.storeHeaders(t)})}validateQueries(t,e){return this.post(`/${t}/query/validate`,{payload:{queries:e},headers:this.storeHeaders(t)})}getDownloadInfo(t,e){const r=e?`?version_id=${e}`:"";return this.get(`/${t}/download${r}`,{headers:this.storeHeaders(t)})}dashboards(t){return new It(this.client,t)}}class Ot extends C{constructor(t){super(t,"/api/v1/email")}send(t){return this.post("/send",{payload:t})}resolveRoute(t){return this.post("/resolve-route",{payload:{route_key:t}})}createRoute(t){return this.post("/routes",{payload:t})}getRoute(t){return this.get(`/routes/${t}`)}updateRoute(t,e){return this.put(`/routes/${t}`,{payload:e})}forwardEmail(t,e){return this.post(`/routes/${t}/forward`,{payload:e})}}class Mt extends C{constructor(t,e="/api/v1/embeddings"){super(t,e)}async status(t){return this.get(`${t}/status`)}async activate(t,e){if(!e.environment)throw new Error("Invalid configuration: select environment");return this.post(`${t}/enable`,{payload:e})}async disable(t){return this.post(`${t}/disable`)}async recalculate(t){return this.post(`${t}/recalculate`)}}class Dt extends h{constructor(t,e){super(`Resource not found: ${e.message}`,t,404,e.payload)}}class Ft{stream;name;type;id;constructor(t,e,r,s){this.stream=t,this.name=e,this.type=r,this.id=s}}const Nt="memories",Lt="agents";function Bt(t){const e=t.endsWith(".tar.gz")?t:`${t}.tar.gz`;return`${Nt}/${e}`}function Ht(t,e){return`${Lt}/${t}/${e}`}class zt extends C{constructor(t){super(t,"/api/v1/files")}async deleteFile(t,e){return this.del(`/${t}`,{query:{prefix:e}})}getMetadata(t){return this.get("/metadata",{query:{file:t}})}setFileMetadata(t,e){const r={file:t,metadata:e};return this.put("/metadata",{payload:r})}getOrCreateBucket(){return this.post("/bucket")}ensureBucketReadAccess(t){const e={principal:t};return this.post("/bucket/read-access",{payload:e})}getBucketReadAccessStatus(t){return this.get("/bucket/read-access",{query:{principal:t}})}list(t){return this.get("/list",{query:{prefix:t}})}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,r){const s={file:t,name:e,disposition:r};return this.post("/download-url",{payload:s})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}bulkGetUploadUrls(t){return this.post("/bulk-upload-urls",{payload:t})}async bulkUpload(t,e=10){const r=t.map(t=>({name:t.name,mime_type:t.type,id:t instanceof Ft?t.id:void 0})),{files:s}=await this.bulkGetUploadUrls({files:r}),n=new Array(t.length);for(let r=0;r<t.length;r+=e){const i=t.slice(r,r+e);await Promise.all(i.map(async(t,e)=>{const i=r+e,{url:o,id:a,mime_type:u}=s[i],l=t instanceof Ft,c=t.type||u,d=await Et(o,{method:"PUT",body:l?t.stream:t,headers:c?{"Content-Type":c}:void 0});if(!d.ok)throw new Error(`Failed to upload file ${t.name}: ${d.statusText}`);const h=d.headers.get("etag")?.replace(/^"(.*)"$/,"$1");n[i]={source:a,name:t.name,type:c,etag:h}}))}return n}async uploadFile(t){return(await this.uploadFileWithPath(t)).id}async uploadFileWithPath(t){const e=t instanceof Ft,{url:r,id:s,path:n}=await this.getUploadUrl(t),i=await Et(r,{method:"PUT",body:e?t.stream:t,headers:{"Content-Type":t.type||"application/gzip"}}).catch(t=>{throw console.error("Failed to upload file",{err:t,url:r,id:s,path:n}),t});if(!i.ok)throw console.log(i),new Error(`Failed to upload file: ${i.statusText}`);return{id:s,path:n}}async downloadFile(t){const e=!t.startsWith("https:"),{url:r}=e?await this.getDownloadUrl(t):{url:t},s=await Et(r,{method:"GET"}).then(e=>{if(e.ok)return e;throw 404===e.status?new Error(`File at ${r} not found`):403===e.status?new Error(`File at ${r} is forbidden`):(console.log(e),new Error(`Failed to download file ${t}: ${e.statusText}`))}).catch(e=>{throw console.error(`Failed to download file ${t}.`,e),e});if(!s.body)throw new Error(`No body in response while downloading file ${t}`);return s.body}async copyFile(t,e){return(await this.post("/copy",{payload:{source:t,dest:e}})).dest}async uploadMemoryPack(t){const e=Bt(t.name),r=t.name.endsWith(".tar.gz")?t.name:`${t.name}.tar.gz`;if(t instanceof File){const s=t;return this.uploadFile(new Ft(s.stream(),r,s.type,e))}return this.uploadFile(new Ft(t.stream,r,t.type,e))}async downloadMemoryPack(t,e=!1){let r=await this.downloadFile(Bt(t));if(e){const t=new DecompressionStream("gzip");r=r.pipeThrough(t)}return r}listByPrefix(t){return this.get("/list",{query:{prefix:t}})}async uploadArtifact(t,e,r){const s=Ht(t,e);if(r instanceof File){const t=r;return this.uploadFile(new Ft(t.stream(),e,t.type,s))}return this.uploadFile(new Ft(r.stream,e,r.type,s))}async downloadArtifact(t,e){const r=Ht(t,e);return this.downloadFile(r)}getArtifactDownloadUrl(t,e,r){const s=Ht(t,e);return this.getDownloadUrl(s,e,r)}async listArtifacts(t){const e=`${Lt}/${t}/`;return(await this.listByPrefix(e)).files}}class Wt extends C{constructor(t){super(t,"/api/v1/hive-memory")}list(t){const e=new URLSearchParams;t?.category&&e.set("category",t.category),t?.scope&&e.set("scope",t.scope),t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset));const r=e.toString();return this.get(r?`/?${r}`:"/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}search(t){return this.post("/search",{payload:t})}recall(t,e){return this.post("/recall",{payload:{task_description:t,tools:e?.tools,category:e?.category,max_results:e?.maxResults}})}getFormatted(t){return this.get(`/${t}/formatted`)}recordUsage(t){return this.post(`/${t}/usage`,{})}getByCategory(t,e){const r=new URLSearchParams;e?.limit&&r.set("limit",String(e.limit)),e?.offset&&r.set("offset",String(e.offset));const s=r.toString();return this.get(`/category/${t}${s?`?${s}`:""}`)}getStats(){return this.get("/stats")}applyDecay(t){return this.post("/admin/decay",{payload:{days_threshold:t?.daysThreshold,decay_rate:t?.decayRate}})}archiveLowConfidence(t){return this.post("/admin/archive",{payload:{threshold:t}})}}class Jt extends C{constructor(t,e="/api/v1/indexing"){super(t,e)}async status(){return this.get("/status")}async reindex(t){return this.post("/reindex",{payload:t})}async reindexAgentRuns(t){return this.post("/agent-runs/reindex",{payload:t})}async analyzeDrift(){return this.post("/analyze-drift",{payload:{}})}async getDriftAnalysis(){return this.get("/drift-analysis")}async enableIndexing(){return this.post("/enable-indexing")}async disableIndexing(){return this.post("/disable-indexing")}async enableQueries(){return this.post("/enable-queries")}async disableQueries(){return this.post("/disable-queries")}index(t,e){return this.post("/internal/index",{payload:{object_id:t,document:e}})}delete(t){return this.post("/internal/delete",{payload:{object_id:t}})}bulkIndex(t,e){return this.post("/internal/bulk-index",{payload:{documents:t,target_index:e}})}ensureIndex(t){return this.post("/internal/ensure-index",{payload:{recreate:t}})}createReindexTarget(){return this.post("/internal/create-reindex-target",{payload:{}})}getStats(){return this.post("/internal/stats",{payload:{}})}fetchBatch(t,e){return this.post("/internal/fetch-batch",{payload:{cursor:t,limit:e}})}getNextIndexCursor(t,e,r){return this.post("/internal/next-cursor",{payload:{cursor:t,limit:e,count:r}})}analyzeDriftBatch(t,e){return this.post("/internal/analyze-drift-batch",{payload:{cursor:t,limit:e}})}triggerReindex(t){return this.post("/internal/trigger-reindex",{payload:t?{full_reindex:t.fullReindex,object_ids:t.objectIds,recreate_index:t.recreateIndex}:{}})}fetchDocumentsByIds(t){return this.post("/internal/fetch-by-ids",{payload:{object_ids:t}})}bulkDelete(t){return this.post("/internal/bulk-delete",{payload:{object_ids:t}})}getConfiguration(){return this.post("/internal/configuration",{payload:{}})}get zenoBulkBaseUrl(){const t=this.client.baseUrl;return t.includes("localhost:")||t.includes("127.0.0.1:")?"https://zeno-bulk-dev-main.api.dev1.vertesia.io":t.includes("zeno-server")?t.replace(/zeno-server/,"zeno-bulk"):t}zenoBulkPost(t,e){return this.client.post(this.zenoBulkBaseUrl+t,{payload:e})}computeShards(t,e,r,s){return this.zenoBulkPost("/reindex/compute-shards",{tenant_id:t,shard_size:e??25e4,updated_since:r,backend:s})}indexShard(t){return this.zenoBulkPost("/reindex/shard",{params:t})}swapAlias(t,e,r,s){return this.zenoBulkPost("/reindex/swap-alias",{tenant_id:t,target_index:e,alias:r,backend:s})}async reindexViaBulk(t,e,r,s,n,i){const o=`${this.zenoBulkBaseUrl}/reindex`,a={tenant_id:t,project_id:n,dry_run:r??!1,backend:s,shard_size:i?.shardSize,shards:i?.shards,bulk_concurrency:i?.bulkConcurrency,bulk_size_bytes:i?.bulkSizeBytes,bulk_max_docs:i?.bulkMaxDocs};if(!e)return this.client.post(o,{payload:{params:a}});let u;if(await this.client.sseRequest("POST",o,{payload:{params:a}},t=>{if(e(t),"event"===t.type&&"done"===t.event)try{u=JSON.parse(t.data)}catch{}}),!u)throw new Error("zeno-bulk SSE stream ended without a done event");return u}}class Vt extends C{objectId;constructor(t,e){super(t,`/${e}/analyze`),this.objectId=e}async start(t){return this.post("/",{payload:t})}async getStatus(){return this.get("/status")}async getResults(){return this.get("/results")}async adaptTables(t){return this.post("/adapt_tables",{payload:t})}async getAdaptedTables(t,e){const r=t?`/adapt_tables/${t}`:"/adapt_tables",s={};e?.format&&(s.format=e.format),void 0!==e?.raw&&(s.raw=e.raw);const n={query:s};return"csv"===e?.format&&(n.responseType="text"),this.get(r,n)}async getXml(){return this.get("/xml")}async getTables(t){const e={};return t&&(e.query={format:t}),this.get("/tables",e)}async getImages(){return this.get("/images")}async getAnnotated(){return this.get("/annotated")}}class Gt extends C{constructor(t){super(t,"/api/v1/objects")}analyze(t){return new Vt(this,t)}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,r){return this.post("/download-url",{payload:{file:t,name:e,disposition:r}})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}getContentSource(t){return this.get(`/${t}/content-source`)}list(t={}){const e=t.limit||100,r=t.offset||0,s=t.query||{};return this.get("/",{query:{limit:e,offset:r,select:t.select,...s,all_revisions:t.all_revisions,from_root:t.from_root||void 0}})}computeFacets(t){return this.post("/facets",{payload:t})}listFolders(t="/"){throw new Error("Not implemented yet")}find(t){return this.post("/find",{payload:t})}count(t){return this.post("/count",{payload:t})}search(t){return this.post("/search",{payload:t})}retrieve(t,e){return this.get(`/${t}`,{query:{select:e}})}getObjectText(t){return this.get(`/${t}/text`)}async upload(t){const e=t instanceof Ft,{url:r,id:s,mime_type:n}=await this.getUploadUrl({id:e?t.id:void 0,name:t.name,mime_type:t.type}),i=t.type||n,o=await Et(r,{method:"PUT",body:e?t.stream:t,headers:i?{"Content-Type":i}:void 0}).catch(t=>{throw console.error("Failed to upload file",t),t});if(!o.ok)throw console.error("Failed to upload file",{status:o.status,statusText:o.statusText,url:r}),new Error(`Failed to upload file: ${o.statusText}`);const a=o.headers.get("etag")?.replace(/^"(.*)"$/,"$1");return{source:s,name:t.name,type:i,etag:a}}async create(t,e){const{content:r,...s}=t,n={...s};r instanceof Ft||r instanceof File?n.content=await this.upload(r):n.content=r;const o={};return e?.processing_priority&&(o[i.PROCESSING_PRIORITY]=e.processing_priority),e?.collection_id&&(o[i.COLLECTION_ID]=e.collection_id),await this.post("/",{payload:n,headers:o})}async createFromExternalSource(t,e={},r){const s=await this.client.files.getMetadata(t),n={...e,content:{source:t,name:s.name,type:s.contentType,etag:s.etag}},o={};return r?.processing_priority&&(o[i.PROCESSING_PRIORITY]=r.processing_priority),r?.collection_id&&(o[i.COLLECTION_ID]=r.collection_id),await this.post("/",{payload:n,headers:o})}async update(t,e,r){const{content:s,...n}=e,o={...n};s instanceof Ft||s instanceof File?o.content=await this.upload(s):o.content=s;const a={};return r?.ifMatch&&(a["if-match"]=r.ifMatch),r?.processing_priority&&(a[i.PROCESSING_PRIORITY]=r.processing_priority),r?.createRevision&&(a[i.CREATE_REVISION]="true",r.revisionLabel&&(a[i.REVISION_LABEL]=r.revisionLabel)),r?.suppressWorkflows&&(a[i.SUPPRESS_WORKFLOWS]="true"),this.put(`/${t}`,{payload:o,headers:a})}getRevisions(t){return this.get(`/${t}/revisions`)}getCollections(t){return this.get(`/${t}/collections`)}delete(t){return Array.isArray(t)?this.client.runOperation({name:"delete",ids:t,params:{}}):this.del(`/${t}`)}bulkUpdate(t){const e=Object.keys(t);return this.client.runOperation({name:"update",ids:e,params:t})}bulkCreate(t,e){return this.client.runOperation({name:"create",ids:[],params:{objects:t,...e}})}listWorkflowRuns(t){return this.get(`/${t}/workflow-runs`)}listRenditions(t){return this.get(`/${t}/renditions`)}getRendition(t,e){const r={max_hw:e.max_hw,generate_if_missing:e.generate_if_missing,sign_url:e.sign_url,block_on_generation:e.block_on_generation};return this.get(`/${t}/renditions/${e.format}`,{query:r})}getRenditionSafe(t,e,r){return o(e,r.format)?this.getRendition(t,r):Promise.resolve(null)}exportProperties(t){return this.post("/export",{payload:t})}setEmbedding(t,e,r){return this.put(`/${t}/embeddings/${e}`,{payload:r})}}class Kt extends C{constructor(t){super(t,"/api/v1/pending-asks")}register(t){return this.post("/",{payload:t})}resolve(t,e){return this.post(`/${t}/resolve`,{payload:e})}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}}class Qt extends C{constructor(t){super(t,"/api/v1/processes")}list(t){const e={};return t?.status&&(e.status=t.status),t?.process&&(e.process=t.process),null!=t?.limit&&(e.limit=String(t.limit)),null!=t?.offset&&(e.offset=String(t.offset)),t?.allVersions&&(e.all_versions="true"),this.get("/",{query:e})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}listVersions(t){return this.get(`/${t}/versions`)}publish(t,e){return this.post(`/${t}/publish`,{payload:e})}revert(t,e){return this.post(`/${t}/revert`,{payload:e})}delete(t){return this.del(`/${t}`)}}class Yt extends C{constructor(t,e="/api/v1/query"){super(t,e)}async execute(t){return this.post("/",{payload:t})}async sql(t){return this.execute({sql:t})}async esql(t){return this.execute({esql:t})}async dsl(t){return this.execute({dsl:t})}}class Xt extends C{constructor(t){super(t,"/api/v1/rendering")}start(t){return this.post("/jobs",{payload:t})}getStatus(t,e){return this.get("/jobs/status",{query:{workflow_id:t,workflow_run_id:e}})}async render(t,e={}){const r=e.pollIntervalMs??1500,s=e.timeoutMs??6e5,n=await this.start(t);if(!n.workflow_id||!n.workflow_run_id)throw new Error("Failed to start rendering workflow");const i=Date.now();for(;;){const e=await this.getStatus(n.workflow_id,n.workflow_run_id);if(e.status===a.COMPLETED){if(!e.download_url&&!e.file_uri)throw new Error(e.error||"Rendering completed but no output file was produced");return{status:"success",format:t.format,download_url:e.download_url,file_uri:e.file_uri}}if(u(e.status)){const t=a[e.status]||String(e.status);throw new Error(e.error||`Rendering failed with status: ${t}`)}if(Date.now()-i>=s)throw new Error(`Rendering timed out after ${s}ms`);await Zt(r)}}}function Zt(t){return new Promise(e=>setTimeout(e,t))}class te extends C{constructor(t){super(t,"/api/v1/schedules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}trigger(t){return this.post(`/${t}/trigger`,{})}pause(t,e){return this.post(`/${t}/pause`,{payload:{note:e}})}resume(t,e){return this.post(`/${t}/resume`,{payload:{note:e}})}}class ee extends C{constructor(t){super(t,"/api/v1/tasks")}list(t){const e={};return t?.status&&(e.status=Array.isArray(t.status)?t.status.join(","):t.status),t?.assignee&&(e.assignee=t.assignee),t?.run_id&&(e.run_id=t.run_id),t?.source_type&&(e.source_type=t.source_type),null!=t?.limit&&(e.limit=String(t.limit)),null!=t?.offset&&(e.offset=String(t.offset)),this.get("/",{query:e})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}complete(t,e){return this.post(`/${t}/complete`,{payload:e})}cancel(t){return this.post(`/${t}/cancel`,{})}delete(t){return this.del(`/${t}`)}}let re=class extends C{constructor(t){super(t,"/api/v1/tools")}getBuiltinCatalog(){return this.get("/")}};class se extends C{constructor(t){super(t,"/api/v1/types/catalog")}list(t={}){return this.get("/",{query:t})}listSysTypes(t){return this.get("/sys",{query:{tag:t}})}listAppTypes(t){return this.get("/apps",{query:{tag:t}})}listStoredTypes(t={}){return this.get("/stored",{query:t})}resolve(t){const e="string"==typeof t?t:t.id;return this.get(`/resolve/${e}`)}}class ne extends C{catalog;constructor(t){super(t,"/api/v1/types"),this.catalog=new se(t)}list(t={},e){const r=t.limit||2e3,s=t.offset||0,n=t.query||{};return this.get("/",{query:{limit:r,offset:s,layout:!!e?.layout,schema:!!e?.schema,...n}})}find(t){return this.post("/find",{payload:t})}retrieve(t){return this.get(`/${t}`)}getTypeByName(t){return this.get(`/name/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}const ie="20260319",oe="x-api-version";class ae extends C{constructor(t){super(t,"/api/v1/workflows")}getActivityCatalog(){return this.get("/activity-catalog")}listRuns(t,e,r){return this.post("/runs",{payload:{documentId:t,eventName:e,ruleId:r}})}listConversations(t){return this.post("/conversations",{payload:t})}searchRuns(t){return this.post("/runs",{payload:t})}sendSignal(t,e,r,s){return this.post(`/runs/${t}/${e}/signal/${r}`,{payload:s})}getRunDetails(t,e,r){const s={};return void 0!==r?.includeHistory&&(s.include_history=r.includeHistory),void 0!==r?.historyFormat&&(s.history_format=r.historyFormat),void 0!==r?.hydratePayloads&&(s.hydrate_payloads=r.hydratePayloads),this.get(`/runs/${e}/${t}`,{query:s})}getRunInteraction(t,e){return this.get(`/runs/${t}/${e}/interaction`)}terminate(t,e,r){const s={reason:r};return this.post(`/runs/${t}/${e}/actions/terminate`,{payload:s})}cancel(t,e,r){const s={reason:r};return this.post(`/runs/${t}/${e}/actions/cancel`,{payload:s})}query(t,e,r){return this.get(`/runs/${t}/${e}/query/${r}`)}execute(t,e={}){return this.post(`/execute/${t}`,{payload:e})}postMessage(t,e){if(!t)throw new Error("runId is required");return this.post(`/runs/${t}/updates`,{payload:e})}async retrieveMessages(t,e,n){const i={since:n};return(await this.get(`/runs/${t}/${e}/updates`,{query:i})).messages.map(t=>r(s(t),e))}async streamMessages(t,n,i,o,a){return new Promise((u,l)=>{let c=0,d=o||0;const h=Date.now();let p=!1,y=null,g=null,f=null,m=null;const w=10,v=t=>{const e=Math.min(1e3*2**t,3e4);return e+.1*Math.random()*e},$=()=>{f&&(clearTimeout(f),f=null),g&&(clearInterval(g),g=null),y&&(y.close(),y=null),a&&m&&(a.removeEventListener("abort",m),m=null)},b=t=>{p||(p=!0,$(),u(t))};if(a){if(a.aborted)return void b(null);m=()=>b(null),a.addEventListener("abort",m,{once:!0})}const S=async(o=!1)=>{if(!p)try{const a=await V(),h=this.client,m=new URL(`${h.workflows.baseUrl}/runs/${t}/${n}/stream`);d>0&&m.searchParams.set("since",d.toString()),m.searchParams.set("skipHistory","true");const _=h._auth?await h._auth():void 0;if(p)return;if(!_)return p=!0,$(),void l(new Error("No auth token available"));const k=_.split(" ")[1];m.searchParams.set("access_token",k),o&&console.log(`Reconnecting to SSE stream for run ${n} (attempt ${c+1}/10)`);const x=new a(m.href);y=x,g=setInterval(()=>{},1e3),x.onopen=()=>{o&&console.log(`Successfully reconnected to SSE stream for run ${n}`),c=0},x.onmessage=t=>{if(t.data&&!t.data.startsWith(":"))try{const o=s(t.data);if(d=o.ts?Math.max(d,o.ts):Date.now(),i){const t=r(o,n);i(t,b)}At(o,n)?(console.log("Closing stream due to COMPLETE message from main workstream"),p||(p=!0,$(),u(null))):o.t===e.COMPLETE&&console.log(`Received COMPLETE message that does not close the root stream for run ${n}`)}catch(e){console.error("Failed to parse SSE message:",e,t.data)}else console.log("Received comment or heartbeat; ignoring it.: ",t.data)},x.onerror=t=>{if(!p)if(console.warn(`SSE stream error for run ${n}:`,t),$(),c<w){const t=v(c);console.log(`Attempting to reconnect in ${t}ms (attempt ${c+1}/10)`),c++,f=setTimeout(()=>{f=null,p||S(!0)},t)}else console.error(`Failed to reconnect to SSE stream for run ${n} after 10 attempts`),p=!0,l(new Error("SSE connection failed after 10 reconnection attempts"))}}catch(t){if(console.error("Error setting up SSE stream:",t),c<w){const t=v(c);c++,f=setTimeout(()=>{f=null,p||S(!0)},t)}else l(t)}};(async()=>{try{const e=await this.retrieveMessages(t,n,o);let r=!1;for(let t=0;t<e.length;t++){const s=e[t];d=Math.max(d,s.timestamp||0),i&&i(s,b),r=t===e.length-1&&Tt(s,n)}if(r)return void b(null)}catch(t){console.warn("Failed to fetch historical messages, continuing with SSE:",t)}!p&&d<=0&&(d=Math.max(1,h-1)),S(!1)})().catch(l)})}async streamMessagesWS(t,r,n,i){return new Promise((o,a)=>{let u=0;const l=10;let c=null,d=i||0,h=!1;const p=t=>{const e=Math.min(1e3*2**t,3e4);return e+.1*Math.random()*e},y=async()=>{if(!h)try{const i=this.client,g=new URL(`${i.workflows.baseUrl}/runs/${t}/${r}/ws`);g.protocol=g.protocol.replace("http","ws"),d>0&&g.searchParams.set("since",d.toString());const f=i._auth?await i._auth():void 0;if(!f)return void a(new Error("No auth token available"));const m=f.split(" ")[1];g.searchParams.set("access_token",m),u>0&&console.log(`Reconnecting to WebSocket for run ${r} (attempt ${u+1}/10)`),c=new WebSocket(g.href),c.onopen=()=>{u>0&&console.log(`Successfully reconnected to WebSocket for run ${r}`),u=0,h||o({cleanup:()=>{h=!0,c&&(c.close(),c=null)},sendSignal:(t,e)=>{if(c?.readyState===WebSocket.OPEN){const r={type:"signal",signalName:t,data:e,requestId:Date.now()};c.send(JSON.stringify(r))}else console.warn("WebSocket not open, cannot send signal")}})},c.onmessage=t=>{try{const r=JSON.parse(t.data);if("type"in r&&"string"==typeof r.type){if("pong"===r.type)return void console.debug("Received pong");if("ack"===r.type)return void console.debug("Signal acknowledged",r);if("error"===r.type)return void console.error("WebSocket error message",r)}const i=s(r);d=i.ts?Math.max(d,i.ts):Date.now(),n&&n(i);const o=i.w||"main";(i.t===e.TERMINATED||i.t===e.COMPLETE&&"main"===o)&&(console.log("Closing WebSocket due to workflow completion"),h=!0,c&&(c.close(),c=null))}catch(t){console.error("Failed to parse WebSocket message",t)}},c.onerror=t=>{console.error("WebSocket error",t)},c.onclose=()=>{if(!h&&u<l){const t=p(u);console.log(`WebSocket closed, reconnecting in ${t}ms (attempt ${u+1}/10)`),u++,setTimeout(y,t)}else u>=l&&a(new Error("WebSocket connection failed after 10 attempts"))}}catch(t){if(console.error("Error setting up WebSocket",t),u<l){const t=p(u);u++,setTimeout(y,t)}else a(t)}};y()})}ingestEvents(t,e,r){return this.post(`/runs/${t}/${e}/events`,{payload:{events:r}})}getAnalyticsSummary(t={}){return this.post("/analytics/summary",{payload:t})}getTokenUsageAnalytics(t={}){return this.post("/analytics/tokens",{payload:t})}getLlmLatencyAnalytics(t={}){return this.post("/analytics/latency/llm",{payload:t})}getToolLatencyAnalytics(t={}){return this.post("/analytics/latency/tools",{payload:t})}getAgentLatencyAnalytics(t={}){return this.post("/analytics/latency/agents",{payload:t})}getErrorAnalytics(t={}){return this.post("/analytics/errors",{payload:t})}getToolAnalytics(t={}){return this.post("/analytics/tools",{payload:t})}getToolParameterAnalytics(t){return this.post("/analytics/tools/parameters",{payload:t})}getAnalyticsFilterOptions(t={}){return this.post("/analytics/filter-options",{payload:t})}getPromptSizeAnalytics(t={}){return this.post("/analytics/prompt-size",{payload:t})}getTopPrincipalsAnalytics(t={}){return this.post("/analytics/top-principals",{payload:t})}getRunsByAgentAnalytics(t={}){return this.post("/analytics/runs-by-agent",{payload:t})}getTimeToFirstResponseAnalytics(t={}){return this.post("/analytics/time-to-first-response",{payload:t})}getFirstResponseBehaviorAnalytics(t={}){return this.post("/analytics/first-response-behavior",{payload:t})}rules=new ue(this);definitions=new le(this)}class ue extends C{constructor(t){super(t,"/rules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}execute(t,e,r){const s={objectIds:e,vars:r};return this.post(`/${t}/execute`,{payload:s})}}class le extends C{constructor(t){super(t,"/definitions")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}class ce extends U{constructor(t={}){super(function(t){if(!t)throw new Error("zeno client serverUrl is required");return t}(t.serverUrl),t.fetch),t.apikey&&this.withApiKey(t.apikey),t.retryPolicy&&this.withRetryPolicy(t.retryPolicy),void 0!==t.timeout&&this.withTimeout(t.timeout),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.errorFactory=t=>404===t.status?new Dt(t.request,t):t}withApiVersion(t){return t?this.headers[oe]=String(t):delete this.headers[oe],this}withAppVersion(t){return t?this.headers[l]=String(t):delete this.headers[l],this}withApiKey(t){return this.withAuthCallback(t?()=>Promise.resolve(`Bearer ${t}`):void 0)}runOperation(t){return this.post("/api/v1/operations",{payload:t})}get initialHeaders(){return{...super.initialHeaders,[oe]:ie}}agents=new qt(this);cost=new Ct(this);objects=new Gt(this);types=new ne(this);workflows=new ae(this);schedules=new te(this);processes=new Qt(this);tasks=new ee(this);files=new zt(this);collections=new Ut(this);embeddings=new Mt(this);email=new Ot(this);pendingAsks=new Kt(this);data=new jt(this);tools=new re(this);indexing=new Jt(this);query=new Yt(this);hiveMemory=new Wt(this);rendering=new Xt(this)}class de extends C{constructor(t){super(t,"/api/v1/tools")}list(t){const e={};return t?.sources?.length&&(e.sources=t.sources.join(",")),t?.exclude?.length&&(e.exclude=t.exclude.join(",")),this.get("/",{query:Object.keys(e).length>0?e:void 0})}validate(t){return this.post("/validate",{payload:{names:t}})}}class he extends C{constructor(t){super(t,"/api/v1/training")}listSessions(t={}){return this.get("/",{query:{...t}})}listSessionNames(t={}){return this.get("/names",{query:{...t}})}createSession(t){return this.post("/",{payload:t})}getSession(t){return this.get(`/${t}`)}addToSession(t,e){return this.post(`/${t}/add`,{payload:{runs:e}})}listSessionRuns(t,e=100,r=0){return this.get(`/${t}/runs`,{query:{limit:e,offset:r}})}buildSession(t){return this.post(`/${t}/build`)}getDataUrl(t){return this.get(`/${t}/url`)}getDataUploadUrl(t,e=!1){return this.get(`/${t}/upload-url`,e?{query:{resumable:"true"}}:{})}startTraining(t){return this.post(`/${t}/start`)}cancelTraining(t){return this.post(`/${t}/cancel`)}getTrainingJob(t){return this.get(`/job/${t}`)}getAndSyncTrainingJob(t){return this.get(`/job/${t}`,{query:{sync:"true"}})}setDataset(t,e="default"){return this.post(`/${t}/dataset`,{payload:{dataset:e}})}}class pe extends C{constructor(t){super(t,"/api/v1/users")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}}class ye extends U{_jwt=null;store;sessionTags;tokenServerUrl;oauthClients;oauthGrants;oauthServer;oauthProviders;remoteMcpConnections;secrets;static async fromAuthToken(t,e,r){e||(e=fe(t));const s=r||we(e.endpoints);return await new ye({serverUrl:s.studio,storeUrl:s.store,tokenServerUrl:s.token||e.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(t={site:"api.vertesia.io"}){let e,r;if(t.serverUrl)e=t.serverUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'serverUrl' is required for VertesiaClient");e=`https://${t.site}`}if(t.storeUrl)r=t.storeUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'storeUrl' is required for VertesiaClient");r=`https://${t.site}`}if(super(e,t.fetch),t.tokenServerUrl)this.tokenServerUrl=t.tokenServerUrl;else if(t.site){const e=t.site.replace("api-preview.","api.").replace(/^api/,"sts");this.tokenServerUrl=`https://${e}`}else if(t.serverUrl||t.storeUrl){const e=t.serverUrl||t.storeUrl||"";try{const t=new URL(e);if(t.hostname.startsWith("api")){const e=t.hostname.replace("api-preview.","api.").replace(/^api/,"sts");this.tokenServerUrl=`https://${e}`}else this.tokenServerUrl="https://sts.dev1.vertesia.io"}catch{this.tokenServerUrl="https://sts.dev1.vertesia.io"}}else this.tokenServerUrl="https://sts.dev1.vertesia.io";this.store=new ce({serverUrl:r,tokenServerUrl:this.tokenServerUrl,apikey:t.apikey,onRequest:t.onRequest,onResponse:t.onResponse,retryPolicy:t.retryPolicy,timeout:t.timeout,fetch:t.fetch}),t.retryPolicy&&this.withRetryPolicy(t.retryPolicy),void 0!==t.timeout&&this.withTimeout(t.timeout),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.sessionTags=t.sessionTags,this.oauthClients=new it(this),this.oauthGrants=new at(this),this.oauthServer=new lt(this,this.tokenServerUrl),this.oauthProviders=new ut(this),this.remoteMcpConnections=new yt(this),this.secrets=new ft(this)}withApiVersion(t){return t?this.headers[oe]=String(t):delete this.headers[oe],this}withAppVersion(t){return t?this.headers[l]=String(t):delete this.headers[l],this}withAuthCallback(t){return this.store.withAuthCallback(t),super.withAuthCallback(t)}withRetryPolicy(t){return this.store.withRetryPolicy(t),super.withRetryPolicy(t)}withTimeout(t){return this.store.withTimeout(t),super.withTimeout(t)}async withApiKey(t){return this.withAuthCallback(t?async()=>{if(!function(t){return t.startsWith("pk-")||t.startsWith("sk-")}(t))return`Bearer ${t}`;if(ge(this._jwt)){const e=await this.getAuthToken(t);this._jwt=e.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){const t=await this._auth();this._jwt||(this._jwt=t.trim().split(" ")[1])}return this._jwt||null}async getDecodedJWT(){const t=await this.getRawJWT();return t?fe(t):null}async getProject(){const t=await this.getDecodedJWT();return t?.project||null}async getAccount(){const t=await this.getDecodedJWT();return t?.account||null}get agents(){return this.store.agents}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get processes(){return this.store.processes}get tasks(){return this.store.tasks}get types(){return this.store.types}get data(){return this.store.data}get storeUrl(){return this.store.baseUrl}async getAuthToken(t){return this.post(`${this.tokenServerUrl}/token/issue`,{headers:{"content-type":"application/json",authorization:`Bearer ${t}`},retryPolicy:{attempts:4,methods:["POST"],statuses:[429,500,502,503,504]}}).catch(t=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:t}),t})}get initialHeaders(){return{...super.initialHeaders,[oe]:ie}}projects=new ct(this);environments=new L(this);interactions=new nt(this);skills=new mt(this);prompts=new ht(this);runs=new gt(this);account=new I(this);accounts=new j(this);apikeys=new M(this);analytics=new O(this);auditTrail=new F(this);training=new he(this);users=new pe(this);iam=new H(this);refs=new pt(this);commands=new N(this);apps=new D(this);tools=new de(this)}function ge(t){if(!t)return!0;const e=fe(t).exp;return Date.now()>=1e3*e-6e4}function fe(t){const e=function(t){const e=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(4*Math.ceil(t.length/4),"="),r=globalThis.Buffer;if(r)return r.from(e,"base64").toString("utf-8");if("undefined"!=typeof atob&&"undefined"!=typeof TextDecoder){const t=atob(e),r=Uint8Array.from(t,t=>t.charCodeAt(0));return(new TextDecoder).decode(r)}throw new Error("No base64 decoder available")}(t.split(".")[1]);return JSON.parse(e)}function me(){const t=globalThis.process;return t?.env?.STS_URL}function we(t){return t?"string"==typeof t?ve(t):t:ve("api.vertesia.io")}function ve(t){if("local"===t)return{studio:"http://localhost:8091",store:"http://localhost:8092",token:me()??"https://sts.dev1.vertesia.io",git:"https://git.dev1.vertesia.io"};{const e=`https://${t}`;return{studio:e,store:e,token:e.replace("api","sts"),git:e.replace("api","git")}}}class $e{id;client;constructor(t,e){this.id=t,this.client=e instanceof ye?e:new ye(e)}retrieve(){return this.client.interactions.retrieve(this.id)}update(t){return this.client.interactions.update(this.id,t)}render(t){throw new Error("Not implemented")}async execute(t={},e){return G(this.client,this.id,t,e)}}export{Lt as ARTIFACTS_PREFIX,qt as AgentsApi,jt as DataApi,Ot as EmailApi,zt as FilesApi,Wt as HiveMemoryApi,Y as IS_INTERACTION_OUTPUT,Jt as IndexingApi,$e as InteractionBase,tt as InteractionOutput,Nt as MEMORIES_PREFIX,it as OAuthClientsApi,at as OAuthGrantsApi,ut as OAuthProvidersApi,lt as OAuthServerApi,Gt as ObjectsApi,Kt as PendingAsksApi,Qt as ProcessApi,Yt as QueryApi,yt as RemoteMcpConnectionsApi,Xt as RenderingApi,te as SchedulesApi,ft as SecretsApi,Ft as StreamSource,ee as TaskApi,se as TypeCatalogApi,ne as TypesApi,ye as VertesiaClient,ae as WorkflowsApi,le as WorkflowsDefinitionApi,ue as WorkflowsRulesApi,ce as ZenoClient,Dt as ZenoClientNotFoundError,rt as createInteractionOutput,we as decodeEndpoints,fe as decodeJWT,Z as enhanceExecutionRun,X as enhanceInteractionExecutionResult,Et as fetchSignedUrl,Ht as getAgentArtifactPath,Bt as getMemoryFilePath,ge as isTokenExpired};
|
|
2
2
|
//# sourceMappingURL=vertesia-client.js.map
|