@vertesia/common 0.51.0 → 0.52.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 (89) hide show
  1. package/lib/cjs/interaction.js +2 -2
  2. package/lib/cjs/interaction.js.map +1 -1
  3. package/lib/cjs/meters.js.map +1 -1
  4. package/lib/cjs/project.js.map +1 -1
  5. package/lib/cjs/store/index.js +1 -0
  6. package/lib/cjs/store/index.js.map +1 -1
  7. package/lib/cjs/store/signals.js +3 -0
  8. package/lib/cjs/store/signals.js.map +1 -0
  9. package/lib/cjs/store/store.js.map +1 -1
  10. package/lib/cjs/store/workflow.js +16 -1
  11. package/lib/cjs/store/workflow.js.map +1 -1
  12. package/lib/cjs/utils/schemas.js +17 -0
  13. package/lib/cjs/utils/schemas.js.map +1 -1
  14. package/lib/esm/interaction.js +2 -2
  15. package/lib/esm/interaction.js.map +1 -1
  16. package/lib/esm/meters.js.map +1 -1
  17. package/lib/esm/project.js.map +1 -1
  18. package/lib/esm/store/index.js +1 -0
  19. package/lib/esm/store/index.js.map +1 -1
  20. package/lib/esm/store/signals.js +2 -0
  21. package/lib/esm/store/signals.js.map +1 -0
  22. package/lib/esm/store/store.js.map +1 -1
  23. package/lib/esm/store/workflow.js +15 -0
  24. package/lib/esm/store/workflow.js.map +1 -1
  25. package/lib/esm/utils/schemas.js +16 -0
  26. package/lib/esm/utils/schemas.js.map +1 -1
  27. package/lib/tsconfig.tsbuildinfo +1 -1
  28. package/lib/types/Progress.d.ts +0 -1
  29. package/lib/types/access-control.d.ts +0 -1
  30. package/lib/types/analytics.d.ts +0 -1
  31. package/lib/types/apikey.d.ts +0 -1
  32. package/lib/types/common.d.ts +1 -1
  33. package/lib/types/common.d.ts.map +1 -1
  34. package/lib/types/environment.d.ts +0 -1
  35. package/lib/types/facets.d.ts +0 -1
  36. package/lib/types/index.d.ts +0 -1
  37. package/lib/types/integrations.d.ts +0 -1
  38. package/lib/types/interaction.d.ts +164 -12
  39. package/lib/types/interaction.d.ts.map +1 -1
  40. package/lib/types/meters.d.ts +7 -1
  41. package/lib/types/meters.d.ts.map +1 -1
  42. package/lib/types/payload.d.ts +0 -1
  43. package/lib/types/project.d.ts +7 -1
  44. package/lib/types/project.d.ts.map +1 -1
  45. package/lib/types/prompt.d.ts +0 -1
  46. package/lib/types/query.d.ts +0 -1
  47. package/lib/types/refs.d.ts +0 -1
  48. package/lib/types/runs.d.ts +8 -1
  49. package/lib/types/runs.d.ts.map +1 -1
  50. package/lib/types/store/activity-catalog.d.ts +1 -2
  51. package/lib/types/store/activity-catalog.d.ts.map +1 -1
  52. package/lib/types/store/agent.d.ts +0 -1
  53. package/lib/types/store/collections.d.ts +0 -1
  54. package/lib/types/store/common.d.ts +0 -1
  55. package/lib/types/store/doc-analyzer.d.ts +63 -15
  56. package/lib/types/store/doc-analyzer.d.ts.map +1 -1
  57. package/lib/types/store/dsl-workflow.d.ts +0 -1
  58. package/lib/types/store/index.d.ts +1 -1
  59. package/lib/types/store/index.d.ts.map +1 -1
  60. package/lib/types/store/object-types.d.ts +0 -1
  61. package/lib/types/store/signals.d.ts +4 -0
  62. package/lib/types/store/signals.d.ts.map +1 -0
  63. package/lib/types/store/store.d.ts +10 -3
  64. package/lib/types/store/store.d.ts.map +1 -1
  65. package/lib/types/store/temporalio.d.ts +0 -1
  66. package/lib/types/store/workflow.d.ts +43 -11
  67. package/lib/types/store/workflow.d.ts.map +1 -1
  68. package/lib/types/training.d.ts +0 -1
  69. package/lib/types/transient-tokens.d.ts +0 -1
  70. package/lib/types/user.d.ts +0 -3
  71. package/lib/types/user.d.ts.map +1 -1
  72. package/lib/types/utils/advanced-content-processing.d.ts +0 -1
  73. package/lib/types/utils/auth.d.ts +0 -1
  74. package/lib/types/utils/schemas.d.ts +2 -1
  75. package/lib/types/utils/schemas.d.ts.map +1 -1
  76. package/package.json +3 -3
  77. package/src/common.ts +1 -0
  78. package/src/interaction.ts +242 -37
  79. package/src/meters.ts +9 -3
  80. package/src/project.ts +7 -0
  81. package/src/runs.ts +9 -0
  82. package/src/store/activity-catalog.ts +1 -1
  83. package/src/store/doc-analyzer.ts +80 -20
  84. package/src/store/index.ts +1 -0
  85. package/src/store/signals.ts +4 -0
  86. package/src/store/store.ts +10 -2
  87. package/src/store/workflow.ts +102 -74
  88. package/src/user.ts +0 -2
  89. package/src/utils/schemas.ts +18 -1
package/src/meters.ts CHANGED
@@ -1,6 +1,4 @@
1
-
2
-
3
-
1
+ import { BillingMethod } from "./user.js";
4
2
 
5
3
 
6
4
  export interface MeterAdjustment {
@@ -21,4 +19,12 @@ export enum MeterNames {
21
19
  input_token_used = 'input_token_used',
22
20
  output_token_used = 'output_token_used',
23
21
  task_run = 'task_run',
22
+ }
23
+
24
+
25
+ export interface StripeBillingStatusResponse {
26
+ status: 'enabled' | 'disabled',
27
+ billing_method: BillingMethod | null,
28
+ portal_url?: string,
29
+ reason?: string
24
30
  }
package/src/project.ts CHANGED
@@ -5,6 +5,7 @@ export interface ICreateProjectPayload {
5
5
  name: string;
6
6
  namespace: string;
7
7
  description?: string;
8
+ auto_config?: boolean;
8
9
  }
9
10
  export enum ProjectRoles {
10
11
  owner = "owner", // all permissions
@@ -43,6 +44,12 @@ export interface ProjectRef {
43
44
  id: string;
44
45
  name: string;
45
46
  account: string;
47
+ /**
48
+ * Only set when fetching the list of projects visible to an user which is an org admin or owner.
49
+ * If present and true, it means that the project is not accessible to the user.(even if it visible in listing)
50
+ * If not present or false then the project is accessible to the user.
51
+ */
52
+ restricted?: boolean;
46
53
  }
47
54
 
48
55
  export enum ResourceVisibility {
package/src/runs.ts CHANGED
@@ -1,6 +1,15 @@
1
1
  import { FacetResult } from './facets.js';
2
2
  import { NamedInteractionExecutionPayload } from './interaction.js';
3
3
 
4
+ /**
5
+ * The run ref is used to identify a run document in the storage
6
+ */
7
+ export interface ExecutionRunDocRef {
8
+ id: string,
9
+ account: string,
10
+ project: string,
11
+ }
12
+
4
13
  /**
5
14
  * Interaction execution payload for creating a new run
6
15
  * It uses interaction field (from NamedInteractionExecutionPayload) to pass the intercation ID to run
@@ -1,4 +1,4 @@
1
- export type TsPropType = "string" | "number" | "boolean" | "record" | "object" | "array" | "enum" | "literal" | "union" | "promise" | "any";
1
+ export type TsPropType = "string" | "number" | "boolean" | "record" | "object" | "array" | "enum" | "literal" | "union" | "promise" | "any" | "void";
2
2
 
3
3
  // generic types are replaced by "any"
4
4
  export interface ActivityTypeDefinition {
@@ -1,4 +1,4 @@
1
- import { WorkflowExecutionPayload, WorkflowExecutionStatus } from "./workflow.js";
1
+ import { WorkflowExecutionPayload, WorkflowRunStatus } from "./workflow.js";
2
2
 
3
3
  export interface PdfToRichtextOptions {
4
4
  features: string[];
@@ -6,9 +6,8 @@ export interface PdfToRichtextOptions {
6
6
  [key: string]: any;
7
7
  }
8
8
 
9
-
10
- export interface PdfToRichTextWorkflowParams extends Omit<WorkflowExecutionPayload, "vars"> {
11
- vars: PdfToRichtextOptions
9
+ export interface PdfToRichTextWorkflowPayload extends Omit<WorkflowExecutionPayload, "vars"> {
10
+ vars: PdfToRichtextOptions;
12
11
  }
13
12
 
14
13
  /**
@@ -17,16 +16,17 @@ export interface PdfToRichTextWorkflowParams extends Omit<WorkflowExecutionPaylo
17
16
  export interface DocImage {
18
17
  id?: string;
19
18
  page_number?: number;
20
- image_number?: number;
21
- title?: string;
22
- url?: string;
23
19
  description?: string;
24
20
  is_meaningful?: boolean;
25
21
  width?: number;
26
22
  height?: number;
27
- path?: string;
28
23
  }
29
24
 
25
+ /**
26
+ * The export type formats for tables.
27
+ */
28
+ export type ExportTableFormats = 'json' | 'csv' | 'xml';
29
+
30
30
  /**
31
31
  * Represents a table in a document that has been analyzed
32
32
  */
@@ -58,28 +58,22 @@ export interface DocTableJson extends DocTable {
58
58
  /**
59
59
  * Represents a document analysis run status
60
60
  */
61
- export interface DocAnalyzeRunStatusResponse {
62
- workflow_id: string | null;
63
- run_id: string | null;
64
- status: WorkflowExecutionStatus;
61
+ export interface DocAnalyzeRunStatusResponse extends WorkflowRunStatus {
65
62
  progress?: DocAnalyzerProgress;
66
63
  }
67
64
 
68
-
69
65
  export interface DocAnalyzerResultResponse {
70
66
  document?: string;
71
67
  tables?: DocTableCsv[] | DocTableJson[];
72
68
  images?: DocImage[];
73
- parts?: { id: string, title: string }[];
74
69
  annotated?: string | null;
75
70
  }
76
71
 
77
-
78
72
  export interface DocAnalyzerProgress {
79
- pages: DocAnalyzerProgressStatus,
80
- images: DocAnalyzerProgressStatus,
81
- tables: DocAnalyzerProgressStatus,
82
- visuals: DocAnalyzerProgressStatus,
73
+ pages: DocAnalyzerProgressStatus;
74
+ images: DocAnalyzerProgressStatus;
75
+ tables: DocAnalyzerProgressStatus;
76
+ visuals: DocAnalyzerProgressStatus;
83
77
  started_at?: number;
84
78
  percent: number;
85
79
  }
@@ -89,4 +83,70 @@ interface DocAnalyzerProgressStatus {
89
83
  processed: number;
90
84
  success: number;
91
85
  failed: number;
92
- }
86
+ }
87
+
88
+ /**
89
+ * Adapt Tables Parameters, part of the request
90
+ */
91
+ export interface AdaptTablesParams {
92
+ /**
93
+ * JSON Schema to to convert the table into
94
+ */
95
+ target_schema: string;
96
+
97
+ /**
98
+ * Natural language description of the type item the table are composed of
99
+ */
100
+ item_name: string;
101
+
102
+ /**
103
+ * Natural language description of the type of table or item to convert
104
+ */
105
+ instructions?: string;
106
+
107
+ /**
108
+ * Format to return the data in (csv, json)
109
+ */
110
+ format?: "csv" | "json";
111
+
112
+ /**
113
+ * Process the table as a whole or by page
114
+ */
115
+ process_as?: "page" | "table";
116
+
117
+ /**
118
+ * Process the table as a CSV file
119
+ */
120
+ process_as_csv?: boolean;
121
+ }
122
+
123
+ interface DocAnalyzerRequestBase {
124
+ synchroneous?: boolean;
125
+
126
+ notify_endpoints?: string[];
127
+
128
+ /**
129
+ * What environmenet to use to run the request
130
+ * If none specified the project embedded environment will be used
131
+ */
132
+ environment?: string;
133
+ }
134
+
135
+ export interface AdaptTablesRequest extends DocAnalyzerRequestBase, AdaptTablesParams {}
136
+
137
+ /**
138
+ * Get Adapted Tables Request
139
+ * @param raw If true, the raw data will be returned
140
+ * @param format The format to return the data in (csv, json)
141
+ */
142
+ export interface GetAdaptedTablesRequestQuery {
143
+ raw?: boolean;
144
+ format: "csv" | "json";
145
+ }
146
+ /**
147
+ * The adapted table result format
148
+ */
149
+ export interface AdaptedTable {
150
+ comment?: string;
151
+ data: Record<string, any>[];
152
+ }
@@ -8,3 +8,4 @@ export * from "./object-types.js";
8
8
  export * from "./store.js";
9
9
  export * from "./temporalio.js";
10
10
  export * from "./workflow.js";
11
+ export * from "./signals.js";
@@ -0,0 +1,4 @@
1
+ export interface UserInputSignal {
2
+ message: string;
3
+ metadata?: Record<string, any>;
4
+ }
@@ -105,8 +105,8 @@ export interface TranscriptSegment {
105
105
  text: string
106
106
  speaker?: number
107
107
  end?: number
108
- language?: string
109
108
  confidence?: number
109
+ language?: string
110
110
  }
111
111
 
112
112
  export interface ContentSource {
@@ -186,11 +186,19 @@ export interface ColumnLayout {
186
186
  default?: any;
187
187
  }
188
188
  export interface ContentObjectType extends ContentObjectTypeItem {
189
- object_schema?: Record<string, any>; // an optional JSON schema for the object properties.
190
189
  }
191
190
  export interface ContentObjectTypeItem extends BaseObject {
192
191
  is_chunkable?: boolean;
192
+ /**
193
+ * This is only included in ContentObjectTypeItem if explicitely requested
194
+ * It is always included in ContentObjectType
195
+ */
193
196
  table_layout?: ColumnLayout[];
197
+ /**
198
+ * this is only included in ContentObjectTypeItem if explicitely requested
199
+ * It is always included in ContentObjectType
200
+ */
201
+ object_schema?: Record<string, any>; // an optional JSON schema for the object properties.
194
202
  }
195
203
 
196
204
  export interface CreateContentObjectTypePayload extends Omit<ContentObjectType, 'id' | 'created_at' | 'updated_at' | 'created_by' | 'updated_by'> {
@@ -1,4 +1,3 @@
1
-
2
1
  export enum ContentEventName {
3
2
  create = "create",
4
3
  change_type = "change_type",
@@ -6,56 +5,60 @@ export enum ContentEventName {
6
5
  delete = "delete",
7
6
  workflow_finished = "workflow_finished",
8
7
  workflow_execution_request = "workflow_execution_request",
8
+ api_request = "api_request",
9
9
  }
10
10
 
11
+ export interface WorkflowExecutionBaseParams<T = Record<string, any>> {
12
+ /**
13
+ * The ref of the user who initiated the workflow.
14
+ */
15
+ initiated_by?: string;
11
16
 
12
- export interface WorkflowExecutionBaseParams<T=Record<string, any>> {
13
-
14
- /**
15
- * The ref of the user who initiated the workflow.
16
- */
17
- initiated_by?: string;
18
-
19
- /**
20
- * The account ID of the user who created the activity.
21
- * This is usefull to select the right database to work on.
22
- */
23
- account_id: string;
24
-
25
- /**
26
- * The project ID of the account who created the activity.
27
- */
28
- project_id: string;
29
-
30
- /**
31
- * The vars field is mainly used to pass the user input to the workflow.
32
- * The user input ar custom user options that can be used to configure the workflow.
33
- * You can see the user input as the arguments for a command line app.
34
- *
35
- * In the case of workflows started by events (e.g. using a a workflow rule) the user input vars will be initialized with the workflow rule configuration field.
36
- *
37
- * In case of dsl workflows the worflow execution payload vars will be applied over the default vars values stored in the DSL vars field.
38
- */
39
- vars: T;
40
-
41
- /**
42
- * Auth Token to access Zeno and Composable from the workers
43
- */
44
- auth_token?: string;
45
-
46
- /**
47
- * The configuration for the workflow execution.
48
- */
49
- config?: {
50
- studio_url: string;
51
- store_url: string;
52
- enabled_integrations?: string[]; //list of enabled integrations
53
- }
54
-
55
- }
17
+ /**
18
+ * The account ID of the user who created the activity.
19
+ * This is usefull to select the right database to work on.
20
+ */
21
+ account_id: string;
22
+
23
+ /**
24
+ * The project ID of the account who created the activity.
25
+ */
26
+ project_id: string;
27
+
28
+ /**
29
+ * The vars field is mainly used to pass the user input to the workflow.
30
+ * The user input ar custom user options that can be used to configure the workflow.
31
+ * You can see the user input as the arguments for a command line app.
32
+ *
33
+ * In the case of workflows started by events (e.g. using a a workflow rule) the user input vars will be initialized with the workflow rule configuration field.
34
+ *
35
+ * In case of dsl workflows the worflow execution payload vars will be applied over the default vars values stored in the DSL vars field.
36
+ */
37
+ vars: T;
38
+
39
+ /**
40
+ * Auth Token to access Zeno and Composable from the workers
41
+ */
42
+ auth_token?: string;
56
43
 
44
+ /**
45
+ * The configuration for the workflow execution.
46
+ */
47
+ config?: {
48
+ studio_url: string;
49
+ store_url: string;
50
+ slack_app_url?: string;
51
+ enabled_integrations?: string[]; //list of enabled integrations
52
+ };
57
53
 
58
- export interface WorkflowExecutionPayload<T=Record<string, any>> extends WorkflowExecutionBaseParams<T> {
54
+ /**
55
+ * The list of endpoints to notify when the workflow finishes.
56
+ * It is handled by a subworkflow execution, so the main workflow will not wait for the notification to be sent.
57
+ */
58
+ notify_endpoints?: string[];
59
+ }
60
+
61
+ export interface WorkflowExecutionPayload<T = Record<string, any>> extends WorkflowExecutionBaseParams<T> {
59
62
  /**
60
63
  * The event which started the workflow who created the activity.
61
64
  */
@@ -72,27 +75,18 @@ export interface WorkflowExecutionPayload<T=Record<string, any>> extends Workflo
72
75
  */
73
76
  objectIds: string[];
74
77
 
75
- /**
76
- * Auth Token to access Zeno and Composable from the workers
77
- */
78
- auth_token: string;
79
-
80
-
81
78
  /**
82
- * The configuration for the workflow execution.
79
+ * Auth Token to access Zeno and Composable from the workers
83
80
  */
84
- config?: {
85
- studio_url: string;
86
- store_url: string;
87
- enabled_integrations?: string[]; //list of enabled integrations
88
- }
81
+ auth_token: string;
89
82
  }
90
83
 
91
-
92
84
  export interface ExecuteWorkflowPayload {
93
85
  task_queue?: string;
94
86
  objectIds?: string[];
95
87
  vars?: Record<string, any>;
88
+ unique?: boolean;
89
+ timeout?: number; //timeout in seconds
96
90
  }
97
91
 
98
92
  export interface ListWorkflowRunsPayload {
@@ -117,7 +111,7 @@ interface WorkflowRunEvent {
117
111
  name: string;
118
112
  id: string;
119
113
  input?: any;
120
- }
114
+ };
121
115
 
122
116
  error?: {
123
117
  message: string;
@@ -126,20 +120,20 @@ interface WorkflowRunEvent {
126
120
  type?: string;
127
121
  };
128
122
 
129
- result?: any
130
-
123
+ result?: any;
131
124
  }
132
125
 
133
126
  export interface WorkflowRun {
134
- status?: WorkflowExecutionStatus | string,
135
- type?: string,
136
- started_at?: number,
137
- closed_at?: number,
138
- execution_duration?: number,
139
- run_id?: string,
140
- workflow_id?: string,
141
- initiated_by?: string,
142
- raw?: any
127
+ status?: WorkflowExecutionStatus | string;
128
+ type?: string;
129
+ started_at?: number;
130
+ closed_at?: number;
131
+ execution_duration?: number;
132
+ run_id?: string;
133
+ workflow_id?: string;
134
+ initiated_by?: string;
135
+ result?: any;
136
+ raw?: any;
143
137
  }
144
138
 
145
139
  export interface WorkflowRunWithDetails extends WorkflowRun {
@@ -149,12 +143,12 @@ export interface ListWorkflowRunsResponse {
149
143
  runs: WorkflowRun[];
150
144
  }
151
145
 
152
- export interface MultiDocumentsInteractionParams extends Omit<WorkflowExecutionPayload, 'config'> {
146
+ export interface MultiDocumentsInteractionParams extends Omit<WorkflowExecutionPayload, "config"> {
153
147
  config: {
154
148
  interactionName: string;
155
149
  action: DocumentActionConfig;
156
150
  data: Record<string, any>;
157
- }
151
+ };
158
152
  }
159
153
 
160
154
  export interface DocumentActionConfig {
@@ -176,4 +170,38 @@ export enum WorkflowExecutionStatus {
176
170
  TERMINATED = 5,
177
171
  CONTINUED_AS_NEW = 6,
178
172
  TIMED_OUT = 7,
179
- }
173
+ }
174
+
175
+ /**
176
+ * Basic response for anything run with an async workflow
177
+ */
178
+ export interface WorkflowRunStatus {
179
+ workflow_id: string | null;
180
+ workflow_run_id: string | null;
181
+ status: WorkflowExecutionStatus;
182
+ }
183
+
184
+ /**
185
+ * Workflow Update Message
186
+ */
187
+ export interface AgentMessage {
188
+ timestamp: number;
189
+ workflow_run_id: string;
190
+ type: AgentMessageType;
191
+ message?: string;
192
+ details?: any;
193
+ }
194
+
195
+ export enum AgentMessageType {
196
+ SYSTEM = "system",
197
+ THOUGHT = "thought",
198
+ PLAN = "plan",
199
+ UPDATE = "update",
200
+ COMPLETE = "complete",
201
+ WARNING = "warning",
202
+ ERROR = "error",
203
+ ANSWER = "answer",
204
+ QUESTION = "question",
205
+ REQUEST_INPUT = "request_input",
206
+ IDLE = "idle",
207
+ }
package/src/user.ts CHANGED
@@ -107,11 +107,9 @@ export interface UserSessionInfo extends SessionInfo<User> { }
107
107
  export interface ApiKeySessionInfo extends SessionInfo<ApiKey> { }
108
108
 
109
109
  export interface OnboardingProgress {
110
- projects: boolean,
111
110
  interactions: boolean,
112
111
  prompts: boolean,
113
112
  environments: boolean,
114
- runs: boolean;
115
113
  default_environment_defined: boolean
116
114
  }
117
115
 
@@ -1,8 +1,25 @@
1
- import { PromptRole } from "@llumiverse/core";
1
+ import { JSONSchema, PromptRole } from "@llumiverse/core";
2
2
  import { JSONSchema4 } from "json-schema";
3
3
  import { InteractionRefWithSchema, PopulatedInteraction } from "../interaction.js";
4
4
  import { PopulatedPromptSegmentDef, PromptSegmentDef, PromptSegmentDefType, PromptTemplateRefWithSchema } from "../prompt.js";
5
5
 
6
+
7
+ export function mergeJSONSchemas(schemas: JSONSchema[]) {
8
+ const props: Record<string, JSONSchema4> = {};
9
+ let required: string[] = [];
10
+ for (const schema of schemas) {
11
+ if (schema.properties) {
12
+ if (schema.required) {
13
+ for (const prop of schema.required as string[]) {
14
+ if (!required.includes(prop)) required.push(prop);
15
+ }
16
+ }
17
+ Object.assign(props, schema.properties);
18
+ }
19
+ }
20
+ return Object.keys(props).length > 0 ? { properties: props, required } as JSONSchema : null;
21
+ }
22
+
6
23
  export function _mergePromptsSchema(prompts: PromptSegmentDef<PromptTemplateRefWithSchema>[] | PopulatedPromptSegmentDef[]) {
7
24
  const props: Record<string, JSONSchema4> = {};
8
25
  let required: string[] = [];