@vertesia/common 1.0.0-dev.20260227.112605Z → 1.0.0-dev.20260331.091034Z

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 (116) hide show
  1. package/lib/cjs/apps.js +19 -0
  2. package/lib/cjs/apps.js.map +1 -1
  3. package/lib/cjs/environment.js.map +1 -1
  4. package/lib/cjs/index.js +1 -0
  5. package/lib/cjs/index.js.map +1 -1
  6. package/lib/cjs/interaction.js +2 -0
  7. package/lib/cjs/interaction.js.map +1 -1
  8. package/lib/cjs/oauth.js +7 -0
  9. package/lib/cjs/oauth.js.map +1 -0
  10. package/lib/cjs/project.js.map +1 -1
  11. package/lib/cjs/store/agent-run.js +16 -0
  12. package/lib/cjs/store/agent-run.js.map +1 -0
  13. package/lib/cjs/store/conversation-state.js +16 -0
  14. package/lib/cjs/store/conversation-state.js.map +1 -1
  15. package/lib/cjs/store/dsl-workflow.js.map +1 -1
  16. package/lib/cjs/store/index.js +1 -0
  17. package/lib/cjs/store/index.js.map +1 -1
  18. package/lib/cjs/store/store.js.map +1 -1
  19. package/lib/cjs/store/workflow.js +1 -0
  20. package/lib/cjs/store/workflow.js.map +1 -1
  21. package/lib/cjs/utils/schemas.js +45 -1
  22. package/lib/cjs/utils/schemas.js.map +1 -1
  23. package/lib/cjs/versions.js +1 -0
  24. package/lib/cjs/versions.js.map +1 -1
  25. package/lib/esm/apps.js +17 -0
  26. package/lib/esm/apps.js.map +1 -1
  27. package/lib/esm/environment.js.map +1 -1
  28. package/lib/esm/index.js +1 -0
  29. package/lib/esm/index.js.map +1 -1
  30. package/lib/esm/interaction.js +3 -1
  31. package/lib/esm/interaction.js.map +1 -1
  32. package/lib/esm/oauth.js +6 -0
  33. package/lib/esm/oauth.js.map +1 -0
  34. package/lib/esm/project.js.map +1 -1
  35. package/lib/esm/store/agent-run.js +15 -0
  36. package/lib/esm/store/agent-run.js.map +1 -0
  37. package/lib/esm/store/conversation-state.js +15 -1
  38. package/lib/esm/store/conversation-state.js.map +1 -1
  39. package/lib/esm/store/dsl-workflow.js.map +1 -1
  40. package/lib/esm/store/index.js +1 -0
  41. package/lib/esm/store/index.js.map +1 -1
  42. package/lib/esm/store/store.js.map +1 -1
  43. package/lib/esm/store/workflow.js +1 -0
  44. package/lib/esm/store/workflow.js.map +1 -1
  45. package/lib/esm/utils/schemas.js +44 -1
  46. package/lib/esm/utils/schemas.js.map +1 -1
  47. package/lib/esm/versions.js +1 -0
  48. package/lib/esm/versions.js.map +1 -1
  49. package/lib/tsconfig.tsbuildinfo +1 -1
  50. package/lib/types/apps.d.ts +153 -29
  51. package/lib/types/apps.d.ts.map +1 -1
  52. package/lib/types/audit-trail.d.ts +1 -1
  53. package/lib/types/audit-trail.d.ts.map +1 -1
  54. package/lib/types/common.d.ts +28 -1
  55. package/lib/types/common.d.ts.map +1 -1
  56. package/lib/types/environment.d.ts +11 -1
  57. package/lib/types/environment.d.ts.map +1 -1
  58. package/lib/types/index.d.ts +1 -0
  59. package/lib/types/index.d.ts.map +1 -1
  60. package/lib/types/interaction.d.ts +78 -5
  61. package/lib/types/interaction.d.ts.map +1 -1
  62. package/lib/types/oauth.d.ts +103 -0
  63. package/lib/types/oauth.d.ts.map +1 -0
  64. package/lib/types/payload.d.ts +13 -0
  65. package/lib/types/payload.d.ts.map +1 -1
  66. package/lib/types/project.d.ts +105 -44
  67. package/lib/types/project.d.ts.map +1 -1
  68. package/lib/types/query.d.ts +2 -0
  69. package/lib/types/query.d.ts.map +1 -1
  70. package/lib/types/runs.d.ts +14 -0
  71. package/lib/types/runs.d.ts.map +1 -1
  72. package/lib/types/store/agent-run.d.ts +256 -0
  73. package/lib/types/store/agent-run.d.ts.map +1 -0
  74. package/lib/types/store/conversation-state.d.ts +21 -0
  75. package/lib/types/store/conversation-state.d.ts.map +1 -1
  76. package/lib/types/store/dsl-workflow.d.ts +24 -6
  77. package/lib/types/store/dsl-workflow.d.ts.map +1 -1
  78. package/lib/types/store/index.d.ts +1 -0
  79. package/lib/types/store/index.d.ts.map +1 -1
  80. package/lib/types/store/signals.d.ts +5 -5
  81. package/lib/types/store/signals.d.ts.map +1 -1
  82. package/lib/types/store/store.d.ts +22 -0
  83. package/lib/types/store/store.d.ts.map +1 -1
  84. package/lib/types/store/workflow.d.ts +59 -10
  85. package/lib/types/store/workflow.d.ts.map +1 -1
  86. package/lib/types/utils/schemas.d.ts +7 -0
  87. package/lib/types/utils/schemas.d.ts.map +1 -1
  88. package/lib/types/versions.d.ts +2 -1
  89. package/lib/types/versions.d.ts.map +1 -1
  90. package/lib/types/workflow-analytics.d.ts +5 -1
  91. package/lib/types/workflow-analytics.d.ts.map +1 -1
  92. package/lib/vertesia-common.js +1 -1
  93. package/lib/vertesia-common.js.map +1 -1
  94. package/package.json +2 -2
  95. package/src/apps.ts +180 -32
  96. package/src/audit-trail.ts +1 -0
  97. package/src/common.ts +24 -1
  98. package/src/environment.ts +11 -1
  99. package/src/index.ts +1 -0
  100. package/src/interaction.ts +91 -9
  101. package/src/oauth.ts +119 -0
  102. package/src/payload.ts +15 -0
  103. package/src/project.ts +111 -46
  104. package/src/query.ts +2 -0
  105. package/src/runs.ts +15 -0
  106. package/src/store/agent-run.ts +350 -0
  107. package/src/store/conversation-state.ts +33 -0
  108. package/src/store/dsl-workflow.ts +26 -6
  109. package/src/store/index.ts +1 -0
  110. package/src/store/signals.ts +5 -5
  111. package/src/store/store.ts +22 -0
  112. package/src/store/workflow.ts +70 -10
  113. package/src/utils/schemas.ts +49 -1
  114. package/src/versions.ts +1 -0
  115. package/src/workflow-analytics.ts +5 -1
  116. package/tsconfig.dist.json +1 -1
package/src/payload.ts CHANGED
@@ -9,6 +9,16 @@ import {
9
9
  RunSearchQuery,
10
10
  SimpleSearchQuery
11
11
  } from "./query.js";
12
+ import { ColumnLayout } from "./store/store.js";
13
+
14
+ export type SortOrder = 'asc' | 'desc';
15
+
16
+ export interface SortOption {
17
+ /** Field path to sort by (e.g. 'updated_at', 'name', 'properties.title') */
18
+ field: string;
19
+ /** Sort direction. Defaults to 'desc'. */
20
+ order?: SortOrder;
21
+ }
12
22
 
13
23
  export interface SearchPayload {
14
24
  facets?: FacetSpec[];
@@ -23,6 +33,10 @@ export interface SearchPayload {
23
33
  select?: string;
24
34
  all_revisions?: boolean;
25
35
  from_root?: string;
36
+ /** Sort criteria. Multiple entries enable multi-field sorting (first entry is primary). */
37
+ sort?: SortOption[];
38
+ /** Arbitrary Elasticsearch aggregation definitions. Ignored when search falls back to MongoDB. */
39
+ aggs?: Record<string, unknown>;
26
40
  }
27
41
 
28
42
  export interface ComputeFacetPayload {
@@ -74,6 +88,7 @@ export interface ExportPropertiesPayload {
74
88
  objectIds: string[];
75
89
  type: string;
76
90
  query?: ComplexSearchQuery;
91
+ table_layout?: ColumnLayout[];
77
92
  }
78
93
 
79
94
  export interface ExportPropertiesResponse {
package/src/project.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { SupportedIntegrations } from "./integrations.js";
2
2
  import { ContentObjectTypeRef } from "./store/store.js";
3
+ import { WorkflowRunStatus } from "./store/workflow.js";
3
4
  import { AccountRef } from "./user.js";
4
5
 
5
6
  export interface ICreateProjectPayload {
@@ -157,11 +158,6 @@ export interface ProjectConfiguration {
157
158
 
158
159
  human_context: string;
159
160
 
160
- /** @deprecated Use defaults.base - kept for backward compatibility */
161
- default_environment?: string;
162
- /** @deprecated Use defaults.base - kept for backward compatibility */
163
- default_model?: string;
164
-
165
161
  defaults?: ProjectModelDefaults;
166
162
 
167
163
  default_visibility?: ResourceVisibility;
@@ -285,34 +281,34 @@ export interface EmbeddingsStatusResponse {
285
281
  */
286
282
  export interface IndexingStatusResponse {
287
283
  /** Whether indexing infrastructure is available globally */
288
- infrastructureEnabled: boolean;
284
+ infrastructure_enabled: boolean;
289
285
  /** Whether indexing is enabled for this project */
290
- indexingEnabled: boolean;
291
- /** @deprecated Now derived from indexingEnabled - queries automatically route to index when indexing is enabled */
286
+ indexing_enabled: boolean;
287
+ /** @deprecated Now derived from indexing_enabled - queries automatically route to index when indexing is enabled */
292
288
  query_enabled: boolean;
293
289
  /** Index status */
294
290
  index: {
295
291
  /** Whether the index exists */
296
292
  exists: boolean;
297
293
  /** Alias name (used for queries) */
298
- aliasName: string;
294
+ alias_name: string;
299
295
  /** Actual index name (versioned) */
300
- indexName: string;
296
+ index_name: string;
301
297
  /** Index version (timestamp when created) */
302
298
  version: number;
303
299
  /** When the current index was created */
304
- createdAt: string | null;
300
+ created_at: string | null;
305
301
  /** Number of documents in the index */
306
- documentCount: number;
302
+ document_count: number;
307
303
  /** Index size in bytes */
308
- sizeBytes: number;
304
+ size_bytes: number;
309
305
  };
310
306
  /** MongoDB document count for comparison */
311
- mongoDocumentCount: number;
307
+ mongo_document_count: number;
312
308
  /** Whether a reindex is currently in progress */
313
- reindexInProgress: boolean;
309
+ reindex_in_progress: boolean;
314
310
  /** Reindex progress (if reindex is in progress) */
315
- reindexProgress?: {
311
+ reindex_progress?: {
316
312
  /** Total documents to reindex */
317
313
  total: number;
318
314
  /** Documents processed so far */
@@ -324,19 +320,29 @@ export interface IndexingStatusResponse {
324
320
  /** Current status (e.g., "indexing", "complete") */
325
321
  status: string;
326
322
  /** Current batch number */
327
- currentBatch: number;
323
+ current_batch: number;
328
324
  /** Total number of batches */
329
- totalBatches: number;
325
+ total_batches: number;
330
326
  /** Percentage complete (0-100) */
331
- percentComplete: number;
327
+ percent_complete: number;
332
328
  /** Batches processed per second */
333
- batchesPerSecond: number;
329
+ batches_per_second: number;
334
330
  /** Documents processed per second */
335
- docsPerSecond: number;
331
+ docs_per_second: number;
336
332
  /** Elapsed time in seconds */
337
- elapsedSeconds: number;
333
+ elapsed_seconds: number;
338
334
  /** Estimated seconds remaining (null if unknown) */
339
- estimatedSecondsRemaining: number | null;
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;
340
346
  };
341
347
  }
342
348
 
@@ -382,8 +388,8 @@ export interface BulkIndexResult {
382
388
  */
383
389
  export interface CreateReindexTargetResult {
384
390
  created: boolean;
385
- indexName: string;
386
- aliasName: string;
391
+ index_name: string;
392
+ alias_name: string;
387
393
  version: number;
388
394
  }
389
395
 
@@ -404,7 +410,7 @@ export interface FetchBatchResult {
404
410
  id: string;
405
411
  document: ElasticsearchDocumentData;
406
412
  }>;
407
- nextCursor: string | null;
413
+ next_cursor: string | null;
408
414
  done: boolean;
409
415
  }
410
416
 
@@ -415,7 +421,26 @@ export interface IndexBatchResult {
415
421
  successful: number;
416
422
  failed: number;
417
423
  processed: number;
418
- nextCursor: string | null;
424
+ next_cursor: string | null;
425
+ done: boolean;
426
+ /** Number of ES bulk flushes performed */
427
+ bulk_flushes?: number;
428
+ /** Total bytes sent to ES */
429
+ total_bytes?: number;
430
+ /** Average bytes per ES bulk flush */
431
+ avg_flush_bytes?: number;
432
+ /** Duration of the batch in milliseconds */
433
+ duration_ms?: number;
434
+ /** Docs per second for this batch */
435
+ docs_per_second?: number;
436
+ }
437
+
438
+ /**
439
+ * Result from discovering the next cursor boundary for batch partitioning
440
+ */
441
+ export interface NextIndexCursorResult {
442
+ next_cursors: string[];
443
+ count: number;
419
444
  done: boolean;
420
445
  }
421
446
 
@@ -425,9 +450,9 @@ export interface IndexBatchResult {
425
450
  export interface TriggerReindexResult {
426
451
  status: string;
427
452
  workflow?: string;
428
- workflowId?: string;
429
- runId?: string;
430
- objectCount?: number;
453
+ workflow_id?: string;
454
+ run_id?: string;
455
+ object_count?: number;
431
456
  reason?: string;
432
457
  enabled?: boolean;
433
458
  }
@@ -438,10 +463,10 @@ export interface TriggerReindexResult {
438
463
  export interface ElasticsearchIndexStats {
439
464
  enabled: boolean;
440
465
  exists?: boolean;
441
- documentCount?: number;
442
- sizeInBytes?: number;
443
- indexName?: string;
444
- aliasName?: string;
466
+ document_count?: number;
467
+ size_in_bytes?: number;
468
+ index_name?: string;
469
+ alias_name?: string;
445
470
  }
446
471
 
447
472
  /**
@@ -461,25 +486,25 @@ export interface EmbeddingTypeConfig {
461
486
  export interface IndexConfiguration {
462
487
  enabled: boolean;
463
488
  exists?: boolean;
464
- indexName?: string;
465
- aliasName?: string;
489
+ index_name?: string;
490
+ alias_name?: string;
466
491
  version?: number;
467
- documentCount?: number;
468
- sizeInBytes?: number;
469
- embeddingDimensions?: {
492
+ document_count?: number;
493
+ size_in_bytes?: number;
494
+ embedding_dimensions?: {
470
495
  text?: number;
471
496
  image?: number;
472
497
  properties?: number;
473
498
  };
474
499
  /** ISO 639-1 language code for text analysis */
475
500
  language?: string;
476
- fieldMappings?: Record<string, unknown>;
477
- projectEmbeddingsConfig?: {
501
+ field_mappings?: Record<string, unknown>;
502
+ project_embeddings_config?: {
478
503
  text?: EmbeddingTypeConfig;
479
504
  image?: EmbeddingTypeConfig;
480
505
  properties?: EmbeddingTypeConfig;
481
506
  };
482
- createdAt?: Date | null;
507
+ created_at?: Date | null;
483
508
  }
484
509
 
485
510
  /**
@@ -527,7 +552,7 @@ export interface FetchDocumentsByIdsResult {
527
552
  id: string;
528
553
  document: ElasticsearchDocumentData;
529
554
  }>;
530
- notFound: string[];
555
+ not_found: string[];
531
556
  }
532
557
 
533
558
  /**
@@ -555,17 +580,57 @@ export interface EnsureIndexResult {
555
580
  language?: string;
556
581
  }
557
582
 
583
+ export interface AnalyzeDriftBatchResult {
584
+ processed: number;
585
+ missing: number;
586
+ stale: number;
587
+ next_cursor: string | null;
588
+ done: boolean;
589
+ sample_missing_ids: string[];
590
+ sample_stale_ids: string[];
591
+ }
592
+
593
+ export interface DriftAnalysisProgress {
594
+ total: number;
595
+ processed: number;
596
+ missing: number;
597
+ stale: number;
598
+ status: string;
599
+ current_batch: number;
600
+ total_batches: number;
601
+ percent_complete: number;
602
+ docs_per_second: number;
603
+ elapsed_seconds: number;
604
+ estimated_seconds_remaining: number | null;
605
+ }
606
+
607
+ export interface DriftAnalysisResult {
608
+ total: number;
609
+ processed: number;
610
+ missing: number;
611
+ stale: number;
612
+ sample_missing_ids: string[];
613
+ sample_stale_ids: string[];
614
+ completed_at: string;
615
+ }
616
+
617
+ export interface DriftAnalysisStatusResponse extends WorkflowRunStatus {
618
+ progress?: DriftAnalysisProgress;
619
+ result?: DriftAnalysisResult;
620
+ error?: string;
621
+ }
622
+
558
623
  /**
559
624
  * Result from swap alias operation
560
625
  */
561
626
  export interface SwapAliasResult {
562
627
  swapped: boolean;
563
- aliasName?: string;
564
- newIndexName?: string;
628
+ alias_name?: string;
629
+ new_index_name?: string;
565
630
  reason?: string;
566
631
  }
567
632
 
568
633
  export interface ProjectIntegrationListEntry {
569
634
  id: SupportedIntegrations;
570
635
  enabled: boolean;
571
- }
636
+ }
package/src/query.ts CHANGED
@@ -44,6 +44,7 @@ export interface SimpleSearchQuery {
44
44
 
45
45
  export interface ObjectSearchQuery extends SimpleSearchQuery {
46
46
  id?: string;
47
+ ids?: string[];
47
48
  createdFrom?: string;
48
49
  createdTo?: string;
49
50
  updatedFrom?: string;
@@ -89,6 +90,7 @@ export interface RunSearchQuery extends SimpleSearchQuery {
89
90
  finish_reason?: string;
90
91
  created_by?: string;
91
92
  workflow_run_ids?: string[];
93
+ workflow_ids?: string[];
92
94
  run_ids?: string[];
93
95
  }
94
96
 
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
  */
@@ -0,0 +1,350 @@
1
+ /**
2
+ * AgentRun Types
3
+ *
4
+ * Defines the stable identity layer for running or completed agents.
5
+ * Decouples the application from Temporal's internal run lifecycle,
6
+ * enabling future continueAsNew support without breaking client references.
7
+ *
8
+ * The AgentRun is stored in MongoDB and provides a stable ID that doesn't
9
+ * change when Temporal workflows restart via continueAsNew.
10
+ *
11
+ * Client code only ever uses `AgentRun.id` — all Temporal workflow details
12
+ * (workflowId, runId) are internal server concerns.
13
+ */
14
+
15
+ import { AgentSearchScope, ConversationVisibility, InteractionExecutionConfiguration, RunSource } from "../interaction.js";
16
+ import { UserChannel } from "../email.js";
17
+ import { ContentObjectTypeRef } from "./store.js";
18
+ import { ConversationActivityState } from "./workflow.js";
19
+
20
+ /**
21
+ * Status of an agent run through its lifecycle.
22
+ */
23
+ export type AgentRunStatus = 'created' | 'running' | 'completed' | 'failed' | 'cancelled';
24
+
25
+ /**
26
+ * How the agent run was created.
27
+ */
28
+ export type AgentRunType = 'api' | 'schedule';
29
+
30
+ /**
31
+ * Shared fields between CreateAgentRunPayload and AgentRun.
32
+ *
33
+ * @typeParam TData - The interaction's expected input data type.
34
+ * @typeParam TProperties - The content type's property schema.
35
+ */
36
+ export interface AgentRunBase<TData = Record<string, any>, TProperties = Record<string, any>> {
37
+ /** Interaction ID or code (e.g. "sys:generic_question") */
38
+ interaction: string;
39
+
40
+ /** Input parameters, typed per interaction */
41
+ data?: TData;
42
+
43
+ /** Execution configuration (environment, model, model_options, etc.) */
44
+ config?: InteractionExecutionConfiguration;
45
+
46
+ /** Whether the agent accepts user input */
47
+ interactive?: boolean;
48
+
49
+ /** Tools configured for this run (+/- syntax supported) */
50
+ tool_names?: string[];
51
+
52
+ /** Scoped collection (if any) */
53
+ collection_id?: string;
54
+
55
+ /** Content type linked to this run — defines the schema for `properties` */
56
+ content_type?: ContentObjectTypeRef;
57
+
58
+ /** Conversation visibility */
59
+ visibility?: ConversationVisibility;
60
+
61
+ /** User-defined or system tags for categorization */
62
+ tags?: string[];
63
+
64
+ /** Categories for organizing runs (e.g. "support", "analysis", "generation") */
65
+ categories?: string[];
66
+
67
+ /** Business metadata — typed by the linked content_type schema */
68
+ properties?: TProperties;
69
+
70
+ /** How the run was started */
71
+ source?: RunSource;
72
+
73
+ /** Schedule ID — set when this run was triggered by a Temporal schedule */
74
+ schedule_id?: string;
75
+
76
+ /** How the run was created */
77
+ type?: AgentRunType;
78
+ }
79
+
80
+ /**
81
+ * AgentRun — the client-facing stable identity for a running or completed agent.
82
+ *
83
+ * All operations use `id` as the sole identifier.
84
+ * Temporal workflow internals are never exposed to clients.
85
+ *
86
+ * @typeParam TData - The interaction's expected input data type.
87
+ * @typeParam TProperties - The content type's property schema.
88
+ */
89
+ export interface AgentRun<TData = Record<string, any>, TProperties = Record<string, any>> extends AgentRunBase<TData, TProperties> {
90
+ /** The stable identifier used by all client code */
91
+ id: string;
92
+
93
+ /** Account ID */
94
+ account: string;
95
+
96
+ /** Project ID */
97
+ project: string;
98
+
99
+ // --- Temporal workflow references ---
100
+
101
+ /** Temporal workflow ID (stable across continueAsNew) */
102
+ workflow_id?: string;
103
+
104
+ /** First Temporal workflow run ID (used for Redis channel and artifact resolution) */
105
+ first_workflow_run_id?: string;
106
+
107
+ // --- Interaction info ---
108
+
109
+ /** Human-readable interaction name */
110
+ interaction_name?: string;
111
+
112
+ // --- Lifecycle ---
113
+
114
+ /** Current status of the agent run */
115
+ status: AgentRunStatus;
116
+
117
+ /** Whether the agent is currently working or idle (waiting for user input) */
118
+ activity_state?: ConversationActivityState;
119
+
120
+ /** When the run started */
121
+ started_at: Date;
122
+
123
+ /** When the run completed (or failed/cancelled) */
124
+ completed_at?: Date;
125
+
126
+ /** User or service that initiated the run */
127
+ started_by: string;
128
+
129
+ // --- Metadata ---
130
+
131
+ /** Conversation title (short, human-readable) */
132
+ title?: string;
133
+
134
+ /** Conversation topic (longer description from topic analysis) */
135
+ topic?: string;
136
+
137
+ /** Lessons learned from the conversation (extracted at completion) */
138
+ lessons_learned?: string[];
139
+
140
+ /** Timestamp when the document was created */
141
+ created_at: Date;
142
+
143
+ /** Timestamp when the document was last updated */
144
+ updated_at: Date;
145
+ }
146
+
147
+ /**
148
+ * Payload to create and start a new agent run.
149
+ *
150
+ * @typeParam TData - The interaction's expected input data type.
151
+ * @typeParam TProperties - The content type's property schema.
152
+ */
153
+ export interface CreateAgentRunPayload<TData = Record<string, any>, TProperties = Record<string, any>> extends AgentRunBase<TData, TProperties> {
154
+ /** Search scope for RAG queries */
155
+ search_scope?: AgentSearchScope;
156
+
157
+ /** User communication channels (email, interactive) */
158
+ user_channels?: UserChannel[];
159
+
160
+ /** Token budget for checkpointing */
161
+ checkpoint_tokens?: number;
162
+
163
+ /** Maximum conversation iterations (default: 20) */
164
+ max_iterations?: number;
165
+
166
+ /** Webhook URLs to notify on completion */
167
+ notify_endpoints?: string[];
168
+
169
+ /** Enable debug mode for verbose logging */
170
+ debug_mode?: boolean;
171
+
172
+ /** Principal ref of the user who initiated the run (for server-to-server forwarding) */
173
+ started_by?: string;
174
+ }
175
+
176
+ /**
177
+ * Filters for listing agent runs.
178
+ */
179
+ export interface ListAgentRunsQuery {
180
+ /** Filter by agent run ID */
181
+ id?: string;
182
+
183
+ /** Filter by status (single or multiple) */
184
+ status?: AgentRunStatus | AgentRunStatus[];
185
+
186
+ /** Filter by interaction ID or code */
187
+ interaction?: string;
188
+
189
+ /** Filter by user who started the run */
190
+ started_by?: string;
191
+
192
+ /** Only return runs started after this date */
193
+ since?: Date;
194
+
195
+ /** Maximum number of results (default: 50) */
196
+ limit?: number;
197
+
198
+ /** Offset for pagination */
199
+ offset?: number;
200
+
201
+ /** Filter by schedule ID */
202
+ schedule_id?: string;
203
+
204
+ /** Filter by run type */
205
+ type?: AgentRunType;
206
+
207
+ /** Field to sort by */
208
+ sort?: 'started_at' | 'updated_at';
209
+
210
+ /** Sort order */
211
+ order?: 'asc' | 'desc';
212
+ }
213
+
214
+ /**
215
+ * Query for searching agent runs via Elasticsearch.
216
+ */
217
+ export interface SearchAgentRunsQuery {
218
+ /** Full-text search across name, title, topic, interaction_name, and content */
219
+ query?: string;
220
+
221
+ /** Filter by status (single or multiple) */
222
+ status?: AgentRunStatus | AgentRunStatus[];
223
+
224
+ /** Filter by interaction ID or code */
225
+ interaction?: string;
226
+
227
+ /** Filter by user who started the run */
228
+ started_by?: string;
229
+
230
+ /** Filter by categories */
231
+ categories?: string[];
232
+
233
+ /** Filter by tags */
234
+ tags?: string[];
235
+
236
+ /** Filter by content type name */
237
+ content_type_name?: string;
238
+
239
+ /** Only return runs started after this date */
240
+ since?: Date;
241
+
242
+ /** Maximum number of results (default: 50) */
243
+ limit?: number;
244
+
245
+ /** Offset for pagination */
246
+ offset?: number;
247
+ }
248
+
249
+ /**
250
+ * A single search hit from Elasticsearch.
251
+ */
252
+ export interface AgentRunSearchHit {
253
+ /** Agent run ID */
254
+ id: string;
255
+
256
+ /** Relevance score */
257
+ score: number;
258
+
259
+ /** Interaction ID */
260
+ interaction: string;
261
+
262
+ /** Human-readable interaction name */
263
+ interaction_name?: string;
264
+
265
+ /** Current status */
266
+ status: AgentRunStatus;
267
+
268
+ /** Whether the agent is currently working or idle */
269
+ activity_state?: ConversationActivityState;
270
+
271
+ /** When the run started */
272
+ started_at: string;
273
+
274
+ /** When the run completed */
275
+ completed_at?: string;
276
+
277
+ /** Who started the run */
278
+ started_by: string;
279
+
280
+ /** Conversation title */
281
+ title?: string;
282
+
283
+ /** Conversation topic */
284
+ topic?: string;
285
+
286
+ /** Lessons learned from the conversation */
287
+ lessons_learned?: string[];
288
+
289
+ /** Tags */
290
+ tags?: string[];
291
+
292
+ /** Categories */
293
+ categories?: string[];
294
+
295
+ /** Whether the agent accepts user input */
296
+ interactive: boolean;
297
+
298
+ /** Collection ID */
299
+ collection_id?: string;
300
+
301
+ /** Content type */
302
+ content_type?: ContentObjectTypeRef;
303
+
304
+ /** Tools configured for this run */
305
+ tool_names?: string[];
306
+
307
+ /** Schedule ID (if schedule-triggered) */
308
+ schedule_id?: string;
309
+
310
+ /** How the run was created */
311
+ type?: AgentRunType;
312
+
313
+ /** Created timestamp */
314
+ created_at: string;
315
+
316
+ /** Updated timestamp */
317
+ updated_at: string;
318
+ }
319
+
320
+ /**
321
+ * Response from the agent runs search endpoint.
322
+ */
323
+ export interface SearchAgentRunsResponse {
324
+ /** Search results */
325
+ hits: AgentRunSearchHit[];
326
+
327
+ /** Total matching results */
328
+ total: number;
329
+ }
330
+
331
+ /**
332
+ * Internal/Temporal details for an AgentRun.
333
+ * Includes fields normally stripped from client responses.
334
+ */
335
+ export interface AgentRunInternals {
336
+ id: string;
337
+ workflow_id?: string;
338
+ first_workflow_run_id?: string;
339
+ artifacts_path?: string;
340
+ status: AgentRunStatus;
341
+ interaction: string;
342
+ interaction_name?: string;
343
+ config?: InteractionExecutionConfiguration;
344
+ interactive: boolean;
345
+ started_at: Date;
346
+ completed_at?: Date;
347
+ started_by: string;
348
+ created_at: Date;
349
+ updated_at: Date;
350
+ }