@vertesia/client 0.81.1 → 1.0.0-dev.20260203.130115Z

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.
Files changed (266) hide show
  1. package/package.json +7 -7
  2. package/src/InteractionsApi.ts +21 -1
  3. package/src/MCPOAuthApi.ts +67 -0
  4. package/src/ProjectsApi.ts +23 -2
  5. package/src/client.ts +19 -5
  6. package/src/index.ts +2 -2
  7. package/src/store/CollectionsApi.ts +4 -4
  8. package/src/store/DashboardApi.ts +216 -0
  9. package/src/store/DataApi.ts +516 -0
  10. package/src/store/EmailApi.ts +211 -0
  11. package/src/store/FilesApi.ts +13 -0
  12. package/src/store/HiveMemoryApi.ts +231 -0
  13. package/src/store/IndexingAdminApi.ts +336 -0
  14. package/src/store/IndexingApi.ts +62 -0
  15. package/src/store/ObjectsApi.ts +40 -0
  16. package/src/store/PendingAsksApi.ts +98 -0
  17. package/src/store/QueryApi.ts +110 -0
  18. package/src/store/SchedulesApi.ts +114 -0
  19. package/src/store/ToolsApi.ts +19 -0
  20. package/src/store/WorkflowsApi.ts +310 -48
  21. package/src/store/client.ts +18 -0
  22. package/src/store/index.ts +9 -0
  23. package/lib/cjs/AccountApi.js +0 -85
  24. package/lib/cjs/AccountApi.js.map +0 -1
  25. package/lib/cjs/AccountsApi.js +0 -16
  26. package/lib/cjs/AccountsApi.js.map +0 -1
  27. package/lib/cjs/AnalyticsApi.js +0 -41
  28. package/lib/cjs/AnalyticsApi.js.map +0 -1
  29. package/lib/cjs/ApiKeysApi.js +0 -63
  30. package/lib/cjs/ApiKeysApi.js.map +0 -1
  31. package/lib/cjs/AppsApi.js +0 -119
  32. package/lib/cjs/AppsApi.js.map +0 -1
  33. package/lib/cjs/CommandsApi.js +0 -19
  34. package/lib/cjs/CommandsApi.js.map +0 -1
  35. package/lib/cjs/EnvironmentsApi.js +0 -72
  36. package/lib/cjs/EnvironmentsApi.js.map +0 -1
  37. package/lib/cjs/GroupsApi.js +0 -78
  38. package/lib/cjs/GroupsApi.js.map +0 -1
  39. package/lib/cjs/IamApi.js +0 -53
  40. package/lib/cjs/IamApi.js.map +0 -1
  41. package/lib/cjs/InteractionBase.js +0 -44
  42. package/lib/cjs/InteractionBase.js.map +0 -1
  43. package/lib/cjs/InteractionCatalogApi.js +0 -64
  44. package/lib/cjs/InteractionCatalogApi.js.map +0 -1
  45. package/lib/cjs/InteractionOutput.js +0 -300
  46. package/lib/cjs/InteractionOutput.js.map +0 -1
  47. package/lib/cjs/InteractionResult.example.js +0 -57
  48. package/lib/cjs/InteractionResult.example.js.map +0 -1
  49. package/lib/cjs/InteractionsApi.js +0 -243
  50. package/lib/cjs/InteractionsApi.js.map +0 -1
  51. package/lib/cjs/ProjectsApi.js +0 -53
  52. package/lib/cjs/ProjectsApi.js.map +0 -1
  53. package/lib/cjs/PromptsApi.js +0 -133
  54. package/lib/cjs/PromptsApi.js.map +0 -1
  55. package/lib/cjs/RefsApi.js +0 -14
  56. package/lib/cjs/RefsApi.js.map +0 -1
  57. package/lib/cjs/RunsApi.js +0 -113
  58. package/lib/cjs/RunsApi.js.map +0 -1
  59. package/lib/cjs/SkillsApi.js +0 -39
  60. package/lib/cjs/SkillsApi.js.map +0 -1
  61. package/lib/cjs/StreamSource.js +0 -17
  62. package/lib/cjs/StreamSource.js.map +0 -1
  63. package/lib/cjs/TrainingApi.js +0 -54
  64. package/lib/cjs/TrainingApi.js.map +0 -1
  65. package/lib/cjs/UsersApi.js +0 -13
  66. package/lib/cjs/UsersApi.js.map +0 -1
  67. package/lib/cjs/client.js +0 -351
  68. package/lib/cjs/client.js.map +0 -1
  69. package/lib/cjs/execute.js +0 -158
  70. package/lib/cjs/execute.js.map +0 -1
  71. package/lib/cjs/index.js +0 -22
  72. package/lib/cjs/index.js.map +0 -1
  73. package/lib/cjs/nodejs/NodeStreamSource.js +0 -45
  74. package/lib/cjs/nodejs/NodeStreamSource.js.map +0 -1
  75. package/lib/cjs/nodejs/index.js +0 -18
  76. package/lib/cjs/nodejs/index.js.map +0 -1
  77. package/lib/cjs/package.json +0 -3
  78. package/lib/cjs/store/AnalyzeDocApi.js +0 -56
  79. package/lib/cjs/store/AnalyzeDocApi.js.map +0 -1
  80. package/lib/cjs/store/CollectionsApi.js +0 -131
  81. package/lib/cjs/store/CollectionsApi.js.map +0 -1
  82. package/lib/cjs/store/CommandsApi.js +0 -17
  83. package/lib/cjs/store/CommandsApi.js.map +0 -1
  84. package/lib/cjs/store/EmbeddingsApi.js +0 -29
  85. package/lib/cjs/store/EmbeddingsApi.js.map +0 -1
  86. package/lib/cjs/store/FilesApi.js +0 -225
  87. package/lib/cjs/store/FilesApi.js.map +0 -1
  88. package/lib/cjs/store/ObjectsApi.js +0 -283
  89. package/lib/cjs/store/ObjectsApi.js.map +0 -1
  90. package/lib/cjs/store/TypesApi.js +0 -57
  91. package/lib/cjs/store/TypesApi.js.map +0 -1
  92. package/lib/cjs/store/WorkersApi.js +0 -16
  93. package/lib/cjs/store/WorkersApi.js.map +0 -1
  94. package/lib/cjs/store/WorkflowsApi.js +0 -425
  95. package/lib/cjs/store/WorkflowsApi.js.map +0 -1
  96. package/lib/cjs/store/client.js +0 -71
  97. package/lib/cjs/store/client.js.map +0 -1
  98. package/lib/cjs/store/errors.js +0 -11
  99. package/lib/cjs/store/errors.js.map +0 -1
  100. package/lib/cjs/store/index.js +0 -23
  101. package/lib/cjs/store/index.js.map +0 -1
  102. package/lib/cjs/store/version.js +0 -6
  103. package/lib/cjs/store/version.js.map +0 -1
  104. package/lib/esm/AccountApi.js +0 -82
  105. package/lib/esm/AccountApi.js.map +0 -1
  106. package/lib/esm/AccountsApi.js +0 -13
  107. package/lib/esm/AccountsApi.js.map +0 -1
  108. package/lib/esm/AnalyticsApi.js +0 -38
  109. package/lib/esm/AnalyticsApi.js.map +0 -1
  110. package/lib/esm/ApiKeysApi.js +0 -59
  111. package/lib/esm/ApiKeysApi.js.map +0 -1
  112. package/lib/esm/AppsApi.js +0 -116
  113. package/lib/esm/AppsApi.js.map +0 -1
  114. package/lib/esm/CommandsApi.js +0 -16
  115. package/lib/esm/CommandsApi.js.map +0 -1
  116. package/lib/esm/EnvironmentsApi.js +0 -69
  117. package/lib/esm/EnvironmentsApi.js.map +0 -1
  118. package/lib/esm/GroupsApi.js +0 -74
  119. package/lib/esm/GroupsApi.js.map +0 -1
  120. package/lib/esm/IamApi.js +0 -47
  121. package/lib/esm/IamApi.js.map +0 -1
  122. package/lib/esm/InteractionBase.js +0 -40
  123. package/lib/esm/InteractionBase.js.map +0 -1
  124. package/lib/esm/InteractionCatalogApi.js +0 -60
  125. package/lib/esm/InteractionCatalogApi.js.map +0 -1
  126. package/lib/esm/InteractionOutput.js +0 -293
  127. package/lib/esm/InteractionOutput.js.map +0 -1
  128. package/lib/esm/InteractionResult.example.js +0 -55
  129. package/lib/esm/InteractionResult.example.js.map +0 -1
  130. package/lib/esm/InteractionsApi.js +0 -240
  131. package/lib/esm/InteractionsApi.js.map +0 -1
  132. package/lib/esm/ProjectsApi.js +0 -50
  133. package/lib/esm/ProjectsApi.js.map +0 -1
  134. package/lib/esm/PromptsApi.js +0 -130
  135. package/lib/esm/PromptsApi.js.map +0 -1
  136. package/lib/esm/RefsApi.js +0 -10
  137. package/lib/esm/RefsApi.js.map +0 -1
  138. package/lib/esm/RunsApi.js +0 -109
  139. package/lib/esm/RunsApi.js.map +0 -1
  140. package/lib/esm/SkillsApi.js +0 -36
  141. package/lib/esm/SkillsApi.js.map +0 -1
  142. package/lib/esm/StreamSource.js +0 -13
  143. package/lib/esm/StreamSource.js.map +0 -1
  144. package/lib/esm/TrainingApi.js +0 -51
  145. package/lib/esm/TrainingApi.js.map +0 -1
  146. package/lib/esm/UsersApi.js +0 -10
  147. package/lib/esm/UsersApi.js.map +0 -1
  148. package/lib/esm/client.js +0 -342
  149. package/lib/esm/client.js.map +0 -1
  150. package/lib/esm/execute.js +0 -118
  151. package/lib/esm/execute.js.map +0 -1
  152. package/lib/esm/index.js +0 -6
  153. package/lib/esm/index.js.map +0 -1
  154. package/lib/esm/nodejs/NodeStreamSource.js +0 -41
  155. package/lib/esm/nodejs/NodeStreamSource.js.map +0 -1
  156. package/lib/esm/nodejs/index.js +0 -2
  157. package/lib/esm/nodejs/index.js.map +0 -1
  158. package/lib/esm/store/AnalyzeDocApi.js +0 -52
  159. package/lib/esm/store/AnalyzeDocApi.js.map +0 -1
  160. package/lib/esm/store/CollectionsApi.js +0 -127
  161. package/lib/esm/store/CollectionsApi.js.map +0 -1
  162. package/lib/esm/store/CommandsApi.js +0 -13
  163. package/lib/esm/store/CommandsApi.js.map +0 -1
  164. package/lib/esm/store/EmbeddingsApi.js +0 -25
  165. package/lib/esm/store/EmbeddingsApi.js.map +0 -1
  166. package/lib/esm/store/FilesApi.js +0 -219
  167. package/lib/esm/store/FilesApi.js.map +0 -1
  168. package/lib/esm/store/ObjectsApi.js +0 -279
  169. package/lib/esm/store/ObjectsApi.js.map +0 -1
  170. package/lib/esm/store/TypesApi.js +0 -53
  171. package/lib/esm/store/TypesApi.js.map +0 -1
  172. package/lib/esm/store/WorkersApi.js +0 -12
  173. package/lib/esm/store/WorkersApi.js.map +0 -1
  174. package/lib/esm/store/WorkflowsApi.js +0 -419
  175. package/lib/esm/store/WorkflowsApi.js.map +0 -1
  176. package/lib/esm/store/client.js +0 -67
  177. package/lib/esm/store/client.js.map +0 -1
  178. package/lib/esm/store/errors.js +0 -7
  179. package/lib/esm/store/errors.js.map +0 -1
  180. package/lib/esm/store/index.js +0 -7
  181. package/lib/esm/store/index.js.map +0 -1
  182. package/lib/esm/store/version.js +0 -3
  183. package/lib/esm/store/version.js.map +0 -1
  184. package/lib/tsconfig.tsbuildinfo +0 -1
  185. package/lib/types/AccountApi.d.ts +0 -59
  186. package/lib/types/AccountApi.d.ts.map +0 -1
  187. package/lib/types/AccountsApi.d.ts +0 -7
  188. package/lib/types/AccountsApi.d.ts.map +0 -1
  189. package/lib/types/AnalyticsApi.d.ts +0 -11
  190. package/lib/types/AnalyticsApi.d.ts.map +0 -1
  191. package/lib/types/ApiKeysApi.d.ts +0 -42
  192. package/lib/types/ApiKeysApi.d.ts.map +0 -1
  193. package/lib/types/AppsApi.d.ts +0 -65
  194. package/lib/types/AppsApi.d.ts.map +0 -1
  195. package/lib/types/CommandsApi.d.ts +0 -10
  196. package/lib/types/CommandsApi.d.ts.map +0 -1
  197. package/lib/types/EnvironmentsApi.d.ts +0 -40
  198. package/lib/types/EnvironmentsApi.d.ts.map +0 -1
  199. package/lib/types/GroupsApi.d.ts +0 -65
  200. package/lib/types/GroupsApi.d.ts.map +0 -1
  201. package/lib/types/IamApi.d.ts +0 -41
  202. package/lib/types/IamApi.d.ts.map +0 -1
  203. package/lib/types/InteractionBase.d.ts +0 -22
  204. package/lib/types/InteractionBase.d.ts.map +0 -1
  205. package/lib/types/InteractionCatalogApi.d.ts +0 -36
  206. package/lib/types/InteractionCatalogApi.d.ts.map +0 -1
  207. package/lib/types/InteractionOutput.d.ts +0 -174
  208. package/lib/types/InteractionOutput.d.ts.map +0 -1
  209. package/lib/types/InteractionResult.example.d.ts +0 -6
  210. package/lib/types/InteractionResult.example.d.ts.map +0 -1
  211. package/lib/types/InteractionsApi.d.ts +0 -165
  212. package/lib/types/InteractionsApi.d.ts.map +0 -1
  213. package/lib/types/ProjectsApi.d.ts +0 -18
  214. package/lib/types/ProjectsApi.d.ts.map +0 -1
  215. package/lib/types/PromptsApi.d.ts +0 -106
  216. package/lib/types/PromptsApi.d.ts.map +0 -1
  217. package/lib/types/RefsApi.d.ts +0 -6
  218. package/lib/types/RefsApi.d.ts.map +0 -1
  219. package/lib/types/RunsApi.d.ts +0 -79
  220. package/lib/types/RunsApi.d.ts.map +0 -1
  221. package/lib/types/SkillsApi.d.ts +0 -26
  222. package/lib/types/SkillsApi.d.ts.map +0 -1
  223. package/lib/types/StreamSource.d.ts +0 -7
  224. package/lib/types/StreamSource.d.ts.map +0 -1
  225. package/lib/types/TrainingApi.d.ts +0 -27
  226. package/lib/types/TrainingApi.d.ts.map +0 -1
  227. package/lib/types/UsersApi.d.ts +0 -6
  228. package/lib/types/UsersApi.d.ts.map +0 -1
  229. package/lib/types/client.d.ts +0 -125
  230. package/lib/types/client.d.ts.map +0 -1
  231. package/lib/types/execute.d.ts +0 -37
  232. package/lib/types/execute.d.ts.map +0 -1
  233. package/lib/types/index.d.ts +0 -10
  234. package/lib/types/index.d.ts.map +0 -1
  235. package/lib/types/nodejs/NodeStreamSource.d.ts +0 -9
  236. package/lib/types/nodejs/NodeStreamSource.d.ts.map +0 -1
  237. package/lib/types/nodejs/index.d.ts +0 -1
  238. package/lib/types/nodejs/index.d.ts.map +0 -1
  239. package/lib/types/store/AnalyzeDocApi.d.ts +0 -17
  240. package/lib/types/store/AnalyzeDocApi.d.ts.map +0 -1
  241. package/lib/types/store/CollectionsApi.d.ts +0 -82
  242. package/lib/types/store/CollectionsApi.d.ts.map +0 -1
  243. package/lib/types/store/CommandsApi.d.ts +0 -10
  244. package/lib/types/store/CommandsApi.d.ts.map +0 -1
  245. package/lib/types/store/EmbeddingsApi.d.ts +0 -12
  246. package/lib/types/store/EmbeddingsApi.d.ts.map +0 -1
  247. package/lib/types/store/FilesApi.d.ts +0 -103
  248. package/lib/types/store/FilesApi.d.ts.map +0 -1
  249. package/lib/types/store/ObjectsApi.d.ts +0 -117
  250. package/lib/types/store/ObjectsApi.d.ts.map +0 -1
  251. package/lib/types/store/TypesApi.d.ts +0 -23
  252. package/lib/types/store/TypesApi.d.ts.map +0 -1
  253. package/lib/types/store/WorkersApi.d.ts +0 -6
  254. package/lib/types/store/WorkersApi.d.ts.map +0 -1
  255. package/lib/types/store/WorkflowsApi.d.ts +0 -71
  256. package/lib/types/store/WorkflowsApi.d.ts.map +0 -1
  257. package/lib/types/store/client.d.ts +0 -35
  258. package/lib/types/store/client.d.ts.map +0 -1
  259. package/lib/types/store/errors.d.ts +0 -4
  260. package/lib/types/store/errors.d.ts.map +0 -1
  261. package/lib/types/store/index.d.ts +0 -6
  262. package/lib/types/store/index.d.ts.map +0 -1
  263. package/lib/types/store/version.d.ts +0 -2
  264. package/lib/types/store/version.d.ts.map +0 -1
  265. package/lib/vertesia-client.js +0 -2
  266. package/lib/vertesia-client.js.map +0 -1
@@ -0,0 +1,114 @@
1
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
+ import {
3
+ AgentSchedule,
4
+ AgentScheduleWithTemporalInfo,
5
+ CreateSchedulePayload,
6
+ ScheduleListItem,
7
+ UpdateSchedulePayload,
8
+ } from "@vertesia/common";
9
+
10
+ /**
11
+ * Client API for managing agent schedules.
12
+ *
13
+ * Schedules allow agents to run on a recurring basis using cron expressions.
14
+ */
15
+ export class SchedulesApi extends ApiTopic {
16
+ constructor(parent: ClientBase) {
17
+ super(parent, "/api/v1/schedules");
18
+ }
19
+
20
+ /**
21
+ * List all schedules in the project.
22
+ */
23
+ list(): Promise<ScheduleListItem[]> {
24
+ return this.get("/");
25
+ }
26
+
27
+ /**
28
+ * Retrieve a schedule by ID.
29
+ * Includes Temporal execution info if available.
30
+ */
31
+ retrieve(id: string): Promise<AgentScheduleWithTemporalInfo> {
32
+ return this.get(`/${id}`);
33
+ }
34
+
35
+ /**
36
+ * Create a new schedule.
37
+ *
38
+ * @param payload - Schedule configuration including name, interaction, and cron expression
39
+ * @returns The created schedule
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const schedule = await client.schedules.create({
44
+ * name: 'Weekly Report',
45
+ * interaction: 'WeeklyReportAgent',
46
+ * cron_expression: '0 9 * * MON', // Every Monday at 9am
47
+ * timezone: 'America/New_York',
48
+ * vars: { reportType: 'summary' }
49
+ * });
50
+ * ```
51
+ */
52
+ create(payload: CreateSchedulePayload): Promise<AgentSchedule> {
53
+ return this.post("/", { payload });
54
+ }
55
+
56
+ /**
57
+ * Update an existing schedule.
58
+ *
59
+ * @param id - Schedule ID
60
+ * @param payload - Fields to update
61
+ * @returns The updated schedule
62
+ */
63
+ update(id: string, payload: UpdateSchedulePayload): Promise<AgentSchedule> {
64
+ return this.put(`/${id}`, { payload });
65
+ }
66
+
67
+ /**
68
+ * Delete a schedule.
69
+ *
70
+ * This also removes the corresponding Temporal schedule.
71
+ *
72
+ * @param id - Schedule ID
73
+ * @returns Object with the deleted schedule ID
74
+ */
75
+ delete(id: string): Promise<{ id: string }> {
76
+ return this.del(`/${id}`);
77
+ }
78
+
79
+ /**
80
+ * Trigger an immediate execution of the scheduled agent.
81
+ *
82
+ * This runs the agent immediately without waiting for the next scheduled time.
83
+ *
84
+ * @param id - Schedule ID
85
+ * @returns Success message
86
+ */
87
+ trigger(id: string): Promise<{ message: string }> {
88
+ return this.post(`/${id}/trigger`, {});
89
+ }
90
+
91
+ /**
92
+ * Pause a schedule.
93
+ *
94
+ * The schedule will not run until resumed.
95
+ *
96
+ * @param id - Schedule ID
97
+ * @param note - Optional note explaining why the schedule was paused
98
+ * @returns Success message
99
+ */
100
+ pause(id: string, note?: string): Promise<{ message: string }> {
101
+ return this.post(`/${id}/pause`, { payload: { note } });
102
+ }
103
+
104
+ /**
105
+ * Resume a paused schedule.
106
+ *
107
+ * @param id - Schedule ID
108
+ * @param note - Optional note explaining why the schedule was resumed
109
+ * @returns Success message
110
+ */
111
+ resume(id: string, note?: string): Promise<{ message: string }> {
112
+ return this.post(`/${id}/resume`, { payload: { note } });
113
+ }
114
+ }
@@ -0,0 +1,19 @@
1
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
+ import type { BuiltinToolsCatalogResponse } from "@vertesia/common";
3
+
4
+ /**
5
+ * API for accessing the builtin tools catalog
6
+ */
7
+ export class ToolsApi extends ApiTopic {
8
+ constructor(parent: ClientBase) {
9
+ super(parent, "/api/v1/tools");
10
+ }
11
+
12
+ /**
13
+ * Get the builtin tools catalog
14
+ * @returns List of all available builtin tools with their descriptions and parameter schemas
15
+ */
16
+ getBuiltinCatalog(): Promise<BuiltinToolsCatalogResponse> {
17
+ return this.get('/');
18
+ }
19
+ }
@@ -1,22 +1,41 @@
1
1
  import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
2
  import {
3
3
  ActivityCatalog,
4
+ AgentEvent,
4
5
  AgentMessage,
5
6
  AgentMessageType,
7
+ CompactMessage,
6
8
  CreateWorkflowRulePayload,
7
9
  DSLWorkflowDefinition,
8
10
  DSLWorkflowSpec,
11
+ ErrorAnalyticsResponse,
9
12
  ExecuteWorkflowPayload,
13
+ FirstResponseBehaviorAnalyticsResponse,
14
+ LatencyAnalyticsResponse,
10
15
  ListWorkflowInteractionsResponse,
11
16
  ListWorkflowRunsPayload,
12
17
  ListWorkflowRunsResponse,
18
+ parseMessage,
19
+ toAgentMessage,
20
+ PromptSizeAnalyticsResponse,
21
+ RunsByAgentAnalyticsResponse,
22
+ TimeToFirstResponseAnalyticsResponse,
23
+ TokenUsageAnalyticsResponse,
24
+ ToolAnalyticsResponse,
25
+ ToolParameterAnalyticsResponse,
26
+ TopPrincipalsAnalyticsResponse,
13
27
  WebSocketClientMessage,
14
28
  WebSocketServerMessage,
15
29
  WorkflowActionPayload,
30
+ WorkflowAnalyticsFilterOptionsResponse,
31
+ WorkflowAnalyticsSummaryQuery,
32
+ WorkflowAnalyticsSummaryResponse,
33
+ WorkflowAnalyticsTimeSeriesQuery,
16
34
  WorkflowDefinitionRef,
17
35
  WorkflowRule,
18
36
  WorkflowRuleItem,
19
37
  WorkflowRunWithDetails,
38
+ WorkflowToolParametersQuery,
20
39
  } from "@vertesia/common";
21
40
  import { VertesiaClient } from "../client.js";
22
41
  import { EventSourceProvider } from "../execute.js";
@@ -49,8 +68,26 @@ export class WorkflowsApi extends ApiTopic {
49
68
  return this.post(`/runs/${workflowId}/${runId}/signal/${signal}`, { payload });
50
69
  }
51
70
 
52
- getRunDetails(runId: string, workflowId: string, includeHistory: boolean = false): Promise<WorkflowRunWithDetails> {
53
- const query = { include_history: includeHistory };
71
+ getRunDetails(
72
+ runId: string,
73
+ workflowId: string,
74
+ options?: {
75
+ includeHistory?: boolean;
76
+ historyFormat?: 'events' | 'tasks' | 'agent';
77
+ }
78
+ ): Promise<WorkflowRunWithDetails> {
79
+ const query: Record<string, any> = {};
80
+
81
+ // Support legacy includeHistory parameter
82
+ if (options?.includeHistory !== undefined) {
83
+ query.include_history = options.includeHistory;
84
+ }
85
+
86
+ // Support new historyFormat parameter
87
+ if (options?.historyFormat !== undefined) {
88
+ query.history_format = options.historyFormat;
89
+ }
90
+
54
91
  return this.get(`/runs/${workflowId}/${runId}`, { query });
55
92
  }
56
93
 
@@ -94,15 +131,29 @@ export class WorkflowsApi extends ApiTopic {
94
131
  return this.post(`/runs/${runId}/updates`, { payload: msg });
95
132
  }
96
133
 
97
- retrieveMessages(workflowId: string, runId: string, since?: number): Promise<AgentMessage[]> {
98
- const query = {
99
- since,
100
- };
101
- return this.get(`/runs/${workflowId}/${runId}/updates`, { query });
134
+ /**
135
+ * Retrieve historical messages for a workflow run.
136
+ * Returns messages in AgentMessage format for backward compatibility.
137
+ * This endpoint returns gzip-compressed responses for large payloads (> 3KB).
138
+ */
139
+ async retrieveMessages(workflowId: string, runId: string, since?: number): Promise<AgentMessage[]> {
140
+ const query = { since };
141
+ const response = await this.get(`/runs/${workflowId}/${runId}/updates`, { query }) as { messages: CompactMessage[] };
142
+ // Convert compact messages to AgentMessage for backward compatibility
143
+ return response.messages.map((m: CompactMessage) => toAgentMessage(m, runId));
102
144
  }
103
145
 
146
+ /**
147
+ * Stream workflow messages in real-time via SSE.
148
+ *
149
+ * This method fetches historical messages via GET /updates (gzip-compressed for large payloads)
150
+ * then connects to SSE for real-time updates only (skipHistory=true).
151
+ *
152
+ * This approach provides better performance for conversations with large historical messages
153
+ * since HTTP responses are compressed while SSE streams cannot be compressed.
154
+ */
104
155
  async streamMessages(workflowId: string, runId: string, onMessage?: (message: AgentMessage, exitFn?: (payload: unknown) => void) => void, since?: number): Promise<unknown> {
105
- return new Promise<unknown>((resolve, reject) => {
156
+ return new Promise<unknown>(async (resolve, reject) => {
106
157
  let reconnectAttempts = 0;
107
158
  let lastMessageTimestamp = since || 0;
108
159
  let isClosed = false;
@@ -139,6 +190,35 @@ export class WorkflowsApi extends ApiTopic {
139
190
  }
140
191
  };
141
192
 
193
+ // 1. Fetch historical messages via GET /updates (gzip-compressed if > 3KB)
194
+ // This is more efficient than receiving historical over uncompressed SSE
195
+ try {
196
+ const historical = await this.retrieveMessages(workflowId, runId, since);
197
+ for (const msg of historical) {
198
+ // Update timestamp for SSE connection
199
+ lastMessageTimestamp = Math.max(lastMessageTimestamp, msg.timestamp || 0);
200
+
201
+ // Deliver historical messages to consumer
202
+ if (onMessage) {
203
+ onMessage(msg, exit);
204
+ }
205
+
206
+ // Check if workflow already completed
207
+ const workstreamId = msg.workstream_id || 'main';
208
+ const streamIsOver = msg.type === AgentMessageType.TERMINATED ||
209
+ (msg.type === AgentMessageType.COMPLETE && workstreamId === 'main');
210
+ if (streamIsOver) {
211
+ console.log("Workflow already completed in historical messages");
212
+ resolve(null);
213
+ return;
214
+ }
215
+ }
216
+ } catch (err) {
217
+ console.warn("Failed to fetch historical messages, continuing with SSE:", err);
218
+ // Continue to SSE - it will send historical if skipHistory is not set
219
+ }
220
+
221
+ // 2. Connect to SSE for real-time updates only (skipHistory=true)
142
222
  const setupStream = async (isReconnect: boolean = false) => {
143
223
  if (isClosed) return;
144
224
 
@@ -152,6 +232,9 @@ export class WorkflowsApi extends ApiTopic {
152
232
  streamUrl.searchParams.set("since", lastMessageTimestamp.toString());
153
233
  }
154
234
 
235
+ // Skip historical messages - we already fetched them via GET /updates
236
+ streamUrl.searchParams.set("skipHistory", "true");
237
+
155
238
  const bearerToken = client._auth ? await client._auth() : undefined;
156
239
  if (!bearerToken) {
157
240
  reject(new Error("No auth token available"));
@@ -186,18 +269,27 @@ export class WorkflowsApi extends ApiTopic {
186
269
  }
187
270
 
188
271
  try {
189
- const message = JSON.parse(ev.data) as AgentMessage;
272
+ // Parse message using parseMessage() which handles both compact and legacy formats
273
+ const compactMessage = parseMessage(ev.data);
274
+
275
+ // Update last message timestamp for reconnection (use ts field or current time)
276
+ if (compactMessage.ts) {
277
+ lastMessageTimestamp = Math.max(lastMessageTimestamp, compactMessage.ts);
278
+ } else {
279
+ lastMessageTimestamp = Date.now();
280
+ }
190
281
 
191
- // Update last message timestamp for reconnection
192
- if (message.timestamp) {
193
- lastMessageTimestamp = Math.max(lastMessageTimestamp, message.timestamp);
282
+ // Convert to AgentMessage for consumers (they shouldn't need to know about compact format)
283
+ if (onMessage) {
284
+ const agentMessage = toAgentMessage(compactMessage, runId);
285
+ onMessage(agentMessage, exit);
194
286
  }
195
287
 
196
- if (onMessage) onMessage(message, exit);
288
+ // Get workstream ID (defaults to 'main' if not set)
289
+ const workstreamId = compactMessage.w || 'main';
197
290
 
198
- const streamIsOver = message.type === AgentMessageType.TERMINATED ||
199
- (message.type === AgentMessageType.COMPLETE &&
200
- (!message.workstream_id || message.workstream_id === 'main'));
291
+ const streamIsOver = compactMessage.t === AgentMessageType.TERMINATED ||
292
+ (compactMessage.t === AgentMessageType.COMPLETE && workstreamId === 'main');
201
293
 
202
294
  // Only close the stream when the main workstream completes or terminates
203
295
  if (streamIsOver) {
@@ -207,8 +299,8 @@ export class WorkflowsApi extends ApiTopic {
207
299
  cleanup();
208
300
  resolve(null);
209
301
  }
210
- } else if (message.type === AgentMessageType.COMPLETE) {
211
- console.log(`Received COMPLETE message from non-main workstream: ${message.workstream_id || 'unknown'}, keeping stream open`);
302
+ } else if (compactMessage.t === AgentMessageType.COMPLETE) {
303
+ console.log(`Received COMPLETE message from non-main workstream: ${workstreamId}, keeping stream open`);
212
304
  }
213
305
  } catch (err) {
214
306
  console.error("Failed to parse SSE message:", err, ev.data);
@@ -269,14 +361,14 @@ export class WorkflowsApi extends ApiTopic {
269
361
  * Stream workflow messages via WebSocket (for mobile/React Native clients)
270
362
  * @param workflowId The workflow ID
271
363
  * @param runId The run ID
272
- * @param onMessage Callback for incoming messages
364
+ * @param onMessage Callback for incoming messages (CompactMessage format)
273
365
  * @param since Optional timestamp to resume from
274
366
  * @returns Promise that resolves with cleanup function and sendSignal helper
275
367
  */
276
368
  async streamMessagesWS(
277
369
  workflowId: string,
278
370
  runId: string,
279
- onMessage?: (message: AgentMessage) => void,
371
+ onMessage?: (message: CompactMessage) => void,
280
372
  since?: number
281
373
  ): Promise<{ cleanup: () => void; sendSignal: (signalName: string, data: any) => void }> {
282
374
  return new Promise((resolve, reject) => {
@@ -359,40 +451,49 @@ export class WorkflowsApi extends ApiTopic {
359
451
 
360
452
  ws.onmessage = (event: MessageEvent) => {
361
453
  try {
362
- const message = JSON.parse(event.data) as WebSocketServerMessage;
454
+ const rawMessage = JSON.parse(event.data) as WebSocketServerMessage;
455
+
456
+ // Handle control messages (pong, ack, error)
457
+ if ('type' in rawMessage && typeof rawMessage.type === 'string') {
458
+ if (rawMessage.type === 'pong') {
459
+ console.debug('Received pong');
460
+ return;
461
+ } else if (rawMessage.type === 'ack') {
462
+ console.debug('Signal acknowledged', rawMessage);
463
+ return;
464
+ } else if (rawMessage.type === 'error') {
465
+ console.error('WebSocket error message', rawMessage);
466
+ return;
467
+ }
468
+ }
363
469
 
364
- // Handle different message types
365
- if ('workflow_run_id' in message) {
366
- // This is an AgentMessage
367
- const agentMessage = message as AgentMessage;
470
+ // Parse agent message (handles both compact and legacy formats)
471
+ const message = parseMessage(rawMessage);
368
472
 
369
- if (agentMessage.timestamp) {
370
- lastMessageTimestamp = Math.max(lastMessageTimestamp, agentMessage.timestamp);
371
- }
473
+ // Update timestamp for reconnection
474
+ if (message.ts) {
475
+ lastMessageTimestamp = Math.max(lastMessageTimestamp, message.ts);
476
+ } else {
477
+ lastMessageTimestamp = Date.now();
478
+ }
372
479
 
373
- if (onMessage) onMessage(agentMessage);
480
+ if (onMessage) onMessage(message);
374
481
 
375
- // Check for stream completion
376
- const streamIsOver =
377
- agentMessage.type === AgentMessageType.TERMINATED ||
378
- (agentMessage.type === AgentMessageType.COMPLETE &&
379
- (!agentMessage.workstream_id || agentMessage.workstream_id === 'main'));
482
+ // Get workstream ID (defaults to 'main' if not set)
483
+ const workstreamId = message.w || 'main';
380
484
 
381
- if (streamIsOver) {
382
- console.log('Closing WebSocket due to workflow completion');
383
- isClosed = true;
384
- if (ws) {
385
- ws.close();
386
- ws = null;
387
- }
485
+ // Check for stream completion
486
+ const streamIsOver =
487
+ message.t === AgentMessageType.TERMINATED ||
488
+ (message.t === AgentMessageType.COMPLETE && workstreamId === 'main');
489
+
490
+ if (streamIsOver) {
491
+ console.log('Closing WebSocket due to workflow completion');
492
+ isClosed = true;
493
+ if (ws) {
494
+ ws.close();
495
+ ws = null;
388
496
  }
389
- } else if (message.type === 'pong') {
390
- // Heartbeat response
391
- console.debug('Received pong');
392
- } else if (message.type === 'ack') {
393
- console.debug('Signal acknowledged', message);
394
- } else if (message.type === 'error') {
395
- console.error('WebSocket error message', message);
396
497
  }
397
498
  } catch (err) {
398
499
  console.error('Failed to parse WebSocket message', err);
@@ -429,6 +530,167 @@ export class WorkflowsApi extends ApiTopic {
429
530
  });
430
531
  }
431
532
 
533
+ /**
534
+ * Ingest telemetry events for a workflow run.
535
+ * Workers use this to send telemetry to zeno-server for BigQuery storage.
536
+ */
537
+ ingestEvents(
538
+ workflowId: string,
539
+ runId: string,
540
+ events: AgentEvent[]
541
+ ): Promise<{ ingested: number; status?: string; error?: string }> {
542
+ return this.post(`/runs/${workflowId}/${runId}/events`, {
543
+ payload: { events },
544
+ });
545
+ }
546
+
547
+ // ========================================================================
548
+ // Analytics API
549
+ // ========================================================================
550
+
551
+ /**
552
+ * Get workflow analytics summary.
553
+ * Returns overall metrics including token usage, success rates, and run counts.
554
+ */
555
+ getAnalyticsSummary(
556
+ query: WorkflowAnalyticsSummaryQuery = {}
557
+ ): Promise<WorkflowAnalyticsSummaryResponse> {
558
+ return this.post('/analytics/summary', { payload: query });
559
+ }
560
+
561
+ /**
562
+ * Get token usage analytics.
563
+ * Returns token consumption metrics by model, agent, tool, or over time.
564
+ */
565
+ getTokenUsageAnalytics(
566
+ query: WorkflowAnalyticsTimeSeriesQuery = {}
567
+ ): Promise<TokenUsageAnalyticsResponse> {
568
+ return this.post('/analytics/tokens', { payload: query });
569
+ }
570
+
571
+ /**
572
+ * Get LLM latency analytics.
573
+ * Returns duration/latency metrics for LLM calls.
574
+ */
575
+ getLlmLatencyAnalytics(
576
+ query: WorkflowAnalyticsTimeSeriesQuery = {}
577
+ ): Promise<LatencyAnalyticsResponse> {
578
+ return this.post('/analytics/latency/llm', { payload: query });
579
+ }
580
+
581
+ /**
582
+ * Get tool latency analytics.
583
+ * Returns duration/latency metrics for tool calls.
584
+ */
585
+ getToolLatencyAnalytics(
586
+ query: WorkflowAnalyticsTimeSeriesQuery = {}
587
+ ): Promise<LatencyAnalyticsResponse> {
588
+ return this.post('/analytics/latency/tools', { payload: query });
589
+ }
590
+
591
+ /**
592
+ * Get agent/workflow latency analytics.
593
+ * Returns duration metrics for complete workflow runs.
594
+ */
595
+ getAgentLatencyAnalytics(
596
+ query: WorkflowAnalyticsTimeSeriesQuery = {}
597
+ ): Promise<LatencyAnalyticsResponse> {
598
+ return this.post('/analytics/latency/agents', { payload: query });
599
+ }
600
+
601
+ /**
602
+ * Get error analytics.
603
+ * Returns error rates, types, and trends.
604
+ */
605
+ getErrorAnalytics(
606
+ query: WorkflowAnalyticsTimeSeriesQuery = {}
607
+ ): Promise<ErrorAnalyticsResponse> {
608
+ return this.post('/analytics/errors', { payload: query });
609
+ }
610
+
611
+ /**
612
+ * Get tool usage analytics.
613
+ * Returns tool invocation counts, success rates, and performance metrics.
614
+ */
615
+ getToolAnalytics(
616
+ query: WorkflowAnalyticsSummaryQuery = {}
617
+ ): Promise<ToolAnalyticsResponse> {
618
+ return this.post('/analytics/tools', { payload: query });
619
+ }
620
+
621
+ /**
622
+ * Get tool parameter analytics.
623
+ * Returns parameter value distributions for a specific tool.
624
+ */
625
+ getToolParameterAnalytics(
626
+ query: WorkflowToolParametersQuery
627
+ ): Promise<ToolParameterAnalyticsResponse> {
628
+ return this.post('/analytics/tools/parameters', { payload: query });
629
+ }
630
+
631
+ /**
632
+ * Get available filter options for analytics.
633
+ * Returns unique agents, environments, and models from telemetry data.
634
+ */
635
+ getAnalyticsFilterOptions(
636
+ query: WorkflowAnalyticsSummaryQuery = {}
637
+ ): Promise<WorkflowAnalyticsFilterOptionsResponse> {
638
+ return this.post('/analytics/filter-options', { payload: query });
639
+ }
640
+
641
+ /**
642
+ * Get average prompt size (input tokens) by agent for startConversation calls.
643
+ * This represents the initial prompt + tools size.
644
+ */
645
+ getPromptSizeAnalytics(
646
+ query: WorkflowAnalyticsSummaryQuery = {}
647
+ ): Promise<PromptSizeAnalyticsResponse> {
648
+ return this.post('/analytics/prompt-size', { payload: query });
649
+ }
650
+
651
+ /**
652
+ * Get top principals (users/API keys) who started the most agent runs.
653
+ * Returns the top N principals sorted by run count descending.
654
+ */
655
+ getTopPrincipalsAnalytics(
656
+ query: WorkflowAnalyticsSummaryQuery = {}
657
+ ): Promise<TopPrincipalsAnalyticsResponse> {
658
+ return this.post('/analytics/top-principals', { payload: query });
659
+ }
660
+
661
+ /**
662
+ * Get agent run distribution - how many runs per agent/interaction type.
663
+ * Returns the top N agents sorted by run count descending.
664
+ */
665
+ getRunsByAgentAnalytics(
666
+ query: WorkflowAnalyticsSummaryQuery = {}
667
+ ): Promise<RunsByAgentAnalyticsResponse> {
668
+ return this.post('/analytics/runs-by-agent', { payload: query });
669
+ }
670
+
671
+ /**
672
+ * Get time to first response analytics.
673
+ * Measures the time from agent start to the completion of the first LLM call.
674
+ * Returns average, min, max, median, p95, and p99 metrics.
675
+ */
676
+ getTimeToFirstResponseAnalytics(
677
+ query: WorkflowAnalyticsTimeSeriesQuery = {}
678
+ ): Promise<TimeToFirstResponseAnalyticsResponse> {
679
+ return this.post('/analytics/time-to-first-response', { payload: query });
680
+ }
681
+
682
+ /**
683
+ * Get first response behavior analytics.
684
+ * Analyzes the agent's first LLM response behavior:
685
+ * - Percentage of agents that start by making a plan
686
+ * - Percentage of agents that return no tool calls at start
687
+ */
688
+ getFirstResponseBehaviorAnalytics(
689
+ query: WorkflowAnalyticsTimeSeriesQuery = {}
690
+ ): Promise<FirstResponseBehaviorAnalyticsResponse> {
691
+ return this.post('/analytics/first-response-behavior', { payload: query });
692
+ }
693
+
432
694
  rules = new WorkflowsRulesApi(this);
433
695
  definitions = new WorkflowsDefinitionApi(this);
434
696
  }
@@ -2,14 +2,23 @@ import { AbstractFetchClient, RequestError } from "@vertesia/api-fetch-client";
2
2
  import { BulkOperationPayload, BulkOperationResult } from "@vertesia/common";
3
3
  import { CollectionsApi } from "./CollectionsApi.js";
4
4
  import { CommandsApi } from "./CommandsApi.js";
5
+ import { DataApi } from "./DataApi.js";
6
+ import { EmailApi } from "./EmailApi.js";
7
+ import { IndexingAdminApi } from "./IndexingAdminApi.js";
8
+ import { IndexingApi } from "./IndexingApi.js";
5
9
  import { EmbeddingsApi } from "./EmbeddingsApi.js";
6
10
  import { ZenoClientNotFoundError } from "./errors.js";
7
11
  import { FilesApi } from "./FilesApi.js";
8
12
  import { ObjectsApi } from "./ObjectsApi.js";
13
+ import { PendingAsksApi } from "./PendingAsksApi.js";
14
+ import { QueryApi } from "./QueryApi.js";
15
+ import { SchedulesApi } from "./SchedulesApi.js";
16
+ import { ToolsApi } from "./ToolsApi.js";
9
17
  import { TypesApi } from "./TypesApi.js";
10
18
  import { VERSION, VERSION_HEADER } from "./version.js";
11
19
  import { WorkersApi } from "./WorkersApi.js";
12
20
  import { WorkflowsApi } from "./WorkflowsApi.js";
21
+ import { HiveMemoryApi } from "./HiveMemoryApi.js";
13
22
 
14
23
  export interface ZenoClientProps {
15
24
  serverUrl?: string;
@@ -77,9 +86,18 @@ export class ZenoClient extends AbstractFetchClient<ZenoClient> {
77
86
  objects = new ObjectsApi(this);
78
87
  types = new TypesApi(this);
79
88
  workflows = new WorkflowsApi(this);
89
+ schedules = new SchedulesApi(this);
80
90
  files = new FilesApi(this);
81
91
  commands = new CommandsApi(this);
82
92
  workers = new WorkersApi(this);
83
93
  collections = new CollectionsApi(this);
84
94
  embeddings = new EmbeddingsApi(this);
95
+ email = new EmailApi(this);
96
+ pendingAsks = new PendingAsksApi(this);
97
+ data = new DataApi(this);
98
+ tools = new ToolsApi(this);
99
+ indexing = new IndexingApi(this);
100
+ query = new QueryApi(this);
101
+ indexingAdmin = new IndexingAdminApi(this);
102
+ hiveMemory = new HiveMemoryApi(this);
85
103
  }
@@ -1,7 +1,16 @@
1
1
  export * from "./client.js";
2
2
  export * from "./CommandsApi.js";
3
+ export * from "./DataApi.js";
4
+ export * from "./EmailApi.js";
5
+ export * from "./errors.js";
3
6
  export * from "./FilesApi.js";
7
+ export * from "./HiveMemoryApi.js";
8
+ export * from "./IndexingAdminApi.js";
9
+ export * from "./IndexingApi.js";
4
10
  export * from "./ObjectsApi.js";
11
+ export * from "./PendingAsksApi.js";
12
+ export * from "./QueryApi.js";
13
+ export * from "./SchedulesApi.js";
5
14
  export * from "./TypesApi.js";
6
15
  export * from "./WorkflowsApi.js";
7
16