@vertesia/common 1.0.0 → 1.1.0-dev.20260427.060440Z

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 (141) hide show
  1. package/lib/cjs/access-control.js +2 -0
  2. package/lib/cjs/access-control.js.map +1 -1
  3. package/lib/cjs/apikey.js.map +1 -1
  4. package/lib/cjs/apps.js +35 -0
  5. package/lib/cjs/apps.js.map +1 -1
  6. package/lib/cjs/audit-trail.js +7 -0
  7. package/lib/cjs/audit-trail.js.map +1 -1
  8. package/lib/cjs/cost-analytics.js +13 -0
  9. package/lib/cjs/cost-analytics.js.map +1 -0
  10. package/lib/cjs/group.js +2 -1
  11. package/lib/cjs/group.js.map +1 -1
  12. package/lib/cjs/index.js +3 -1
  13. package/lib/cjs/index.js.map +1 -1
  14. package/lib/cjs/interaction.js +2 -0
  15. package/lib/cjs/interaction.js.map +1 -1
  16. package/lib/cjs/oauth-server.js +3 -0
  17. package/lib/cjs/oauth-server.js.map +1 -0
  18. package/lib/cjs/oauth.js +1 -1
  19. package/lib/cjs/project.js.map +1 -1
  20. package/lib/cjs/store/conversation-state.js.map +1 -1
  21. package/lib/cjs/store/rendering.js +4 -0
  22. package/lib/cjs/store/rendering.js.map +1 -1
  23. package/lib/cjs/store/schedule.js.map +1 -1
  24. package/lib/cjs/store/store.js +4 -1
  25. package/lib/cjs/store/store.js.map +1 -1
  26. package/lib/cjs/store/workflow.js.map +1 -1
  27. package/lib/cjs/user.js +1 -0
  28. package/lib/cjs/user.js.map +1 -1
  29. package/lib/esm/access-control.js +2 -0
  30. package/lib/esm/access-control.js.map +1 -1
  31. package/lib/esm/apikey.js.map +1 -1
  32. package/lib/esm/apps.js +30 -0
  33. package/lib/esm/apps.js.map +1 -1
  34. package/lib/esm/audit-trail.js +6 -1
  35. package/lib/esm/audit-trail.js.map +1 -1
  36. package/lib/esm/cost-analytics.js +10 -0
  37. package/lib/esm/cost-analytics.js.map +1 -0
  38. package/lib/esm/group.js +1 -0
  39. package/lib/esm/group.js.map +1 -1
  40. package/lib/esm/index.js +3 -1
  41. package/lib/esm/index.js.map +1 -1
  42. package/lib/esm/interaction.js +2 -0
  43. package/lib/esm/interaction.js.map +1 -1
  44. package/lib/esm/oauth-server.js +2 -0
  45. package/lib/esm/oauth-server.js.map +1 -0
  46. package/lib/esm/oauth.js +1 -1
  47. package/lib/esm/project.js.map +1 -1
  48. package/lib/esm/store/conversation-state.js.map +1 -1
  49. package/lib/esm/store/rendering.js +3 -0
  50. package/lib/esm/store/rendering.js.map +1 -1
  51. package/lib/esm/store/schedule.js.map +1 -1
  52. package/lib/esm/store/store.js +3 -0
  53. package/lib/esm/store/store.js.map +1 -1
  54. package/lib/esm/store/workflow.js.map +1 -1
  55. package/lib/esm/user.js +1 -0
  56. package/lib/esm/user.js.map +1 -1
  57. package/lib/tsconfig.tsbuildinfo +1 -1
  58. package/lib/types/access-control.d.ts +2 -0
  59. package/lib/types/access-control.d.ts.map +1 -1
  60. package/lib/types/analytics.d.ts +12 -6
  61. package/lib/types/analytics.d.ts.map +1 -1
  62. package/lib/types/apikey.d.ts +1 -0
  63. package/lib/types/apikey.d.ts.map +1 -1
  64. package/lib/types/apps.d.ts +351 -40
  65. package/lib/types/apps.d.ts.map +1 -1
  66. package/lib/types/ask-user.d.ts +0 -4
  67. package/lib/types/ask-user.d.ts.map +1 -1
  68. package/lib/types/audit-trail.d.ts +32 -5
  69. package/lib/types/audit-trail.d.ts.map +1 -1
  70. package/lib/types/cost-analytics.d.ts +154 -0
  71. package/lib/types/cost-analytics.d.ts.map +1 -0
  72. package/lib/types/group.d.ts +1 -0
  73. package/lib/types/group.d.ts.map +1 -1
  74. package/lib/types/index.d.ts +3 -1
  75. package/lib/types/index.d.ts.map +1 -1
  76. package/lib/types/interaction.d.ts +33 -4
  77. package/lib/types/interaction.d.ts.map +1 -1
  78. package/lib/types/oauth-server.d.ts +224 -0
  79. package/lib/types/oauth-server.d.ts.map +1 -0
  80. package/lib/types/oauth.d.ts +29 -18
  81. package/lib/types/oauth.d.ts.map +1 -1
  82. package/lib/types/project.d.ts +87 -19
  83. package/lib/types/project.d.ts.map +1 -1
  84. package/lib/types/query.d.ts +7 -0
  85. package/lib/types/query.d.ts.map +1 -1
  86. package/lib/types/refs.d.ts +4 -0
  87. package/lib/types/refs.d.ts.map +1 -1
  88. package/lib/types/runs.d.ts +14 -0
  89. package/lib/types/runs.d.ts.map +1 -1
  90. package/lib/types/store/agent-run.d.ts +160 -2
  91. package/lib/types/store/agent-run.d.ts.map +1 -1
  92. package/lib/types/store/conversation-state.d.ts +21 -2
  93. package/lib/types/store/conversation-state.d.ts.map +1 -1
  94. package/lib/types/store/doc-analyzer.d.ts +10 -0
  95. package/lib/types/store/doc-analyzer.d.ts.map +1 -1
  96. package/lib/types/store/rendering.d.ts +6 -0
  97. package/lib/types/store/rendering.d.ts.map +1 -1
  98. package/lib/types/store/schedule.d.ts +2 -5
  99. package/lib/types/store/schedule.d.ts.map +1 -1
  100. package/lib/types/store/store.d.ts +9 -0
  101. package/lib/types/store/store.d.ts.map +1 -1
  102. package/lib/types/store/workflow.d.ts +2 -2
  103. package/lib/types/store/workflow.d.ts.map +1 -1
  104. package/lib/types/tool-execution.d.ts +4 -0
  105. package/lib/types/tool-execution.d.ts.map +1 -1
  106. package/lib/types/transient-tokens.d.ts +1 -1
  107. package/lib/types/transient-tokens.d.ts.map +1 -1
  108. package/lib/types/user.d.ts +1 -0
  109. package/lib/types/user.d.ts.map +1 -1
  110. package/lib/types/workflow-analytics.d.ts +12 -0
  111. package/lib/types/workflow-analytics.d.ts.map +1 -1
  112. package/lib/vertesia-common.js +1 -1
  113. package/lib/vertesia-common.js.map +1 -1
  114. package/package.json +4 -4
  115. package/src/access-control.ts +2 -0
  116. package/src/analytics.ts +13 -6
  117. package/src/apikey.ts +1 -0
  118. package/src/apps.ts +401 -40
  119. package/src/ask-user.ts +0 -4
  120. package/src/audit-trail.ts +44 -5
  121. package/src/cost-analytics.ts +165 -0
  122. package/src/group.ts +3 -1
  123. package/src/index.ts +3 -2
  124. package/src/interaction.ts +37 -3
  125. package/src/oauth-server.ts +248 -0
  126. package/src/oauth.ts +30 -18
  127. package/src/project.ts +94 -21
  128. package/src/query.ts +7 -0
  129. package/src/refs.ts +4 -0
  130. package/src/runs.ts +15 -0
  131. package/src/store/agent-run.ts +186 -2
  132. package/src/store/conversation-state.ts +24 -2
  133. package/src/store/doc-analyzer.ts +12 -0
  134. package/src/store/rendering.ts +10 -0
  135. package/src/store/schedule.ts +2 -6
  136. package/src/store/store.ts +11 -0
  137. package/src/store/workflow.ts +3 -2
  138. package/src/tool-execution.ts +4 -0
  139. package/src/transient-tokens.ts +1 -1
  140. package/src/user.ts +1 -0
  141. package/src/workflow-analytics.ts +12 -0
package/src/oauth.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
- * OAuth Application types for generic, project-level OAuth 2.0 integration.
2
+ * OAuth Provider types for generic, project-level OAuth 2.0 integration.
3
3
  * Decoupled from MCP — can be used by MCP collections, tool activities, or any OAuth-protected API.
4
4
  */
5
5
 
6
6
  /**
7
- * OAuth Application data stored in MongoDB.
7
+ * OAuth Provider data stored in MongoDB.
8
8
  * Represents the configuration for an OAuth 2.0 provider at the project level.
9
9
  */
10
- export interface OAuthApplicationData {
10
+ export interface OAuthProviderData {
11
11
  /**
12
12
  * Unique name within the project (kebab-case identifier).
13
13
  */
@@ -19,12 +19,20 @@ export interface OAuthApplicationData {
19
19
  display_name: string;
20
20
 
21
21
  /**
22
- * The project this OAuth application belongs to.
22
+ * The project this OAuth provider belongs to.
23
23
  */
24
24
  project: string;
25
25
 
26
+ /**
27
+ * The OAuth 2.0 grant type to use.
28
+ * - 'authorization_code': 3-legged flow requiring user authorization (default).
29
+ * - 'client_credentials': 2-legged server-to-server flow using client_id + client_secret.
30
+ */
31
+ grant_type?: 'authorization_code' | 'client_credentials';
32
+
26
33
  /**
27
34
  * The OAuth 2.0 authorization endpoint URL.
35
+ * Only used for authorization_code flow.
28
36
  * Optional when endpoints are discovered via .well-known (e.g. MCP servers).
29
37
  */
30
38
  authorization_endpoint?: string;
@@ -52,7 +60,7 @@ export interface OAuthApplicationData {
52
60
 
53
61
  /**
54
62
  * Whether to use PKCE (Proof Key for Code Exchange) in the authorization flow.
55
- * Defaults to true.
63
+ * Only applies to authorization_code flow. Defaults to true.
56
64
  */
57
65
  use_pkce: boolean;
58
66
 
@@ -66,19 +74,20 @@ export interface OAuthApplicationData {
66
74
  }
67
75
 
68
76
  /**
69
- * OAuth Application as returned by the API (with id).
77
+ * OAuth Provider as returned by the API (with id).
70
78
  */
71
- export interface OAuthApplication extends OAuthApplicationData {
79
+ export interface OAuthProvider extends OAuthProviderData {
72
80
  id: string;
73
81
  }
74
82
 
75
83
  /**
76
- * Payload for creating an OAuth Application.
84
+ * Payload for creating an OAuth Provider.
77
85
  * The client_secret is accepted as plaintext on create and stored encrypted.
78
86
  */
79
- export interface CreateOAuthApplicationPayload {
87
+ export interface CreateOAuthProviderPayload {
80
88
  name: string;
81
89
  display_name: string;
90
+ grant_type?: 'authorization_code' | 'client_credentials';
82
91
  authorization_endpoint?: string;
83
92
  token_endpoint?: string;
84
93
  client_id: string;
@@ -93,18 +102,18 @@ export interface CreateOAuthApplicationPayload {
93
102
  }
94
103
 
95
104
  /**
96
- * Payload for updating an OAuth Application.
105
+ * Payload for updating an OAuth Provider.
97
106
  * All fields are optional — only provided fields are updated.
98
107
  * To clear the client_secret, set it to an empty string.
99
108
  */
100
- export type UpdateOAuthApplicationPayload = Partial<CreateOAuthApplicationPayload>;
109
+ export type UpdateOAuthProviderPayload = Partial<CreateOAuthProviderPayload>;
101
110
 
102
111
  /**
103
- * OAuth authentication status for a user against an OAuth Application.
112
+ * OAuth authentication status for a user against an OAuth Provider.
104
113
  */
105
- export interface OAuthAppAuthStatus {
106
- oauth_app_id: string;
107
- oauth_app_name: string;
114
+ export interface OAuthProviderAuthStatus {
115
+ oauth_provider_id: string;
116
+ oauth_provider_name: string;
108
117
  authenticated: boolean;
109
118
  expires_at?: string;
110
119
  scope?: string;
@@ -112,8 +121,11 @@ export interface OAuthAppAuthStatus {
112
121
 
113
122
  /**
114
123
  * Response from the OAuth authorize endpoint.
124
+ * For authorization_code flow: contains authorization_url and state for browser redirect.
125
+ * For client_credentials flow: contains connected=true (token was fetched server-side, no redirect needed).
115
126
  */
116
- export interface OAuthAppAuthorizeResponse {
117
- authorization_url: string;
118
- state: string;
127
+ export interface OAuthProviderAuthorizeResponse {
128
+ authorization_url?: string;
129
+ state?: string;
130
+ connected?: boolean;
119
131
  }
package/src/project.ts CHANGED
@@ -333,6 +333,16 @@ export interface IndexingStatusResponse {
333
333
  elapsed_seconds: number;
334
334
  /** Estimated seconds remaining (null if unknown) */
335
335
  estimated_seconds_remaining: number | null;
336
+ /** Total bytes sent to ES */
337
+ total_bytes?: number;
338
+ /** Total ES bulk flushes */
339
+ bulk_flushes?: number;
340
+ /** Average bytes per ES bulk flush */
341
+ avg_flush_bytes?: number;
342
+ /** Configured batch size */
343
+ batch_size?: number;
344
+ /** Configured parallel batch count */
345
+ parallel_batch_count?: number;
336
346
  };
337
347
  }
338
348
 
@@ -404,17 +414,6 @@ export interface FetchBatchResult {
404
414
  done: boolean;
405
415
  }
406
416
 
407
- /**
408
- * Result from indexing a batch
409
- */
410
- export interface IndexBatchResult {
411
- successful: number;
412
- failed: number;
413
- processed: number;
414
- next_cursor: string | null;
415
- done: boolean;
416
- }
417
-
418
417
  /**
419
418
  * Result from discovering the next cursor boundary for batch partitioning
420
419
  */
@@ -437,6 +436,90 @@ export interface TriggerReindexResult {
437
436
  enabled?: boolean;
438
437
  }
439
438
 
439
+ // ========================================================================
440
+ // Zeno Bulk (Go service) types
441
+ // ========================================================================
442
+
443
+ export interface ComputeShardsRequest {
444
+ tenant_id: string;
445
+ shard_size?: number;
446
+ }
447
+
448
+ export interface ComputeShardsResult {
449
+ shards: Array<{ min?: string; max?: string }>;
450
+ count: number;
451
+ }
452
+
453
+ export interface IndexShardParams {
454
+ tenant_id: string;
455
+ target_index: string;
456
+ shard_min: string;
457
+ shard_max?: string;
458
+ dry_run?: boolean;
459
+ concurrency?: number;
460
+ batch_size?: number;
461
+ bulk_size_bytes?: number;
462
+ bulk_concurrency?: number;
463
+ updated_since?: string;
464
+ }
465
+
466
+ export interface IndexShardRequest {
467
+ force?: boolean;
468
+ params: IndexShardParams;
469
+ }
470
+
471
+ export interface IndexShardResult {
472
+ status: string;
473
+ projects_done: number;
474
+ projects_total: number;
475
+ scanned: number;
476
+ written: number;
477
+ skipped: number;
478
+ errors: number;
479
+ read_docs_s: string;
480
+ write_docs_s: string;
481
+ read_mb: string;
482
+ write_mb: string;
483
+ read_mb_s: string;
484
+ write_mb_s: string;
485
+ duration_sec: number;
486
+ failed_projects?: Array<{ tenant: string; error: string }>;
487
+ }
488
+
489
+ export interface SwapAliasRequest {
490
+ tenant_id: string;
491
+ target_index: string;
492
+ /** ES alias name. If not provided, the Go service derives it from the tenant ID. */
493
+ alias?: string;
494
+ }
495
+
496
+ export interface SwapAliasResult {
497
+ status: string;
498
+ alias: string;
499
+ old_index: string;
500
+ new_index: string;
501
+ }
502
+
503
+ export interface ReindexViaBulkRequest {
504
+ tenant_id: string;
505
+ dry_run?: boolean;
506
+ }
507
+
508
+ export interface ReindexViaBulkResult {
509
+ status: string;
510
+ error?: string;
511
+ projects_done: number;
512
+ projects_total: number;
513
+ scanned: number;
514
+ written: number;
515
+ errors: number;
516
+ read_docs_s: string;
517
+ write_docs_s: string;
518
+ read_mb: string;
519
+ write_mb: string;
520
+ duration_sec: number;
521
+ }
522
+
440
523
  /**
441
524
  * Elasticsearch index statistics
442
525
  */
@@ -600,16 +683,6 @@ export interface DriftAnalysisStatusResponse extends WorkflowRunStatus {
600
683
  error?: string;
601
684
  }
602
685
 
603
- /**
604
- * Result from swap alias operation
605
- */
606
- export interface SwapAliasResult {
607
- swapped: boolean;
608
- alias_name?: string;
609
- new_index_name?: string;
610
- reason?: string;
611
- }
612
-
613
686
  export interface ProjectIntegrationListEntry {
614
687
  id: SupportedIntegrations;
615
688
  enabled: boolean;
package/src/query.ts CHANGED
@@ -72,6 +72,11 @@ export interface InteractionSearchQuery extends SimpleSearchQuery {
72
72
  version?: string;
73
73
  model?: string;
74
74
  environment?: string;
75
+ is_agent?: boolean;
76
+ is_tool?: boolean;
77
+ is_skill?: boolean;
78
+ is_basic?: boolean;
79
+ is_sub_agent?: boolean;
75
80
  }
76
81
 
77
82
  export interface RunSearchQuery extends SimpleSearchQuery {
@@ -90,7 +95,9 @@ export interface RunSearchQuery extends SimpleSearchQuery {
90
95
  finish_reason?: string;
91
96
  created_by?: string;
92
97
  workflow_run_ids?: string[];
98
+ workflow_ids?: string[];
93
99
  run_ids?: string[];
100
+ is_agent?: boolean;
94
101
  }
95
102
 
96
103
  export interface WorkflowExecutionSearchQuery extends SimpleSearchQuery {
package/src/refs.ts CHANGED
@@ -27,4 +27,8 @@ export interface ResourceRef {
27
27
  name: string
28
28
  type: string
29
29
  description?: string
30
+ version?: number
31
+ status?: string
32
+ tags?: string[]
33
+ endpoint?: string
30
34
  }
package/src/runs.ts CHANGED
@@ -17,6 +17,21 @@ export interface ExecutionRunDocRef {
17
17
  export interface RunCreatePayload extends NamedInteractionExecutionPayload {
18
18
  }
19
19
 
20
+ /**
21
+ * Payload for cloning an existing ExecutionRun.
22
+ * Creates a new run document with the same interaction/config but fresh status.
23
+ * Used by fork flows to create a new ExecutionRun for the forked workflow.
24
+ */
25
+ export interface RunClonePayload {
26
+ /** The _id of the source ExecutionRun to clone */
27
+ source_run_id: string;
28
+ /** Temporal workflow reference for the new run */
29
+ workflow: {
30
+ run_id: string;
31
+ workflow_id: string;
32
+ };
33
+ }
34
+
20
35
  /**
21
36
  * To be used as a value for a numeric or date filters
22
37
  */
@@ -12,16 +12,29 @@
12
12
  * (workflowId, runId) are internal server concerns.
13
13
  */
14
14
 
15
- import { AgentSearchScope, ConversationVisibility, InteractionExecutionConfiguration, RunSource } from "../interaction.js";
15
+ import { AgentSearchScope, ConversationVisibility, InteractionExecutionConfiguration, InteractionRef, RunSource } from "../interaction.js";
16
16
  import { UserChannel } from "../email.js";
17
+ import { AgentEvent } from "../workflow-analytics.js";
18
+ import { UserInputSignal } from "./signals.js";
17
19
  import { ContentObjectTypeRef } from "./store.js";
18
- import { ConversationActivityState } from "./workflow.js";
20
+ import { AgentMessage, CompactMessage, ConversationActivityState, ConversationFileRef, WorkflowRunEvent } from "./workflow.js";
19
21
 
20
22
  /**
21
23
  * Status of an agent run through its lifecycle.
22
24
  */
23
25
  export type AgentRunStatus = 'created' | 'running' | 'completed' | 'failed' | 'cancelled';
24
26
 
27
+ /**
28
+ * Archive lifecycle state for an agent run.
29
+ *
30
+ * - `none`: No archive exists (default)
31
+ * - `pending`: Terminal status recorded; archive workflow triggered
32
+ * - `archiving`: Archive workflow is running
33
+ * - `complete`: Archive stored in GCS successfully
34
+ * - `failed`: Archive attempt failed (see `last_archive_error`)
35
+ */
36
+ export type AgentRunArchiveState = 'none' | 'pending' | 'archiving' | 'complete' | 'failed';
37
+
25
38
  /**
26
39
  * How the agent run was created.
27
40
  */
@@ -109,6 +122,8 @@ export interface AgentRun<TData = Record<string, any>, TProperties = Record<stri
109
122
  /** Human-readable interaction name */
110
123
  interaction_name?: string;
111
124
 
125
+ interactionRef: InteractionRef;
126
+
112
127
  // --- Lifecycle ---
113
128
 
114
129
  /** Current status of the agent run */
@@ -137,6 +152,25 @@ export interface AgentRun<TData = Record<string, any>, TProperties = Record<stri
137
152
  /** Lessons learned from the conversation (extracted at completion) */
138
153
  lessons_learned?: string[];
139
154
 
155
+ // --- Archival ---
156
+
157
+ /** Archive lifecycle state */
158
+ archive_state?: AgentRunArchiveState;
159
+
160
+ /** When the last successful archive completed */
161
+ archived_at?: Date;
162
+
163
+ /** Archive format version (for forward compatibility) */
164
+ archive_version?: number;
165
+
166
+ /** Last archive error message (when archive_state === 'failed') */
167
+ last_archive_error?: string;
168
+
169
+ /** Source agent run ID when this run was forked (enables message history chaining) */
170
+ forked_from?: string;
171
+
172
+ // --- Timestamps ---
173
+
140
174
  /** Timestamp when the document was created */
141
175
  created_at: Date;
142
176
 
@@ -168,8 +202,143 @@ export interface CreateAgentRunPayload<TData = Record<string, any>, TProperties
168
202
 
169
203
  /** Enable debug mode for verbose logging */
170
204
  debug_mode?: boolean;
205
+
206
+ /** Principal ref of the user who initiated the run (for server-to-server forwarding) */
207
+ started_by?: string;
208
+ }
209
+
210
+ /**
211
+ * Payload to record an AgentRun for an already-running workflow.
212
+ *
213
+ * Used by server-side callers that have already started a Temporal workflow
214
+ * and need to create the stable AgentRun MongoDB document against it.
215
+ *
216
+ * @typeParam TData - The interaction's expected input data type.
217
+ */
218
+ export interface RecordAgentRunPayload<TData = CreateAgentRunPayload["data"]> extends Pick<AgentRunBase<TData>, "interaction" | "data" | "schedule_id" | "visibility" | "type"> {
219
+ /** Temporal workflow ID (stable across continueAsNew) */
220
+ workflow_id: string;
221
+
222
+ /** First Temporal workflow run ID (stable stream/artifact identity) */
223
+ first_workflow_run_id: string;
224
+ }
225
+
226
+ /**
227
+ * Response from terminating an agent run.
228
+ */
229
+ export interface TerminateAgentRunResponse {
230
+ message: string;
231
+ reason?: string;
232
+ }
233
+
234
+ /**
235
+ * Payload for updating an AgentRun's lifecycle and derived metadata.
236
+ */
237
+ export interface UpdateAgentRunStatusPayload {
238
+ status?: AgentRunStatus;
239
+ activity_state?: ConversationActivityState;
240
+ title?: string;
241
+ topic?: string;
242
+ lessons_learned?: string[];
243
+ /** ES-only: conversation content text (not stored in MongoDB) */
244
+ content?: string;
245
+ /** Archive state fields (set by the archive workflow) */
246
+ archive_state?: AgentRunArchiveState;
247
+ archived_at?: string;
248
+ archive_version?: number;
249
+ last_archive_error?: string;
250
+ }
251
+
252
+ /**
253
+ * Generic signal payload sent to a running agent workflow.
254
+ */
255
+ export type SignalAgentPayload =
256
+ | UserInputSignal
257
+ | ConversationFileRef
258
+ | Record<string, unknown>;
259
+
260
+ /**
261
+ * Response from signaling an agent workflow.
262
+ */
263
+ export interface SignalAgentResponse {
264
+ status: string;
265
+ message: string;
171
266
  }
172
267
 
268
+ /**
269
+ * Response payload for retrieving compact agent updates.
270
+ */
271
+ export interface AgentRunUpdatesResponse {
272
+ messages: CompactMessage[];
273
+ }
274
+
275
+ /**
276
+ * Payload for posting an update into an agent's workflow stream.
277
+ */
278
+ export type PostAgentRunUpdatePayload = Partial<AgentMessage>;
279
+
280
+ /**
281
+ * Response from posting an agent update.
282
+ */
283
+ export interface PostAgentRunUpdateResponse {
284
+ success: boolean;
285
+ }
286
+
287
+ /**
288
+ * Signed artifact URL response for agent artifacts.
289
+ */
290
+ export interface AgentArtifactUrlResponse {
291
+ url: string;
292
+ path: string;
293
+ }
294
+
295
+ /**
296
+ * Telemetry ingestion payload for an agent run.
297
+ */
298
+ export interface IngestAgentEventsPayload {
299
+ events: AgentEvent[];
300
+ }
301
+
302
+ /**
303
+ * Telemetry ingestion response for an agent run.
304
+ */
305
+ export interface IngestAgentEventsResponse {
306
+ ingested: number;
307
+ status?: string;
308
+ error?: string;
309
+ }
310
+
311
+ /**
312
+ * History event payload emitted by the agent details SSE stream.
313
+ */
314
+ export interface AgentRunDetailsHistoryStreamEvent {
315
+ runId?: string;
316
+ event: WorkflowRunEvent;
317
+ }
318
+
319
+ /**
320
+ * Control payload emitted by the agent details SSE stream.
321
+ */
322
+ export type AgentRunDetailsControlStreamEvent =
323
+ | { type: 'continueAsNew'; newRunId: string }
324
+ | { type: 'done' };
325
+
326
+ /**
327
+ * Error payload emitted by the agent details SSE stream.
328
+ */
329
+ export interface AgentRunDetailsErrorStreamEvent {
330
+ type: 'error';
331
+ message: string;
332
+ }
333
+
334
+ /**
335
+ * Typed SSE event envelope for the agent details stream.
336
+ */
337
+ export type AgentRunDetailsStreamEvent =
338
+ | { type: 'history'; data: AgentRunDetailsHistoryStreamEvent }
339
+ | { type: 'control'; data: AgentRunDetailsControlStreamEvent }
340
+ | { type: 'error'; data: AgentRunDetailsErrorStreamEvent };
341
+
173
342
  /**
174
343
  * Filters for listing agent runs.
175
344
  */
@@ -189,12 +358,18 @@ export interface ListAgentRunsQuery {
189
358
  /** Only return runs started after this date */
190
359
  since?: Date;
191
360
 
361
+ /** Only return runs started at or before this date */
362
+ until?: Date;
363
+
192
364
  /** Maximum number of results (default: 50) */
193
365
  limit?: number;
194
366
 
195
367
  /** Offset for pagination */
196
368
  offset?: number;
197
369
 
370
+ /** Cursor for stable pagination */
371
+ cursor?: string;
372
+
198
373
  /** Filter by schedule ID */
199
374
  schedule_id?: string;
200
375
 
@@ -208,6 +383,12 @@ export interface ListAgentRunsQuery {
208
383
  order?: 'asc' | 'desc';
209
384
  }
210
385
 
386
+ export interface ListAgentRunsResponse {
387
+ items: AgentRun[];
388
+ total_count: number;
389
+ next_cursor: string | null;
390
+ }
391
+
211
392
  /**
212
393
  * Query for searching agent runs via Elasticsearch.
213
394
  */
@@ -236,6 +417,9 @@ export interface SearchAgentRunsQuery {
236
417
  /** Only return runs started after this date */
237
418
  since?: Date;
238
419
 
420
+ /** Only return runs started at or before this date */
421
+ until?: Date;
422
+
239
423
  /** Maximum number of results (default: 50) */
240
424
  limit?: number;
241
425
 
@@ -78,6 +78,15 @@ export interface ConversationState {
78
78
  /** Names of currently active tools (base + unlocked). Tool definitions loaded from tool_reference. */
79
79
  active_tool_names?: string[];
80
80
 
81
+ /** Active tools that should not be evicted by bounded active-tool pruning. */
82
+ pinned_tool_names?: string[];
83
+
84
+ /**
85
+ * Activation and usage metadata for tools seen during the conversation.
86
+ * Used to keep the active tool set bounded without losing recovery context.
87
+ */
88
+ tool_activation_metadata?: Record<string, ToolActivationMetadata>;
89
+
81
90
  /** Skills that have been used in this conversation (for auto-syncing scripts and package installation) */
82
91
  used_skills?: UsedSkill[];
83
92
 
@@ -156,8 +165,8 @@ export interface ConversationState {
156
165
  export interface AvailableSkill {
157
166
  /** Skill name (e.g., "analyze_data") - without the "learn_" prefix */
158
167
  name: string;
159
- /** Source URL of the skill collection (e.g., "https://tools.vertesia.io/api/skills/data-analysis") */
160
- src: string;
168
+ /** Source URL of the skill collection (e.g., "https://tools.vertesia.io/api/skills/data-analysis"). Undefined for interaction-based skills. */
169
+ src?: string;
161
170
  }
162
171
 
163
172
  /**
@@ -192,3 +201,16 @@ export interface UsedSkill {
192
201
  /** System-level packages to install via sudo apt-get (e.g., ["poppler-utils"]) */
193
202
  system_packages?: string[];
194
203
  }
204
+
205
+ export interface ToolActivationMetadata {
206
+ /** Turn when the tool became active in this conversation. */
207
+ activated_at_iteration: number;
208
+ /** Most recent turn where the tool was actually executed. */
209
+ last_used_iteration?: number;
210
+ /** Number of successful executions in this conversation. */
211
+ use_count: number;
212
+ /** Activation source, e.g. "base", "discover_tools", "skill:presentation_authoring". */
213
+ source: string;
214
+ /** Whether this tool is pinned and should be preserved during eviction. */
215
+ pinned?: boolean;
216
+ }
@@ -10,6 +10,18 @@ export interface PdfToRichTextWorkflowPayload extends Omit<WorkflowExecutionPayl
10
10
  vars: PdfToRichtextOptions;
11
11
  }
12
12
 
13
+ export interface TransformTablesWorkflowPayload extends Omit<WorkflowExecutionPayload, "vars"> {
14
+ vars: AdaptTablesParams;
15
+ environment?: string;
16
+ }
17
+
18
+ export interface TransformTablesWorkflowResult {
19
+ result_path: string;
20
+ status: string;
21
+ table_count: number;
22
+ item_count: number;
23
+ }
24
+
13
25
  /**
14
26
  * Represents a image in a document that has been analyzed
15
27
  */
@@ -25,6 +25,16 @@ export interface ImageRenditionVars extends BaseRenditionVars {
25
25
  max_pages?: number;
26
26
  }
27
27
 
28
+ export interface ImageRenditionParams {
29
+ max_hw: number;
30
+ format: ImageRenditionFormat;
31
+ outputPath?: string;
32
+ }
33
+
34
+ export function getRenditionsPath(contentEtag: string, params: ImageRenditionParams) {
35
+ return `renditions/${contentEtag}/${params.max_hw}`;
36
+ }
37
+
28
38
  /** Metadata for PDF rendering (displayed in header/footer) */
29
39
  export interface PdfRenderingMetadata {
30
40
  /** Document ID to display in footer */
@@ -67,14 +67,11 @@ export interface AgentSchedule {
67
67
  /** Timestamp when the schedule was last updated */
68
68
  updated_at: Date;
69
69
 
70
- /** Timestamp of the last successful execution */
70
+ /** Timestamp of the last action taken by the Temporal schedule. Sourced from Temporal, not persisted in Mongo. */
71
71
  last_run_at?: Date;
72
72
 
73
- /** Timestamp of the next scheduled execution */
73
+ /** Timestamp of the next scheduled execution. Sourced from Temporal, not persisted in Mongo. */
74
74
  next_run_at?: Date;
75
-
76
- /** Total number of times this schedule has executed */
77
- run_count?: number;
78
75
  }
79
76
 
80
77
  /**
@@ -152,7 +149,6 @@ export interface ScheduleListItem {
152
149
  enabled: boolean;
153
150
  last_run_at?: Date;
154
151
  next_run_at?: Date;
155
- run_count?: number;
156
152
  created_by: string;
157
153
  updated_at: Date;
158
154
  }
@@ -178,6 +178,17 @@ export interface Transcript {
178
178
  etag?: string;
179
179
  }
180
180
 
181
+ export const TextExtractionStatus = {
182
+ success: "success",
183
+ } as const;
184
+
185
+ export interface TranscriptMediaResult {
186
+ hasText: boolean;
187
+ status: typeof TextExtractionStatus.success;
188
+ message?: string;
189
+ gladiaTranscriptionId?: string;
190
+ }
191
+
181
192
  export interface TranscriptSegment {
182
193
  start: number;
183
194
  text: string;