@vertesia/common 1.0.0-dev.20260305.083323Z → 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.
Files changed (113) 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 +60 -3
  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 +10 -0
  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 +48 -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 +85 -44
  67. package/lib/types/project.d.ts.map +1 -1
  68. package/lib/types/query.d.ts +1 -0
  69. package/lib/types/query.d.ts.map +1 -1
  70. package/lib/types/store/agent-run.d.ts +254 -0
  71. package/lib/types/store/agent-run.d.ts.map +1 -0
  72. package/lib/types/store/conversation-state.d.ts +21 -0
  73. package/lib/types/store/conversation-state.d.ts.map +1 -1
  74. package/lib/types/store/dsl-workflow.d.ts +24 -6
  75. package/lib/types/store/dsl-workflow.d.ts.map +1 -1
  76. package/lib/types/store/index.d.ts +1 -0
  77. package/lib/types/store/index.d.ts.map +1 -1
  78. package/lib/types/store/signals.d.ts +5 -5
  79. package/lib/types/store/signals.d.ts.map +1 -1
  80. package/lib/types/store/store.d.ts +22 -0
  81. package/lib/types/store/store.d.ts.map +1 -1
  82. package/lib/types/store/workflow.d.ts +59 -10
  83. package/lib/types/store/workflow.d.ts.map +1 -1
  84. package/lib/types/utils/schemas.d.ts +7 -0
  85. package/lib/types/utils/schemas.d.ts.map +1 -1
  86. package/lib/types/versions.d.ts +2 -1
  87. package/lib/types/versions.d.ts.map +1 -1
  88. package/lib/types/workflow-analytics.d.ts +5 -1
  89. package/lib/types/workflow-analytics.d.ts.map +1 -1
  90. package/lib/vertesia-common.js +1 -1
  91. package/lib/vertesia-common.js.map +1 -1
  92. package/package.json +2 -2
  93. package/src/apps.ts +77 -3
  94. package/src/audit-trail.ts +1 -0
  95. package/src/common.ts +24 -1
  96. package/src/environment.ts +10 -0
  97. package/src/index.ts +1 -0
  98. package/src/interaction.ts +57 -9
  99. package/src/oauth.ts +119 -0
  100. package/src/payload.ts +15 -0
  101. package/src/project.ts +91 -46
  102. package/src/query.ts +1 -0
  103. package/src/store/agent-run.ts +347 -0
  104. package/src/store/conversation-state.ts +33 -0
  105. package/src/store/dsl-workflow.ts +26 -6
  106. package/src/store/index.ts +1 -0
  107. package/src/store/signals.ts +5 -5
  108. package/src/store/store.ts +22 -0
  109. package/src/store/workflow.ts +70 -10
  110. package/src/utils/schemas.ts +49 -1
  111. package/src/versions.ts +1 -0
  112. package/src/workflow-analytics.ts +5 -1
  113. package/tsconfig.dist.json +1 -1
@@ -1,4 +1,5 @@
1
1
  export * from "./activity-catalog.js";
2
+ export * from "./agent-run.js";
2
3
  export * from "./collections.js";
3
4
  export * from "./common.js";
4
5
  export * from "./conversation-state.js";
@@ -3,23 +3,23 @@ export interface UserInputSignal {
3
3
  metadata?: Record<string, any>;
4
4
  auth_token?: string;
5
5
  /**
6
- * Email attachments to be processed as store objects.
6
+ * Attachments to be processed as store objects.
7
7
  * These will be downloaded, uploaded to store, and processed for text extraction
8
8
  * before the conversation continues.
9
9
  */
10
- attachments?: EmailAttachment[];
10
+ attachments?: Attachment[];
11
11
  }
12
12
 
13
13
  /**
14
- * Email attachment metadata for processing in conversation workflows.
14
+ * Attachment metadata for processing in conversation workflows.
15
15
  */
16
- export interface EmailAttachment {
16
+ export interface Attachment {
17
17
  /** Original filename */
18
18
  filename: string;
19
19
  /** MIME content type */
20
20
  content_type: string;
21
21
  /** Size in bytes */
22
22
  size: number;
23
- /** Resend download URL (temporary, expires) */
23
+ /** Download URL (temporary, may expire) */
24
24
  download_url: string;
25
25
  }
@@ -45,6 +45,15 @@ export interface InheritedPropertyMetadata {
45
45
  /** The collection ID that provided this property */
46
46
  collection: string;
47
47
  }
48
+ /**
49
+ * Computed per-request permissions for the current user on a content object.
50
+ * Not stored in the database — computed on the fly by the API from the object's security field.
51
+ */
52
+ export interface ContentObjectUserPermissions {
53
+ can_write: boolean;
54
+ can_delete: boolean;
55
+ }
56
+
48
57
  export interface ContentObject<T = any> extends ContentObjectItem<T> {
49
58
  text?: string; // the text representation of the object
50
59
  text_etag?: string;
@@ -285,6 +294,11 @@ export interface ContentObjectItem<T = Record<string, any>> extends BaseObject {
285
294
  * The document score, used for ranking and sorting.
286
295
  */
287
296
  score?: number;
297
+
298
+ /**
299
+ * Computed per-request: the current user's effective permissions on this object.
300
+ */
301
+ user_permissions?: ContentObjectUserPermissions;
288
302
  }
289
303
 
290
304
  /**
@@ -609,6 +623,14 @@ export interface SetFileMetadataPayload {
609
623
  metadata: Record<string, string>;
610
624
  }
611
625
 
626
+ export interface BulkUploadUrlsPayload {
627
+ files: { name: string; mime_type?: string; id?: string }[];
628
+ }
629
+
630
+ export interface BulkUploadUrlsResponse {
631
+ files: GetFileUrlResponse[];
632
+ }
633
+
612
634
  export enum ContentObjectProcessingPriority {
613
635
  normal = "normal",
614
636
  low = "low",
@@ -86,14 +86,6 @@ export interface WorkflowExecutionBaseParams<T = Record<string, any>> {
86
86
  */
87
87
  ancestors?: WorkflowAncestor[]
88
88
 
89
- /**
90
- * If true, copy workspace artifacts (scripts/, files/, skills/, docs/, out/)
91
- * from parent workflow to this workflow on startup.
92
- * Defaults to true when spawning child workflows.
93
- * conversation.json and tools.json are never copied.
94
- */
95
- inherit_artifacts?: boolean;
96
-
97
89
  /**
98
90
  * List of enabled processing queues. Managed by the application.
99
91
  */
@@ -228,6 +220,8 @@ export interface ExecuteWorkflowPayload {
228
220
  run_at?: string;
229
221
  }
230
222
 
223
+ export type ConversationActivityState = 'working' | 'idle';
224
+
231
225
  export interface ListWorkflowRunsPayload {
232
226
  /**
233
227
  * The document ID passed to a workflow run.
@@ -297,6 +291,16 @@ export interface ListWorkflowRunsPayload {
297
291
  * Filter by whether the workflow has reported errors (TemporalReportedProblems).
298
292
  */
299
293
  has_reported_errors?: boolean;
294
+
295
+ /**
296
+ * Filter by the activity state of the conversation (running or idle).
297
+ */
298
+ activity_state?: ConversationActivityState;
299
+
300
+ /**
301
+ * Filter by whether the conversation is interactive.
302
+ */
303
+ interactive?: boolean;
300
304
  }
301
305
 
302
306
  /**
@@ -399,6 +403,8 @@ interface TaskBase {
399
403
  completed: string | null;
400
404
  error: string | null;
401
405
  result: any;
406
+ /** Temporal run ID that produced this task (set when aggregating across continueAsNew runs). */
407
+ runId?: string;
402
408
  }
403
409
 
404
410
  // Activity-specific task
@@ -461,7 +467,7 @@ export type HistoryFormat = 'events' | 'tasks' | 'agent';
461
467
  */
462
468
  export interface AgentTask {
463
469
  /** Type discriminator for future task types */
464
- taskType: 'tool_call' | 'llm_call' | 'input' | 'timer' | 'subagent' | 'processing';
470
+ taskType: 'tool_call' | 'llm_call' | 'input' | 'timer' | 'subagent' | 'processing' | 'signal';
465
471
 
466
472
  /** Tool-specific fields */
467
473
  toolName: string;
@@ -474,7 +480,7 @@ export interface AgentTask {
474
480
  scheduled_at: string | null;
475
481
  started_at: string | null;
476
482
  completed_at: string | null;
477
- status: 'running' | 'completed' | 'error' | 'warning';
483
+ status: 'running' | 'completed' | 'error' | 'warning' | 'received' | 'sent';
478
484
 
479
485
  /** Tool data */
480
486
  parameters?: Record<string, unknown>;
@@ -490,9 +496,15 @@ export interface AgentTask {
490
496
  /** Available skills for this LLM call */
491
497
  availableSkills?: string[];
492
498
 
499
+ /** Temporal run ID that produced this task. */
500
+ runId?: string;
501
+
493
502
  /** Workstream tracking */
494
503
  workstreamId?: string;
495
504
 
505
+ /** Signal direction for signal tasks */
506
+ direction?: 'sending' | 'receiving';
507
+
496
508
  /** LLM stop reason for llm_call tasks (e.g., "stop", "length", "tool_use") */
497
509
  finish_reason?: string;
498
510
  }
@@ -538,6 +550,16 @@ export interface WorkflowRun {
538
550
  * A brief summary of the conversation workflow.
539
551
  */
540
552
  topic?: string;
553
+ /**
554
+ * The current activity state of the conversation.
555
+ * - 'working': The agent is actively processing
556
+ * - 'idle': The agent is waiting for user input
557
+ */
558
+ activity_state?: ConversationActivityState;
559
+ /**
560
+ * Whether this conversation is interactive (accepts user input).
561
+ */
562
+ interactive?: boolean;
541
563
  }
542
564
 
543
565
  export interface PendingActivity {
@@ -573,6 +595,7 @@ export interface WorkflowInteractionVars {
573
595
  interaction: string,
574
596
  interactive: boolean,
575
597
  debug_mode?: boolean,
598
+ non_blocking_subagents?: boolean,
576
599
  /**
577
600
  * Array of channels to use for user communication.
578
601
  * Multiple channels can be active simultaneously.
@@ -664,6 +687,7 @@ export enum AgentMessageType {
664
687
  TERMINATED = 11,
665
688
  STREAMING_CHUNK = 12,
666
689
  BATCH_PROGRESS = 13,
690
+ RESTARTING = 14,
667
691
  }
668
692
 
669
693
  // ============================================
@@ -1255,3 +1279,39 @@ export interface AgentIntakeWorkflowResult {
1255
1279
  /** Whether embeddings were generated */
1256
1280
  hasEmbeddings: boolean;
1257
1281
  }
1282
+
1283
+ // ---------------------------------------------------------------------------
1284
+ // Workstream query types (used by client helpers)
1285
+ // ---------------------------------------------------------------------------
1286
+
1287
+ /** Progress reported by a child workstream */
1288
+ export interface WorkstreamProgressInfo {
1289
+ launch_id: string;
1290
+ workstream_id: string;
1291
+ phase: 'planning' | 'executing_tool' | 'synthesizing' | 'blocked' | 'done';
1292
+ current_step?: string;
1293
+ current_tool?: string;
1294
+ percent?: number;
1295
+ updated_at: number;
1296
+ }
1297
+
1298
+ /** Entry returned by the ActiveWorkstreams query */
1299
+ export interface ActiveWorkstreamEntry {
1300
+ launch_id: string;
1301
+ workstream_id: string;
1302
+ interaction: string;
1303
+ started_at: number;
1304
+ elapsed_ms: number;
1305
+ deadline_ms: number;
1306
+ status: 'running' | 'canceling';
1307
+ latest_progress?: WorkstreamProgressInfo;
1308
+ /** Child workflow ID — use to fetch per-workstream messages */
1309
+ child_workflow_id: string;
1310
+ /** Child workflow run ID — use with retrieveMessages / streamMessages */
1311
+ child_workflow_run_id?: string;
1312
+ }
1313
+
1314
+ /** Result of the ActiveWorkstreams Temporal query */
1315
+ export interface ActiveWorkstreamsQueryResult {
1316
+ running: ActiveWorkstreamEntry[];
1317
+ }
@@ -24,7 +24,9 @@ export function sanitizeToolDefinitions(tools: ToolDefinition[] | undefined): To
24
24
  return tools.map(sanitizeToolDefinition);
25
25
  }
26
26
 
27
- // Remove custom properties from the JSON before sending further down execution pipeline
27
+ // Remove custom properties from the JSON before sending further down execution pipeline.
28
+ // Before stripping UI-only fields (editor, format), translate them into LLM-friendly
29
+ // schema hints so the model knows the expected value format.
28
30
  export function removeExtraProperties<T>(schema: T): T {
29
31
  if (!schema) return schema;
30
32
  if (Array.isArray(schema)) {
@@ -33,6 +35,13 @@ export function removeExtraProperties<T>(schema: T): T {
33
35
  }
34
36
  } else if (typeof schema === 'object') {
35
37
  const obj = schema as Record<string, any>;
38
+
39
+ // If this looks like a property definition (has editor/format for document/media),
40
+ // enrich it with type and description hints before stripping.
41
+ if (isDocumentProperty(obj)) {
42
+ enrichDocumentProperty(obj);
43
+ }
44
+
36
45
  for (const [key, value] of Object.entries(obj)) {
37
46
  if (key === 'editor' && (value === 'textarea' || value === 'document' || value === 'media')) {
38
47
  delete obj[key];
@@ -46,6 +55,45 @@ export function removeExtraProperties<T>(schema: T): T {
46
55
  return schema;
47
56
  }
48
57
 
58
+ /**
59
+ * Returns true if the schema property represents a document reference
60
+ * (identified by editor: "document" or format: "document" / "media").
61
+ */
62
+ function isDocumentProperty(obj: Record<string, any>): boolean {
63
+ return obj.editor === 'document' ||
64
+ obj.format === 'document' ||
65
+ obj.format === 'media';
66
+ }
67
+
68
+ /**
69
+ * Canonical hint string appended to document property descriptions.
70
+ * Used by ensureDocumentStorePrefix (in @dglabs/workflows) to detect document
71
+ * properties after serialization, when editor/format fields have been stripped.
72
+ * Exported so both packages use the exact same string — do NOT duplicate.
73
+ */
74
+ export const DOCUMENT_STORE_HINT = "Use 'store:<document_id>' format to reference a document from the content store.";
75
+
76
+ /**
77
+ * Enriches a document property schema with LLM-friendly hints:
78
+ * - Sets type to "string" if not already set
79
+ * - Appends a store: prefix hint to the description
80
+ */
81
+ function enrichDocumentProperty(obj: Record<string, any>): void {
82
+ // Set type to string if missing (document references are string IDs)
83
+ if (!obj.type) {
84
+ obj.type = 'string';
85
+ }
86
+
87
+ // Always ensure the canonical hint is present in the description.
88
+ // Check for the exact hint string (not just 'store:') to avoid missing detection
89
+ // after serialization when only the description survives.
90
+ if (!obj.description) {
91
+ obj.description = DOCUMENT_STORE_HINT;
92
+ } else if (!obj.description.includes(DOCUMENT_STORE_HINT)) {
93
+ obj.description = `${obj.description} ${DOCUMENT_STORE_HINT}`;
94
+ }
95
+ }
96
+
49
97
  export function mergeJSONSchemas(schemas: JSONSchema[]) {
50
98
  const props: Record<string, JSONSchema> = {};
51
99
  let required: string[] = [];
package/src/versions.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export enum ApiVersions {
2
2
  COMPLETION_RESULT_V1 = 20250925,
3
3
  DOWNLOAD_URL_NO_MIME_TYPE_V1 = 20260210,
4
+ MEDIA_BLOB_STORAGE_V1 = 20260319,
4
5
  }
@@ -63,6 +63,8 @@ export interface BaseAgentEvent {
63
63
  timestamp: string;
64
64
  /** Globally unique ID for this agent run */
65
65
  runId: string;
66
+ /** Stable AgentRun ID (MongoDB _id) that persists across workflow restarts */
67
+ agentRunId?: string;
66
68
  /** LLM model identifier (e.g., "claude-3-5-sonnet", "gemini-1.5-pro") */
67
69
  model: string;
68
70
  /** Environment ID (MongoDB ObjectId of the environment) */
@@ -288,8 +290,10 @@ export interface WorkflowAnalyticsFilter {
288
290
  toolTypes?: ('builtin' | 'interaction' | 'remote' | 'skill')[];
289
291
  /** Filter by success/failure status */
290
292
  success?: boolean;
291
- /** Filter by specific workflow run IDs */
293
+ /** Filter by specific workflow run IDs (Temporal run IDs) */
292
294
  runIds?: string[];
295
+ /** Filter by stable AgentRun IDs (MongoDB _id, persists across restarts) */
296
+ agentRunIds?: string[];
293
297
  /** Filter by principal IDs (users or API keys) */
294
298
  principals?: string[];
295
299
  }
@@ -4,7 +4,7 @@
4
4
  "declaration": true,
5
5
  "declarationMap": true,
6
6
  "jsx": "react-jsx",
7
- "target": "ES2022",
7
+ "target": "ES2024",
8
8
  "module": "ESNext",
9
9
  "moduleResolution": "Bundler",
10
10
  "rootDir": "./src",