@vertesia/client 0.24.0-dev.202601221707
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/LICENSE +13 -0
- package/README.md +110 -0
- package/lib/cjs/AccountApi.js +85 -0
- package/lib/cjs/AccountApi.js.map +1 -0
- package/lib/cjs/AccountsApi.js +16 -0
- package/lib/cjs/AccountsApi.js.map +1 -0
- package/lib/cjs/AnalyticsApi.js +41 -0
- package/lib/cjs/AnalyticsApi.js.map +1 -0
- package/lib/cjs/ApiKeysApi.js +63 -0
- package/lib/cjs/ApiKeysApi.js.map +1 -0
- package/lib/cjs/AppsApi.js +119 -0
- package/lib/cjs/AppsApi.js.map +1 -0
- package/lib/cjs/CommandsApi.js +19 -0
- package/lib/cjs/CommandsApi.js.map +1 -0
- package/lib/cjs/EnvironmentsApi.js +72 -0
- package/lib/cjs/EnvironmentsApi.js.map +1 -0
- package/lib/cjs/GroupsApi.js +78 -0
- package/lib/cjs/GroupsApi.js.map +1 -0
- package/lib/cjs/IamApi.js +53 -0
- package/lib/cjs/IamApi.js.map +1 -0
- package/lib/cjs/InteractionBase.js +44 -0
- package/lib/cjs/InteractionBase.js.map +1 -0
- package/lib/cjs/InteractionCatalogApi.js +64 -0
- package/lib/cjs/InteractionCatalogApi.js.map +1 -0
- package/lib/cjs/InteractionOutput.js +300 -0
- package/lib/cjs/InteractionOutput.js.map +1 -0
- package/lib/cjs/InteractionResult.example.js +57 -0
- package/lib/cjs/InteractionResult.example.js.map +1 -0
- package/lib/cjs/InteractionsApi.js +262 -0
- package/lib/cjs/InteractionsApi.js.map +1 -0
- package/lib/cjs/MCPOAuthApi.js +62 -0
- package/lib/cjs/MCPOAuthApi.js.map +1 -0
- package/lib/cjs/ProjectsApi.js +72 -0
- package/lib/cjs/ProjectsApi.js.map +1 -0
- package/lib/cjs/PromptsApi.js +133 -0
- package/lib/cjs/PromptsApi.js.map +1 -0
- package/lib/cjs/RefsApi.js +14 -0
- package/lib/cjs/RefsApi.js.map +1 -0
- package/lib/cjs/RunsApi.js +113 -0
- package/lib/cjs/RunsApi.js.map +1 -0
- package/lib/cjs/SkillsApi.js +39 -0
- package/lib/cjs/SkillsApi.js.map +1 -0
- package/lib/cjs/StreamSource.js +17 -0
- package/lib/cjs/StreamSource.js.map +1 -0
- package/lib/cjs/TrainingApi.js +54 -0
- package/lib/cjs/TrainingApi.js.map +1 -0
- package/lib/cjs/UsersApi.js +13 -0
- package/lib/cjs/UsersApi.js.map +1 -0
- package/lib/cjs/client.js +360 -0
- package/lib/cjs/client.js.map +1 -0
- package/lib/cjs/execute.js +158 -0
- package/lib/cjs/execute.js.map +1 -0
- package/lib/cjs/index.js +22 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/nodejs/NodeStreamSource.js +45 -0
- package/lib/cjs/nodejs/NodeStreamSource.js.map +1 -0
- package/lib/cjs/nodejs/index.js +18 -0
- package/lib/cjs/nodejs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/store/AnalyzeDocApi.js +56 -0
- package/lib/cjs/store/AnalyzeDocApi.js.map +1 -0
- package/lib/cjs/store/CollectionsApi.js +131 -0
- package/lib/cjs/store/CollectionsApi.js.map +1 -0
- package/lib/cjs/store/CommandsApi.js +17 -0
- package/lib/cjs/store/CommandsApi.js.map +1 -0
- package/lib/cjs/store/DashboardApi.js +182 -0
- package/lib/cjs/store/DashboardApi.js.map +1 -0
- package/lib/cjs/store/DataApi.js +433 -0
- package/lib/cjs/store/DataApi.js.map +1 -0
- package/lib/cjs/store/EmailApi.js +103 -0
- package/lib/cjs/store/EmailApi.js.map +1 -0
- package/lib/cjs/store/EmbeddingsApi.js +29 -0
- package/lib/cjs/store/EmbeddingsApi.js.map +1 -0
- package/lib/cjs/store/FilesApi.js +237 -0
- package/lib/cjs/store/FilesApi.js.map +1 -0
- package/lib/cjs/store/ObjectsApi.js +314 -0
- package/lib/cjs/store/ObjectsApi.js.map +1 -0
- package/lib/cjs/store/PendingAsksApi.js +43 -0
- package/lib/cjs/store/PendingAsksApi.js.map +1 -0
- package/lib/cjs/store/SchedulesApi.js +103 -0
- package/lib/cjs/store/SchedulesApi.js.map +1 -0
- package/lib/cjs/store/ToolsApi.js +21 -0
- package/lib/cjs/store/ToolsApi.js.map +1 -0
- package/lib/cjs/store/TypesApi.js +57 -0
- package/lib/cjs/store/TypesApi.js.map +1 -0
- package/lib/cjs/store/WorkersApi.js +16 -0
- package/lib/cjs/store/WorkersApi.js.map +1 -0
- package/lib/cjs/store/WorkflowsApi.js +596 -0
- package/lib/cjs/store/WorkflowsApi.js.map +1 -0
- package/lib/cjs/store/client.js +81 -0
- package/lib/cjs/store/client.js.map +1 -0
- package/lib/cjs/store/errors.js +11 -0
- package/lib/cjs/store/errors.js.map +1 -0
- package/lib/cjs/store/index.js +27 -0
- package/lib/cjs/store/index.js.map +1 -0
- package/lib/cjs/store/version.js +6 -0
- package/lib/cjs/store/version.js.map +1 -0
- package/lib/esm/AccountApi.js +82 -0
- package/lib/esm/AccountApi.js.map +1 -0
- package/lib/esm/AccountsApi.js +13 -0
- package/lib/esm/AccountsApi.js.map +1 -0
- package/lib/esm/AnalyticsApi.js +38 -0
- package/lib/esm/AnalyticsApi.js.map +1 -0
- package/lib/esm/ApiKeysApi.js +59 -0
- package/lib/esm/ApiKeysApi.js.map +1 -0
- package/lib/esm/AppsApi.js +116 -0
- package/lib/esm/AppsApi.js.map +1 -0
- package/lib/esm/CommandsApi.js +16 -0
- package/lib/esm/CommandsApi.js.map +1 -0
- package/lib/esm/EnvironmentsApi.js +69 -0
- package/lib/esm/EnvironmentsApi.js.map +1 -0
- package/lib/esm/GroupsApi.js +74 -0
- package/lib/esm/GroupsApi.js.map +1 -0
- package/lib/esm/IamApi.js +47 -0
- package/lib/esm/IamApi.js.map +1 -0
- package/lib/esm/InteractionBase.js +40 -0
- package/lib/esm/InteractionBase.js.map +1 -0
- package/lib/esm/InteractionCatalogApi.js +60 -0
- package/lib/esm/InteractionCatalogApi.js.map +1 -0
- package/lib/esm/InteractionOutput.js +293 -0
- package/lib/esm/InteractionOutput.js.map +1 -0
- package/lib/esm/InteractionResult.example.js +55 -0
- package/lib/esm/InteractionResult.example.js.map +1 -0
- package/lib/esm/InteractionsApi.js +259 -0
- package/lib/esm/InteractionsApi.js.map +1 -0
- package/lib/esm/MCPOAuthApi.js +59 -0
- package/lib/esm/MCPOAuthApi.js.map +1 -0
- package/lib/esm/ProjectsApi.js +69 -0
- package/lib/esm/ProjectsApi.js.map +1 -0
- package/lib/esm/PromptsApi.js +130 -0
- package/lib/esm/PromptsApi.js.map +1 -0
- package/lib/esm/RefsApi.js +10 -0
- package/lib/esm/RefsApi.js.map +1 -0
- package/lib/esm/RunsApi.js +109 -0
- package/lib/esm/RunsApi.js.map +1 -0
- package/lib/esm/SkillsApi.js +36 -0
- package/lib/esm/SkillsApi.js.map +1 -0
- package/lib/esm/StreamSource.js +13 -0
- package/lib/esm/StreamSource.js.map +1 -0
- package/lib/esm/TrainingApi.js +51 -0
- package/lib/esm/TrainingApi.js.map +1 -0
- package/lib/esm/UsersApi.js +10 -0
- package/lib/esm/UsersApi.js.map +1 -0
- package/lib/esm/client.js +351 -0
- package/lib/esm/client.js.map +1 -0
- package/lib/esm/execute.js +118 -0
- package/lib/esm/execute.js.map +1 -0
- package/lib/esm/index.js +6 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/nodejs/NodeStreamSource.js +41 -0
- package/lib/esm/nodejs/NodeStreamSource.js.map +1 -0
- package/lib/esm/nodejs/index.js +2 -0
- package/lib/esm/nodejs/index.js.map +1 -0
- package/lib/esm/store/AnalyzeDocApi.js +52 -0
- package/lib/esm/store/AnalyzeDocApi.js.map +1 -0
- package/lib/esm/store/CollectionsApi.js +127 -0
- package/lib/esm/store/CollectionsApi.js.map +1 -0
- package/lib/esm/store/CommandsApi.js +13 -0
- package/lib/esm/store/CommandsApi.js.map +1 -0
- package/lib/esm/store/DashboardApi.js +178 -0
- package/lib/esm/store/DashboardApi.js.map +1 -0
- package/lib/esm/store/DataApi.js +429 -0
- package/lib/esm/store/DataApi.js.map +1 -0
- package/lib/esm/store/EmailApi.js +99 -0
- package/lib/esm/store/EmailApi.js.map +1 -0
- package/lib/esm/store/EmbeddingsApi.js +25 -0
- package/lib/esm/store/EmbeddingsApi.js.map +1 -0
- package/lib/esm/store/FilesApi.js +231 -0
- package/lib/esm/store/FilesApi.js.map +1 -0
- package/lib/esm/store/ObjectsApi.js +309 -0
- package/lib/esm/store/ObjectsApi.js.map +1 -0
- package/lib/esm/store/PendingAsksApi.js +39 -0
- package/lib/esm/store/PendingAsksApi.js.map +1 -0
- package/lib/esm/store/SchedulesApi.js +99 -0
- package/lib/esm/store/SchedulesApi.js.map +1 -0
- package/lib/esm/store/ToolsApi.js +17 -0
- package/lib/esm/store/ToolsApi.js.map +1 -0
- package/lib/esm/store/TypesApi.js +53 -0
- package/lib/esm/store/TypesApi.js.map +1 -0
- package/lib/esm/store/WorkersApi.js +12 -0
- package/lib/esm/store/WorkersApi.js.map +1 -0
- package/lib/esm/store/WorkflowsApi.js +590 -0
- package/lib/esm/store/WorkflowsApi.js.map +1 -0
- package/lib/esm/store/client.js +77 -0
- package/lib/esm/store/client.js.map +1 -0
- package/lib/esm/store/errors.js +7 -0
- package/lib/esm/store/errors.js.map +1 -0
- package/lib/esm/store/index.js +11 -0
- package/lib/esm/store/index.js.map +1 -0
- package/lib/esm/store/version.js +3 -0
- package/lib/esm/store/version.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/AccountApi.d.ts +59 -0
- package/lib/types/AccountApi.d.ts.map +1 -0
- package/lib/types/AccountsApi.d.ts +7 -0
- package/lib/types/AccountsApi.d.ts.map +1 -0
- package/lib/types/AnalyticsApi.d.ts +11 -0
- package/lib/types/AnalyticsApi.d.ts.map +1 -0
- package/lib/types/ApiKeysApi.d.ts +42 -0
- package/lib/types/ApiKeysApi.d.ts.map +1 -0
- package/lib/types/AppsApi.d.ts +65 -0
- package/lib/types/AppsApi.d.ts.map +1 -0
- package/lib/types/CommandsApi.d.ts +10 -0
- package/lib/types/CommandsApi.d.ts.map +1 -0
- package/lib/types/EnvironmentsApi.d.ts +40 -0
- package/lib/types/EnvironmentsApi.d.ts.map +1 -0
- package/lib/types/GroupsApi.d.ts +65 -0
- package/lib/types/GroupsApi.d.ts.map +1 -0
- package/lib/types/IamApi.d.ts +41 -0
- package/lib/types/IamApi.d.ts.map +1 -0
- package/lib/types/InteractionBase.d.ts +22 -0
- package/lib/types/InteractionBase.d.ts.map +1 -0
- package/lib/types/InteractionCatalogApi.d.ts +36 -0
- package/lib/types/InteractionCatalogApi.d.ts.map +1 -0
- package/lib/types/InteractionOutput.d.ts +174 -0
- package/lib/types/InteractionOutput.d.ts.map +1 -0
- package/lib/types/InteractionResult.example.d.ts +6 -0
- package/lib/types/InteractionResult.example.d.ts.map +1 -0
- package/lib/types/InteractionsApi.d.ts +183 -0
- package/lib/types/InteractionsApi.d.ts.map +1 -0
- package/lib/types/MCPOAuthApi.d.ts +45 -0
- package/lib/types/MCPOAuthApi.d.ts.map +1 -0
- package/lib/types/ProjectsApi.d.ts +28 -0
- package/lib/types/ProjectsApi.d.ts.map +1 -0
- package/lib/types/PromptsApi.d.ts +106 -0
- package/lib/types/PromptsApi.d.ts.map +1 -0
- package/lib/types/RefsApi.d.ts +6 -0
- package/lib/types/RefsApi.d.ts.map +1 -0
- package/lib/types/RunsApi.d.ts +79 -0
- package/lib/types/RunsApi.d.ts.map +1 -0
- package/lib/types/SkillsApi.d.ts +26 -0
- package/lib/types/SkillsApi.d.ts.map +1 -0
- package/lib/types/StreamSource.d.ts +7 -0
- package/lib/types/StreamSource.d.ts.map +1 -0
- package/lib/types/TrainingApi.d.ts +27 -0
- package/lib/types/TrainingApi.d.ts.map +1 -0
- package/lib/types/UsersApi.d.ts +6 -0
- package/lib/types/UsersApi.d.ts.map +1 -0
- package/lib/types/client.d.ts +136 -0
- package/lib/types/client.d.ts.map +1 -0
- package/lib/types/execute.d.ts +37 -0
- package/lib/types/execute.d.ts.map +1 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/nodejs/NodeStreamSource.d.ts +9 -0
- package/lib/types/nodejs/NodeStreamSource.d.ts.map +1 -0
- package/lib/types/nodejs/index.d.ts +1 -0
- package/lib/types/nodejs/index.d.ts.map +1 -0
- package/lib/types/store/AnalyzeDocApi.d.ts +17 -0
- package/lib/types/store/AnalyzeDocApi.d.ts.map +1 -0
- package/lib/types/store/CollectionsApi.d.ts +82 -0
- package/lib/types/store/CollectionsApi.d.ts.map +1 -0
- package/lib/types/store/CommandsApi.d.ts +10 -0
- package/lib/types/store/CommandsApi.d.ts.map +1 -0
- package/lib/types/store/DashboardApi.d.ts +149 -0
- package/lib/types/store/DashboardApi.d.ts.map +1 -0
- package/lib/types/store/DataApi.d.ts +392 -0
- package/lib/types/store/DataApi.d.ts.map +1 -0
- package/lib/types/store/EmailApi.d.ts +185 -0
- package/lib/types/store/EmailApi.d.ts.map +1 -0
- package/lib/types/store/EmbeddingsApi.d.ts +12 -0
- package/lib/types/store/EmbeddingsApi.d.ts.map +1 -0
- package/lib/types/store/FilesApi.d.ts +110 -0
- package/lib/types/store/FilesApi.d.ts.map +1 -0
- package/lib/types/store/ObjectsApi.d.ts +139 -0
- package/lib/types/store/ObjectsApi.d.ts.map +1 -0
- package/lib/types/store/PendingAsksApi.d.ts +79 -0
- package/lib/types/store/PendingAsksApi.d.ts.map +1 -0
- package/lib/types/store/SchedulesApi.d.ts +89 -0
- package/lib/types/store/SchedulesApi.d.ts.map +1 -0
- package/lib/types/store/ToolsApi.d.ts +13 -0
- package/lib/types/store/ToolsApi.d.ts.map +1 -0
- package/lib/types/store/TypesApi.d.ts +23 -0
- package/lib/types/store/TypesApi.d.ts.map +1 -0
- package/lib/types/store/WorkersApi.d.ts +6 -0
- package/lib/types/store/WorkersApi.d.ts.map +1 -0
- package/lib/types/store/WorkflowsApi.d.ts +167 -0
- package/lib/types/store/WorkflowsApi.d.ts.map +1 -0
- package/lib/types/store/client.d.ts +45 -0
- package/lib/types/store/client.d.ts.map +1 -0
- package/lib/types/store/errors.d.ts +4 -0
- package/lib/types/store/errors.d.ts.map +1 -0
- package/lib/types/store/index.d.ts +10 -0
- package/lib/types/store/index.d.ts.map +1 -0
- package/lib/types/store/version.d.ts +2 -0
- package/lib/types/store/version.d.ts.map +1 -0
- package/lib/vertesia-client.js +2 -0
- package/lib/vertesia-client.js.map +1 -0
- package/package.json +71 -0
- package/src/AccountApi.ts +96 -0
- package/src/AccountsApi.ts +22 -0
- package/src/AnalyticsApi.ts +36 -0
- package/src/ApiKeysApi.ts +67 -0
- package/src/AppsApi.ts +134 -0
- package/src/CommandsApi.ts +23 -0
- package/src/EnvironmentsApi.ts +94 -0
- package/src/GroupsApi.ts +92 -0
- package/src/IamApi.ts +70 -0
- package/src/InteractionBase.ts +44 -0
- package/src/InteractionCatalogApi.ts +72 -0
- package/src/InteractionOutput.test.ts +305 -0
- package/src/InteractionOutput.ts +328 -0
- package/src/InteractionResult.example.ts +72 -0
- package/src/InteractionsApi.ts +308 -0
- package/src/MCPOAuthApi.ts +67 -0
- package/src/ProjectsApi.ts +85 -0
- package/src/PromptsApi.ts +160 -0
- package/src/RefsApi.ts +18 -0
- package/src/RunsApi.ts +151 -0
- package/src/SkillsApi.ts +46 -0
- package/src/StreamSource.ts +3 -0
- package/src/TrainingApi.ts +71 -0
- package/src/UsersApi.ts +18 -0
- package/src/client.test.ts +99 -0
- package/src/client.ts +419 -0
- package/src/execute.ts +126 -0
- package/src/index.ts +10 -0
- package/src/nodejs/NodeStreamSource.ts +43 -0
- package/src/nodejs/index.ts +1 -0
- package/src/store/AnalyzeDocApi.ts +61 -0
- package/src/store/CollectionsApi.ts +166 -0
- package/src/store/CommandsApi.ts +15 -0
- package/src/store/DashboardApi.ts +216 -0
- package/src/store/DataApi.ts +516 -0
- package/src/store/EmailApi.ts +211 -0
- package/src/store/EmbeddingsApi.ts +39 -0
- package/src/store/FilesApi.ts +288 -0
- package/src/store/ObjectsApi.ts +432 -0
- package/src/store/PendingAsksApi.ts +98 -0
- package/src/store/SchedulesApi.ts +114 -0
- package/src/store/ToolsApi.ts +19 -0
- package/src/store/TypesApi.ts +65 -0
- package/src/store/WorkersApi.ts +17 -0
- package/src/store/WorkflowsApi.ts +752 -0
- package/src/store/client.ts +95 -0
- package/src/store/errors.ts +7 -0
- package/src/store/index.ts +11 -0
- package/src/store/version.ts +2 -0
- package/tsconfig.dist.json +20 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
+
import { EmailRouteData } from "@vertesia/common";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Request payload for sending an email via the agent.
|
|
6
|
+
* Resend configuration is fetched from project settings.
|
|
7
|
+
* From address is constructed as: {project_namespace}+{agent_name}@{email_domain}
|
|
8
|
+
*/
|
|
9
|
+
export interface SendEmailRequest {
|
|
10
|
+
/** Email address to send to */
|
|
11
|
+
to_email: string;
|
|
12
|
+
/** Email subject */
|
|
13
|
+
subject: string;
|
|
14
|
+
/** Email body in markdown format */
|
|
15
|
+
body: string;
|
|
16
|
+
/** Agent/interaction endpoint name (used in from address) */
|
|
17
|
+
agent_name: string;
|
|
18
|
+
/** Display name for the sender (overrides project default) */
|
|
19
|
+
from_name?: string;
|
|
20
|
+
/** Workflow run ID for routing replies */
|
|
21
|
+
run_id: string;
|
|
22
|
+
/** Existing route key (for subsequent emails in same conversation) */
|
|
23
|
+
route_key?: string;
|
|
24
|
+
/** Message ID for In-Reply-To header (email threading) */
|
|
25
|
+
in_reply_to?: string;
|
|
26
|
+
/** Chain of message IDs for References header */
|
|
27
|
+
references?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Response from sending an email.
|
|
32
|
+
*/
|
|
33
|
+
export interface SendEmailResponse {
|
|
34
|
+
success: boolean;
|
|
35
|
+
/** Resend email ID */
|
|
36
|
+
email_id?: string;
|
|
37
|
+
/** Message-ID header for threading */
|
|
38
|
+
message_id?: string;
|
|
39
|
+
/** Short route key for reply routing */
|
|
40
|
+
route_key?: string;
|
|
41
|
+
/** Error message if failed */
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Response from creating an email route.
|
|
47
|
+
*/
|
|
48
|
+
export interface CreateRouteResponse {
|
|
49
|
+
/** The generated route key (8-char alphanumeric) */
|
|
50
|
+
route_key: string;
|
|
51
|
+
/** Full reply-to address: r+{route_key}@{email_domain} */
|
|
52
|
+
reply_to: string;
|
|
53
|
+
/** The email domain for sending and receiving */
|
|
54
|
+
email_domain: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Request to forward an email to a workflow.
|
|
59
|
+
* Used by external services that handle email reception themselves.
|
|
60
|
+
*/
|
|
61
|
+
export interface ForwardEmailRequest {
|
|
62
|
+
/** Email content received by the external service */
|
|
63
|
+
email: {
|
|
64
|
+
/** Sender email address */
|
|
65
|
+
from: string;
|
|
66
|
+
/** Email subject */
|
|
67
|
+
subject?: string;
|
|
68
|
+
/** Plain text body */
|
|
69
|
+
text: string;
|
|
70
|
+
/** HTML body (optional) */
|
|
71
|
+
html?: string;
|
|
72
|
+
/** Message-ID header for threading */
|
|
73
|
+
message_id?: string;
|
|
74
|
+
};
|
|
75
|
+
/** Custom context data from the external service (e.g., auth tokens, user IDs) */
|
|
76
|
+
context?: Record<string, unknown>;
|
|
77
|
+
/** Attachments with download URLs */
|
|
78
|
+
attachments?: Array<{
|
|
79
|
+
filename: string;
|
|
80
|
+
content_type: string;
|
|
81
|
+
size: number;
|
|
82
|
+
download_url: string;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Response from forwarding an email.
|
|
88
|
+
*/
|
|
89
|
+
export interface ForwardEmailResponse {
|
|
90
|
+
success: boolean;
|
|
91
|
+
run_id: string;
|
|
92
|
+
workflow_id: string;
|
|
93
|
+
route_key: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Request to create an email route.
|
|
98
|
+
*/
|
|
99
|
+
export interface CreateRouteRequest {
|
|
100
|
+
/** Workflow run ID for routing replies */
|
|
101
|
+
run_id: string;
|
|
102
|
+
/** Email address of the user (for context) */
|
|
103
|
+
user_email: string;
|
|
104
|
+
/** Subject of the email thread (optional) */
|
|
105
|
+
thread_subject?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Email API for sending emails from workflows.
|
|
110
|
+
*/
|
|
111
|
+
export class EmailApi extends ApiTopic {
|
|
112
|
+
constructor(parent: ClientBase) {
|
|
113
|
+
super(parent, "/api/v1/email");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Send an email from an agent/workflow.
|
|
118
|
+
* Creates a route key if not provided, sends via Resend, and returns routing info.
|
|
119
|
+
*/
|
|
120
|
+
send(request: SendEmailRequest): Promise<SendEmailResponse> {
|
|
121
|
+
return this.post("/send", { payload: request });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Resolve a route key to get email context.
|
|
126
|
+
* Used by webhook handler to look up workflow info from reply email.
|
|
127
|
+
* @deprecated Use getRoute() instead
|
|
128
|
+
*/
|
|
129
|
+
resolveRoute(routeKey: string): Promise<EmailRouteData> {
|
|
130
|
+
return this.post("/resolve-route", { payload: { route_key: routeKey } });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ============================================================================
|
|
134
|
+
// Routes API - for external service integration
|
|
135
|
+
// ============================================================================
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Create a new email route without sending an email.
|
|
139
|
+
* Useful for external services that want to handle email sending themselves
|
|
140
|
+
* but need reply routing back to Vertesia workflows.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const { route_key, reply_to } = await client.store.email.createRoute({
|
|
145
|
+
* run_id: workflowRunId,
|
|
146
|
+
* user_email: "user@example.com",
|
|
147
|
+
* thread_subject: "Contract Review"
|
|
148
|
+
* });
|
|
149
|
+
* // Use reply_to as the Reply-To header when sending your own email
|
|
150
|
+
* // Replies will be routed back to the workflow
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
createRoute(request: CreateRouteRequest): Promise<CreateRouteResponse> {
|
|
154
|
+
return this.post("/routes", { payload: request });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Get an email route by key.
|
|
159
|
+
*/
|
|
160
|
+
getRoute(routeKey: string): Promise<EmailRouteData & { route_key: string }> {
|
|
161
|
+
return this.get(`/routes/${routeKey}`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Update an email route (e.g., to update threading info).
|
|
166
|
+
*/
|
|
167
|
+
updateRoute(routeKey: string, updates: Partial<EmailRouteData>): Promise<{ success: boolean; route_key: string }> {
|
|
168
|
+
return this.put(`/routes/${routeKey}`, { payload: updates });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Forward an email to a workflow via route key.
|
|
173
|
+
*
|
|
174
|
+
* Use this when your service receives an email reply and needs to forward
|
|
175
|
+
* it to the Vertesia workflow. You can add custom context data (like auth
|
|
176
|
+
* tokens or user IDs) that will be merged into `payload.vars.data`.
|
|
177
|
+
*
|
|
178
|
+
* **Important**: Use camelCase keys in context to match the agent start
|
|
179
|
+
* pattern. This ensures tools work identically whether the agent was
|
|
180
|
+
* started directly or received an email reply.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* // In your email webhook handler:
|
|
185
|
+
* const result = await client.store.email.forwardEmail(routeKey, {
|
|
186
|
+
* email: {
|
|
187
|
+
* from: inboundEmail.from,
|
|
188
|
+
* subject: inboundEmail.subject,
|
|
189
|
+
* text: inboundEmail.text,
|
|
190
|
+
* message_id: inboundEmail.messageId,
|
|
191
|
+
* },
|
|
192
|
+
* context: {
|
|
193
|
+
* // Use camelCase - merged into payload.vars.data
|
|
194
|
+
* apiKey: generateServiceToken(),
|
|
195
|
+
* tenantId: resolvedUser.tenantId,
|
|
196
|
+
* userId: resolvedUser.id,
|
|
197
|
+
* userEmail: resolvedUser.email,
|
|
198
|
+
* },
|
|
199
|
+
* attachments: inboundEmail.attachments?.map(att => ({
|
|
200
|
+
* filename: att.filename,
|
|
201
|
+
* content_type: att.contentType,
|
|
202
|
+
* size: att.size,
|
|
203
|
+
* download_url: att.url,
|
|
204
|
+
* })),
|
|
205
|
+
* });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
forwardEmail(routeKey: string, request: ForwardEmailRequest): Promise<ForwardEmailResponse> {
|
|
209
|
+
return this.post(`/routes/${routeKey}/forward`, { payload: request });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
+
import {
|
|
3
|
+
EmbeddingsStatusResponse,
|
|
4
|
+
GenericCommandResponse,
|
|
5
|
+
ProjectConfigurationEmbeddings,
|
|
6
|
+
SupportedEmbeddingTypes,
|
|
7
|
+
} from "@vertesia/common";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @since 0.52.0
|
|
11
|
+
*/
|
|
12
|
+
export class EmbeddingsApi extends ApiTopic {
|
|
13
|
+
|
|
14
|
+
constructor(parent: ClientBase, basePath: string = "/api/v1/embeddings") {
|
|
15
|
+
super(parent, basePath);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async status(type: SupportedEmbeddingTypes): Promise<EmbeddingsStatusResponse> {
|
|
19
|
+
return this.get(type + "/status");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async activate(type: SupportedEmbeddingTypes, config: Partial<ProjectConfigurationEmbeddings>): Promise<GenericCommandResponse> {
|
|
23
|
+
|
|
24
|
+
if (!config.environment) {
|
|
25
|
+
throw new Error("Invalid configuration: select environment");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return this.post(type + "/enable", { payload: config });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async disable(type: SupportedEmbeddingTypes): Promise<GenericCommandResponse> {
|
|
32
|
+
return this.post(type + "/disable");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async recalculate(type: SupportedEmbeddingTypes): Promise<GenericCommandResponse> {
|
|
36
|
+
return this.post(type + "/recalculate");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
+
import {
|
|
3
|
+
GetFileUrlPayload,
|
|
4
|
+
GetFileUrlResponse,
|
|
5
|
+
GetUploadUrlPayload,
|
|
6
|
+
SetFileMetadataPayload,
|
|
7
|
+
} from "@vertesia/common";
|
|
8
|
+
import { StreamSource } from "../StreamSource.js";
|
|
9
|
+
|
|
10
|
+
export const MEMORIES_PREFIX = "memories";
|
|
11
|
+
export const ARTIFACTS_PREFIX = "agents";
|
|
12
|
+
|
|
13
|
+
export function getMemoryFilePath(name: string) {
|
|
14
|
+
const nameWithExt = name.endsWith(".tar.gz") ? name : name + ".tar.gz";
|
|
15
|
+
return `${MEMORIES_PREFIX}/${nameWithExt}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Build the storage path for an agent artifact
|
|
20
|
+
* @param runId - The workflow run ID
|
|
21
|
+
* @param name - The artifact filename
|
|
22
|
+
*/
|
|
23
|
+
export function getAgentArtifactPath(runId: string, name: string): string {
|
|
24
|
+
return `${ARTIFACTS_PREFIX}/${runId}/${name}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class FilesApi extends ApiTopic {
|
|
28
|
+
constructor(parent: ClientBase) {
|
|
29
|
+
super(parent, "/api/v1/files");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async deleteFile(path: string, prefix?: boolean): Promise<void | number> {
|
|
33
|
+
const res = await this.delete(`/${path}`, { query: { prefix } });
|
|
34
|
+
return res.count;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* get the metadata of a blob given its URI. Supported URI are:
|
|
39
|
+
* starting with s3:// and gs://.
|
|
40
|
+
* For s3 blobs use #region to specify the region. Ex: s3://bucket/key#us-west-2
|
|
41
|
+
* @param uri
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
getMetadata(uri: string): Promise<{
|
|
45
|
+
name: string;
|
|
46
|
+
size: number;
|
|
47
|
+
contentType: string;
|
|
48
|
+
contentDisposition?: string;
|
|
49
|
+
etag?: string;
|
|
50
|
+
customMetadata?: Record<string, string>;
|
|
51
|
+
}> {
|
|
52
|
+
return this.get("/metadata", {
|
|
53
|
+
query: {
|
|
54
|
+
file: uri,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Set custom metadata on a file
|
|
61
|
+
* @param file - The file path or URI
|
|
62
|
+
* @param metadata - Custom metadata key-value pairs
|
|
63
|
+
* @returns Success status
|
|
64
|
+
*/
|
|
65
|
+
setFileMetadata(file: string, metadata: Record<string, string>): Promise<{ success: boolean; file: string }> {
|
|
66
|
+
const payload: SetFileMetadataPayload = { file, metadata };
|
|
67
|
+
return this.put("/metadata", { payload });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get or create a bucket for the project. If the bucket already exists, it does nothing.
|
|
72
|
+
* The bucket URI is returned.
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
getOrCreateBucket(): Promise<{ bucket: string }> {
|
|
76
|
+
return this.post("/bucket");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getUploadUrl(payload: GetUploadUrlPayload): Promise<GetFileUrlResponse> {
|
|
80
|
+
return this.post("/upload-url", {
|
|
81
|
+
payload,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Strictly typed: provide either simple args or a full payload via a separate method
|
|
86
|
+
getDownloadUrl(file: string, name?: string, disposition?: "inline" | "attachment"): Promise<GetFileUrlResponse> {
|
|
87
|
+
const payload: GetFileUrlPayload = { file, name, disposition };
|
|
88
|
+
return this.post("/download-url", { payload });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getDownloadUrlWithOptions(payload: GetFileUrlPayload): Promise<GetFileUrlResponse> {
|
|
92
|
+
return this.post("/download-url", { payload });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Upload content to a file and return the full path (including bucket name) of the uploaded file
|
|
97
|
+
* @param source
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
async uploadFile(source: StreamSource | File): Promise<string> {
|
|
101
|
+
const isStream = source instanceof StreamSource;
|
|
102
|
+
const { url, id, path } = await this.getUploadUrl(source);
|
|
103
|
+
|
|
104
|
+
await fetch(url, {
|
|
105
|
+
method: "PUT",
|
|
106
|
+
body: isStream ? source.stream : source,
|
|
107
|
+
//@ts-ignore: duplex is not in the types. See https://github.com/node-fetch/node-fetch/issues/1769
|
|
108
|
+
duplex: isStream ? "half" : undefined,
|
|
109
|
+
headers: {
|
|
110
|
+
"Content-Type": source.type || "application/gzip",
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
.then((res: Response) => {
|
|
114
|
+
if (res.ok) {
|
|
115
|
+
return res;
|
|
116
|
+
} else {
|
|
117
|
+
console.log(res);
|
|
118
|
+
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
.catch((err) => {
|
|
122
|
+
console.error("Failed to upload file", { err, url, id, path });
|
|
123
|
+
throw err;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return id;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @param location can be a relative path in the project, a reference to a cloud storage, or a accessible HTTPS URL (typically signed URL)
|
|
132
|
+
* @returns ReadableStream
|
|
133
|
+
*/
|
|
134
|
+
async downloadFile(location: string): Promise<ReadableStream<Uint8Array<ArrayBuffer>>> {
|
|
135
|
+
//if start with HTTPS, no download url needed - assume it's signed already
|
|
136
|
+
const needSign = !location.startsWith("https:");
|
|
137
|
+
const { url } = needSign
|
|
138
|
+
? await this.getDownloadUrl(location)
|
|
139
|
+
: { url: location };
|
|
140
|
+
|
|
141
|
+
const res = await fetch(url, {
|
|
142
|
+
method: "GET",
|
|
143
|
+
})
|
|
144
|
+
.then((res: Response) => {
|
|
145
|
+
if (res.ok) {
|
|
146
|
+
return res;
|
|
147
|
+
} else if (res.status === 404) {
|
|
148
|
+
throw new Error(`File at ${url} not found`); //TODO: type fetch error better with a fetch error class
|
|
149
|
+
} else if (res.status === 403) {
|
|
150
|
+
throw new Error(`File at ${url} is forbidden`);
|
|
151
|
+
} else {
|
|
152
|
+
console.log(res);
|
|
153
|
+
throw new Error(
|
|
154
|
+
`Failed to download file ${location}: ${res.statusText}`,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
.catch((err) => {
|
|
159
|
+
console.error(`Failed to download file ${location}.`, err);
|
|
160
|
+
throw err;
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
if (!res.body) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`No body in response while downloading file ${location}`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return res.body;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Copy a file to a new destination within the same bucket.
|
|
174
|
+
* @param source - Source file path (relative to project bucket)
|
|
175
|
+
* @param dest - Destination file path (relative to project bucket)
|
|
176
|
+
* @returns The destination file URI
|
|
177
|
+
*/
|
|
178
|
+
async copyFile(source: string, dest: string): Promise<string> {
|
|
179
|
+
const response = await this.post("/copy", {
|
|
180
|
+
payload: { source, dest },
|
|
181
|
+
}) as { success: boolean; source: string; dest: string };
|
|
182
|
+
return response.dest;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async uploadMemoryPack(source: StreamSource | File): Promise<string> {
|
|
186
|
+
const fileId = getMemoryFilePath(source.name);
|
|
187
|
+
const nameWithExt = source.name.endsWith(".tar.gz")
|
|
188
|
+
? source.name
|
|
189
|
+
: source.name + ".tar.gz";
|
|
190
|
+
if (source instanceof File) {
|
|
191
|
+
let file = source as File;
|
|
192
|
+
return this.uploadFile(
|
|
193
|
+
new StreamSource(file.stream(), nameWithExt, file.type, fileId),
|
|
194
|
+
);
|
|
195
|
+
} else {
|
|
196
|
+
return this.uploadFile(
|
|
197
|
+
new StreamSource(
|
|
198
|
+
source.stream,
|
|
199
|
+
nameWithExt,
|
|
200
|
+
source.type,
|
|
201
|
+
fileId,
|
|
202
|
+
),
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async downloadMemoryPack(
|
|
208
|
+
name: string,
|
|
209
|
+
gunzip: boolean = false,
|
|
210
|
+
): Promise<ReadableStream<Uint8Array>> {
|
|
211
|
+
let stream = await this.downloadFile(getMemoryFilePath(name));
|
|
212
|
+
if (gunzip) {
|
|
213
|
+
const ds = new DecompressionStream("gzip");
|
|
214
|
+
stream = stream.pipeThrough(ds);
|
|
215
|
+
}
|
|
216
|
+
return stream;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ==================== Agent Artifact Methods ====================
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* List files by prefix
|
|
223
|
+
* @param prefix - Path prefix to filter files
|
|
224
|
+
* @returns Array of file paths matching the prefix
|
|
225
|
+
*/
|
|
226
|
+
listByPrefix(prefix: string): Promise<{ files: string[] }> {
|
|
227
|
+
return this.get("/list", { query: { prefix } });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Upload an artifact for an agent run
|
|
232
|
+
* @param runId - The workflow run ID
|
|
233
|
+
* @param name - Artifact name (e.g., "output.json")
|
|
234
|
+
* @param source - File content source
|
|
235
|
+
* @returns The full path of the uploaded artifact
|
|
236
|
+
*/
|
|
237
|
+
async uploadArtifact(runId: string, name: string, source: StreamSource | File): Promise<string> {
|
|
238
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
239
|
+
if (source instanceof File) {
|
|
240
|
+
const file = source as File;
|
|
241
|
+
return this.uploadFile(
|
|
242
|
+
new StreamSource(file.stream(), name, file.type, artifactPath)
|
|
243
|
+
);
|
|
244
|
+
} else {
|
|
245
|
+
return this.uploadFile(
|
|
246
|
+
new StreamSource(source.stream, name, source.type, artifactPath)
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Download an artifact from an agent run
|
|
253
|
+
* @param runId - The workflow run ID
|
|
254
|
+
* @param name - Artifact name
|
|
255
|
+
* @returns ReadableStream of the artifact content
|
|
256
|
+
*/
|
|
257
|
+
async downloadArtifact(runId: string, name: string): Promise<ReadableStream<Uint8Array>> {
|
|
258
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
259
|
+
return this.downloadFile(artifactPath);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Get download URL for an artifact
|
|
264
|
+
* @param runId - The workflow run ID
|
|
265
|
+
* @param name - Artifact name
|
|
266
|
+
* @param disposition - Content disposition (inline or attachment)
|
|
267
|
+
* @returns Signed URL response
|
|
268
|
+
*/
|
|
269
|
+
getArtifactDownloadUrl(
|
|
270
|
+
runId: string,
|
|
271
|
+
name: string,
|
|
272
|
+
disposition?: "inline" | "attachment"
|
|
273
|
+
): Promise<GetFileUrlResponse> {
|
|
274
|
+
const artifactPath = getAgentArtifactPath(runId, name);
|
|
275
|
+
return this.getDownloadUrl(artifactPath, name, disposition);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* List artifacts for an agent run
|
|
280
|
+
* @param runId - The workflow run ID
|
|
281
|
+
* @returns Array of artifact file paths
|
|
282
|
+
*/
|
|
283
|
+
async listArtifacts(runId: string): Promise<string[]> {
|
|
284
|
+
const prefix = `${ARTIFACTS_PREFIX}/${runId}/`;
|
|
285
|
+
const result = await this.listByPrefix(prefix);
|
|
286
|
+
return result.files;
|
|
287
|
+
}
|
|
288
|
+
}
|