@vertesia/common 0.80.0-dev.20251121 → 0.80.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 (53) hide show
  1. package/README.md +53 -0
  2. package/lib/cjs/index.js +1 -0
  3. package/lib/cjs/index.js.map +1 -1
  4. package/lib/cjs/interaction.js.map +1 -1
  5. package/lib/cjs/project.js +47 -1
  6. package/lib/cjs/project.js.map +1 -1
  7. package/lib/cjs/skill.js +14 -0
  8. package/lib/cjs/skill.js.map +1 -0
  9. package/lib/cjs/store/store.js +3 -1
  10. package/lib/cjs/store/store.js.map +1 -1
  11. package/lib/cjs/user.js.map +1 -1
  12. package/lib/cjs/utils/schemas.js +26 -0
  13. package/lib/cjs/utils/schemas.js.map +1 -1
  14. package/lib/esm/index.js +1 -0
  15. package/lib/esm/index.js.map +1 -1
  16. package/lib/esm/interaction.js.map +1 -1
  17. package/lib/esm/project.js +45 -0
  18. package/lib/esm/project.js.map +1 -1
  19. package/lib/esm/skill.js +13 -0
  20. package/lib/esm/skill.js.map +1 -0
  21. package/lib/esm/store/store.js +2 -0
  22. package/lib/esm/store/store.js.map +1 -1
  23. package/lib/esm/user.js.map +1 -1
  24. package/lib/esm/utils/schemas.js +25 -0
  25. package/lib/esm/utils/schemas.js.map +1 -1
  26. package/lib/tsconfig.tsbuildinfo +1 -1
  27. package/lib/types/index.d.ts +1 -0
  28. package/lib/types/index.d.ts.map +1 -1
  29. package/lib/types/interaction.d.ts +54 -2
  30. package/lib/types/interaction.d.ts.map +1 -1
  31. package/lib/types/project.d.ts +56 -0
  32. package/lib/types/project.d.ts.map +1 -1
  33. package/lib/types/skill.d.ts +78 -0
  34. package/lib/types/skill.d.ts.map +1 -0
  35. package/lib/types/store/doc-analyzer.d.ts +8 -0
  36. package/lib/types/store/doc-analyzer.d.ts.map +1 -1
  37. package/lib/types/store/store.d.ts +26 -9
  38. package/lib/types/store/store.d.ts.map +1 -1
  39. package/lib/types/user.d.ts +1 -6
  40. package/lib/types/user.d.ts.map +1 -1
  41. package/lib/types/utils/schemas.d.ts +1 -0
  42. package/lib/types/utils/schemas.d.ts.map +1 -1
  43. package/lib/vertesia-common.js +1 -1
  44. package/lib/vertesia-common.js.map +1 -1
  45. package/package.json +11 -2
  46. package/src/index.ts +1 -0
  47. package/src/interaction.ts +65 -3
  48. package/src/project.ts +96 -0
  49. package/src/skill.ts +90 -0
  50. package/src/store/doc-analyzer.ts +9 -0
  51. package/src/store/store.ts +34 -12
  52. package/src/user.ts +2 -7
  53. package/src/utils/schemas.ts +22 -0
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@vertesia/common",
3
- "version": "0.80.0-dev.20251121",
3
+ "version": "0.80.0",
4
+ "license": "Apache-2.0",
4
5
  "type": "module",
5
6
  "types": "./lib/types/index.d.ts",
6
7
  "files": [
@@ -27,13 +28,21 @@
27
28
  "dependencies": {
28
29
  "ajv": "^8.16.0",
29
30
  "json-schema": "^0.4.0",
30
- "@llumiverse/common": "0.23.0-dev.20251121"
31
+ "@llumiverse/common": "0.23.0"
31
32
  },
32
33
  "repository": {
33
34
  "type": "git",
34
35
  "url": "https://github.com/vertesia/composableai.git",
35
36
  "directory": "packages/common"
36
37
  },
38
+ "keywords": [
39
+ "vertesia",
40
+ "common",
41
+ "types",
42
+ "llm",
43
+ "ai",
44
+ "typescript"
45
+ ],
37
46
  "ts_dual_module": {
38
47
  "outDir": "lib"
39
48
  },
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export * from './query.js';
20
20
  export * from './rate-limiter.js';
21
21
  export * from './refs.js';
22
22
  export * from './runs.js';
23
+ export * from './skill.js';
23
24
  export * from "./store/index.js";
24
25
  export * from './tenant.js';
25
26
  export * from "./training.js";
@@ -269,11 +269,20 @@ export interface InteractionEndpoint {
269
269
  version: number;
270
270
  tags: string[];
271
271
  agent_runner_options?: AgentRunnerOptions;
272
+ /**
273
+ * @deprecated This is deprecated. Use CompletionResult.type information instead.
274
+ */
272
275
  output_modality?: Modalities;
273
276
  result_schema?: JSONSchema;
274
277
  params_schema?: JSONSchema;
275
278
  }
276
279
 
280
+ export interface InteractionTags {
281
+ tag: string;
282
+ count: number;
283
+ interactions: InteractionRef[];
284
+ }
285
+
277
286
  export interface InteractionRef {
278
287
  id: string;
279
288
  name: string;
@@ -373,6 +382,9 @@ export interface InteractionData {
373
382
  model?: string;
374
383
  model_options?: ModelOptions;
375
384
  restriction?: RunDataStorageLevel;
385
+ /**
386
+ * @deprecated This is deprecated. Use CompletionResult.type information instead.
387
+ */
376
388
  output_modality?: Modalities;
377
389
  }
378
390
  export interface Interaction extends InteractionData {
@@ -453,7 +465,8 @@ export interface InteractionExecutionPayload {
453
465
  */
454
466
  data?: Record<string, any> | `memory:${string}`;
455
467
  config?: InteractionExecutionConfiguration;
456
- result_schema?: JSONSchema4;
468
+ //Use null to explicitly state no schema, will not fallback to interaction schema
469
+ result_schema?: JSONSchema4 | null;
457
470
  stream?: boolean;
458
471
  do_validate?: boolean;
459
472
  tags?: string | string[]; // tags to be added to the execution run
@@ -519,6 +532,27 @@ export enum AgentSearchScope {
519
532
  Collection = 'collection'
520
533
  }
521
534
 
535
+ /**
536
+ * Context triggers for auto-injection of skills.
537
+ * When these conditions match, the skill is automatically injected into the agent context.
538
+ */
539
+ export interface SkillContextTriggers {
540
+ /**
541
+ * Keywords in user input that should trigger this skill
542
+ */
543
+ keywords?: string[];
544
+
545
+ /**
546
+ * If these tools are being used, suggest this skill
547
+ */
548
+ tool_names?: string[];
549
+
550
+ /**
551
+ * Regex patterns to match against input data
552
+ */
553
+ data_patterns?: string[];
554
+ }
555
+
522
556
  /**
523
557
  * Configuration options for Agent Runner functionality.
524
558
  * These options control how interactions are exposed and executed in the Agent Runner.
@@ -534,6 +568,24 @@ export interface AgentRunnerOptions {
534
568
  */
535
569
  is_tool?: boolean;
536
570
 
571
+ /**
572
+ * Whether this interaction is a skill (provides instructions without execution).
573
+ * Skills are injected into the agent's context based on context_triggers.
574
+ */
575
+ is_skill?: boolean;
576
+
577
+ /**
578
+ * Context triggers for auto-injection of this skill.
579
+ * Only used when is_skill is true.
580
+ */
581
+ context_triggers?: SkillContextTriggers;
582
+
583
+ /**
584
+ * Injection priority for skills (higher = more likely to be selected when multiple match).
585
+ * Only used when is_skill is true.
586
+ */
587
+ skill_priority?: number;
588
+
537
589
  /**
538
590
  * Array of default tool names available to this agent.
539
591
  * For interactions: defines default tools.
@@ -725,7 +777,11 @@ export interface BaseExecutionRun<P = any> {
725
777
  config: InteractionExecutionConfiguration;
726
778
  error?: InteractionExecutionError;
727
779
  source: RunSource;
728
- output_modality: Modalities;
780
+
781
+ /**
782
+ * @deprecated This is deprecated. Use CompletionResult.type information instead.
783
+ */
784
+ output_modality?: Modalities;
729
785
  created_by: string;
730
786
  updated_by: string;
731
787
 
@@ -773,6 +829,11 @@ export interface ExecutionRunWorkflow {
773
829
  activity_type?: string;
774
830
  }
775
831
 
832
+ export interface PromptModalities {
833
+ hasVideo: boolean;
834
+ hasImage: boolean;
835
+ }
836
+
776
837
  export interface InteractionExecutionResult<P = any> extends ExecutionRun<P> {
777
838
  tool_use?: ToolUse[];
778
839
  conversation?: unknown;
@@ -839,7 +900,8 @@ export interface RateLimitRequestPayload {
839
900
  interaction: string,
840
901
  environment_id?: string,
841
902
  model_id?: string,
842
- workflow_run_id?: string
903
+ workflow_run_id?: string,
904
+ modalities?: PromptModalities;
843
905
  }
844
906
 
845
907
  export interface RateLimitRequestResponse {
package/src/project.ts CHANGED
@@ -62,13 +62,109 @@ export enum ResourceVisibility {
62
62
  }
63
63
 
64
64
 
65
+ // ==========================================
66
+ // Project Model Defaults Types
67
+ // ==========================================
68
+
69
+ /**
70
+ * Environment and model pair for a default configuration.
71
+ */
72
+ export interface ModelDefault {
73
+ environment: string;
74
+ model: string;
75
+ }
76
+
77
+ /**
78
+ * Modality-specific default model overrides.
79
+ * These override the base default when specific input modalities are detected.
80
+ */
81
+ export interface ModalityDefaults {
82
+ /** Override for inputs containing images */
83
+ image?: ModelDefault;
84
+ /** Override for inputs containing video (requires video-capable model) */
85
+ video?: ModelDefault;
86
+ }
87
+
88
+ /**
89
+ * System interaction category enum.
90
+ * Categories group one or more system interactions for default model assignment.
91
+ */
92
+ export enum SystemInteractionCategory {
93
+ content_type = "content_type",
94
+ intake = "intake",
95
+ analysis = "analysis",
96
+ non_applicable = "non_applicable"
97
+ }
98
+
99
+ /**
100
+ * Map system interaction endpoints to categories.
101
+ */
102
+ export const SYSTEM_INTERACTION_CATEGORIES: Record<string, SystemInteractionCategory> = {
103
+ "ExtractInformation": SystemInteractionCategory.intake,
104
+ "SelectDocumentType": SystemInteractionCategory.intake,
105
+ "GenerateMetadataModel": SystemInteractionCategory.content_type,
106
+ "ChunkDocument": SystemInteractionCategory.intake,
107
+ "IdentifyTextSections": SystemInteractionCategory.intake,
108
+ "AnalyzeDocument": SystemInteractionCategory.analysis,
109
+ "ReduceTextSections": SystemInteractionCategory.analysis,
110
+ "GenericAgent": SystemInteractionCategory.non_applicable,
111
+ "AdhocTaskAgent": SystemInteractionCategory.non_applicable,
112
+ "Mediator": SystemInteractionCategory.non_applicable,
113
+ "AnalyzeConversation": SystemInteractionCategory.analysis,
114
+ "GetAgentConversationTopic": SystemInteractionCategory.analysis,
115
+ };
116
+
117
+ /**
118
+ * Get category for a system interaction endpoint.
119
+ * Returns undefined if category is non-applicable or endpoint is not recognized.
120
+ * Note: Caller is responsible for determining if the interaction is a system interaction.
121
+ * @param endpoint - The interaction endpoint name
122
+ */
123
+ export function getSystemInteractionCategory(endpoint: string): SystemInteractionCategory | undefined {
124
+ if (endpoint.startsWith("sys:")) {
125
+ // Strip sys: prefix
126
+ endpoint = endpoint.substring(4);
127
+ }
128
+ const category = SYSTEM_INTERACTION_CATEGORIES[endpoint];
129
+ if (category === SystemInteractionCategory.non_applicable) {
130
+ return undefined;
131
+ }
132
+ return category || undefined;
133
+ }
134
+
135
+ export type SystemDefaults = {
136
+ [K in SystemInteractionCategory]?: ModelDefault;
137
+ };
138
+
139
+ /**
140
+ * Extensible project defaults using map/dictionary pattern.
141
+ */
142
+ export interface ProjectModelDefaults {
143
+ /** Base default model - used when no other default applies */
144
+ base?: ModelDefault;
145
+ /** Modality-based overrides (image, video) - override base when specific input modalities detected */
146
+ modality?: ModalityDefaults;
147
+ /** System interaction category defaults */
148
+ system?: SystemDefaults;
149
+ }
150
+
151
+ // ==========================================
152
+ // Project Configuration
153
+ // ==========================================
154
+
65
155
  export interface ProjectConfiguration {
66
156
 
67
157
  human_context: string;
68
158
 
159
+ /** @deprecated Use defaults.base - kept for backward compatibility */
69
160
  default_environment?: string;
161
+ /** @deprecated Use defaults.base - kept for backward compatibility */
70
162
  default_model?: string;
71
163
 
164
+ defaults?: ProjectModelDefaults;
165
+
166
+ default_visibility?: ResourceVisibility;
167
+
72
168
  sync_content_properties?: boolean;
73
169
 
74
170
  embeddings: {
package/src/skill.ts ADDED
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Skill types for interaction-based skills.
3
+ *
4
+ * Skills are interactions with `agent_runner_options.is_skill = true`.
5
+ * They provide contextual instructions to agents without executing code.
6
+ * When a skill is called, its rendered prompt is returned as instructions.
7
+ *
8
+ * Skills can have associated scripts stored at:
9
+ * skills/{skill_name}/*.py, *.js, etc.
10
+ * These are automatically synced to the sandbox when the skill is used.
11
+ */
12
+
13
+ /**
14
+ * Context provided when searching for relevant skills
15
+ */
16
+ export interface SkillContext {
17
+ /**
18
+ * The task description or user prompt
19
+ */
20
+ task_description?: string;
21
+
22
+ /**
23
+ * Tools currently being used or available
24
+ */
25
+ tool_names?: string[];
26
+
27
+ /**
28
+ * Sample of input data for pattern matching
29
+ */
30
+ data_sample?: string;
31
+
32
+ /**
33
+ * Additional keywords to consider
34
+ */
35
+ keywords?: string[];
36
+ }
37
+
38
+ /**
39
+ * Payload for finding relevant skills
40
+ */
41
+ export interface FindRelevantSkillsPayload {
42
+ context: SkillContext;
43
+ limit?: number;
44
+ }
45
+
46
+ /**
47
+ * Result from skill injection into agent context.
48
+ * Contains the rendered prompt/instructions from a skill interaction.
49
+ */
50
+ export interface InjectedSkill {
51
+ /**
52
+ * The skill/interaction name
53
+ */
54
+ name: string;
55
+
56
+ /**
57
+ * The skill's rendered instructions (from the interaction prompt)
58
+ */
59
+ instructions: string;
60
+
61
+ /**
62
+ * Tools related to this skill
63
+ */
64
+ related_tools?: string[];
65
+
66
+ /**
67
+ * UI module for rendering results
68
+ */
69
+ ui_module?: string;
70
+
71
+ /**
72
+ * Match score (0-1) indicating relevance
73
+ */
74
+ match_score?: number;
75
+ }
76
+
77
+ /**
78
+ * Result from generateTools activity with skills
79
+ */
80
+ export interface ToolsWithSkills {
81
+ /**
82
+ * Array of tool definitions
83
+ */
84
+ tools: unknown[]; // ToolDefinition[]
85
+
86
+ /**
87
+ * Skills injected based on context
88
+ */
89
+ injected_skills: InjectedSkill[];
90
+ }
@@ -55,11 +55,18 @@ export interface DocTableJson extends DocTable {
55
55
  data: Object[];
56
56
  }
57
57
 
58
+ /**
59
+ * Output format for document processing workflows
60
+ */
61
+ export type DocProcessorOutputFormat = "xml" | "markdown";
62
+
58
63
  /**
59
64
  * Represents a document analysis run status
60
65
  */
61
66
  export interface DocAnalyzeRunStatusResponse extends WorkflowRunStatus {
62
67
  progress?: DocAnalyzerProgress;
68
+ /** The output format being used for processing (markdown or xml) */
69
+ output_format?: DocProcessorOutputFormat;
63
70
  }
64
71
 
65
72
  export interface DocAnalyzerResultResponse {
@@ -76,6 +83,8 @@ export interface DocAnalyzerProgress {
76
83
  visuals: DocAnalyzerProgressStatus;
77
84
  started_at?: number;
78
85
  percent: number;
86
+ /** The output format being used for processing (markdown or xml) */
87
+ output_format?: DocProcessorOutputFormat;
79
88
  }
80
89
 
81
90
  interface DocAnalyzerProgressStatus {
@@ -13,6 +13,7 @@ export enum ContentObjectApiHeaders {
13
13
  export enum ContentObjectStatus {
14
14
  created = "created",
15
15
  processing = "processing", // the was created and still processing
16
+ ready = "ready", // the object is rendered and ready to be used
16
17
  completed = "completed",
17
18
  failed = "failed",
18
19
  archived = "archived",
@@ -75,6 +76,27 @@ export interface GenerationRunMetadata {
75
76
  target?: string;
76
77
  }
77
78
 
79
+ // Base rendition interface for document and audio
80
+ export interface Rendition {
81
+ name: string;
82
+ content: ContentSource;
83
+ }
84
+
85
+ // Rendition with dimensions for video and image
86
+ export interface RenditionWithDimensions extends Rendition {
87
+ dimensions: Dimensions;
88
+ }
89
+
90
+ /**
91
+ * @deprecated Use RenditionWithDimensions instead
92
+ */
93
+ export type VideoRendition = RenditionWithDimensions;
94
+
95
+ export const POSTER_RENDITION_NAME = "Poster";
96
+ export const AUDIO_RENDITION_NAME = "Audio";
97
+ export const WEB_VIDEO_RENDITION_NAME = "Web";
98
+ export const PDF_RENDITION_NAME = "PDF";
99
+
78
100
  export interface ContentMetadata {
79
101
  // Common fields for all media types
80
102
  type?: ContentNature;
@@ -83,9 +105,10 @@ export interface ContentMetadata {
83
105
  location?: Location;
84
106
  generation_runs: GenerationRunMetadata[];
85
107
  etag?: string;
108
+ renditions?: Rendition[];
86
109
  }
87
110
 
88
- // Example of type-specific metadata interfaces (optional, for better type safety)
111
+ // Type-specific metadata interfaces
89
112
  export interface TemporalMediaMetadata extends ContentMetadata {
90
113
  duration?: number; // in seconds
91
114
  transcript?: Transcript;
@@ -94,26 +117,17 @@ export interface TemporalMediaMetadata extends ContentMetadata {
94
117
  export interface ImageMetadata extends ContentMetadata {
95
118
  type: ContentNature.Image;
96
119
  dimensions?: Dimensions;
120
+ renditions?: RenditionWithDimensions[];
97
121
  }
98
122
 
99
123
  export interface AudioMetadata extends TemporalMediaMetadata {
100
124
  type: ContentNature.Audio;
101
125
  }
102
126
 
103
- export interface VideoRendition {
104
- name: string;
105
- dimensions: Dimensions;
106
- content: ContentSource
107
- }
108
-
109
- export const POSTER_RENDITION_NAME = "Poster";
110
- export const AUDIO_RENDITION_NAME = "Audio";
111
- export const WEB_VIDEO_RENDITION_NAME = "Web";
112
-
113
127
  export interface VideoMetadata extends TemporalMediaMetadata {
114
128
  type: ContentNature.Video;
115
129
  dimensions?: Dimensions;
116
- renditions?: VideoRendition[];
130
+ renditions?: RenditionWithDimensions[];
117
131
  hasAudio?: boolean;
118
132
  }
119
133
 
@@ -398,6 +412,7 @@ export interface GetRenditionParams {
398
412
  max_hw?: number;
399
413
  generate_if_missing?: boolean;
400
414
  sign_url?: boolean;
415
+ block_on_generation?: boolean;
401
416
  }
402
417
 
403
418
  export interface GetRenditionResponse {
@@ -428,6 +443,13 @@ export interface GetFileUrlResponse {
428
443
  path: string;
429
444
  }
430
445
 
446
+ export interface SetFileMetadataPayload {
447
+ /** The file path (relative to bucket) or full URI */
448
+ file: string;
449
+ /** Custom metadata key-value pairs to set on the file */
450
+ metadata: Record<string, string>;
451
+ }
452
+
431
453
  export enum ContentObjectProcessingPriority {
432
454
  normal = "normal",
433
455
  low = "low",
package/src/user.ts CHANGED
@@ -38,21 +38,16 @@ export enum BillingMethod {
38
38
  invoice = 'invoice'
39
39
  }
40
40
 
41
-
42
- interface AccountBilling {
41
+ export interface AccountBilling {
43
42
  method: BillingMethod;
44
43
  stripe_customer_id?: string;
45
44
  }
45
+
46
46
  export interface Account {
47
47
  id: string;
48
48
  name: string;
49
49
 
50
50
  email_domains: string[];
51
- members: {
52
- role: ProjectRoles;
53
- user: UserRef;
54
- disabled: boolean;
55
- }[];
56
51
 
57
52
  onboarding: {
58
53
  completed: boolean,
@@ -5,6 +5,28 @@ import { InCodePrompt, InteractionRefWithSchema, PopulatedInteraction } from "..
5
5
  import { ExecutablePromptSegmentDef, PromptSegmentDefType } from "../prompt.js";
6
6
 
7
7
 
8
+ // Remove custom properties from the JSON before sending further down execution pipeline
9
+ export function removeExtraProperties<T>(schema: T): T {
10
+ if (!schema) return schema;
11
+ if (Array.isArray(schema)) {
12
+ for (const item of schema) {
13
+ removeExtraProperties(item);
14
+ }
15
+ } else if (typeof schema === 'object') {
16
+ const obj = schema as Record<string, any>;
17
+ for (const [key, value] of Object.entries(obj)) {
18
+ if (key === 'editor' && (value === 'textarea' || value === 'document' || value === 'media')) {
19
+ delete obj[key];
20
+ } else if (key === 'format' && (value === 'textarea' || value === 'document' || value === 'media')) {
21
+ delete obj[key];
22
+ } else if (typeof value === 'object') {
23
+ removeExtraProperties(value)
24
+ }
25
+ }
26
+ }
27
+ return schema;
28
+ }
29
+
8
30
  export function mergeJSONSchemas(schemas: JSONSchema[]) {
9
31
  const props: Record<string, JSONSchema4> = {};
10
32
  let required: string[] = [];