@vertesia/common 1.0.0-dev.20260227.112605Z → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/apps.js +19 -0
- package/lib/cjs/apps.js.map +1 -1
- package/lib/cjs/environment.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interaction.js +2 -0
- package/lib/cjs/interaction.js.map +1 -1
- package/lib/cjs/oauth.js +7 -0
- package/lib/cjs/oauth.js.map +1 -0
- package/lib/cjs/project.js.map +1 -1
- package/lib/cjs/store/agent-run.js +16 -0
- package/lib/cjs/store/agent-run.js.map +1 -0
- package/lib/cjs/store/conversation-state.js +16 -0
- package/lib/cjs/store/conversation-state.js.map +1 -1
- package/lib/cjs/store/dsl-workflow.js.map +1 -1
- package/lib/cjs/store/index.js +1 -0
- package/lib/cjs/store/index.js.map +1 -1
- package/lib/cjs/store/store.js.map +1 -1
- package/lib/cjs/store/workflow.js +1 -0
- package/lib/cjs/store/workflow.js.map +1 -1
- package/lib/cjs/utils/schemas.js +45 -1
- package/lib/cjs/utils/schemas.js.map +1 -1
- package/lib/cjs/versions.js +1 -0
- package/lib/cjs/versions.js.map +1 -1
- package/lib/esm/apps.js +17 -0
- package/lib/esm/apps.js.map +1 -1
- package/lib/esm/environment.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interaction.js +3 -1
- package/lib/esm/interaction.js.map +1 -1
- package/lib/esm/oauth.js +6 -0
- package/lib/esm/oauth.js.map +1 -0
- package/lib/esm/project.js.map +1 -1
- package/lib/esm/store/agent-run.js +15 -0
- package/lib/esm/store/agent-run.js.map +1 -0
- package/lib/esm/store/conversation-state.js +15 -1
- package/lib/esm/store/conversation-state.js.map +1 -1
- package/lib/esm/store/dsl-workflow.js.map +1 -1
- package/lib/esm/store/index.js +1 -0
- package/lib/esm/store/index.js.map +1 -1
- package/lib/esm/store/store.js.map +1 -1
- package/lib/esm/store/workflow.js +1 -0
- package/lib/esm/store/workflow.js.map +1 -1
- package/lib/esm/utils/schemas.js +44 -1
- package/lib/esm/utils/schemas.js.map +1 -1
- package/lib/esm/versions.js +1 -0
- package/lib/esm/versions.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/apps.d.ts +61 -3
- package/lib/types/apps.d.ts.map +1 -1
- package/lib/types/audit-trail.d.ts +1 -1
- package/lib/types/audit-trail.d.ts.map +1 -1
- package/lib/types/common.d.ts +28 -1
- package/lib/types/common.d.ts.map +1 -1
- package/lib/types/environment.d.ts +11 -1
- package/lib/types/environment.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/interaction.d.ts +68 -5
- package/lib/types/interaction.d.ts.map +1 -1
- package/lib/types/oauth.d.ts +103 -0
- package/lib/types/oauth.d.ts.map +1 -0
- package/lib/types/payload.d.ts +13 -0
- package/lib/types/payload.d.ts.map +1 -1
- package/lib/types/project.d.ts +85 -44
- package/lib/types/project.d.ts.map +1 -1
- package/lib/types/query.d.ts +1 -0
- package/lib/types/query.d.ts.map +1 -1
- package/lib/types/store/agent-run.d.ts +254 -0
- package/lib/types/store/agent-run.d.ts.map +1 -0
- package/lib/types/store/conversation-state.d.ts +21 -0
- package/lib/types/store/conversation-state.d.ts.map +1 -1
- package/lib/types/store/dsl-workflow.d.ts +24 -6
- package/lib/types/store/dsl-workflow.d.ts.map +1 -1
- package/lib/types/store/index.d.ts +1 -0
- package/lib/types/store/index.d.ts.map +1 -1
- package/lib/types/store/signals.d.ts +5 -5
- package/lib/types/store/signals.d.ts.map +1 -1
- package/lib/types/store/store.d.ts +22 -0
- package/lib/types/store/store.d.ts.map +1 -1
- package/lib/types/store/workflow.d.ts +59 -10
- package/lib/types/store/workflow.d.ts.map +1 -1
- package/lib/types/utils/schemas.d.ts +7 -0
- package/lib/types/utils/schemas.d.ts.map +1 -1
- package/lib/types/versions.d.ts +2 -1
- package/lib/types/versions.d.ts.map +1 -1
- package/lib/types/workflow-analytics.d.ts +5 -1
- package/lib/types/workflow-analytics.d.ts.map +1 -1
- package/lib/vertesia-common.js +1 -1
- package/lib/vertesia-common.js.map +1 -1
- package/package.json +2 -2
- package/src/apps.ts +78 -4
- package/src/audit-trail.ts +1 -0
- package/src/common.ts +24 -1
- package/src/environment.ts +11 -1
- package/src/index.ts +1 -0
- package/src/interaction.ts +79 -9
- package/src/oauth.ts +119 -0
- package/src/payload.ts +15 -0
- package/src/project.ts +91 -46
- package/src/query.ts +1 -0
- package/src/store/agent-run.ts +347 -0
- package/src/store/conversation-state.ts +33 -0
- package/src/store/dsl-workflow.ts +26 -6
- package/src/store/index.ts +1 -0
- package/src/store/signals.ts +5 -5
- package/src/store/store.ts +22 -0
- package/src/store/workflow.ts +70 -10
- package/src/utils/schemas.ts +49 -1
- package/src/versions.ts +1 -0
- package/src/workflow-analytics.ts +5 -1
- package/tsconfig.dist.json +1 -1
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
|
-
|
|
284
|
+
infrastructure_enabled: boolean;
|
|
289
285
|
/** Whether indexing is enabled for this project */
|
|
290
|
-
|
|
291
|
-
/** @deprecated Now derived from
|
|
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
|
-
|
|
294
|
+
alias_name: string;
|
|
299
295
|
/** Actual index name (versioned) */
|
|
300
|
-
|
|
296
|
+
index_name: string;
|
|
301
297
|
/** Index version (timestamp when created) */
|
|
302
298
|
version: number;
|
|
303
299
|
/** When the current index was created */
|
|
304
|
-
|
|
300
|
+
created_at: string | null;
|
|
305
301
|
/** Number of documents in the index */
|
|
306
|
-
|
|
302
|
+
document_count: number;
|
|
307
303
|
/** Index size in bytes */
|
|
308
|
-
|
|
304
|
+
size_bytes: number;
|
|
309
305
|
};
|
|
310
306
|
/** MongoDB document count for comparison */
|
|
311
|
-
|
|
307
|
+
mongo_document_count: number;
|
|
312
308
|
/** Whether a reindex is currently in progress */
|
|
313
|
-
|
|
309
|
+
reindex_in_progress: boolean;
|
|
314
310
|
/** Reindex progress (if reindex is in progress) */
|
|
315
|
-
|
|
311
|
+
reindex_progress?: {
|
|
316
312
|
/** Total documents to reindex */
|
|
317
313
|
total: number;
|
|
318
314
|
/** Documents processed so far */
|
|
@@ -324,19 +320,19 @@ export interface IndexingStatusResponse {
|
|
|
324
320
|
/** Current status (e.g., "indexing", "complete") */
|
|
325
321
|
status: string;
|
|
326
322
|
/** Current batch number */
|
|
327
|
-
|
|
323
|
+
current_batch: number;
|
|
328
324
|
/** Total number of batches */
|
|
329
|
-
|
|
325
|
+
total_batches: number;
|
|
330
326
|
/** Percentage complete (0-100) */
|
|
331
|
-
|
|
327
|
+
percent_complete: number;
|
|
332
328
|
/** Batches processed per second */
|
|
333
|
-
|
|
329
|
+
batches_per_second: number;
|
|
334
330
|
/** Documents processed per second */
|
|
335
|
-
|
|
331
|
+
docs_per_second: number;
|
|
336
332
|
/** Elapsed time in seconds */
|
|
337
|
-
|
|
333
|
+
elapsed_seconds: number;
|
|
338
334
|
/** Estimated seconds remaining (null if unknown) */
|
|
339
|
-
|
|
335
|
+
estimated_seconds_remaining: number | null;
|
|
340
336
|
};
|
|
341
337
|
}
|
|
342
338
|
|
|
@@ -382,8 +378,8 @@ export interface BulkIndexResult {
|
|
|
382
378
|
*/
|
|
383
379
|
export interface CreateReindexTargetResult {
|
|
384
380
|
created: boolean;
|
|
385
|
-
|
|
386
|
-
|
|
381
|
+
index_name: string;
|
|
382
|
+
alias_name: string;
|
|
387
383
|
version: number;
|
|
388
384
|
}
|
|
389
385
|
|
|
@@ -404,7 +400,7 @@ export interface FetchBatchResult {
|
|
|
404
400
|
id: string;
|
|
405
401
|
document: ElasticsearchDocumentData;
|
|
406
402
|
}>;
|
|
407
|
-
|
|
403
|
+
next_cursor: string | null;
|
|
408
404
|
done: boolean;
|
|
409
405
|
}
|
|
410
406
|
|
|
@@ -415,7 +411,16 @@ export interface IndexBatchResult {
|
|
|
415
411
|
successful: number;
|
|
416
412
|
failed: number;
|
|
417
413
|
processed: number;
|
|
418
|
-
|
|
414
|
+
next_cursor: string | null;
|
|
415
|
+
done: boolean;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Result from discovering the next cursor boundary for batch partitioning
|
|
420
|
+
*/
|
|
421
|
+
export interface NextIndexCursorResult {
|
|
422
|
+
next_cursors: string[];
|
|
423
|
+
count: number;
|
|
419
424
|
done: boolean;
|
|
420
425
|
}
|
|
421
426
|
|
|
@@ -425,9 +430,9 @@ export interface IndexBatchResult {
|
|
|
425
430
|
export interface TriggerReindexResult {
|
|
426
431
|
status: string;
|
|
427
432
|
workflow?: string;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
433
|
+
workflow_id?: string;
|
|
434
|
+
run_id?: string;
|
|
435
|
+
object_count?: number;
|
|
431
436
|
reason?: string;
|
|
432
437
|
enabled?: boolean;
|
|
433
438
|
}
|
|
@@ -438,10 +443,10 @@ export interface TriggerReindexResult {
|
|
|
438
443
|
export interface ElasticsearchIndexStats {
|
|
439
444
|
enabled: boolean;
|
|
440
445
|
exists?: boolean;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
446
|
+
document_count?: number;
|
|
447
|
+
size_in_bytes?: number;
|
|
448
|
+
index_name?: string;
|
|
449
|
+
alias_name?: string;
|
|
445
450
|
}
|
|
446
451
|
|
|
447
452
|
/**
|
|
@@ -461,25 +466,25 @@ export interface EmbeddingTypeConfig {
|
|
|
461
466
|
export interface IndexConfiguration {
|
|
462
467
|
enabled: boolean;
|
|
463
468
|
exists?: boolean;
|
|
464
|
-
|
|
465
|
-
|
|
469
|
+
index_name?: string;
|
|
470
|
+
alias_name?: string;
|
|
466
471
|
version?: number;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
472
|
+
document_count?: number;
|
|
473
|
+
size_in_bytes?: number;
|
|
474
|
+
embedding_dimensions?: {
|
|
470
475
|
text?: number;
|
|
471
476
|
image?: number;
|
|
472
477
|
properties?: number;
|
|
473
478
|
};
|
|
474
479
|
/** ISO 639-1 language code for text analysis */
|
|
475
480
|
language?: string;
|
|
476
|
-
|
|
477
|
-
|
|
481
|
+
field_mappings?: Record<string, unknown>;
|
|
482
|
+
project_embeddings_config?: {
|
|
478
483
|
text?: EmbeddingTypeConfig;
|
|
479
484
|
image?: EmbeddingTypeConfig;
|
|
480
485
|
properties?: EmbeddingTypeConfig;
|
|
481
486
|
};
|
|
482
|
-
|
|
487
|
+
created_at?: Date | null;
|
|
483
488
|
}
|
|
484
489
|
|
|
485
490
|
/**
|
|
@@ -527,7 +532,7 @@ export interface FetchDocumentsByIdsResult {
|
|
|
527
532
|
id: string;
|
|
528
533
|
document: ElasticsearchDocumentData;
|
|
529
534
|
}>;
|
|
530
|
-
|
|
535
|
+
not_found: string[];
|
|
531
536
|
}
|
|
532
537
|
|
|
533
538
|
/**
|
|
@@ -555,17 +560,57 @@ export interface EnsureIndexResult {
|
|
|
555
560
|
language?: string;
|
|
556
561
|
}
|
|
557
562
|
|
|
563
|
+
export interface AnalyzeDriftBatchResult {
|
|
564
|
+
processed: number;
|
|
565
|
+
missing: number;
|
|
566
|
+
stale: number;
|
|
567
|
+
next_cursor: string | null;
|
|
568
|
+
done: boolean;
|
|
569
|
+
sample_missing_ids: string[];
|
|
570
|
+
sample_stale_ids: string[];
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export interface DriftAnalysisProgress {
|
|
574
|
+
total: number;
|
|
575
|
+
processed: number;
|
|
576
|
+
missing: number;
|
|
577
|
+
stale: number;
|
|
578
|
+
status: string;
|
|
579
|
+
current_batch: number;
|
|
580
|
+
total_batches: number;
|
|
581
|
+
percent_complete: number;
|
|
582
|
+
docs_per_second: number;
|
|
583
|
+
elapsed_seconds: number;
|
|
584
|
+
estimated_seconds_remaining: number | null;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export interface DriftAnalysisResult {
|
|
588
|
+
total: number;
|
|
589
|
+
processed: number;
|
|
590
|
+
missing: number;
|
|
591
|
+
stale: number;
|
|
592
|
+
sample_missing_ids: string[];
|
|
593
|
+
sample_stale_ids: string[];
|
|
594
|
+
completed_at: string;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export interface DriftAnalysisStatusResponse extends WorkflowRunStatus {
|
|
598
|
+
progress?: DriftAnalysisProgress;
|
|
599
|
+
result?: DriftAnalysisResult;
|
|
600
|
+
error?: string;
|
|
601
|
+
}
|
|
602
|
+
|
|
558
603
|
/**
|
|
559
604
|
* Result from swap alias operation
|
|
560
605
|
*/
|
|
561
606
|
export interface SwapAliasResult {
|
|
562
607
|
swapped: boolean;
|
|
563
|
-
|
|
564
|
-
|
|
608
|
+
alias_name?: string;
|
|
609
|
+
new_index_name?: string;
|
|
565
610
|
reason?: string;
|
|
566
611
|
}
|
|
567
612
|
|
|
568
613
|
export interface ProjectIntegrationListEntry {
|
|
569
614
|
id: SupportedIntegrations;
|
|
570
615
|
enabled: boolean;
|
|
571
|
-
}
|
|
616
|
+
}
|
package/src/query.ts
CHANGED
|
@@ -0,0 +1,347 @@
|
|
|
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
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Filters for listing agent runs.
|
|
175
|
+
*/
|
|
176
|
+
export interface ListAgentRunsQuery {
|
|
177
|
+
/** Filter by agent run ID */
|
|
178
|
+
id?: string;
|
|
179
|
+
|
|
180
|
+
/** Filter by status (single or multiple) */
|
|
181
|
+
status?: AgentRunStatus | AgentRunStatus[];
|
|
182
|
+
|
|
183
|
+
/** Filter by interaction ID or code */
|
|
184
|
+
interaction?: string;
|
|
185
|
+
|
|
186
|
+
/** Filter by user who started the run */
|
|
187
|
+
started_by?: string;
|
|
188
|
+
|
|
189
|
+
/** Only return runs started after this date */
|
|
190
|
+
since?: Date;
|
|
191
|
+
|
|
192
|
+
/** Maximum number of results (default: 50) */
|
|
193
|
+
limit?: number;
|
|
194
|
+
|
|
195
|
+
/** Offset for pagination */
|
|
196
|
+
offset?: number;
|
|
197
|
+
|
|
198
|
+
/** Filter by schedule ID */
|
|
199
|
+
schedule_id?: string;
|
|
200
|
+
|
|
201
|
+
/** Filter by run type */
|
|
202
|
+
type?: AgentRunType;
|
|
203
|
+
|
|
204
|
+
/** Field to sort by */
|
|
205
|
+
sort?: 'started_at' | 'updated_at';
|
|
206
|
+
|
|
207
|
+
/** Sort order */
|
|
208
|
+
order?: 'asc' | 'desc';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Query for searching agent runs via Elasticsearch.
|
|
213
|
+
*/
|
|
214
|
+
export interface SearchAgentRunsQuery {
|
|
215
|
+
/** Full-text search across name, title, topic, interaction_name, and content */
|
|
216
|
+
query?: string;
|
|
217
|
+
|
|
218
|
+
/** Filter by status (single or multiple) */
|
|
219
|
+
status?: AgentRunStatus | AgentRunStatus[];
|
|
220
|
+
|
|
221
|
+
/** Filter by interaction ID or code */
|
|
222
|
+
interaction?: string;
|
|
223
|
+
|
|
224
|
+
/** Filter by user who started the run */
|
|
225
|
+
started_by?: string;
|
|
226
|
+
|
|
227
|
+
/** Filter by categories */
|
|
228
|
+
categories?: string[];
|
|
229
|
+
|
|
230
|
+
/** Filter by tags */
|
|
231
|
+
tags?: string[];
|
|
232
|
+
|
|
233
|
+
/** Filter by content type name */
|
|
234
|
+
content_type_name?: string;
|
|
235
|
+
|
|
236
|
+
/** Only return runs started after this date */
|
|
237
|
+
since?: Date;
|
|
238
|
+
|
|
239
|
+
/** Maximum number of results (default: 50) */
|
|
240
|
+
limit?: number;
|
|
241
|
+
|
|
242
|
+
/** Offset for pagination */
|
|
243
|
+
offset?: number;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* A single search hit from Elasticsearch.
|
|
248
|
+
*/
|
|
249
|
+
export interface AgentRunSearchHit {
|
|
250
|
+
/** Agent run ID */
|
|
251
|
+
id: string;
|
|
252
|
+
|
|
253
|
+
/** Relevance score */
|
|
254
|
+
score: number;
|
|
255
|
+
|
|
256
|
+
/** Interaction ID */
|
|
257
|
+
interaction: string;
|
|
258
|
+
|
|
259
|
+
/** Human-readable interaction name */
|
|
260
|
+
interaction_name?: string;
|
|
261
|
+
|
|
262
|
+
/** Current status */
|
|
263
|
+
status: AgentRunStatus;
|
|
264
|
+
|
|
265
|
+
/** Whether the agent is currently working or idle */
|
|
266
|
+
activity_state?: ConversationActivityState;
|
|
267
|
+
|
|
268
|
+
/** When the run started */
|
|
269
|
+
started_at: string;
|
|
270
|
+
|
|
271
|
+
/** When the run completed */
|
|
272
|
+
completed_at?: string;
|
|
273
|
+
|
|
274
|
+
/** Who started the run */
|
|
275
|
+
started_by: string;
|
|
276
|
+
|
|
277
|
+
/** Conversation title */
|
|
278
|
+
title?: string;
|
|
279
|
+
|
|
280
|
+
/** Conversation topic */
|
|
281
|
+
topic?: string;
|
|
282
|
+
|
|
283
|
+
/** Lessons learned from the conversation */
|
|
284
|
+
lessons_learned?: string[];
|
|
285
|
+
|
|
286
|
+
/** Tags */
|
|
287
|
+
tags?: string[];
|
|
288
|
+
|
|
289
|
+
/** Categories */
|
|
290
|
+
categories?: string[];
|
|
291
|
+
|
|
292
|
+
/** Whether the agent accepts user input */
|
|
293
|
+
interactive: boolean;
|
|
294
|
+
|
|
295
|
+
/** Collection ID */
|
|
296
|
+
collection_id?: string;
|
|
297
|
+
|
|
298
|
+
/** Content type */
|
|
299
|
+
content_type?: ContentObjectTypeRef;
|
|
300
|
+
|
|
301
|
+
/** Tools configured for this run */
|
|
302
|
+
tool_names?: string[];
|
|
303
|
+
|
|
304
|
+
/** Schedule ID (if schedule-triggered) */
|
|
305
|
+
schedule_id?: string;
|
|
306
|
+
|
|
307
|
+
/** How the run was created */
|
|
308
|
+
type?: AgentRunType;
|
|
309
|
+
|
|
310
|
+
/** Created timestamp */
|
|
311
|
+
created_at: string;
|
|
312
|
+
|
|
313
|
+
/** Updated timestamp */
|
|
314
|
+
updated_at: string;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Response from the agent runs search endpoint.
|
|
319
|
+
*/
|
|
320
|
+
export interface SearchAgentRunsResponse {
|
|
321
|
+
/** Search results */
|
|
322
|
+
hits: AgentRunSearchHit[];
|
|
323
|
+
|
|
324
|
+
/** Total matching results */
|
|
325
|
+
total: number;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Internal/Temporal details for an AgentRun.
|
|
330
|
+
* Includes fields normally stripped from client responses.
|
|
331
|
+
*/
|
|
332
|
+
export interface AgentRunInternals {
|
|
333
|
+
id: string;
|
|
334
|
+
workflow_id?: string;
|
|
335
|
+
first_workflow_run_id?: string;
|
|
336
|
+
artifacts_path?: string;
|
|
337
|
+
status: AgentRunStatus;
|
|
338
|
+
interaction: string;
|
|
339
|
+
interaction_name?: string;
|
|
340
|
+
config?: InteractionExecutionConfiguration;
|
|
341
|
+
interactive: boolean;
|
|
342
|
+
started_at: Date;
|
|
343
|
+
completed_at?: Date;
|
|
344
|
+
started_by: string;
|
|
345
|
+
created_at: Date;
|
|
346
|
+
updated_at: Date;
|
|
347
|
+
}
|
|
@@ -136,6 +136,20 @@ export interface ConversationState {
|
|
|
136
136
|
|
|
137
137
|
/** LLM stop reason from the latest call (e.g., "stop", "length", "tool_use") */
|
|
138
138
|
finish_reason?: string;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The AgentRun ID (MongoDB _id) that owns this conversation.
|
|
142
|
+
* Used for artifact storage paths: agents/{agent_run_id}/
|
|
143
|
+
* Undefined for legacy workflows started before the AgentRun system.
|
|
144
|
+
*/
|
|
145
|
+
agent_run_id?: string;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* For workstreams: the launch ID assigned by the parent workflow.
|
|
149
|
+
* When set, artifacts are stored under agents/{agent_run_id}/workstreams/{launch_id}/
|
|
150
|
+
* to consolidate all artifacts under the parent agent run.
|
|
151
|
+
*/
|
|
152
|
+
launch_id?: string;
|
|
139
153
|
}
|
|
140
154
|
|
|
141
155
|
/** Skill metadata collected at workflow start for upfront sandbox hydration */
|
|
@@ -146,6 +160,25 @@ export interface AvailableSkill {
|
|
|
146
160
|
src: string;
|
|
147
161
|
}
|
|
148
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Compute the storage ID for a conversation's artifacts.
|
|
165
|
+
* - Root workflows: `{agent_run_id}` (or fallbackRunId if no agent_run_id)
|
|
166
|
+
* - Workstreams: `{agent_run_id}/workstreams/{launch_id}`
|
|
167
|
+
*
|
|
168
|
+
* Both studio-server and workflow activities must use the same logic so
|
|
169
|
+
* parent and child conversations don't overwrite each other.
|
|
170
|
+
*/
|
|
171
|
+
export function getConversationStorageId(
|
|
172
|
+
state: Pick<ConversationState, 'agent_run_id' | 'launch_id'> | undefined,
|
|
173
|
+
fallbackRunId: string,
|
|
174
|
+
): string {
|
|
175
|
+
const baseId = state?.agent_run_id || fallbackRunId;
|
|
176
|
+
if (state?.launch_id && state?.agent_run_id) {
|
|
177
|
+
return `${baseId}/workstreams/${state.launch_id}`;
|
|
178
|
+
}
|
|
179
|
+
return baseId;
|
|
180
|
+
}
|
|
181
|
+
|
|
149
182
|
/** Skill metadata tracked when a skill is used */
|
|
150
183
|
export interface UsedSkill {
|
|
151
184
|
/** Skill name (e.g., "analyze_data") */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StringValue } from "ms";
|
|
2
|
+
import { ToolExecutionMetadata } from "../tool-execution.js";
|
|
2
3
|
import { BaseObject } from "./common.js";
|
|
3
4
|
import { WorkflowExecutionPayload } from "./index.js";
|
|
4
5
|
import { ParentClosePolicyType } from "./temporalio.js";
|
|
@@ -221,12 +222,6 @@ export interface DSLChildWorkflowStep extends DSLWorkflowStepBase {
|
|
|
221
222
|
* If spec is defined then the name must be "dslWorkflow"
|
|
222
223
|
*/
|
|
223
224
|
spec?: DSLWorkflowSpec;
|
|
224
|
-
/**
|
|
225
|
-
* If true, copy the parent's workspace artifacts (scripts/, files/, skills/, docs/, out/)
|
|
226
|
-
* to the child workflow's agent space before execution. Defaults to true.
|
|
227
|
-
* conversation.json and tools.json are never copied.
|
|
228
|
-
*/
|
|
229
|
-
inherit_artifacts?: boolean;
|
|
230
225
|
options?: {
|
|
231
226
|
memo?: Record<string, any>;
|
|
232
227
|
retry?: DSLRetryPolicy;
|
|
@@ -312,3 +307,28 @@ export interface WorkflowDefinitionRef {
|
|
|
312
307
|
}
|
|
313
308
|
|
|
314
309
|
export const WorkflowDefinitionRefPopulate = "id name description tags created_at updated_at"
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Payload sent to a remote activity endpoint on a tool server.
|
|
313
|
+
* This is POSTed by the `executeRemoteActivity` bridge activity.
|
|
314
|
+
*/
|
|
315
|
+
export interface RemoteActivityExecutionPayload<ParamsT extends Record<string, any> = Record<string, any>> {
|
|
316
|
+
/** The activity name (unprefixed, as known by the tool server) */
|
|
317
|
+
activity_name: string;
|
|
318
|
+
/** The resolved activity parameters */
|
|
319
|
+
params: ParamsT;
|
|
320
|
+
/** Execution metadata (same shape as tool execution metadata) */
|
|
321
|
+
metadata?: ToolExecutionMetadata;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Response from a remote activity endpoint on a tool server.
|
|
326
|
+
*/
|
|
327
|
+
export interface RemoteActivityExecutionResponse {
|
|
328
|
+
/** The result data (stored into workflow vars via the step's `output` field) */
|
|
329
|
+
result: any;
|
|
330
|
+
/** Whether the execution failed */
|
|
331
|
+
is_error?: boolean;
|
|
332
|
+
/** Error message if is_error is true */
|
|
333
|
+
error?: string;
|
|
334
|
+
}
|