@api-client/core 0.19.0 → 0.19.2
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/build/src/decorators/observed.d.ts.map +1 -1
- package/build/src/decorators/observed.js +49 -8
- package/build/src/decorators/observed.js.map +1 -1
- package/build/src/mocking/ModelingMock.d.ts +2 -0
- package/build/src/mocking/ModelingMock.d.ts.map +1 -1
- package/build/src/mocking/ModelingMock.js +2 -0
- package/build/src/mocking/ModelingMock.js.map +1 -1
- package/build/src/mocking/lib/Ai.d.ts +11 -0
- package/build/src/mocking/lib/Ai.d.ts.map +1 -0
- package/build/src/mocking/lib/Ai.js +53 -0
- package/build/src/mocking/lib/Ai.js.map +1 -0
- package/build/src/modeling/ai/DataDomainDelta.d.ts +146 -0
- package/build/src/modeling/ai/DataDomainDelta.d.ts.map +1 -0
- package/build/src/modeling/ai/DataDomainDelta.js +729 -0
- package/build/src/modeling/ai/DataDomainDelta.js.map +1 -0
- package/build/src/modeling/ai/DomainSerialization.d.ts +20 -0
- package/build/src/modeling/ai/DomainSerialization.d.ts.map +1 -0
- package/build/src/modeling/ai/DomainSerialization.js +185 -0
- package/build/src/modeling/ai/DomainSerialization.js.map +1 -0
- package/build/src/modeling/ai/domain_response_schema.d.ts +806 -0
- package/build/src/modeling/ai/domain_response_schema.d.ts.map +1 -0
- package/build/src/modeling/ai/domain_response_schema.js +289 -0
- package/build/src/modeling/ai/domain_response_schema.js.map +1 -0
- package/build/src/modeling/ai/domain_tools.d.ts +68 -0
- package/build/src/modeling/ai/domain_tools.d.ts.map +1 -0
- package/build/src/modeling/ai/domain_tools.js +71 -0
- package/build/src/modeling/ai/domain_tools.js.map +1 -0
- package/build/src/modeling/ai/index.d.ts +10 -0
- package/build/src/modeling/ai/index.d.ts.map +1 -0
- package/build/src/modeling/ai/index.js +9 -0
- package/build/src/modeling/ai/index.js.map +1 -0
- package/build/src/modeling/ai/message_parser.d.ts +23 -0
- package/build/src/modeling/ai/message_parser.d.ts.map +1 -0
- package/build/src/modeling/ai/message_parser.js +93 -0
- package/build/src/modeling/ai/message_parser.js.map +1 -0
- package/build/src/modeling/ai/prompts/domain_system.d.ts +6 -0
- package/build/src/modeling/ai/prompts/domain_system.d.ts.map +1 -0
- package/build/src/modeling/ai/prompts/domain_system.js +80 -0
- package/build/src/modeling/ai/prompts/domain_system.js.map +1 -0
- package/build/src/modeling/ai/tools/DataDomain.tools.d.ts +25 -0
- package/build/src/modeling/ai/tools/DataDomain.tools.d.ts.map +1 -0
- package/build/src/modeling/ai/tools/DataDomain.tools.js +334 -0
- package/build/src/modeling/ai/tools/DataDomain.tools.js.map +1 -0
- package/build/src/modeling/ai/tools/Semantic.tools.d.ts +48 -0
- package/build/src/modeling/ai/tools/Semantic.tools.d.ts.map +1 -0
- package/build/src/modeling/ai/tools/Semantic.tools.js +36 -0
- package/build/src/modeling/ai/tools/Semantic.tools.js.map +1 -0
- package/build/src/modeling/ai/tools/config.d.ts +13 -0
- package/build/src/modeling/ai/tools/config.d.ts.map +1 -0
- package/build/src/modeling/ai/tools/config.js +2 -0
- package/build/src/modeling/ai/tools/config.js.map +1 -0
- package/build/src/modeling/ai/types.d.ts +302 -0
- package/build/src/modeling/ai/types.d.ts.map +1 -0
- package/build/src/modeling/ai/types.js +40 -0
- package/build/src/modeling/ai/types.js.map +1 -0
- package/build/src/models/AiMessage.d.ts +185 -0
- package/build/src/models/AiMessage.d.ts.map +1 -0
- package/build/src/models/AiMessage.js +203 -0
- package/build/src/models/AiMessage.js.map +1 -0
- package/build/src/models/AiSession.d.ts +80 -0
- package/build/src/models/AiSession.d.ts.map +1 -0
- package/build/src/models/AiSession.js +102 -0
- package/build/src/models/AiSession.js.map +1 -0
- package/build/src/models/kinds.d.ts +2 -0
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +2 -0
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/sdk/AiSdk.d.ts +93 -0
- package/build/src/sdk/AiSdk.d.ts.map +1 -0
- package/build/src/sdk/AiSdk.js +348 -0
- package/build/src/sdk/AiSdk.js.map +1 -0
- package/build/src/sdk/RouteBuilder.d.ts +7 -0
- package/build/src/sdk/RouteBuilder.d.ts.map +1 -1
- package/build/src/sdk/RouteBuilder.js +18 -0
- package/build/src/sdk/RouteBuilder.js.map +1 -1
- package/build/src/sdk/Sdk.d.ts +2 -0
- package/build/src/sdk/Sdk.d.ts.map +1 -1
- package/build/src/sdk/Sdk.js +2 -0
- package/build/src/sdk/Sdk.js.map +1 -1
- package/build/src/sdk/SdkBase.d.ts +4 -0
- package/build/src/sdk/SdkBase.d.ts.map +1 -1
- package/build/src/sdk/SdkBase.js.map +1 -1
- package/build/src/sdk/SdkMock.d.ts +15 -0
- package/build/src/sdk/SdkMock.d.ts.map +1 -1
- package/build/src/sdk/SdkMock.js +118 -0
- package/build/src/sdk/SdkMock.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/decorators/observed.ts +51 -9
- package/src/mocking/ModelingMock.ts +2 -0
- package/src/mocking/lib/Ai.ts +71 -0
- package/src/modeling/ai/DataDomainDelta.ts +798 -0
- package/src/modeling/ai/DomainSerialization.ts +199 -0
- package/src/modeling/ai/domain_response_schema.ts +301 -0
- package/src/modeling/ai/domain_tools.ts +76 -0
- package/src/modeling/ai/message_parser.ts +101 -0
- package/src/modeling/ai/prompts/domain_system.ts +79 -0
- package/src/modeling/ai/readme.md +8 -0
- package/src/modeling/ai/tools/DataDomain.tools.ts +365 -0
- package/src/modeling/ai/tools/Semantic.tools.ts +38 -0
- package/src/modeling/ai/tools/config.ts +13 -0
- package/src/modeling/ai/tools/readme.md +3 -0
- package/src/modeling/ai/types.ts +306 -0
- package/src/models/AiMessage.ts +335 -0
- package/src/models/AiSession.ts +160 -0
- package/src/models/kinds.ts +2 -0
- package/src/sdk/AiSdk.ts +395 -0
- package/src/sdk/RouteBuilder.ts +27 -0
- package/src/sdk/Sdk.ts +3 -0
- package/src/sdk/SdkBase.ts +4 -0
- package/src/sdk/SdkMock.ts +185 -0
- package/tests/unit/decorators/observed_recursive.spec.ts +39 -0
- package/tests/unit/mocking/current/Ai.spec.ts +109 -0
- package/tests/unit/modeling/ai/DataDomainDelta.spec.ts +419 -0
- package/tests/unit/modeling/ai/DomainAiTools.spec.ts +29 -0
- package/tests/unit/modeling/ai/DomainSerialization.spec.ts +143 -0
- package/tests/unit/modeling/ai/message_parser.spec.ts +157 -0
- package/tests/unit/modeling/ai/tools/DataDomain.tools.spec.ts +64 -0
- package/tests/unit/modeling/ai/tools/Semantic.tools.spec.ts +55 -0
- package/tests/unit/models/AiMessage.spec.ts +216 -0
- package/tests/unit/models/AiSession.spec.ts +147 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain_response_schema.d.ts","sourceRoot":"","sources":["../../../../src/modeling/ai/domain_response_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AA0MjC;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+FzB,CAAA"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { Type } from './types.js';
|
|
2
|
+
const SemanticSchema = {
|
|
3
|
+
type: Type.OBJECT,
|
|
4
|
+
properties: {
|
|
5
|
+
id: { type: Type.STRING },
|
|
6
|
+
config: { type: Type.OBJECT },
|
|
7
|
+
},
|
|
8
|
+
required: ['id'],
|
|
9
|
+
};
|
|
10
|
+
const SchemaDefaultValue = {
|
|
11
|
+
type: Type.OBJECT,
|
|
12
|
+
properties: {
|
|
13
|
+
type: {
|
|
14
|
+
type: Type.STRING,
|
|
15
|
+
description: 'Enum: literal, function',
|
|
16
|
+
},
|
|
17
|
+
value: {
|
|
18
|
+
type: Type.STRING,
|
|
19
|
+
description: 'The default value of the property',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
required: ['type'],
|
|
23
|
+
};
|
|
24
|
+
const PropertySchemaShape = {
|
|
25
|
+
type: Type.OBJECT,
|
|
26
|
+
properties: {
|
|
27
|
+
minimum: { type: Type.NUMBER },
|
|
28
|
+
maximum: { type: Type.NUMBER },
|
|
29
|
+
exclusiveMinimum: { type: Type.BOOLEAN },
|
|
30
|
+
exclusiveMaximum: { type: Type.BOOLEAN },
|
|
31
|
+
multipleOf: { type: Type.NUMBER },
|
|
32
|
+
enum: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
33
|
+
examples: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
34
|
+
defaultValue: SchemaDefaultValue,
|
|
35
|
+
pattern: { type: Type.STRING },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const PropertyConstraintsSchema = {
|
|
39
|
+
type: Type.OBJECT,
|
|
40
|
+
properties: {
|
|
41
|
+
required: { type: Type.BOOLEAN },
|
|
42
|
+
unique: { type: Type.BOOLEAN },
|
|
43
|
+
index: { type: Type.BOOLEAN },
|
|
44
|
+
primary: { type: Type.BOOLEAN },
|
|
45
|
+
multiple: { type: Type.BOOLEAN },
|
|
46
|
+
readOnly: { type: Type.BOOLEAN },
|
|
47
|
+
writeOnly: { type: Type.BOOLEAN },
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Must comply with the `AiDomainProperty` type.
|
|
52
|
+
*/
|
|
53
|
+
const PropertySchema = {
|
|
54
|
+
type: Type.OBJECT,
|
|
55
|
+
properties: {
|
|
56
|
+
key: { type: Type.STRING },
|
|
57
|
+
name: { type: Type.STRING },
|
|
58
|
+
displayName: { type: Type.STRING },
|
|
59
|
+
description: { type: Type.STRING },
|
|
60
|
+
type: {
|
|
61
|
+
type: Type.STRING,
|
|
62
|
+
description: 'Enum: string, number, boolean, date, datetime, time, binary',
|
|
63
|
+
},
|
|
64
|
+
constraints: PropertyConstraintsSchema,
|
|
65
|
+
deprecated: { type: Type.BOOLEAN },
|
|
66
|
+
schema: PropertySchemaShape,
|
|
67
|
+
semantics: {
|
|
68
|
+
type: Type.ARRAY,
|
|
69
|
+
items: SemanticSchema,
|
|
70
|
+
description: "List of semantics applied to this property. Note: ONLY use semantics with scope='property'.",
|
|
71
|
+
},
|
|
72
|
+
tags: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
73
|
+
},
|
|
74
|
+
required: ['key', 'name', 'type', 'displayName', 'description'],
|
|
75
|
+
};
|
|
76
|
+
const AssociationSchemaShape = {
|
|
77
|
+
type: Type.OBJECT,
|
|
78
|
+
properties: {
|
|
79
|
+
linked: { type: Type.BOOLEAN },
|
|
80
|
+
unionType: { type: Type.STRING, description: 'Enum: allOf, anyOf, oneOf, not' },
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Must comply with the `AiDomainAssociation` type.
|
|
85
|
+
*/
|
|
86
|
+
const AssociationSchema = {
|
|
87
|
+
type: Type.OBJECT,
|
|
88
|
+
properties: {
|
|
89
|
+
key: { type: Type.STRING },
|
|
90
|
+
name: { type: Type.STRING },
|
|
91
|
+
displayName: { type: Type.STRING },
|
|
92
|
+
description: { type: Type.STRING },
|
|
93
|
+
targets: { type: Type.ARRAY, items: { type: Type.STRING }, description: 'List of target entity keys' },
|
|
94
|
+
required: { type: Type.BOOLEAN },
|
|
95
|
+
multiple: {
|
|
96
|
+
type: Type.BOOLEAN,
|
|
97
|
+
description: 'Whether the association can have multiple targets (like User has multiple addresses)',
|
|
98
|
+
},
|
|
99
|
+
onDelete: { type: Type.STRING, description: 'Enum: restrict, cascade, setNull, doNothing' },
|
|
100
|
+
semantics: {
|
|
101
|
+
type: Type.ARRAY,
|
|
102
|
+
items: SemanticSchema,
|
|
103
|
+
description: "List of semantics applied to this association. Note: ONLY use semantics with scope='association'.",
|
|
104
|
+
},
|
|
105
|
+
schema: AssociationSchemaShape,
|
|
106
|
+
},
|
|
107
|
+
required: ['key', 'name', 'targets', 'displayName', 'description'],
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Must comply with the `AiDataModel` type.
|
|
111
|
+
*/
|
|
112
|
+
const ModelSchema = {
|
|
113
|
+
type: Type.OBJECT,
|
|
114
|
+
properties: {
|
|
115
|
+
key: { type: Type.STRING },
|
|
116
|
+
name: { type: Type.STRING },
|
|
117
|
+
description: { type: Type.STRING },
|
|
118
|
+
},
|
|
119
|
+
required: ['key', 'name'],
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Must comply with the `AiDomainEntityResponseSchema` type.
|
|
123
|
+
*/
|
|
124
|
+
const EntitySchema = {
|
|
125
|
+
type: Type.OBJECT,
|
|
126
|
+
properties: {
|
|
127
|
+
key: { type: Type.STRING },
|
|
128
|
+
modelKey: { type: Type.STRING, description: 'The Domain Model this entity belongs to (e.g. "users", "shipping")' },
|
|
129
|
+
name: { type: Type.STRING },
|
|
130
|
+
displayName: { type: Type.STRING },
|
|
131
|
+
description: { type: Type.STRING },
|
|
132
|
+
tags: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
133
|
+
semantics: {
|
|
134
|
+
type: Type.ARRAY,
|
|
135
|
+
items: SemanticSchema,
|
|
136
|
+
description: "List of semantics applied to this entity. Note: ONLY use semantics with scope='entity'.",
|
|
137
|
+
},
|
|
138
|
+
properties: { type: Type.ARRAY, items: PropertySchema },
|
|
139
|
+
associations: { type: Type.ARRAY, items: AssociationSchema },
|
|
140
|
+
},
|
|
141
|
+
required: ['key', 'name', 'modelKey', 'displayName', 'description'],
|
|
142
|
+
};
|
|
143
|
+
const PropertyDeltaSchema = {
|
|
144
|
+
type: Type.OBJECT,
|
|
145
|
+
properties: {
|
|
146
|
+
key: { type: Type.STRING },
|
|
147
|
+
name: { type: Type.STRING },
|
|
148
|
+
displayName: { type: Type.STRING },
|
|
149
|
+
description: { type: Type.STRING },
|
|
150
|
+
type: {
|
|
151
|
+
type: Type.STRING,
|
|
152
|
+
description: 'Enum: string, number, boolean, date, datetime, time, binary',
|
|
153
|
+
},
|
|
154
|
+
constraints: PropertyConstraintsSchema,
|
|
155
|
+
deprecated: { type: Type.BOOLEAN },
|
|
156
|
+
schema: PropertySchemaShape,
|
|
157
|
+
addedSemantics: {
|
|
158
|
+
type: Type.ARRAY,
|
|
159
|
+
items: SemanticSchema,
|
|
160
|
+
description: "Semantics to add. Note: ONLY use semantics with scope='property'.",
|
|
161
|
+
},
|
|
162
|
+
modifiedSemantics: { type: Type.ARRAY, items: SemanticSchema },
|
|
163
|
+
deletedSemanticIds: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
164
|
+
},
|
|
165
|
+
required: ['key'],
|
|
166
|
+
};
|
|
167
|
+
const AssociationDeltaSchema = {
|
|
168
|
+
type: Type.OBJECT,
|
|
169
|
+
properties: {
|
|
170
|
+
key: { type: Type.STRING },
|
|
171
|
+
name: { type: Type.STRING },
|
|
172
|
+
displayName: { type: Type.STRING },
|
|
173
|
+
description: { type: Type.STRING },
|
|
174
|
+
targets: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
175
|
+
required: { type: Type.BOOLEAN },
|
|
176
|
+
multiple: {
|
|
177
|
+
type: Type.BOOLEAN,
|
|
178
|
+
description: 'Whether the association can have multiple targets (like User has multiple addresses)',
|
|
179
|
+
},
|
|
180
|
+
onDelete: { type: Type.STRING, description: 'Enum: restrict, cascade, setNull, doNothing' },
|
|
181
|
+
addedSemantics: {
|
|
182
|
+
type: Type.ARRAY,
|
|
183
|
+
items: SemanticSchema,
|
|
184
|
+
description: "Semantics to add. Note: ONLY use semantics with scope='association'.",
|
|
185
|
+
},
|
|
186
|
+
modifiedSemantics: { type: Type.ARRAY, items: SemanticSchema },
|
|
187
|
+
deletedSemanticIds: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
188
|
+
},
|
|
189
|
+
required: ['key'],
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Must comply with the `AiDomainDeltaResponse` type.
|
|
193
|
+
*/
|
|
194
|
+
export const DOMAIN_SCHEMA = {
|
|
195
|
+
type: Type.OBJECT,
|
|
196
|
+
properties: {
|
|
197
|
+
sessionTitle: {
|
|
198
|
+
type: Type.STRING,
|
|
199
|
+
description: 'A short, 3-to-5 word descriptive title for this data modeling session.',
|
|
200
|
+
},
|
|
201
|
+
reasoning: {
|
|
202
|
+
type: Type.STRING,
|
|
203
|
+
description: 'Conversational response analyzing the request or explaining changes, in markdown format',
|
|
204
|
+
},
|
|
205
|
+
delta: {
|
|
206
|
+
type: Type.OBJECT,
|
|
207
|
+
properties: {
|
|
208
|
+
addedModels: {
|
|
209
|
+
type: Type.ARRAY,
|
|
210
|
+
items: ModelSchema,
|
|
211
|
+
description: 'Brand new models to create',
|
|
212
|
+
},
|
|
213
|
+
deletedModelKeys: {
|
|
214
|
+
type: Type.ARRAY,
|
|
215
|
+
items: { type: Type.STRING },
|
|
216
|
+
description: 'Keys of completely removed models. This also removes all entities and associations in the model.',
|
|
217
|
+
},
|
|
218
|
+
modifiedModels: {
|
|
219
|
+
type: Type.ARRAY,
|
|
220
|
+
items: ModelSchema,
|
|
221
|
+
description: 'Models to modify in the domain',
|
|
222
|
+
},
|
|
223
|
+
addedEntities: {
|
|
224
|
+
type: Type.ARRAY,
|
|
225
|
+
items: EntitySchema,
|
|
226
|
+
description: 'Brand new entities to create',
|
|
227
|
+
},
|
|
228
|
+
deletedEntityKeys: {
|
|
229
|
+
type: Type.ARRAY,
|
|
230
|
+
items: { type: Type.STRING },
|
|
231
|
+
description: 'Keys of completely removed entities',
|
|
232
|
+
},
|
|
233
|
+
modifiedEntities: {
|
|
234
|
+
type: Type.ARRAY,
|
|
235
|
+
items: {
|
|
236
|
+
type: Type.OBJECT,
|
|
237
|
+
properties: {
|
|
238
|
+
key: { type: Type.STRING, description: 'The original key of the existing entity being modified' },
|
|
239
|
+
modelKey: {
|
|
240
|
+
type: Type.STRING,
|
|
241
|
+
description: 'Change this to migrate the entity to a different model (boundary)',
|
|
242
|
+
},
|
|
243
|
+
name: { type: Type.STRING },
|
|
244
|
+
displayName: { type: Type.STRING },
|
|
245
|
+
description: { type: Type.STRING },
|
|
246
|
+
tags: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
247
|
+
addedSemantics: {
|
|
248
|
+
type: Type.ARRAY,
|
|
249
|
+
items: SemanticSchema,
|
|
250
|
+
description: "Semantics to add. Note: ONLY use semantics with scope='entity'.",
|
|
251
|
+
},
|
|
252
|
+
modifiedSemantics: { type: Type.ARRAY, items: SemanticSchema },
|
|
253
|
+
deletedSemanticIds: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
254
|
+
addedProperties: { type: Type.ARRAY, items: PropertySchema },
|
|
255
|
+
modifiedProperties: { type: Type.ARRAY, items: PropertyDeltaSchema },
|
|
256
|
+
deletedPropertyKeys: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
257
|
+
addedAssociations: { type: Type.ARRAY, items: AssociationSchema },
|
|
258
|
+
modifiedAssociations: { type: Type.ARRAY, items: AssociationDeltaSchema },
|
|
259
|
+
deletedAssociationKeys: { type: Type.ARRAY, items: { type: Type.STRING } },
|
|
260
|
+
},
|
|
261
|
+
required: [
|
|
262
|
+
'key',
|
|
263
|
+
// 'addedSemantics',
|
|
264
|
+
// 'modifiedSemantics',
|
|
265
|
+
// 'deletedSemanticIds',
|
|
266
|
+
// 'addedProperties',
|
|
267
|
+
// 'modifiedProperties',
|
|
268
|
+
// 'deletedPropertyKeys',
|
|
269
|
+
// 'addedAssociations',
|
|
270
|
+
// 'modifiedAssociations',
|
|
271
|
+
// 'deletedAssociationKeys',
|
|
272
|
+
],
|
|
273
|
+
},
|
|
274
|
+
description: 'Modifications to existing entities like adding, removing, or changing properties/associations',
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
required: [
|
|
278
|
+
'addedModels',
|
|
279
|
+
'deletedModelKeys',
|
|
280
|
+
'modifiedModels',
|
|
281
|
+
'addedEntities',
|
|
282
|
+
'deletedEntityKeys',
|
|
283
|
+
'modifiedEntities',
|
|
284
|
+
],
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
required: ['reasoning', 'delta'],
|
|
288
|
+
};
|
|
289
|
+
//# sourceMappingURL=domain_response_schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain_response_schema.js","sourceRoot":"","sources":["../../../../src/modeling/ai/domain_response_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,MAAM,cAAc,GAAG;IACrB,IAA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aAAa;gBACb,kBAAkB;gBAClB,gBAAgB;gBAChB,eAAe;gBACf,mBAAmB;gBACnB,kBAAkB;aACnB;SACF;KACF;IACD,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC;CACjC,CAAA","sourcesContent":["import { Type } from './types.js'\n\nconst SemanticSchema = {\n type: Type.OBJECT,\n properties: {\n id: { type: Type.STRING },\n config: { type: Type.OBJECT },\n },\n required: ['id'],\n}\n\nconst SchemaDefaultValue = {\n type: Type.OBJECT,\n properties: {\n type: {\n type: Type.STRING,\n description: 'Enum: literal, function',\n },\n value: {\n type: Type.STRING,\n description: 'The default value of the property',\n },\n },\n required: ['type'],\n}\n\nconst PropertySchemaShape = {\n type: Type.OBJECT,\n properties: {\n minimum: { type: Type.NUMBER },\n maximum: { type: Type.NUMBER },\n exclusiveMinimum: { type: Type.BOOLEAN },\n exclusiveMaximum: { type: Type.BOOLEAN },\n multipleOf: { type: Type.NUMBER },\n enum: { type: Type.ARRAY, items: { type: Type.STRING } },\n examples: { type: Type.ARRAY, items: { type: Type.STRING } },\n defaultValue: SchemaDefaultValue,\n pattern: { type: Type.STRING },\n },\n}\n\nconst PropertyConstraintsSchema = {\n type: Type.OBJECT,\n properties: {\n required: { type: Type.BOOLEAN },\n unique: { type: Type.BOOLEAN },\n index: { type: Type.BOOLEAN },\n primary: { type: Type.BOOLEAN },\n multiple: { type: Type.BOOLEAN },\n readOnly: { type: Type.BOOLEAN },\n writeOnly: { type: Type.BOOLEAN },\n },\n}\n\n/**\n * Must comply with the `AiDomainProperty` type.\n */\nconst PropertySchema = {\n type: Type.OBJECT,\n properties: {\n key: { type: Type.STRING },\n name: { type: Type.STRING },\n displayName: { type: Type.STRING },\n description: { type: Type.STRING },\n type: {\n type: Type.STRING,\n description: 'Enum: string, number, boolean, date, datetime, time, binary',\n },\n constraints: PropertyConstraintsSchema,\n deprecated: { type: Type.BOOLEAN },\n schema: PropertySchemaShape,\n semantics: {\n type: Type.ARRAY,\n items: SemanticSchema,\n description: \"List of semantics applied to this property. Note: ONLY use semantics with scope='property'.\",\n },\n tags: { type: Type.ARRAY, items: { type: Type.STRING } },\n },\n required: ['key', 'name', 'type', 'displayName', 'description'],\n}\n\nconst AssociationSchemaShape = {\n type: Type.OBJECT,\n properties: {\n linked: { type: Type.BOOLEAN },\n unionType: { type: Type.STRING, description: 'Enum: allOf, anyOf, oneOf, not' },\n },\n}\n\n/**\n * Must comply with the `AiDomainAssociation` type.\n */\nconst AssociationSchema = {\n type: Type.OBJECT,\n properties: {\n key: { type: Type.STRING },\n name: { type: Type.STRING },\n displayName: { type: Type.STRING },\n description: { type: Type.STRING },\n targets: { type: Type.ARRAY, items: { type: Type.STRING }, description: 'List of target entity keys' },\n required: { type: Type.BOOLEAN },\n multiple: {\n type: Type.BOOLEAN,\n description: 'Whether the association can have multiple targets (like User has multiple addresses)',\n },\n onDelete: { type: Type.STRING, description: 'Enum: restrict, cascade, setNull, doNothing' },\n semantics: {\n type: Type.ARRAY,\n items: SemanticSchema,\n description: \"List of semantics applied to this association. Note: ONLY use semantics with scope='association'.\",\n },\n schema: AssociationSchemaShape,\n },\n required: ['key', 'name', 'targets', 'displayName', 'description'],\n}\n\n/**\n * Must comply with the `AiDataModel` type.\n */\nconst ModelSchema = {\n type: Type.OBJECT,\n properties: {\n key: { type: Type.STRING },\n name: { type: Type.STRING },\n description: { type: Type.STRING },\n },\n required: ['key', 'name'],\n}\n\n/**\n * Must comply with the `AiDomainEntityResponseSchema` type.\n */\nconst EntitySchema = {\n type: Type.OBJECT,\n properties: {\n key: { type: Type.STRING },\n modelKey: { type: Type.STRING, description: 'The Domain Model this entity belongs to (e.g. \"users\", \"shipping\")' },\n name: { type: Type.STRING },\n displayName: { type: Type.STRING },\n description: { type: Type.STRING },\n tags: { type: Type.ARRAY, items: { type: Type.STRING } },\n semantics: {\n type: Type.ARRAY,\n items: SemanticSchema,\n description: \"List of semantics applied to this entity. Note: ONLY use semantics with scope='entity'.\",\n },\n properties: { type: Type.ARRAY, items: PropertySchema },\n associations: { type: Type.ARRAY, items: AssociationSchema },\n },\n required: ['key', 'name', 'modelKey', 'displayName', 'description'],\n}\n\nconst PropertyDeltaSchema = {\n type: Type.OBJECT,\n properties: {\n key: { type: Type.STRING },\n name: { type: Type.STRING },\n displayName: { type: Type.STRING },\n description: { type: Type.STRING },\n type: {\n type: Type.STRING,\n description: 'Enum: string, number, boolean, date, datetime, time, binary',\n },\n constraints: PropertyConstraintsSchema,\n deprecated: { type: Type.BOOLEAN },\n schema: PropertySchemaShape,\n addedSemantics: {\n type: Type.ARRAY,\n items: SemanticSchema,\n description: \"Semantics to add. Note: ONLY use semantics with scope='property'.\",\n },\n modifiedSemantics: { type: Type.ARRAY, items: SemanticSchema },\n deletedSemanticIds: { type: Type.ARRAY, items: { type: Type.STRING } },\n },\n required: ['key'],\n}\n\nconst AssociationDeltaSchema = {\n type: Type.OBJECT,\n properties: {\n key: { type: Type.STRING },\n name: { type: Type.STRING },\n displayName: { type: Type.STRING },\n description: { type: Type.STRING },\n targets: { type: Type.ARRAY, items: { type: Type.STRING } },\n required: { type: Type.BOOLEAN },\n multiple: {\n type: Type.BOOLEAN,\n description: 'Whether the association can have multiple targets (like User has multiple addresses)',\n },\n onDelete: { type: Type.STRING, description: 'Enum: restrict, cascade, setNull, doNothing' },\n addedSemantics: {\n type: Type.ARRAY,\n items: SemanticSchema,\n description: \"Semantics to add. Note: ONLY use semantics with scope='association'.\",\n },\n modifiedSemantics: { type: Type.ARRAY, items: SemanticSchema },\n deletedSemanticIds: { type: Type.ARRAY, items: { type: Type.STRING } },\n },\n required: ['key'],\n}\n\n/**\n * Must comply with the `AiDomainDeltaResponse` type.\n */\nexport const DOMAIN_SCHEMA = {\n type: Type.OBJECT,\n properties: {\n sessionTitle: {\n type: Type.STRING,\n description: 'A short, 3-to-5 word descriptive title for this data modeling session.',\n },\n reasoning: {\n type: Type.STRING,\n description: 'Conversational response analyzing the request or explaining changes, in markdown format',\n },\n delta: {\n type: Type.OBJECT,\n properties: {\n addedModels: {\n type: Type.ARRAY,\n items: ModelSchema,\n description: 'Brand new models to create',\n },\n deletedModelKeys: {\n type: Type.ARRAY,\n items: { type: Type.STRING },\n description:\n 'Keys of completely removed models. This also removes all entities and associations in the model.',\n },\n modifiedModels: {\n type: Type.ARRAY,\n items: ModelSchema,\n description: 'Models to modify in the domain',\n },\n addedEntities: {\n type: Type.ARRAY,\n items: EntitySchema,\n description: 'Brand new entities to create',\n },\n deletedEntityKeys: {\n type: Type.ARRAY,\n items: { type: Type.STRING },\n description: 'Keys of completely removed entities',\n },\n modifiedEntities: {\n type: Type.ARRAY,\n items: {\n type: Type.OBJECT,\n properties: {\n key: { type: Type.STRING, description: 'The original key of the existing entity being modified' },\n modelKey: {\n type: Type.STRING,\n description: 'Change this to migrate the entity to a different model (boundary)',\n },\n name: { type: Type.STRING },\n displayName: { type: Type.STRING },\n description: { type: Type.STRING },\n tags: { type: Type.ARRAY, items: { type: Type.STRING } },\n addedSemantics: {\n type: Type.ARRAY,\n items: SemanticSchema,\n description: \"Semantics to add. Note: ONLY use semantics with scope='entity'.\",\n },\n modifiedSemantics: { type: Type.ARRAY, items: SemanticSchema },\n deletedSemanticIds: { type: Type.ARRAY, items: { type: Type.STRING } },\n addedProperties: { type: Type.ARRAY, items: PropertySchema },\n modifiedProperties: { type: Type.ARRAY, items: PropertyDeltaSchema },\n deletedPropertyKeys: { type: Type.ARRAY, items: { type: Type.STRING } },\n addedAssociations: { type: Type.ARRAY, items: AssociationSchema },\n modifiedAssociations: { type: Type.ARRAY, items: AssociationDeltaSchema },\n deletedAssociationKeys: { type: Type.ARRAY, items: { type: Type.STRING } },\n },\n required: [\n 'key',\n // 'addedSemantics',\n // 'modifiedSemantics',\n // 'deletedSemanticIds',\n // 'addedProperties',\n // 'modifiedProperties',\n // 'deletedPropertyKeys',\n // 'addedAssociations',\n // 'modifiedAssociations',\n // 'deletedAssociationKeys',\n ],\n },\n description: 'Modifications to existing entities like adding, removing, or changing properties/associations',\n },\n },\n required: [\n 'addedModels',\n 'deletedModelKeys',\n 'modifiedModels',\n 'addedEntities',\n 'deletedEntityKeys',\n 'modifiedEntities',\n ],\n },\n },\n required: ['reasoning', 'delta'],\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Type } from './types.js';
|
|
2
|
+
import { ToolConfig } from './tools/config.js';
|
|
3
|
+
/**
|
|
4
|
+
* All tools available for the AI to use when modeling a domain.
|
|
5
|
+
*/
|
|
6
|
+
export declare const tools: {
|
|
7
|
+
functionDeclarations: ({
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
parametersJsonSchema: {
|
|
11
|
+
type: Type;
|
|
12
|
+
properties: {
|
|
13
|
+
semanticId?: undefined;
|
|
14
|
+
entityKey?: undefined;
|
|
15
|
+
dataType?: undefined;
|
|
16
|
+
};
|
|
17
|
+
required: never[];
|
|
18
|
+
};
|
|
19
|
+
} | {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
parametersJsonSchema: {
|
|
23
|
+
type: Type;
|
|
24
|
+
properties: {
|
|
25
|
+
semanticId: {
|
|
26
|
+
type: Type;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
entityKey?: undefined;
|
|
30
|
+
dataType?: undefined;
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
};
|
|
34
|
+
} | {
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
parametersJsonSchema: {
|
|
38
|
+
type: Type;
|
|
39
|
+
properties: {
|
|
40
|
+
entityKey: {
|
|
41
|
+
type: Type;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
semanticId?: undefined;
|
|
45
|
+
dataType?: undefined;
|
|
46
|
+
};
|
|
47
|
+
required: string[];
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
parametersJsonSchema: {
|
|
53
|
+
type: Type;
|
|
54
|
+
properties: {
|
|
55
|
+
dataType: {
|
|
56
|
+
type: Type;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
semanticId?: undefined;
|
|
60
|
+
entityKey?: undefined;
|
|
61
|
+
};
|
|
62
|
+
required: string[];
|
|
63
|
+
};
|
|
64
|
+
})[];
|
|
65
|
+
}[];
|
|
66
|
+
export type ToolFunction = (config: ToolConfig, args: Record<string, unknown>) => unknown | Promise<unknown>;
|
|
67
|
+
export declare const functions: Record<string, ToolFunction>;
|
|
68
|
+
//# sourceMappingURL=domain_tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain_tools.d.ts","sourceRoot":"","sources":["../../../../src/modeling/ai/domain_tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAE5G,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAKlD,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Type } from './types.js';
|
|
2
|
+
import { get_semantic_details, list_semantics } from './tools/Semantic.tools.js';
|
|
3
|
+
import { explain_schema, get_entity_details } from './tools/DataDomain.tools.js';
|
|
4
|
+
/**
|
|
5
|
+
* All tools available for the AI to use when modeling a domain.
|
|
6
|
+
*/
|
|
7
|
+
export const tools = [
|
|
8
|
+
{
|
|
9
|
+
functionDeclarations: [
|
|
10
|
+
{
|
|
11
|
+
name: 'list_semantics',
|
|
12
|
+
description: 'List all available data semantics, their scopes, and whether they have configuration options.',
|
|
13
|
+
parametersJsonSchema: {
|
|
14
|
+
type: Type.OBJECT,
|
|
15
|
+
properties: {},
|
|
16
|
+
required: [],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'get_semantic_details',
|
|
21
|
+
description: 'Get detailed information about a specific data semantic, notably its JSON ' +
|
|
22
|
+
'configuration schema properties, to determine what additional config you might want to provide.',
|
|
23
|
+
parametersJsonSchema: {
|
|
24
|
+
type: Type.OBJECT,
|
|
25
|
+
properties: {
|
|
26
|
+
semanticId: {
|
|
27
|
+
type: Type.STRING,
|
|
28
|
+
description: 'The exact ID of the semantic (e.g. Semantic#Password, Semantic#Tags)',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ['semanticId'],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'get_entity_details',
|
|
36
|
+
description: 'Get the full details of an entity given its key, including properties, associations, and tags.',
|
|
37
|
+
parametersJsonSchema: {
|
|
38
|
+
type: Type.OBJECT,
|
|
39
|
+
properties: {
|
|
40
|
+
entityKey: {
|
|
41
|
+
type: Type.STRING,
|
|
42
|
+
description: 'The exact key/ID of the entity to fetch details for.',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
required: ['entityKey'],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'explain_schema',
|
|
50
|
+
description: 'Explains the schema of a data type.',
|
|
51
|
+
parametersJsonSchema: {
|
|
52
|
+
type: Type.OBJECT,
|
|
53
|
+
properties: {
|
|
54
|
+
dataType: {
|
|
55
|
+
type: Type.STRING,
|
|
56
|
+
description: 'The data type (e.g. string, number, boolean, date, datetime, time, binary)',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ['dataType'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
export const functions = {
|
|
66
|
+
list_semantics,
|
|
67
|
+
get_semantic_details,
|
|
68
|
+
explain_schema,
|
|
69
|
+
get_entity_details,
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=domain_tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain_tools.js","sourceRoot":"","sources":["../../../../src/modeling/ai/domain_tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAGhF;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB;QACE,oBAAoB,EAAE;YACpB;gBACE,IAAI,EAAE,gBAAgB;gBACtB,WAAW,EAAE,+FAA+F;gBAC5G,oBAAoB,EAAE;oBACpB,IAAI,EAAE,IAAI,CAAC,MAAM;oBACjB,UAAU,EAAE,EAAE;oBACd,QAAQ,EAAE,EAAE;iBACb;aACF;YACD;gBACE,IAAI,EAAE,sBAAsB;gBAC5B,WAAW,EACT,4EAA4E;oBAC5E,iGAAiG;gBACnG,oBAAoB,EAAE;oBACpB,IAAI,EAAE,IAAI,CAAC,MAAM;oBACjB,UAAU,EAAE;wBACV,UAAU,EAAE;4BACV,IAAI,EAAE,IAAI,CAAC,MAAM;4BACjB,WAAW,EAAE,sEAAsE;yBACpF;qBACF;oBACD,QAAQ,EAAE,CAAC,YAAY,CAAC;iBACzB;aACF;YACD;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,WAAW,EAAE,gGAAgG;gBAC7G,oBAAoB,EAAE;oBACpB,IAAI,EAAE,IAAI,CAAC,MAAM;oBACjB,UAAU,EAAE;wBACV,SAAS,EAAE;4BACT,IAAI,EAAE,IAAI,CAAC,MAAM;4BACjB,WAAW,EAAE,sDAAsD;yBACpE;qBACF;oBACD,QAAQ,EAAE,CAAC,WAAW,CAAC;iBACxB;aACF;YACD;gBACE,IAAI,EAAE,gBAAgB;gBACtB,WAAW,EAAE,qCAAqC;gBAClD,oBAAoB,EAAE;oBACpB,IAAI,EAAE,IAAI,CAAC,MAAM;oBACjB,UAAU,EAAE;wBACV,QAAQ,EAAE;4BACR,IAAI,EAAE,IAAI,CAAC,MAAM;4BACjB,WAAW,EAAE,4EAA4E;yBAC1F;qBACF;oBACD,QAAQ,EAAE,CAAC,UAAU,CAAC;iBACvB;aACF;SACF;KACF;CACF,CAAA;AAID,MAAM,CAAC,MAAM,SAAS,GAAiC;IACrD,cAAc;IACd,oBAAoB;IACpB,cAAc;IACd,kBAAkB;CACnB,CAAA","sourcesContent":["import { Type } from './types.js'\nimport { get_semantic_details, list_semantics } from './tools/Semantic.tools.js'\nimport { explain_schema, get_entity_details } from './tools/DataDomain.tools.js'\nimport { ToolConfig } from './tools/config.js'\n\n/**\n * All tools available for the AI to use when modeling a domain.\n */\nexport const tools = [\n {\n functionDeclarations: [\n {\n name: 'list_semantics',\n description: 'List all available data semantics, their scopes, and whether they have configuration options.',\n parametersJsonSchema: {\n type: Type.OBJECT,\n properties: {},\n required: [],\n },\n },\n {\n name: 'get_semantic_details',\n description:\n 'Get detailed information about a specific data semantic, notably its JSON ' +\n 'configuration schema properties, to determine what additional config you might want to provide.',\n parametersJsonSchema: {\n type: Type.OBJECT,\n properties: {\n semanticId: {\n type: Type.STRING,\n description: 'The exact ID of the semantic (e.g. Semantic#Password, Semantic#Tags)',\n },\n },\n required: ['semanticId'],\n },\n },\n {\n name: 'get_entity_details',\n description: 'Get the full details of an entity given its key, including properties, associations, and tags.',\n parametersJsonSchema: {\n type: Type.OBJECT,\n properties: {\n entityKey: {\n type: Type.STRING,\n description: 'The exact key/ID of the entity to fetch details for.',\n },\n },\n required: ['entityKey'],\n },\n },\n {\n name: 'explain_schema',\n description: 'Explains the schema of a data type.',\n parametersJsonSchema: {\n type: Type.OBJECT,\n properties: {\n dataType: {\n type: Type.STRING,\n description: 'The data type (e.g. string, number, boolean, date, datetime, time, binary)',\n },\n },\n required: ['dataType'],\n },\n },\n ],\n },\n]\n\nexport type ToolFunction = (config: ToolConfig, args: Record<string, unknown>) => unknown | Promise<unknown>\n\nexport const functions: Record<string, ToolFunction> = {\n list_semantics,\n get_semantic_details,\n explain_schema,\n get_entity_details,\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as domainSystemInstructions } from './prompts/domain_system.js';
|
|
2
|
+
export { functions as domainFunctions, tools as domainTools } from './domain_tools.js';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export { DataDomainDelta } from './DataDomainDelta.js';
|
|
5
|
+
export { serializeDomainForAi, serializeEntity } from './DomainSerialization.js';
|
|
6
|
+
export { DOMAIN_SCHEMA } from './domain_response_schema.js';
|
|
7
|
+
export { detectReasoning, parseAiChatMessage } from './message_parser.js';
|
|
8
|
+
export { AiSemanticsConfig } from './Semantics.js';
|
|
9
|
+
export type { ToolConfig } from './tools/config.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modeling/ai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAChF,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACtF,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as domainSystemInstructions } from './prompts/domain_system.js';
|
|
2
|
+
export { functions as domainFunctions, tools as domainTools } from './domain_tools.js';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export { DataDomainDelta } from './DataDomainDelta.js';
|
|
5
|
+
export { serializeDomainForAi, serializeEntity } from './DomainSerialization.js';
|
|
6
|
+
export { DOMAIN_SCHEMA } from './domain_response_schema.js';
|
|
7
|
+
export { detectReasoning, parseAiChatMessage } from './message_parser.js';
|
|
8
|
+
export { AiSemanticsConfig } from './Semantics.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modeling/ai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAChF,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACtF,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA","sourcesContent":["export { default as domainSystemInstructions } from './prompts/domain_system.js'\nexport { functions as domainFunctions, tools as domainTools } from './domain_tools.js'\nexport * from './types.js'\nexport { DataDomainDelta } from './DataDomainDelta.js'\nexport { serializeDomainForAi, serializeEntity } from './DomainSerialization.js'\nexport { DOMAIN_SCHEMA } from './domain_response_schema.js'\nexport { detectReasoning, parseAiChatMessage } from './message_parser.js'\nexport { AiSemanticsConfig } from './Semantics.js'\nexport type { ToolConfig } from './tools/config.js'\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AiModelMessageWithDelta } from './types.js';
|
|
2
|
+
import type { AiMessageSchema, AiUserMessage } from '../../models/AiMessage.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parses an incoming `AiMessage` and maps it directly into its runtime
|
|
5
|
+
* representations `AiUserMessage` or `AiModelMessageWithDelta`.
|
|
6
|
+
*
|
|
7
|
+
* If the message is a model message, it attempts to parse the structured JSON
|
|
8
|
+
* contents in `msg.text` and sets the `delta` field accordingly. The `text` field
|
|
9
|
+
* is replaced with the reasoning text, or remains original if parsing fails/is omitted.
|
|
10
|
+
*
|
|
11
|
+
* @param msg The generic AI chat message.
|
|
12
|
+
* @returns The parsed in-memory wrapper context message.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseAiChatMessage(msg: AiMessageSchema): AiUserMessage | AiModelMessageWithDelta;
|
|
15
|
+
/**
|
|
16
|
+
* When a model response is generated it may contain the `reasoning` property. But because
|
|
17
|
+
* that property might still be generated it might not be a valid JSON. This function checks
|
|
18
|
+
* if the text contains reasoning and returns it if it does.
|
|
19
|
+
* @param text The text to check.
|
|
20
|
+
* @returns The reasoning string if it exists, otherwise undefined.
|
|
21
|
+
*/
|
|
22
|
+
export declare function detectReasoning(text: string): string | undefined;
|
|
23
|
+
//# sourceMappingURL=message_parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message_parser.d.ts","sourceRoot":"","sources":["../../../../src/modeling/ai/message_parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAG/E;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,aAAa,GAAG,uBAAuB,CAoBhG;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAwDhE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { DataDomainDelta } from './DataDomainDelta.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parses an incoming `AiMessage` and maps it directly into its runtime
|
|
4
|
+
* representations `AiUserMessage` or `AiModelMessageWithDelta`.
|
|
5
|
+
*
|
|
6
|
+
* If the message is a model message, it attempts to parse the structured JSON
|
|
7
|
+
* contents in `msg.text` and sets the `delta` field accordingly. The `text` field
|
|
8
|
+
* is replaced with the reasoning text, or remains original if parsing fails/is omitted.
|
|
9
|
+
*
|
|
10
|
+
* @param msg The generic AI chat message.
|
|
11
|
+
* @returns The parsed in-memory wrapper context message.
|
|
12
|
+
*/
|
|
13
|
+
export function parseAiChatMessage(msg) {
|
|
14
|
+
if (msg.role === 'user') {
|
|
15
|
+
return msg;
|
|
16
|
+
}
|
|
17
|
+
const modelMsg = { ...msg };
|
|
18
|
+
// Try to parse the delta structure
|
|
19
|
+
if (modelMsg.state === 'complete' && modelMsg.text) {
|
|
20
|
+
try {
|
|
21
|
+
const parsedJSON = JSON.parse(modelMsg.text);
|
|
22
|
+
modelMsg.delta = parsedJSON.delta ? DataDomainDelta.normalize(parsedJSON.delta) : undefined;
|
|
23
|
+
modelMsg.text = parsedJSON.reasoning || modelMsg.text;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// It might legitimately not be valid JSON yet if it crashed mid-stream,
|
|
27
|
+
// fallback to retaining original shape.
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return modelMsg;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* When a model response is generated it may contain the `reasoning` property. But because
|
|
34
|
+
* that property might still be generated it might not be a valid JSON. This function checks
|
|
35
|
+
* if the text contains reasoning and returns it if it does.
|
|
36
|
+
* @param text The text to check.
|
|
37
|
+
* @returns The reasoning string if it exists, otherwise undefined.
|
|
38
|
+
*/
|
|
39
|
+
export function detectReasoning(text) {
|
|
40
|
+
try {
|
|
41
|
+
const parsedJSON = JSON.parse(text);
|
|
42
|
+
return parsedJSON.reasoning;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Continue below
|
|
46
|
+
}
|
|
47
|
+
const searchStr = '"reasoning"';
|
|
48
|
+
const keyIndex = text.indexOf(searchStr);
|
|
49
|
+
if (keyIndex === -1) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const afterKey = text.substring(keyIndex + searchStr.length);
|
|
53
|
+
const colonIndex = afterKey.indexOf(':');
|
|
54
|
+
if (colonIndex === -1) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const afterColon = afterKey.substring(colonIndex + 1);
|
|
58
|
+
const quoteIndex = afterColon.indexOf('"');
|
|
59
|
+
if (quoteIndex === -1) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const valueStr = afterColon.substring(quoteIndex + 1);
|
|
63
|
+
let isEscaped = false;
|
|
64
|
+
let endIndex = -1;
|
|
65
|
+
for (let i = 0; i < valueStr.length; i++) {
|
|
66
|
+
const char = valueStr[i];
|
|
67
|
+
if (char === '\\' && !isEscaped) {
|
|
68
|
+
isEscaped = true;
|
|
69
|
+
}
|
|
70
|
+
else if (char === '"' && !isEscaped) {
|
|
71
|
+
endIndex = i;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
isEscaped = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const extracted = endIndex !== -1 ? valueStr.substring(0, endIndex) : valueStr;
|
|
79
|
+
try {
|
|
80
|
+
// Try to safely parse the literal string value.
|
|
81
|
+
return JSON.parse('"' + extracted + '"');
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// string replace fallback
|
|
85
|
+
return extracted
|
|
86
|
+
.replace(/\\n/g, '\n')
|
|
87
|
+
.replace(/\\r/g, '\r')
|
|
88
|
+
.replace(/\\t/g, '\t')
|
|
89
|
+
.replace(/\\"/g, '"')
|
|
90
|
+
.replace(/\\\\/g, '\\');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=message_parser.js.map
|