@vertesia/common 0.79.1 → 0.80.0-dev.20251121
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/LICENSE +13 -0
- package/lib/cjs/project.js.map +1 -1
- package/lib/cjs/store/store.js.map +1 -1
- package/lib/esm/project.js.map +1 -1
- package/lib/esm/store/store.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/Progress.d.ts +0 -1
- package/lib/types/access-control.d.ts +0 -1
- package/lib/types/analytics.d.ts +0 -1
- package/lib/types/apikey.d.ts +0 -1
- package/lib/types/apps.d.ts +0 -1
- package/lib/types/common.d.ts +0 -1
- package/lib/types/environment.d.ts +0 -1
- package/lib/types/facets.d.ts +0 -1
- package/lib/types/group.d.ts +0 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/integrations.d.ts +0 -1
- package/lib/types/interaction.d.ts +0 -1
- package/lib/types/json-schema.d.ts +0 -1
- package/lib/types/json.d.ts +0 -1
- package/lib/types/meters.d.ts +0 -1
- package/lib/types/model_utility.d.ts +0 -1
- package/lib/types/payload.d.ts +0 -1
- package/lib/types/project.d.ts +1 -1
- package/lib/types/project.d.ts.map +1 -1
- package/lib/types/prompt.d.ts +0 -1
- package/lib/types/query.d.ts +0 -1
- package/lib/types/rate-limiter.d.ts +0 -1
- package/lib/types/refs.d.ts +0 -1
- package/lib/types/runs.d.ts +0 -1
- package/lib/types/store/activity-catalog.d.ts +0 -1
- package/lib/types/store/agent.d.ts +0 -1
- package/lib/types/store/collections.d.ts +12 -1
- package/lib/types/store/collections.d.ts.map +1 -1
- package/lib/types/store/common.d.ts +0 -1
- package/lib/types/store/doc-analyzer.d.ts +0 -1
- package/lib/types/store/dsl-workflow.d.ts +0 -1
- package/lib/types/store/index.d.ts +0 -1
- package/lib/types/store/object-types.d.ts +0 -1
- package/lib/types/store/signals.d.ts +0 -1
- package/lib/types/store/store.d.ts +14 -1
- package/lib/types/store/store.d.ts.map +1 -1
- package/lib/types/store/temporalio.d.ts +0 -1
- package/lib/types/store/workflow.d.ts +0 -1
- package/lib/types/sts-token-types.d.ts +0 -1
- package/lib/types/tenant.d.ts +0 -1
- package/lib/types/training.d.ts +0 -1
- package/lib/types/transient-tokens.d.ts +0 -1
- package/lib/types/user.d.ts +0 -1
- package/lib/types/utils/auth.d.ts +0 -1
- package/lib/types/utils/schemas.d.ts +0 -1
- package/lib/types/utils/type-helpers.d.ts +0 -1
- package/lib/types/versions.d.ts +0 -1
- package/lib/vertesia-common.js.map +1 -1
- package/package.json +43 -38
- package/src/access-control.ts +4 -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 +2 -0
- package/src/prompt.ts +16 -9
- package/src/store/collections.ts +12 -0
- package/src/store/store.ts +22 -3
- package/src/store/workflow.ts +53 -8
- package/src/sts-token-types.ts +117 -0
- package/src/utils/schemas.ts +32 -9
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/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 {
|
|
@@ -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 {
|
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,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
|
+
}
|
package/src/store/workflow.ts
CHANGED
|
@@ -341,21 +341,27 @@ export interface ListWorkflowRunsResponse {
|
|
|
341
341
|
export interface ListWorkflowInteractionsResponse {
|
|
342
342
|
workflow_id: string,
|
|
343
343
|
run_id: string,
|
|
344
|
-
interaction:
|
|
344
|
+
interaction: WorkflowInteractionVars
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
export interface
|
|
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
|
-
|
|
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
|
+
}
|
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
|
+
}
|