@vertesia/common 0.79.0 → 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/lib/cjs/access-control.js +3 -3
- package/lib/cjs/access-control.js.map +1 -1
- package/lib/cjs/apikey.js +1 -0
- package/lib/cjs/apikey.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interaction.js +12 -2
- package/lib/cjs/interaction.js.map +1 -1
- package/lib/cjs/prompt.js +0 -1
- package/lib/cjs/prompt.js.map +1 -1
- package/lib/cjs/store/store.js +13 -1
- package/lib/cjs/store/store.js.map +1 -1
- package/lib/cjs/store/workflow.js.map +1 -1
- package/lib/cjs/sts-token-types.js.map +1 -1
- package/lib/cjs/utils/schemas.js +27 -5
- package/lib/cjs/utils/schemas.js.map +1 -1
- package/lib/esm/access-control.js +3 -3
- package/lib/esm/access-control.js.map +1 -1
- package/lib/esm/apikey.js +1 -0
- package/lib/esm/apikey.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interaction.js +11 -1
- package/lib/esm/interaction.js.map +1 -1
- package/lib/esm/prompt.js +0 -1
- package/lib/esm/prompt.js.map +1 -1
- package/lib/esm/store/store.js +12 -0
- package/lib/esm/store/store.js.map +1 -1
- package/lib/esm/store/workflow.js.map +1 -1
- package/lib/esm/sts-token-types.js.map +1 -1
- package/lib/esm/utils/schemas.js +26 -5
- package/lib/esm/utils/schemas.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/Progress.d.ts +1 -0
- package/lib/types/access-control.d.ts +4 -3
- package/lib/types/access-control.d.ts.map +1 -1
- package/lib/types/analytics.d.ts +1 -0
- package/lib/types/apikey.d.ts +7 -2
- package/lib/types/apikey.d.ts.map +1 -1
- package/lib/types/apps.d.ts +8 -0
- package/lib/types/apps.d.ts.map +1 -1
- package/lib/types/common.d.ts +1 -0
- package/lib/types/environment.d.ts +1 -0
- package/lib/types/facets.d.ts +1 -0
- package/lib/types/group.d.ts +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/integrations.d.ts +1 -0
- package/lib/types/interaction.d.ts +253 -18
- package/lib/types/interaction.d.ts.map +1 -1
- package/lib/types/json-schema.d.ts +1 -0
- package/lib/types/json.d.ts +1 -0
- package/lib/types/meters.d.ts +1 -0
- package/lib/types/model_utility.d.ts +1 -0
- package/lib/types/payload.d.ts +1 -0
- package/lib/types/project.d.ts +6 -5
- package/lib/types/project.d.ts.map +1 -1
- package/lib/types/prompt.d.ts +16 -8
- package/lib/types/prompt.d.ts.map +1 -1
- package/lib/types/query.d.ts +3 -0
- package/lib/types/query.d.ts.map +1 -1
- package/lib/types/rate-limiter.d.ts +1 -0
- package/lib/types/refs.d.ts +1 -0
- package/lib/types/runs.d.ts +1 -0
- package/lib/types/store/activity-catalog.d.ts +1 -0
- package/lib/types/store/agent.d.ts +1 -0
- package/lib/types/store/collections.d.ts +5 -2
- package/lib/types/store/collections.d.ts.map +1 -1
- package/lib/types/store/common.d.ts +1 -0
- package/lib/types/store/doc-analyzer.d.ts +1 -0
- package/lib/types/store/dsl-workflow.d.ts +1 -0
- package/lib/types/store/index.d.ts +1 -0
- package/lib/types/store/object-types.d.ts +1 -0
- package/lib/types/store/signals.d.ts +1 -0
- package/lib/types/store/store.d.ts +29 -5
- package/lib/types/store/store.d.ts.map +1 -1
- package/lib/types/store/temporalio.d.ts +1 -0
- package/lib/types/store/workflow.d.ts +65 -8
- package/lib/types/store/workflow.d.ts.map +1 -1
- package/lib/types/sts-token-types.d.ts +4 -0
- package/lib/types/sts-token-types.d.ts.map +1 -1
- package/lib/types/tenant.d.ts +1 -0
- package/lib/types/training.d.ts +1 -0
- package/lib/types/transient-tokens.d.ts +1 -0
- package/lib/types/user.d.ts +1 -0
- package/lib/types/utils/auth.d.ts +1 -0
- package/lib/types/utils/schemas.d.ts +5 -3
- package/lib/types/utils/schemas.d.ts.map +1 -1
- package/lib/types/utils/type-helpers.d.ts +1 -0
- package/lib/types/versions.d.ts +1 -0
- package/lib/vertesia-common.js +1 -1
- package/lib/vertesia-common.js.map +1 -1
- package/package.json +43 -38
- package/src/access-control.ts +5 -4
- package/src/apikey.ts +22 -21
- package/src/apps.ts +8 -0
- package/src/index.ts +1 -0
- package/src/interaction.ts +296 -18
- package/src/project.ts +7 -5
- package/src/prompt.ts +16 -9
- package/src/query.ts +2 -0
- package/src/store/collections.ts +16 -2
- package/src/store/store.ts +50 -13
- package/src/store/workflow.ts +79 -8
- package/src/sts-token-types.ts +117 -0
- package/src/utils/schemas.ts +32 -9
- package/LICENSE +0 -13
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
|
-
|
|
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
|
package/src/query.ts
CHANGED
package/src/store/collections.ts
CHANGED
|
@@ -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 {
|
|
@@ -31,9 +33,15 @@ export interface CollectionItem extends BaseObject {
|
|
|
31
33
|
// A ref to the object type
|
|
32
34
|
type?: ContentObjectTypeRef;
|
|
33
35
|
/**
|
|
34
|
-
*
|
|
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)
|
|
35
38
|
*/
|
|
36
|
-
|
|
39
|
+
skip_head_sync: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The parent collections if any.
|
|
42
|
+
* A collection can have multiple parents.
|
|
43
|
+
*/
|
|
44
|
+
parents?: string[] | null;
|
|
37
45
|
/**
|
|
38
46
|
* The table layout to use for the collection.
|
|
39
47
|
* The layout defined in the type could serve as a fallback if not defined here.
|
|
@@ -50,6 +58,11 @@ export interface Collection extends CollectionItem {
|
|
|
50
58
|
properties: Record<string, any>;
|
|
51
59
|
query?: Record<string, any>;
|
|
52
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[];
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
export interface StaticCollection extends Collection {
|
|
@@ -63,6 +76,7 @@ export interface DynamicCollection extends Collection {
|
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
export interface CollectionSearchPayload {
|
|
79
|
+
parent?: string | null;
|
|
66
80
|
dynamic?: boolean;
|
|
67
81
|
status?: CollectionStatus;
|
|
68
82
|
limit?: number;
|
package/src/store/store.ts
CHANGED
|
@@ -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,15 +41,22 @@ 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
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
export enum ContentNature {
|
|
53
|
+
Video = "video",
|
|
54
|
+
Image = "image",
|
|
55
|
+
Audio = "audio",
|
|
56
|
+
Document = "document",
|
|
57
|
+
Code = "code",
|
|
58
|
+
Other = "other"
|
|
59
|
+
}
|
|
44
60
|
|
|
45
61
|
export interface Dimensions {
|
|
46
62
|
width: number;
|
|
@@ -76,27 +92,39 @@ export interface TemporalMediaMetadata extends ContentMetadata {
|
|
|
76
92
|
}
|
|
77
93
|
|
|
78
94
|
export interface ImageMetadata extends ContentMetadata {
|
|
79
|
-
type:
|
|
95
|
+
type: ContentNature.Image;
|
|
80
96
|
dimensions?: Dimensions;
|
|
81
97
|
}
|
|
82
98
|
|
|
83
99
|
export interface AudioMetadata extends TemporalMediaMetadata {
|
|
84
|
-
type:
|
|
100
|
+
type: ContentNature.Audio;
|
|
85
101
|
}
|
|
86
102
|
|
|
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
|
+
|
|
87
113
|
export interface VideoMetadata extends TemporalMediaMetadata {
|
|
88
|
-
type:
|
|
114
|
+
type: ContentNature.Video;
|
|
89
115
|
dimensions?: Dimensions;
|
|
116
|
+
renditions?: VideoRendition[];
|
|
117
|
+
hasAudio?: boolean;
|
|
90
118
|
}
|
|
91
119
|
|
|
92
120
|
export interface TextSection {
|
|
93
121
|
description: string; // the description of the section
|
|
94
122
|
first_line_index: number;
|
|
95
|
-
last_line_index: number;
|
|
123
|
+
last_line_index: number;
|
|
96
124
|
}
|
|
97
125
|
|
|
98
126
|
export interface DocumentMetadata extends ContentMetadata {
|
|
99
|
-
type:
|
|
127
|
+
type: ContentNature.Document;
|
|
100
128
|
page_count?: number;
|
|
101
129
|
content_processor?: {
|
|
102
130
|
type?: string;
|
|
@@ -338,6 +366,11 @@ export interface WorkflowRule extends WorkflowRuleItem {
|
|
|
338
366
|
* When set to true the rule will not be updated by the system
|
|
339
367
|
*/
|
|
340
368
|
customer_override?: boolean;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Optional task queue name to use when starting workflows for this rule
|
|
372
|
+
*/
|
|
373
|
+
task_queue?: string;
|
|
341
374
|
}
|
|
342
375
|
|
|
343
376
|
export interface CreateWorkflowRulePayload extends UploadWorkflowRulePayload {
|
|
@@ -382,6 +415,10 @@ export interface GetUploadUrlPayload {
|
|
|
382
415
|
|
|
383
416
|
export interface GetFileUrlPayload {
|
|
384
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";
|
|
385
422
|
}
|
|
386
423
|
|
|
387
424
|
export interface GetFileUrlResponse {
|
|
@@ -394,4 +431,4 @@ export interface GetFileUrlResponse {
|
|
|
394
431
|
export enum ContentObjectProcessingPriority {
|
|
395
432
|
normal = "normal",
|
|
396
433
|
low = "low",
|
|
397
|
-
}
|
|
434
|
+
}
|
package/src/store/workflow.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSONSchema4 } from "json-schema";
|
|
2
|
-
import { InteractionRef } from "../interaction.js";
|
|
2
|
+
import { ConversationVisibility, InteractionRef } from "../interaction.js";
|
|
3
3
|
|
|
4
4
|
export enum ContentEventName {
|
|
5
5
|
create = "create",
|
|
@@ -202,6 +202,11 @@ export interface ListWorkflowRunsPayload {
|
|
|
202
202
|
*/
|
|
203
203
|
initiated_by?: string;
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* The interaction name used to filter conversations.
|
|
207
|
+
*/
|
|
208
|
+
interaction?: string;
|
|
209
|
+
|
|
205
210
|
/**
|
|
206
211
|
* Lucene query string to search for the workflow runs.
|
|
207
212
|
* This is a full text search on the workflow run history.
|
|
@@ -301,6 +306,16 @@ export interface WorkflowRun {
|
|
|
301
306
|
* An interaction is used to start the agent, the data is stored on temporal "vars"
|
|
302
307
|
*/
|
|
303
308
|
interactions?: InteractionRef[];
|
|
309
|
+
/**
|
|
310
|
+
* The visibility of the workflow run.
|
|
311
|
+
* - 'private': Only visible to the user who initiated the workflow
|
|
312
|
+
* - 'project': Visible to all users in the project
|
|
313
|
+
*/
|
|
314
|
+
visibility?: ConversationVisibility;
|
|
315
|
+
/**
|
|
316
|
+
* A brief summary of the conversation workflow.
|
|
317
|
+
*/
|
|
318
|
+
topic?: string;
|
|
304
319
|
}
|
|
305
320
|
|
|
306
321
|
export interface WorkflowRunWithDetails extends WorkflowRun {
|
|
@@ -326,20 +341,27 @@ export interface ListWorkflowRunsResponse {
|
|
|
326
341
|
export interface ListWorkflowInteractionsResponse {
|
|
327
342
|
workflow_id: string,
|
|
328
343
|
run_id: string,
|
|
329
|
-
interaction:
|
|
344
|
+
interaction: WorkflowInteractionVars
|
|
330
345
|
}
|
|
331
346
|
|
|
332
|
-
export interface
|
|
347
|
+
export interface WorkflowInteractionVars {
|
|
333
348
|
type: string,
|
|
334
|
-
model: string,
|
|
335
|
-
tools: [],
|
|
336
349
|
interaction: string,
|
|
337
|
-
environment: string,
|
|
338
|
-
prompt_data: JSONSchema4,
|
|
339
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
|
+
},
|
|
340
358
|
interactionParamsSchema?: JSONSchema4
|
|
341
|
-
debug_mode?: boolean;
|
|
342
359
|
collection_id?: string;
|
|
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;
|
|
343
365
|
}
|
|
344
366
|
|
|
345
367
|
export interface MultiDocumentsInteractionParams extends Omit<WorkflowExecutionPayload, "config"> {
|
|
@@ -421,3 +443,52 @@ export interface Plan {
|
|
|
421
443
|
}
|
|
422
444
|
|
|
423
445
|
export const LOW_PRIORITY_TASK_QUEUE = "low_priority";
|
|
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
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Payload for applying actions to a workflow run (e.g., cancel, terminate).
|
|
488
|
+
*/
|
|
489
|
+
export interface WorkflowActionPayload {
|
|
490
|
+
/**
|
|
491
|
+
* Optional reason for the action.
|
|
492
|
+
*/
|
|
493
|
+
reason?: string;
|
|
494
|
+
}
|
|
@@ -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
|
+
}
|
package/src/utils/schemas.ts
CHANGED
|
@@ -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 {
|
|
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:
|
|
25
|
+
export function _mergePromptsSchema(prompts: ExecutablePromptSegmentDef[]) {
|
|
26
26
|
const props: Record<string, JSONSchema4> = {};
|
|
27
|
-
let required
|
|
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
|
-
|
|
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.
|
|
54
|
+
required.add('chat');
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
return Object.keys(props).length > 0 ? {
|
|
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
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Copyright 2024 Composable
|
|
2
|
-
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
See the License for the specific language governing permissions and
|
|
13
|
-
limitations under the License.
|