@vertesia/common 0.79.1 → 0.80.0-dev-20251118

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertesia/common",
3
- "version": "0.79.1",
3
+ "version": "0.80.0-dev-20251118",
4
4
  "type": "module",
5
5
  "types": "./lib/types/index.d.ts",
6
6
  "files": [
@@ -34,6 +34,11 @@
34
34
  "ajv": "^8.16.0",
35
35
  "json-schema": "^0.4.0"
36
36
  },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/vertesia/composableai.git",
40
+ "directory": "packages/common"
41
+ },
37
42
  "ts_dual_module": {
38
43
  "outDir": "lib"
39
44
  }
@@ -44,9 +44,9 @@ export enum Permission {
44
44
  workflow_admin = "workflow:admin",
45
45
  workflow_superadmin = "workflow:superadmin",
46
46
 
47
- /**
48
- * whether the user has access to Sutdio App.
49
- */
47
+ iam_impersonate = "iam:impersonate",
48
+
49
+ /** whether the user has access to Sutdio App. */
50
50
  studio_access = "studio:access",
51
51
  }
52
52
 
@@ -95,4 +95,4 @@ export interface AcesQueryOptions {
95
95
  role?: string
96
96
  type?: AccessControlResourceType
97
97
 
98
- }
98
+ }
package/src/apikey.ts CHANGED
@@ -2,9 +2,8 @@ import { UserGroupRef } from "./group.js";
2
2
  import { ProjectRef, ProjectRoles } from "./project.js";
3
3
  import { AccountRef } from "./user.js";
4
4
 
5
-
6
5
  export enum ApiKeyTypes {
7
- secret = 'sk'
6
+ secret = "sk",
8
7
  }
9
8
  export interface ApiKey {
10
9
  id: string;
@@ -15,27 +14,23 @@ export interface ApiKey {
15
14
  account: string; // the account id
16
15
  project: ProjectRef; // the project id if any
17
16
  enabled: boolean;
18
- created_by: string,
19
- updated_by: string,
17
+ created_by: string;
18
+ updated_by: string;
20
19
  created_at: Date;
21
20
  updated_at: Date;
22
21
  expires_at?: Date; // in case of public key only
23
22
  }
24
23
 
24
+ export interface CreateOrUpdateApiKeyPayload extends Partial<ApiKey> {}
25
25
 
26
- export interface CreateOrUpdateApiKeyPayload extends Partial<ApiKey> {
27
-
28
- }
29
-
30
- export interface ApiKeyWithValue extends Omit<ApiKey, 'maskedValue'> {
26
+ export interface ApiKeyWithValue extends Omit<ApiKey, "maskedValue"> {
31
27
  value: string;
32
28
  }
33
29
 
34
-
35
30
  export interface CreatePublicKeyPayload {
36
- name?: string,
37
- projectId?: string,
38
- ttl?: number,
31
+ name?: string;
32
+ projectId?: string;
33
+ ttl?: number;
39
34
  }
40
35
 
41
36
  export interface AuthTokenResponse {
@@ -43,12 +38,12 @@ export interface AuthTokenResponse {
43
38
  }
44
39
 
45
40
  export interface AuthTokenPayload {
46
- sub: string
41
+ sub: string;
47
42
  name: string;
48
43
  email?: string;
49
44
  picture?: string;
50
45
 
51
- type: PrincipalType
46
+ type: PrincipalType;
52
47
  account: AccountRef;
53
48
 
54
49
  account_roles: ProjectRoles[];
@@ -77,20 +72,26 @@ export interface AuthTokenPayload {
77
72
  * Either a n API domain like 'api.vertesia.io' | 'api-preview.vertesia.io' | 'api-staging.vertesia.io' | 'local'
78
73
  * or explicit studio and store URLs.
79
74
  */
80
- endpoints?: string | {
81
- studio: string,
82
- store: string
83
- }
75
+ endpoints?:
76
+ | string
77
+ | {
78
+ studio: string;
79
+ store: string;
80
+ };
84
81
 
85
82
  iss: string; //issuer
86
83
  aud: string; //audience
87
84
  exp: number; //expires in (EPOC seconds)
88
- }
85
+ tags?: string[]; //tags
89
86
 
87
+ permissions?: string[]; //permissions
88
+ scopes?: string[]; //scopes
89
+ }
90
90
 
91
91
  export enum PrincipalType {
92
92
  User = "user",
93
93
  Group = "group",
94
94
  ApiKey = "apikey",
95
95
  ServiceAccount = "service_account",
96
- }
96
+ Agent = "agent",
97
+ }
package/src/apps.ts CHANGED
@@ -54,6 +54,14 @@ export interface AppManifestData {
54
54
  */
55
55
  tool_collections?: string[]
56
56
 
57
+ /**
58
+ * An URL providing interactions definitions in JSON format.
59
+ * The URL must provide 2 endpoints:
60
+ * 1. GET URL - must return a JSON array with the list of interactions (as AppInteractionRef[])
61
+ * 2. GET URL/{interaction_name} - must return the full interaction definition for the specified interaction.
62
+ */
63
+ interactions?: string;
64
+
57
65
  /**
58
66
  * A JSON chema for the app installation settings.
59
67
  */
package/src/index.ts CHANGED
@@ -28,5 +28,6 @@ export * from './user.js';
28
28
  export * from './utils/auth.js';
29
29
  export * from './utils/schemas.js';
30
30
  export type * from './utils/type-helpers.js';
31
+ export * from './sts-token-types.js';
31
32
  export * from './versions.js';
32
33
 
@@ -4,6 +4,7 @@ import type {
4
4
  JSONSchema,
5
5
  Modalities,
6
6
  ModelOptions,
7
+ PromptRole,
7
8
  StatelessExecutionOptions,
8
9
  ToolDefinition,
9
10
  ToolUse,
@@ -15,10 +16,12 @@ import { ExecutionTokenUsage } from "@llumiverse/common";
15
16
  import { ExecutionEnvironmentRef } from "./environment.js";
16
17
  import { ProjectRef } from "./project.js";
17
18
  import {
19
+ ExecutablePromptSegmentDef,
18
20
  PopulatedPromptSegmentDef,
19
21
  PromptSegmentDef,
20
22
  PromptTemplateRef,
21
23
  PromptTemplateRefWithSchema,
24
+ TemplateType,
22
25
  } from "./prompt.js";
23
26
  import { ExecutionRunDocRef } from "./runs.js";
24
27
  import { AccountRef } from "./user.js";
@@ -29,6 +32,193 @@ export interface InteractionExecutionError {
29
32
  data?: any;
30
33
  }
31
34
 
35
+
36
+ // ------------------ in code interactions -----------------
37
+ /**
38
+ * Reference to an interaction in the catalog.
39
+ * Used in catalog listing. The id is composed of the namespace and the interaction name.
40
+ * Stored interactions can use `oid:` prefix.
41
+ * If no prefix is used it fallback on `oid:`.
42
+ */
43
+ export interface CatalogInteractionRef {
44
+ /**
45
+ * The type of interaction
46
+ */
47
+ type: "sys" | "app" | "stored" | "draft";
48
+
49
+ /**
50
+ * the interaction id that can be used to execute the interaction.
51
+ */
52
+ id: string;
53
+
54
+ /**
55
+ * The interaction name which identify the interaction in the provider interaction list.
56
+ * For the stored interactions this is the same as the endpoint property.
57
+ * For other types of interactions this is the local name of the interaction.
58
+ */
59
+ name: string;
60
+
61
+ /**
62
+ * Only applies for stored interactions. The version of the interaction.
63
+ * Undefined for non stored interactions
64
+ */
65
+ version?: number;
66
+
67
+ /**
68
+ * Only applies for stored interactions. Whether the interaction is published or not.
69
+ */
70
+ published?: boolean;
71
+
72
+ /**
73
+ * The tags associated with the interaction.
74
+ */
75
+ tags: string[];
76
+
77
+ /**
78
+ * Agent Runner configuration options.
79
+ */
80
+ agent_runner_options?: AgentRunnerOptions;
81
+
82
+ /**
83
+ * The name of the interaction. For display purposes only.
84
+ */
85
+ title: string;
86
+
87
+ /**
88
+ * Optional description of the interaction.
89
+ */
90
+ description?: string;
91
+ }
92
+
93
+ export interface InCodePrompt {
94
+ role: PromptRole,
95
+ content: string,
96
+ content_type: TemplateType;
97
+ schema?: JSONSchema;
98
+ /**
99
+ * optional name of the prompt segment. Use kebab case for prompt names
100
+ */
101
+ name?: string;
102
+ /**
103
+ * optional reference to an external resource if any.
104
+ * Used internally by the system to synchronize stored prompts with in-code prompts.
105
+ */
106
+ externalId?: string;
107
+ }
108
+ export interface InCodeInteraction {
109
+ /**
110
+ * The interaction type.
111
+ */
112
+ type: "sys" | "app" | "stored" | "draft";
113
+
114
+ /**
115
+ * The id of the interaction. Required.
116
+ * The id is a unique identifier for the interaction.
117
+ * It is recommended to use a URL safe string and not include spaces.
118
+ * The id composaed by some namespace or prefix and the interaction name.
119
+ * Example: sys:generic_question, app:review_contract, tmp:my_temp_interaction
120
+ */
121
+ id: string;
122
+
123
+ /**
124
+ * The interaction code name. Required.
125
+ * Should be a URL safe string and not include spaces. It is recommended to use kebab-case or camel-case.
126
+ * The endpoints must satisfy the following regexp: /^[a-zA-Z0-9-_]+$/. No whitespaces or special characters are allowed.
127
+ */
128
+ name: string;
129
+
130
+ /**
131
+ * Only applies for stored interactions. The version of the interaction.
132
+ * Undefined for non stored interactions
133
+ */
134
+ version?: number;
135
+
136
+ /**
137
+ * Only applies for stored interactions. Whether the interaction is published or not.
138
+ */
139
+ published?: boolean;
140
+
141
+ /**
142
+ * A title for the interaction. If not provided, the endpoint will be used.
143
+ */
144
+ title?: string;
145
+
146
+ /**
147
+ * An optional description of the interaction.
148
+ */
149
+ description?: string;
150
+
151
+ /**
152
+ * The JSON schema to be used for the result if any.
153
+ */
154
+ result_schema?: JSONSchema | SchemaRef;
155
+
156
+ /**
157
+ * The modality of the interaction output.
158
+ * If not specified Modalities.Text is assumed.
159
+ */
160
+ output_modality?: Modalities,
161
+
162
+ /**
163
+ * How to store the run data for executions of this interaction.
164
+ * Defaults to STANDARD.
165
+ */
166
+ storage?: RunDataStorageLevel;
167
+
168
+ /**
169
+ * Optional tags for the interaction.
170
+ */
171
+ tags?: string[];
172
+
173
+ /**
174
+ * Agent Runner configuration options.
175
+ */
176
+ agent_runner_options?: AgentRunnerOptions;
177
+
178
+ /**
179
+ * Default options for the model to be used when executing this interaction.
180
+ * (like temperature etc)
181
+ */
182
+ model_options?: ModelOptions;
183
+
184
+ /**
185
+ * The prompts composing the interaction. Required.
186
+ */
187
+ prompts: InCodePrompt[]
188
+
189
+ /**
190
+ * Optional reference to an external resource if any.
191
+ * Used internally by the system to synchronize stored interactions with in-code interactions.
192
+ */
193
+ externalId?: string;
194
+
195
+ /**
196
+ * Runtime configuration (system use only)
197
+ *
198
+ * This field is populated by the system when converting stored interactions
199
+ * and contains runtime-specific defaults like target model/environment IDs.
200
+ *
201
+ * DO NOT set this field manually when writing interaction definitions.
202
+ * These values are environment-specific and not portable.
203
+ *
204
+ * @internal
205
+ */
206
+ runtime?: {
207
+ /**
208
+ * Default target environment for the interaction execution
209
+ */
210
+ environment?: string;
211
+
212
+ /**
213
+ * Default (recommended) target model for the interaction execution
214
+ */
215
+ model?: string;
216
+ }
217
+ }
218
+ export interface InteractionSpec extends Omit<InCodeInteraction, 'id' | 'runtime' | 'type' | 'published' | 'version'> {
219
+ }
220
+ // ---------------------------------------------------------
221
+
32
222
  /**
33
223
  * The payload to query the interaction endpoints
34
224
  */
@@ -78,6 +268,7 @@ export interface InteractionEndpoint {
78
268
  visibility?: InteractionVisibility;
79
269
  version: number;
80
270
  tags: string[];
271
+ agent_runner_options?: AgentRunnerOptions;
81
272
  output_modality?: Modalities;
82
273
  result_schema?: JSONSchema;
83
274
  params_schema?: JSONSchema;
@@ -93,11 +284,12 @@ export interface InteractionRef {
93
284
  visibility?: InteractionVisibility;
94
285
  version: number;
95
286
  tags: string[];
287
+ agent_runner_options?: AgentRunnerOptions;
96
288
  prompts?: PromptSegmentDef<PromptTemplateRef>[];
97
289
  updated_at: Date;
98
290
  }
99
291
  export const InteractionRefPopulate =
100
- "id name endpoint parent description status version visibility tags updated_at prompts";
292
+ "id name endpoint parent description status version visibility tags agent_runner_options updated_at prompts";
101
293
 
102
294
  export const InteractionRefWithSchemaPopulate =
103
295
  `${InteractionRefPopulate} result_schema`;
@@ -167,28 +359,32 @@ export interface CachePolicy {
167
359
  ttl: number;
168
360
  }
169
361
  export type InteractionVisibility = "public" | "private";
170
- export interface Interaction {
362
+
363
+ export interface InteractionData {
171
364
  readonly id: string;
172
365
  name: string;
173
366
  endpoint: string;
174
367
  description?: string;
368
+ project: string | ProjectRef;
369
+ tags: string[];
370
+ agent_runner_options?: AgentRunnerOptions;
371
+ result_schema?: JSONSchema4 | SchemaRef;
372
+ environment?: string | ExecutionEnvironmentRef;
373
+ model?: string;
374
+ model_options?: ModelOptions;
375
+ restriction?: RunDataStorageLevel;
376
+ output_modality?: Modalities;
377
+ }
378
+ export interface Interaction extends InteractionData {
175
379
  status: InteractionStatus;
176
380
  parent?: string;
177
381
  // only used for versions (status === "published")
178
382
  visibility: InteractionVisibility;
179
383
  version: number;
180
- tags: string[];
181
384
  test_data?: JSONObject;
182
385
  interaction_schema?: JSONSchema4 | SchemaRef;
183
- result_schema?: JSONSchema4 | SchemaRef;
184
386
  cache_policy?: CachePolicy;
185
- model: string;
186
- model_options?: ModelOptions;
187
387
  prompts: PromptSegmentDef[];
188
- output_modality?: Modalities;
189
- environment: string | ExecutionEnvironmentRef;
190
- restriction?: RunDataStorageLevel;
191
- project: string | ProjectRef;
192
388
  // only for drafts - when it was last published
193
389
  last_published_at?: Date;
194
390
  created_by: string;
@@ -201,6 +397,14 @@ export interface PopulatedInteraction extends Omit<Interaction, "prompts"> {
201
397
  prompts: PopulatedPromptSegmentDef[];
202
398
  }
203
399
 
400
+ /**
401
+ * Used to describe an interaction that can be executed. Contains only the interaction data useful
402
+ * to execute the interaction plus the prompt templates
403
+ */
404
+ export interface ExecutableInteraction extends InteractionData {
405
+ prompts: ExecutablePromptSegmentDef[];
406
+ }
407
+
204
408
  export interface InteractionCreatePayload
205
409
  extends Omit<
206
410
  Interaction,
@@ -218,6 +422,7 @@ export interface InteractionCreatePayload
218
422
  | "endpoint"
219
423
  > {
220
424
  visibility?: InteractionVisibility;
425
+ tags?: string[];
221
426
  }
222
427
 
223
428
  export interface InteractionUpdatePayload
@@ -271,6 +476,12 @@ export interface InteractionExecutionPayload {
271
476
  * The workflow related to this Interaction Run.
272
477
  */
273
478
  workflow?: ExecutionRunWorkflow;
479
+
480
+ /**
481
+ * Only used by ad-hoc interactions which defines the prompt in the execution payload itself
482
+ * These are temporary interactions using "tmp:" suffix.
483
+ */
484
+ prompts?: InCodePrompt[];
274
485
  }
275
486
 
276
487
  export interface NamedInteractionExecutionPayload extends InteractionExecutionPayload {
@@ -298,11 +509,58 @@ interface AsyncExecutionPayloadBase extends Omit<NamedInteractionExecutionPayloa
298
509
 
299
510
  export type ConversationVisibility = 'private' | 'project';
300
511
 
512
+ /**
513
+ * Defines the scope for agent search operations.
514
+ */
515
+ export enum AgentSearchScope {
516
+ /**
517
+ * Search is scoped to a specific collection.
518
+ */
519
+ Collection = 'collection'
520
+ }
521
+
522
+ /**
523
+ * Configuration options for Agent Runner functionality.
524
+ * These options control how interactions are exposed and executed in the Agent Runner.
525
+ */
526
+ export interface AgentRunnerOptions {
527
+ /**
528
+ * Whether this interaction is an agent (executable in Agent Runner).
529
+ */
530
+ is_agent?: boolean;
531
+
532
+ /**
533
+ * Whether this interaction is available as a tool (sub-agent).
534
+ */
535
+ is_tool?: boolean;
536
+
537
+ /**
538
+ * Array of default tool names available to this agent.
539
+ * For interactions: defines default tools.
540
+ * For execution payloads: you can use + and - to add or remove from default,
541
+ * if no sign, then list replaces default.
542
+ */
543
+ tool_names?: string[];
544
+
545
+ /**
546
+ * On which scope should the search be applied by the search_tool.
547
+ * Only supports 'collection' scope or undefined for now.
548
+ */
549
+ search_scope?: AgentSearchScope;
550
+
551
+ /**
552
+ * The ID of the collection to restrict agent operations to.
553
+ * When specified, the agent's search and retrieval operations are limited to documents
554
+ * within this collection'.
555
+ */
556
+ collection_id?: string;
557
+ }
558
+
301
559
  export interface AsyncConversationExecutionPayload extends AsyncExecutionPayloadBase {
302
560
  type: "conversation";
303
561
 
304
- /**
305
- * Visibility determine if the conversation should be seen by the user only or by anyone with access to the project
562
+ /**
563
+ * Visibility determine if the conversation should be seen by the user only or by anyone with access to the project
306
564
  * If not specified, the default is project
307
565
  **/
308
566
  visibility?: ConversationVisibility;
@@ -332,7 +590,7 @@ export interface AsyncConversationExecutionPayload extends AsyncExecutionPayload
332
590
  * On which scope should the searched by applied, by the search_tool.
333
591
  * Only supports collection scope or null for now.
334
592
  */
335
- search_scope?: string;
593
+ search_scope?: AgentSearchScope.Collection;
336
594
 
337
595
  /**
338
596
  * The collection in which this workflow is executing
@@ -424,7 +682,7 @@ export interface RunSource {
424
682
  client_ip: string;
425
683
  }
426
684
 
427
- export interface ExecutionRun<P = any> {
685
+ export interface BaseExecutionRun<P = any> {
428
686
  readonly id: string;
429
687
  /**
430
688
  * Only used by runs that were created by a virtual run to point toward the virtual run parent
@@ -443,8 +701,12 @@ export interface ExecutionRun<P = any> {
443
701
  */
444
702
  parameters: P; //params used to create the interaction, only in varies on?
445
703
  tags?: string[];
446
- //TODO a string is returned when executing not the interaction object
447
- interaction: Interaction;
704
+ // only set when the target interaction is a stored interaction
705
+ //TODO check the code where Interaction type is used (should be in run details)
706
+ // TODO when execution string is passed as the type of interaction
707
+ interaction?: string | Interaction;
708
+ // only set when the target interaction is an in-code interaction
709
+ interaction_code?: string; // Interaction code name in case of in-code interaction (not stored in the DB as an Interaction document)
448
710
  //TODO a string is returned when execution not the env object
449
711
  environment: ExecutionEnvironmentRef;
450
712
  modelId: string;
@@ -477,6 +739,14 @@ export interface ExecutionRun<P = any> {
477
739
  workflow?: ExecutionRunWorkflow;
478
740
  }
479
741
 
742
+ export interface ExecutionRun<P = any> extends BaseExecutionRun<P> {
743
+ interaction?: Interaction;
744
+ }
745
+
746
+ export interface PopulatedExecutionRun<P = any> extends BaseExecutionRun<P> {
747
+ interaction?: Interaction;
748
+ }
749
+
480
750
  export interface ExecutionRunWorkflow {
481
751
  /**
482
752
  * The Temporal Workflow Run ID related to this Interaction Run.
@@ -510,7 +780,8 @@ export interface InteractionExecutionResult<P = any> extends ExecutionRun<P> {
510
780
  }
511
781
 
512
782
  export interface ExecutionRunRef extends Omit<ExecutionRun, "result" | "parameters" | "interaction"> {
513
- interaction: InteractionRef;
783
+ interaction?: InteractionRef;
784
+ interaction_code?: string;
514
785
  }
515
786
 
516
787
  export const ExecutionRunRefSelect = "-result -parameters -result_schema -prompt";
@@ -553,10 +824,17 @@ export interface GenerateTestDataPayload {
553
824
  config: InteractionExecutionConfiguration;
554
825
  }
555
826
 
556
- export interface ImprovePromptPayload {
827
+ export interface ImprovePromptPayloadConfig {
557
828
  config: InteractionExecutionConfiguration;
558
829
  }
559
830
 
831
+ export interface ImprovePromptPayload extends ImprovePromptPayloadConfig {
832
+ interaction_name: string; // name of the interaction to improve
833
+ context?: string,
834
+ prompt: { name: string, content: string }[]; // prompt array
835
+ result_schema?: JSONSchema, // optional interactionr result schema
836
+ }
837
+
560
838
  export interface RateLimitRequestPayload {
561
839
  interaction: string,
562
840
  environment_id?: string,
package/src/project.ts CHANGED
@@ -69,6 +69,8 @@ export interface ProjectConfiguration {
69
69
  default_environment?: string;
70
70
  default_model?: string;
71
71
 
72
+ sync_content_properties?: boolean;
73
+
72
74
  embeddings: {
73
75
  text?: ProjectConfigurationEmbeddings;
74
76
  image?: ProjectConfigurationEmbeddings;
package/src/prompt.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { JSONSchema4 } from "json-schema";
2
1
  import type { JSONObject } from "@llumiverse/common";
3
- import { ProjectRef } from "./project.js";
4
2
  import { PromptRole } from "@llumiverse/common";
3
+ import type { JSONSchema4 } from "json-schema";
4
+ import { ProjectRef } from "./project.js";
5
5
 
6
6
  export interface ChatPromptSchema {
7
7
  role: PromptRole.user | PromptRole.assistant;
@@ -31,6 +31,13 @@ export interface PopulatedPromptSegmentDef
31
31
  extends Omit<PromptSegmentDef, "template"> {
32
32
  template?: PromptTemplate;
33
33
  }
34
+ /**
35
+ * Used for prompt rendering at interaction execution
36
+ */
37
+ export interface ExecutablePromptSegmentDef
38
+ extends Omit<PromptSegmentDef, "template"> {
39
+ template?: ExecutablePromptTemplate;
40
+ }
34
41
 
35
42
  export interface PromptTemplateRef {
36
43
  id: string;
@@ -47,25 +54,25 @@ export interface PromptTemplateRefWithSchema extends PromptTemplateRef {
47
54
 
48
55
  export enum TemplateType {
49
56
  text = "text",
50
- js = "js",
51
57
  jst = "jst",
52
58
  }
53
-
54
- export interface PromptTemplate {
59
+ export interface ExecutablePromptTemplate {
60
+ role: PromptRole;
61
+ content: string;
62
+ content_type: TemplateType;
63
+ inputSchema?: JSONSchema4;
64
+ }
65
+ export interface PromptTemplate extends ExecutablePromptTemplate {
55
66
  id: string;
56
67
  name: string;
57
- role: PromptRole;
58
68
  status: PromptStatus;
59
69
  version: number;
60
70
  // only to be used by published versions
61
71
  // the id draft version which is the source of this published version (only when published)
62
72
  parent?: string;
63
73
  description?: string;
64
- content_type: TemplateType;
65
- content: string;
66
74
  test_data?: JSONObject; // optional test data satisfying the schema
67
75
  script?: string; // cache the template output
68
- inputSchema?: JSONSchema4;
69
76
  project: string | ProjectRef; // or projectRef? ObjectIdType;
70
77
  // The name of a field in the input data that is of the specified schema and on each the template will iterate.
71
78
  // If not specified then the schema will define the whole input data
@@ -10,6 +10,7 @@ export interface CreateCollectionPayload {
10
10
  name: string;
11
11
  dynamic: boolean;
12
12
  description?: string;
13
+ skip_head_sync?: boolean;
13
14
  tags?: string[];
14
15
  type?: string;
15
16
  query?: Record<string, any>;
@@ -18,6 +19,7 @@ export interface CreateCollectionPayload {
18
19
  table_layout?: ColumnLayout[] | null;
19
20
  allowed_types?: string[];
20
21
  updated_by?: string,
22
+ shared_properties?: string[];
21
23
  }
22
24
 
23
25
  export interface CollectionItem extends BaseObject {
@@ -30,6 +32,11 @@ export interface CollectionItem extends BaseObject {
30
32
  status: CollectionStatus;
31
33
  // A ref to the object type
32
34
  type?: ContentObjectTypeRef;
35
+ /**
36
+ * A flag to indicate whether to track and sync member HEAD revisions.
37
+ * The default is to sync HEAD revisions for collection members (skip_head_sync: false)
38
+ */
39
+ skip_head_sync: boolean;
33
40
  /**
34
41
  * The parent collections if any.
35
42
  * A collection can have multiple parents.
@@ -51,6 +58,11 @@ export interface Collection extends CollectionItem {
51
58
  properties: Record<string, any>;
52
59
  query?: Record<string, any>;
53
60
  security?: Record<string, string[]>; // ACL for collection access
61
+ /**
62
+ * List of property names from the collection's properties that should be shared with (injected into) member objects.
63
+ * These properties will be propagated to all members of this collection and merged as arrays.
64
+ */
65
+ shared_properties?: string[];
54
66
  }
55
67
 
56
68
  export interface StaticCollection extends Collection {
@@ -24,6 +24,15 @@ export interface Embedding {
24
24
  etag?: string; // the etag of the text used for the embedding
25
25
  }
26
26
 
27
+ /**
28
+ * Metadata about a single inherited property.
29
+ */
30
+ export interface InheritedPropertyMetadata {
31
+ /** The property name that was inherited */
32
+ name: string;
33
+ /** The collection ID that provided this property */
34
+ collection: string;
35
+ }
27
36
  export interface ContentObject<T = any> extends ContentObjectItem<T> {
28
37
  text?: string; // the text representation of the object
29
38
  text_etag?: string;
@@ -32,6 +41,12 @@ export interface ContentObject<T = any> extends ContentObjectItem<T> {
32
41
  parts_etag?: string; // the etag of the text used for the parts list
33
42
  transcript?: Transcript;
34
43
  security?: Record<string, string[]>; // Security field for granular permissions
44
+
45
+ /**
46
+ * Inherited properties metadata - tracks which properties were inherited from parent collections.
47
+ * Used to display readonly inherited properties in the UI and enable incremental sync optimization.
48
+ */
49
+ inherited_properties?: InheritedPropertyMetadata[];
35
50
  }
36
51
 
37
52
  export enum ContentNature {
@@ -105,7 +120,7 @@ export interface VideoMetadata extends TemporalMediaMetadata {
105
120
  export interface TextSection {
106
121
  description: string; // the description of the section
107
122
  first_line_index: number;
108
- last_line_index: number;
123
+ last_line_index: number;
109
124
  }
110
125
 
111
126
  export interface DocumentMetadata extends ContentMetadata {
@@ -355,7 +370,7 @@ export interface WorkflowRule extends WorkflowRuleItem {
355
370
  /**
356
371
  * Optional task queue name to use when starting workflows for this rule
357
372
  */
358
- task_queue?: string;
373
+ task_queue?: string;
359
374
  }
360
375
 
361
376
  export interface CreateWorkflowRulePayload extends UploadWorkflowRulePayload {
@@ -400,6 +415,10 @@ export interface GetUploadUrlPayload {
400
415
 
401
416
  export interface GetFileUrlPayload {
402
417
  file: string;
418
+ // Optional filename to use in Content-Disposition for downloads
419
+ name?: string;
420
+ // Optional disposition for downloads (default: attachment)
421
+ disposition?: "inline" | "attachment";
403
422
  }
404
423
 
405
424
  export interface GetFileUrlResponse {
@@ -412,4 +431,4 @@ export interface GetFileUrlResponse {
412
431
  export enum ContentObjectProcessingPriority {
413
432
  normal = "normal",
414
433
  low = "low",
415
- }
434
+ }
@@ -341,21 +341,27 @@ export interface ListWorkflowRunsResponse {
341
341
  export interface ListWorkflowInteractionsResponse {
342
342
  workflow_id: string,
343
343
  run_id: string,
344
- interaction: WorkflowInteraction
344
+ interaction: WorkflowInteractionVars
345
345
  }
346
346
 
347
- export interface WorkflowInteraction {
347
+ export interface WorkflowInteractionVars {
348
348
  type: string,
349
- model: string,
350
- tools: [],
351
349
  interaction: string,
352
- environment: string,
353
- data: JSONSchema4,
354
350
  interactive: boolean,
351
+ debug_mode?: boolean,
352
+ data?: Record<string, any>,
353
+ tool_names: string[],
354
+ config: {
355
+ environment: string,
356
+ model: string
357
+ },
355
358
  interactionParamsSchema?: JSONSchema4
356
- debug_mode?: boolean;
357
359
  collection_id?: string;
358
- config: Record<string, any>;
360
+ /**
361
+ * Optional version of the interaction to use when restoring conversations.
362
+ * If not specified, the latest version will be used.
363
+ */
364
+ version?: number;
359
365
  }
360
366
 
361
367
  export interface MultiDocumentsInteractionParams extends Omit<WorkflowExecutionPayload, "config"> {
@@ -438,6 +444,45 @@ export interface Plan {
438
444
 
439
445
  export const LOW_PRIORITY_TASK_QUEUE = "low_priority";
440
446
 
447
+ /**
448
+ * WebSocket message types for bidirectional communication
449
+ */
450
+ export interface WebSocketSignalMessage {
451
+ type: 'signal';
452
+ signalName: string;
453
+ data: any;
454
+ requestId?: string | number;
455
+ }
456
+
457
+ export interface WebSocketPingMessage {
458
+ type: 'ping';
459
+ }
460
+
461
+ export interface WebSocketPongMessage {
462
+ type: 'pong';
463
+ }
464
+
465
+ export interface WebSocketAckMessage {
466
+ type: 'ack';
467
+ requestId: string | number;
468
+ }
469
+
470
+ export interface WebSocketErrorMessage {
471
+ type: 'error';
472
+ requestId?: string | number;
473
+ error: string;
474
+ }
475
+
476
+ export type WebSocketClientMessage =
477
+ | WebSocketSignalMessage
478
+ | WebSocketPingMessage;
479
+
480
+ export type WebSocketServerMessage =
481
+ | WebSocketPongMessage
482
+ | WebSocketAckMessage
483
+ | WebSocketErrorMessage
484
+ | AgentMessage;
485
+
441
486
  /**
442
487
  * Payload for applying actions to a workflow run (e.g., cancel, terminate).
443
488
  */
@@ -0,0 +1,117 @@
1
+ /**
2
+ * STS Token Request Types
3
+ * These types define the structure for token requests to the Security Token Service
4
+ */
5
+
6
+ export type TokenType = 'apikey' | 'user' | 'project' | 'environment' | 'agent' | 'service_account';
7
+ export type SigningAlgorithm = 'ES256' | 'RS256';
8
+
9
+ interface BaseTokenRequest {
10
+ type: TokenType;
11
+ audience?: string;
12
+ /** Signing algorithm - defaults to ES256. Use RS256 for Azure AD compatibility. */
13
+ algorithm?: SigningAlgorithm;
14
+ }
15
+
16
+ // API key doesn't need account/project as it's determined from the key
17
+ export interface ApiKeyTokenRequest extends BaseTokenRequest {
18
+ type: 'apikey';
19
+ key: string;
20
+ }
21
+
22
+ // User token needs optional account/project for scoping
23
+ export interface UserTokenRequest extends BaseTokenRequest {
24
+ type: 'user';
25
+ user_id?: string; // Optional - can be determined from auth token
26
+ account_id?: string; // Optional - for scoping to specific account
27
+ project_id?: string; // Optional - for scoping to specific project
28
+ expires_at?: number;
29
+
30
+ on_behalf_of?: string; // Optional - user ID when acting on behalf of another user
31
+ }
32
+
33
+ // Project token requires project_id and account_id
34
+ export interface ProjectTokenRequest extends BaseTokenRequest {
35
+ type: 'project';
36
+ project_id: string;
37
+ account_id: string;
38
+ }
39
+
40
+ // Environment token requires IDs - names fetched from DB
41
+ export interface EnvironmentTokenRequest extends BaseTokenRequest {
42
+ type: 'environment';
43
+ environment_id: string;
44
+ environment_name: string; // Still required as environments may not be in DB
45
+ project_id: string; // Will fetch name and verify account
46
+ account_id: string; // Will fetch name and verify project belongs to it
47
+ }
48
+
49
+ // Agent token for service accounts acting as agents
50
+ export interface AgentTokenRequest extends BaseTokenRequest {
51
+ type: 'agent';
52
+ account_id: string;
53
+ project_id: string; // Will verify it belongs to account
54
+ name?: string;
55
+ on_behalf_of: string; // Required: signed Vertesia token to verify user context
56
+ }
57
+
58
+ // Service account token
59
+ export interface ServiceAccountTokenRequest extends BaseTokenRequest {
60
+ type: 'service_account';
61
+ account_id: string;
62
+ project_id: string; // Will verify it belongs to account
63
+ roles?: string[]; // Optional - roles for the service account token
64
+ name?: string;
65
+ }
66
+
67
+ export type IssueTokenRequest =
68
+ | ApiKeyTokenRequest
69
+ | UserTokenRequest
70
+ | ProjectTokenRequest
71
+ | EnvironmentTokenRequest
72
+ | AgentTokenRequest
73
+ | ServiceAccountTokenRequest;
74
+
75
+ export interface RefreshTokenRequest {
76
+ token: string;
77
+ }
78
+
79
+ export interface RevokeTokenRequest {
80
+ token: string;
81
+ }
82
+
83
+ // Helper type guards for type narrowing
84
+ export function isApiKeyRequest(req: IssueTokenRequest): req is ApiKeyTokenRequest {
85
+ return req.type === 'apikey';
86
+ }
87
+
88
+ export function isUserRequest(req: IssueTokenRequest): req is UserTokenRequest {
89
+ return req.type === 'user';
90
+ }
91
+
92
+ export function isProjectRequest(req: IssueTokenRequest): req is ProjectTokenRequest {
93
+ return req.type === 'project';
94
+ }
95
+
96
+ export function isEnvironmentRequest(req: IssueTokenRequest): req is EnvironmentTokenRequest {
97
+ return req.type === 'environment';
98
+ }
99
+
100
+ export function isAgentRequest(req: IssueTokenRequest): req is AgentTokenRequest {
101
+ return req.type === 'agent';
102
+ }
103
+
104
+ export function isServiceAccountRequest(req: IssueTokenRequest): req is ServiceAccountTokenRequest {
105
+ return req.type === 'service_account';
106
+ }
107
+
108
+ // Response types
109
+ export interface TokenResponse {
110
+ token: string;
111
+ }
112
+
113
+ export interface ValidateTokenResponse {
114
+ valid: boolean;
115
+ payload?: any;
116
+ error?: string;
117
+ }
@@ -1,8 +1,8 @@
1
- import { PromptRole } from "@llumiverse/common";
2
1
  import type { JSONSchema } from "@llumiverse/common";
2
+ import { PromptRole } from "@llumiverse/common";
3
3
  import type { JSONSchema4 } from "json-schema";
4
- import { InteractionRefWithSchema, PopulatedInteraction } from "../interaction.js";
5
- import { PopulatedPromptSegmentDef, PromptSegmentDef, PromptSegmentDefType, PromptTemplateRefWithSchema } from "../prompt.js";
4
+ import { InCodePrompt, InteractionRefWithSchema, PopulatedInteraction } from "../interaction.js";
5
+ import { ExecutablePromptSegmentDef, PromptSegmentDefType } from "../prompt.js";
6
6
 
7
7
 
8
8
  export function mergeJSONSchemas(schemas: JSONSchema[]) {
@@ -22,15 +22,15 @@ export function mergeJSONSchemas(schemas: JSONSchema[]) {
22
22
  return schema;
23
23
  }
24
24
 
25
- export function _mergePromptsSchema(prompts: PromptSegmentDef<PromptTemplateRefWithSchema>[] | PopulatedPromptSegmentDef[]) {
25
+ export function _mergePromptsSchema(prompts: ExecutablePromptSegmentDef[]) {
26
26
  const props: Record<string, JSONSchema4> = {};
27
- let required: string[] = [];
27
+ let required = new Set<String>();
28
28
  for (const prompt of prompts) {
29
29
  if (prompt.template?.inputSchema?.properties) {
30
30
  const schema = prompt.template?.inputSchema;
31
31
  if (schema.required) {
32
32
  for (const prop of schema.required as string[]) {
33
- if (!required.includes(prop)) required.push(prop);
33
+ required.add(prop);
34
34
  }
35
35
  }
36
36
  Object.assign(props, schema.properties);
@@ -51,13 +51,36 @@ export function _mergePromptsSchema(prompts: PromptSegmentDef<PromptTemplateRefW
51
51
  }
52
52
  }
53
53
  });
54
- required.push('chat');
54
+ required.add('chat');
55
55
  }
56
56
  }
57
- return Object.keys(props).length > 0 ? { properties: props, required } as JSONSchema4 : null;
57
+ return Object.keys(props).length > 0 ? {
58
+ properties: props,
59
+ required: Array.from(required)
60
+ } as JSONSchema4 : null;
58
61
  }
59
62
 
60
63
  export function mergePromptsSchema(interaction: InteractionRefWithSchema | PopulatedInteraction) {
61
64
  if (!interaction.prompts) return null;
62
- return _mergePromptsSchema(interaction.prompts);
65
+ return _mergePromptsSchema(interaction.prompts as ExecutablePromptSegmentDef[]);
63
66
  }
67
+
68
+ export function mergeInCodePromptSchemas(prompts: InCodePrompt[]) {
69
+ const props: Record<string, JSONSchema> = {};
70
+ let required = new Set<String>();
71
+ for (const prompt of prompts) {
72
+ if (prompt.schema?.properties) {
73
+ const schema = prompt.schema;
74
+ if (schema.required) {
75
+ for (const prop of schema.required as string[]) {
76
+ required.add(prop);
77
+ }
78
+ }
79
+ Object.assign(props, schema.properties);
80
+ }
81
+ }
82
+ return Object.keys(props).length > 0 ? {
83
+ properties: props,
84
+ required: Array.from(required)
85
+ } as JSONSchema : null;
86
+ }