@accordproject/template-engine 3.1.0 → 4.2.1
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/README.md +41 -0
- package/lib/JavaScriptEvaluator.d.ts +71 -0
- package/lib/JavaScriptEvaluator.js +245 -0
- package/lib/JavaScriptEvaluator.js.map +1 -0
- package/lib/TemplateArchiveProcessor.d.ts +151 -0
- package/lib/TemplateArchiveProcessor.js +447 -0
- package/lib/TemplateArchiveProcessor.js.map +1 -0
- package/lib/TemplateMarkInterpreter.d.ts +34 -0
- package/lib/TemplateMarkInterpreter.js +689 -0
- package/lib/TemplateMarkInterpreter.js.map +1 -0
- package/lib/TemplateMarkNodes.d.ts +19 -0
- package/lib/TemplateMarkNodes.js +45 -0
- package/lib/TemplateMarkNodes.js.map +1 -0
- package/lib/TemplateMarkToJavaScriptCompiler.d.ts +20 -0
- package/lib/TemplateMarkToJavaScriptCompiler.js +99 -0
- package/lib/TemplateMarkToJavaScriptCompiler.js.map +1 -0
- package/lib/TypeScriptCompilationContext.d.ts +42 -0
- package/lib/TypeScriptCompilationContext.js +170 -0
- package/lib/TypeScriptCompilationContext.js.map +1 -0
- package/lib/TypeScriptRuntime.d.ts +17 -0
- package/lib/TypeScriptRuntime.js +84 -0
- package/lib/TypeScriptRuntime.js.map +1 -0
- package/lib/TypeScriptToJavaScriptCompiler.d.ts +11 -0
- package/lib/TypeScriptToJavaScriptCompiler.js +169 -0
- package/lib/TypeScriptToJavaScriptCompiler.js.map +1 -0
- package/lib/drafting/Boolean/index.d.ts +6 -0
- package/lib/drafting/Boolean/index.js +30 -0
- package/lib/drafting/Boolean/index.js.map +1 -0
- package/lib/drafting/DateTime/index.d.ts +8 -0
- package/lib/drafting/DateTime/index.js +33 -0
- package/lib/drafting/DateTime/index.js.map +1 -0
- package/lib/drafting/Double/format.d.ts +14 -0
- package/lib/drafting/Double/format.js +62 -0
- package/lib/drafting/Double/format.js.map +1 -0
- package/lib/drafting/Double/index.d.ts +8 -0
- package/lib/drafting/Double/index.js +33 -0
- package/lib/drafting/Double/index.js.map +1 -0
- package/lib/drafting/DraftFormat.d.ts +5 -0
- package/lib/drafting/DraftFormat.js +18 -0
- package/lib/drafting/DraftFormat.js.map +1 -0
- package/lib/drafting/Duration/index.d.ts +6 -0
- package/lib/drafting/Duration/index.js +39 -0
- package/lib/drafting/Duration/index.js.map +1 -0
- package/lib/drafting/Integer/format.d.ts +14 -0
- package/lib/drafting/Integer/format.js +52 -0
- package/lib/drafting/Integer/format.js.map +1 -0
- package/lib/drafting/Integer/index.d.ts +8 -0
- package/lib/drafting/Integer/index.js +33 -0
- package/lib/drafting/Integer/index.js.map +1 -0
- package/lib/drafting/Long/index.d.ts +8 -0
- package/lib/drafting/Long/index.js +33 -0
- package/lib/drafting/Long/index.js.map +1 -0
- package/lib/drafting/MonetaryAmount/currencycode.d.ts +35 -0
- package/lib/drafting/MonetaryAmount/currencycode.js +53 -0
- package/lib/drafting/MonetaryAmount/currencycode.js.map +1 -0
- package/lib/drafting/MonetaryAmount/formatTokens.d.ts +13 -0
- package/lib/drafting/MonetaryAmount/formatTokens.js +44 -0
- package/lib/drafting/MonetaryAmount/formatTokens.js.map +1 -0
- package/lib/drafting/MonetaryAmount/index.d.ts +13 -0
- package/lib/drafting/MonetaryAmount/index.js +51 -0
- package/lib/drafting/MonetaryAmount/index.js.map +1 -0
- package/lib/drafting/PreciseAmount/index.d.ts +17 -0
- package/lib/drafting/PreciseAmount/index.js +113 -0
- package/lib/drafting/PreciseAmount/index.js.map +1 -0
- package/lib/drafting/String/index.d.ts +6 -0
- package/lib/drafting/String/index.js +25 -0
- package/lib/drafting/String/index.js.map +1 -0
- package/lib/drafting/index.d.ts +2 -0
- package/lib/drafting/index.js +63 -0
- package/lib/drafting/index.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +42 -0
- package/lib/index.js.map +1 -0
- package/lib/llm/LLMConfig.d.ts +121 -0
- package/lib/llm/LLMConfig.js +30 -0
- package/lib/llm/LLMConfig.js.map +1 -0
- package/lib/llm/LLMExecutor.d.ts +77 -0
- package/lib/llm/LLMExecutor.js +603 -0
- package/lib/llm/LLMExecutor.js.map +1 -0
- package/lib/llm/ModelManagerSchema.d.ts +14 -0
- package/lib/llm/ModelManagerSchema.js +67 -0
- package/lib/llm/ModelManagerSchema.js.map +1 -0
- package/lib/llm/Reasoners.d.ts +190 -0
- package/lib/llm/Reasoners.js +643 -0
- package/lib/llm/Reasoners.js.map +1 -0
- package/lib/model-gen/concerto.d.ts +13 -0
- package/lib/model-gen/concerto.js +4 -0
- package/lib/model-gen/concerto.js.map +1 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.d.ts +196 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.js +4 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.js.map +1 -0
- package/lib/model-gen/concerto@1.0.0.d.ts +19 -0
- package/lib/model-gen/concerto@1.0.0.js +4 -0
- package/lib/model-gen/concerto@1.0.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.d.ts +49 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.js +4 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.d.ts +89 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.js +4 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.d.ts +76 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.js +11 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.js.map +1 -0
- package/lib/runtime/declarations.d.ts +2 -0
- package/lib/runtime/declarations.js +21 -0
- package/lib/runtime/declarations.js.map +1 -0
- package/lib/slc/model-gen/concerto.d.ts +13 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.d.ts +6 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.js +5 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.js.map +1 -0
- package/lib/slc/model-gen/concerto.js +5 -0
- package/lib/slc/model-gen/concerto.js.map +1 -0
- package/lib/slc/model-gen/concerto@1.0.0.d.ts +24 -0
- package/lib/slc/model-gen/concerto@1.0.0.js +6 -0
- package/lib/slc/model-gen/concerto@1.0.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.d.ts +7 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.js +5 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.d.ts +15 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.js +4 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.d.ts +46 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.js +48 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.js.map +1 -0
- package/lib/utils.d.ts +35 -0
- package/lib/utils.js +122 -0
- package/lib/utils.js.map +1 -0
- package/lib/worker.d.ts +1 -0
- package/{dist → lib}/worker.js +12 -10
- package/lib/worker.js.map +1 -0
- package/package.json +46 -25
- package/umd/template-engine.js +13 -0
- package/umd/template-engine.js.LICENSE.txt +21 -0
- package/dist/index.d.ts +0 -186
- package/dist/index.js +0 -1275
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1248
- package/dist/index.mjs.map +0 -1
- package/dist/worker.js.map +0 -1
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LLMExecutor = void 0;
|
|
4
|
+
const Reasoners_1 = require("./Reasoners");
|
|
5
|
+
const ModelManagerSchema_1 = require("./ModelManagerSchema");
|
|
6
|
+
/**
|
|
7
|
+
* Reads the root types declared by a template.
|
|
8
|
+
* @param template - template instance
|
|
9
|
+
* @returns request, response, state, and event types
|
|
10
|
+
*/
|
|
11
|
+
function getTemplateRoots(template) {
|
|
12
|
+
const requests = template.getRequestTypes();
|
|
13
|
+
const responses = template.getResponseTypes();
|
|
14
|
+
const states = template.getStateTypes();
|
|
15
|
+
const events = template.getEmitTypes();
|
|
16
|
+
return { requests, responses, states, events };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Checks whether a template is stateless.
|
|
20
|
+
* @param template - template instance
|
|
21
|
+
* @returns true when the template has no persistent state
|
|
22
|
+
*/
|
|
23
|
+
function isStatelessTemplate(template) {
|
|
24
|
+
return !template.isStateful();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Recursively stamps `additionalProperties: false` onto every object schema so
|
|
28
|
+
* strict structured-output providers reject unexpected keys.
|
|
29
|
+
*
|
|
30
|
+
* TODO: push this down into concerto-codegen's JSONSchemaVisitor as an opt-in
|
|
31
|
+
* flag (e.g. `additionalPropertiesFalse`) rather than post-processing here — see
|
|
32
|
+
* the tracking issue filed against accordproject/concerto-codegen.
|
|
33
|
+
* @param schema - the schema node to mutate in place
|
|
34
|
+
* @returns the same schema node, with `additionalProperties: false` applied
|
|
35
|
+
*/
|
|
36
|
+
function enforceAdditionalPropertiesFalse(schema) {
|
|
37
|
+
if (schema.type === 'object' || schema.properties) {
|
|
38
|
+
schema.additionalProperties = false;
|
|
39
|
+
if (schema.properties) {
|
|
40
|
+
for (const val of Object.values(schema.properties)) {
|
|
41
|
+
enforceAdditionalPropertiesFalse(val);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (schema.items) {
|
|
46
|
+
enforceAdditionalPropertiesFalse(schema.items);
|
|
47
|
+
}
|
|
48
|
+
return schema;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fully resolves all $ref pointers in a schema node, recursively.
|
|
52
|
+
* This produces a self-contained schema with no dangling $refs,
|
|
53
|
+
*/
|
|
54
|
+
function deepResolve(node, definitions, visiting = new Set() // cycle guard
|
|
55
|
+
) {
|
|
56
|
+
if (Array.isArray(node)) {
|
|
57
|
+
return node.map(item => deepResolve(item, definitions, visiting));
|
|
58
|
+
}
|
|
59
|
+
if (node && typeof node === 'object') {
|
|
60
|
+
if (node.$ref) {
|
|
61
|
+
const refKey = node.$ref.replace('#/definitions/', '');
|
|
62
|
+
if (visiting.has(refKey)) {
|
|
63
|
+
// Circular ref — leave as a plain object stub to avoid infinite loop
|
|
64
|
+
return { type: 'object', additionalProperties: false };
|
|
65
|
+
}
|
|
66
|
+
const refDef = definitions[refKey];
|
|
67
|
+
if (!refDef)
|
|
68
|
+
throw new Error(`Schema definition not found: ${refKey}`);
|
|
69
|
+
visiting = new Set(visiting); // clone so sibling refs aren't affected
|
|
70
|
+
visiting.add(refKey);
|
|
71
|
+
return deepResolve(refDef, definitions, visiting);
|
|
72
|
+
}
|
|
73
|
+
const result = {};
|
|
74
|
+
for (const [k, v] of Object.entries(node)) {
|
|
75
|
+
result[k] = deepResolve(v, definitions, visiting);
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
return node;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Schema keywords removed for structured-output providers.
|
|
83
|
+
*/
|
|
84
|
+
const UNSUPPORTED_KEYWORDS = new Set([
|
|
85
|
+
'pattern',
|
|
86
|
+
'format',
|
|
87
|
+
'minLength',
|
|
88
|
+
'maxLength',
|
|
89
|
+
'minimum',
|
|
90
|
+
'maximum',
|
|
91
|
+
'exclusiveMinimum',
|
|
92
|
+
'exclusiveMaximum',
|
|
93
|
+
'multipleOf',
|
|
94
|
+
]);
|
|
95
|
+
/**
|
|
96
|
+
* Recursively strips provider-unsupported keywords (see {@link UNSUPPORTED_KEYWORDS})
|
|
97
|
+
* from a schema node and pins the Concerto `$class` discriminator to a `const` of
|
|
98
|
+
* its exact fully-qualified name, so the model emits the correct type tag.
|
|
99
|
+
* @param node - the schema node to clean
|
|
100
|
+
* @returns a cleaned copy of the node
|
|
101
|
+
*/
|
|
102
|
+
function cleanForStructuredOutput(node) {
|
|
103
|
+
if (Array.isArray(node)) {
|
|
104
|
+
return node.map(cleanForStructuredOutput);
|
|
105
|
+
}
|
|
106
|
+
if (node && typeof node === 'object') {
|
|
107
|
+
const out = {};
|
|
108
|
+
for (const [k, v] of Object.entries(node)) {
|
|
109
|
+
if (UNSUPPORTED_KEYWORDS.has(k))
|
|
110
|
+
continue;
|
|
111
|
+
if (k === 'default')
|
|
112
|
+
continue; // model defaults aren't allowed in strict mode
|
|
113
|
+
if (k === 'properties' && v && typeof v === 'object') {
|
|
114
|
+
const props = {};
|
|
115
|
+
for (const [propKey, propVal] of Object.entries(v)) {
|
|
116
|
+
// Pin the Concerto type discriminator to its exact FQN.
|
|
117
|
+
if (propKey === '$class' && propVal && propVal.default) {
|
|
118
|
+
props[propKey] = { type: 'string', enum: [propVal.default] };
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
props[propKey] = cleanForStructuredOutput(propVal);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
out[k] = props;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
out[k] = cleanForStructuredOutput(v);
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
return node;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Resolves a tree-shaken type into a standalone schema.
|
|
135
|
+
* @param definitions - available schema definitions
|
|
136
|
+
* @param fqn - fully-qualified type name
|
|
137
|
+
* @returns a resolved schema for the requested type
|
|
138
|
+
*/
|
|
139
|
+
function resolveTypeSchema(definitions, fqn) {
|
|
140
|
+
const def = definitions[fqn];
|
|
141
|
+
if (!def)
|
|
142
|
+
throw new Error(`Type not found in tree-shaken model: ${fqn}`);
|
|
143
|
+
const resolved = deepResolve(def, definitions);
|
|
144
|
+
return cleanForStructuredOutput(enforceAdditionalPropertiesFalse(resolved));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resolves one or more type names into a schema.
|
|
148
|
+
* @param definitions - available schema definitions
|
|
149
|
+
* @param fqns - fully-qualified type names
|
|
150
|
+
* @returns a schema or null when no types are provided
|
|
151
|
+
*/
|
|
152
|
+
function resolveUnionSchema(definitions, fqns) {
|
|
153
|
+
if (fqns.length === 0)
|
|
154
|
+
return null;
|
|
155
|
+
if (fqns.length === 1)
|
|
156
|
+
return resolveTypeSchema(definitions, fqns[0]);
|
|
157
|
+
return { anyOf: fqns.map(fqn => resolveTypeSchema(definitions, fqn)) };
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Adds a description to a schema node.
|
|
161
|
+
* @param def - schema node
|
|
162
|
+
* @param description - description text
|
|
163
|
+
* @returns the updated schema node
|
|
164
|
+
*/
|
|
165
|
+
function withDescription(def, description) {
|
|
166
|
+
return { ...def, description };
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Closes a plain object schema to additional properties.
|
|
170
|
+
* @param def - schema node
|
|
171
|
+
* @returns the updated schema node
|
|
172
|
+
*/
|
|
173
|
+
function closeObjectSchema(def) {
|
|
174
|
+
if ('anyOf' in def)
|
|
175
|
+
return def;
|
|
176
|
+
return { ...def, additionalProperties: false };
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Build the JSON Schema fragment for the contract `state` property: the resolved
|
|
180
|
+
* state definition for full-schema providers, or an open object otherwise.
|
|
181
|
+
* @param full - whether to expand the resolved state definition
|
|
182
|
+
* @param stateDef - the resolved state schema, or null when unavailable
|
|
183
|
+
* @returns the `state` schema fragment
|
|
184
|
+
*/
|
|
185
|
+
function buildStateSchema(full, stateDef) {
|
|
186
|
+
if (full && stateDef) {
|
|
187
|
+
return closeObjectSchema(withDescription(stateDef, 'The contract state. Must match the Concerto state model.'));
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
type: 'object',
|
|
191
|
+
description: 'The contract state. Must match the Concerto state model.',
|
|
192
|
+
additionalProperties: false,
|
|
193
|
+
properties: {},
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Builds the schema for the `result` property.
|
|
198
|
+
* @param full - whether to expand the resolved response definition
|
|
199
|
+
* @param resultDef - the resolved response schema, or null when unavailable
|
|
200
|
+
* @returns the `result` schema fragment
|
|
201
|
+
*/
|
|
202
|
+
function buildResultSchema(full, resultDef) {
|
|
203
|
+
if (full && resultDef) {
|
|
204
|
+
return closeObjectSchema(withDescription(resultDef, 'The response object. Must match the Concerto response model.'));
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
type: 'object',
|
|
208
|
+
description: 'The response object. Must match the Concerto response model.',
|
|
209
|
+
additionalProperties: false,
|
|
210
|
+
properties: {},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Build the JSON Schema fragment for a single item of the `events` array: the
|
|
215
|
+
* lone event definition, an `anyOf` across several, or an open object.
|
|
216
|
+
* @param full - whether to expand the resolved event definitions
|
|
217
|
+
* @param eventDefs - the resolved event schemas, or null when unavailable
|
|
218
|
+
* @returns the event-item schema fragment
|
|
219
|
+
*/
|
|
220
|
+
function buildEventItemSchema(full, eventDefs) {
|
|
221
|
+
if (full && eventDefs && eventDefs.length === 1) {
|
|
222
|
+
return eventDefs[0];
|
|
223
|
+
}
|
|
224
|
+
if (full && eventDefs && eventDefs.length > 1) {
|
|
225
|
+
// A template may emit more than one kind of event — each array item must
|
|
226
|
+
// match one of them.
|
|
227
|
+
return { anyOf: eventDefs };
|
|
228
|
+
}
|
|
229
|
+
return { type: 'object', additionalProperties: false, properties: {} };
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Build the full JSON Schema for an `init` response (`{ state }`).
|
|
233
|
+
* @param full - whether to expand the resolved state definition
|
|
234
|
+
* @param stateDef - the resolved state schema, or null when unavailable
|
|
235
|
+
* @param stateless - true when the template carries no custom state
|
|
236
|
+
* @returns the init-response schema
|
|
237
|
+
*/
|
|
238
|
+
function buildInitSchema(full, stateDef, stateless = false) {
|
|
239
|
+
if (stateless) {
|
|
240
|
+
// Stateless templates carry no state — init always returns an empty object.
|
|
241
|
+
return {
|
|
242
|
+
type: 'object',
|
|
243
|
+
properties: {
|
|
244
|
+
state: {
|
|
245
|
+
type: 'object',
|
|
246
|
+
description: 'Empty state for a stateless template.',
|
|
247
|
+
additionalProperties: false,
|
|
248
|
+
properties: {},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
required: ['state'],
|
|
252
|
+
additionalProperties: false,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
type: 'object',
|
|
257
|
+
properties: {
|
|
258
|
+
state: buildStateSchema(full, stateDef),
|
|
259
|
+
},
|
|
260
|
+
required: ['state'],
|
|
261
|
+
additionalProperties: false,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Build the full JSON Schema for a `trigger` response (`{ result, events }`,
|
|
266
|
+
* plus `state` for stateful templates).
|
|
267
|
+
* @param full - whether to expand the resolved definitions
|
|
268
|
+
* @param resultDef - the resolved response schema, or null when unavailable
|
|
269
|
+
* @param stateDef - the resolved state schema, or null when unavailable
|
|
270
|
+
* @param eventDefs - the resolved event schemas, or null when unavailable
|
|
271
|
+
* @param stateless - true when the template carries no custom state
|
|
272
|
+
* @returns the trigger-response schema
|
|
273
|
+
*/
|
|
274
|
+
function buildTriggerSchema(full, resultDef, stateDef, eventDefs, stateless = false) {
|
|
275
|
+
const properties = {
|
|
276
|
+
result: buildResultSchema(full, resultDef),
|
|
277
|
+
events: {
|
|
278
|
+
type: 'array',
|
|
279
|
+
items: buildEventItemSchema(full, eventDefs),
|
|
280
|
+
description: 'Emitted events.',
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
const required = ['result', 'events'];
|
|
284
|
+
if (!stateless) {
|
|
285
|
+
// Stateful templates must carry their updated state back in the response.
|
|
286
|
+
properties.state = buildStateSchema(full, stateDef);
|
|
287
|
+
required.push('state');
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
type: 'object',
|
|
291
|
+
properties,
|
|
292
|
+
required,
|
|
293
|
+
additionalProperties: false,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Parse JSON from raw LLM output, tolerating a Markdown ```json ``` code fence.
|
|
298
|
+
* @param text - the raw model output
|
|
299
|
+
* @returns the parsed JSON value
|
|
300
|
+
* @throws {Error} if no valid JSON can be extracted
|
|
301
|
+
*/
|
|
302
|
+
function extractJson(text) {
|
|
303
|
+
const raw = text.trim();
|
|
304
|
+
try {
|
|
305
|
+
return JSON.parse(raw);
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
const match = raw.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
309
|
+
if (match)
|
|
310
|
+
return JSON.parse(match[1]);
|
|
311
|
+
throw new Error(`LLM did not return valid JSON. Raw output: ${text}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Assert that a parsed value has the shape of an {@link InitResponse}.
|
|
316
|
+
* @param value - the value to check
|
|
317
|
+
* @throws {Error} if the value is not a valid init response
|
|
318
|
+
* TODO - replace these with Concerto based deserialization:
|
|
319
|
+
* template.getModelManager().getSerializer().fromJSON( json )
|
|
320
|
+
* throws error if object is not a valid Concerto instance
|
|
321
|
+
*/
|
|
322
|
+
function assertInitShape(value) {
|
|
323
|
+
if (!value || typeof value !== 'object' || !value.state || typeof value.state !== 'object') {
|
|
324
|
+
throw new Error('Invalid init response shape from LLM');
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Assert that a parsed value has the shape of a {@link TriggerResponse}.
|
|
329
|
+
* @param value - the value to check
|
|
330
|
+
* @param stateless - true when `state` is not required (stateless template)
|
|
331
|
+
* @throws {Error} if the value is not a valid trigger response
|
|
332
|
+
*/
|
|
333
|
+
function assertTriggerShape(value, stateless = false) {
|
|
334
|
+
if (!value || typeof value !== 'object')
|
|
335
|
+
throw new Error('Invalid trigger response: not an object');
|
|
336
|
+
if (!value.result || typeof value.result !== 'object')
|
|
337
|
+
throw new Error('Invalid trigger response: missing result');
|
|
338
|
+
if (!stateless && (!value.state || typeof value.state !== 'object'))
|
|
339
|
+
throw new Error('Invalid trigger response: missing state (stateful template)');
|
|
340
|
+
if (!Array.isArray(value.events))
|
|
341
|
+
throw new Error('Invalid trigger response: events must be an array');
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Normalise a request's `$timestamp` to an ISO-8601 string. Concerto-
|
|
345
|
+
* deserialized requests expose a `Date`; raw JSON requests expose a string.
|
|
346
|
+
* @param request - the incoming request, may be undefined
|
|
347
|
+
* @returns the request timestamp as an ISO string, or null when the request
|
|
348
|
+
* carries no usable `$timestamp`
|
|
349
|
+
*/
|
|
350
|
+
function getRequestTimestamp(request) {
|
|
351
|
+
const raw = request?.$timestamp;
|
|
352
|
+
if (!raw)
|
|
353
|
+
return null;
|
|
354
|
+
const date = raw instanceof Date ? raw : new Date(raw);
|
|
355
|
+
return Number.isNaN(date.getTime()) ? null : date.toISOString();
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Inject Accord Project runtime metadata (`$timestamp` on result/events,
|
|
359
|
+
* `$identifier` on state), mirroring canonical Cicero engine output. Property
|
|
360
|
+
* order is irrelevant — Concerto does not enforce it — so the fields are simply
|
|
361
|
+
* assigned. `$identifier` resolves via:
|
|
362
|
+
* `state.$identifier → data.$identifier → data.clauseId → data.contractId → 'state-1'`.
|
|
363
|
+
* @param response - the LLM response to enrich, mutated in place
|
|
364
|
+
* @param timestamp - the ISO timestamp to stamp, defaults to now
|
|
365
|
+
* @param data - the contract data, used to resolve the state `$identifier`
|
|
366
|
+
* @returns the same response, with metadata applied
|
|
367
|
+
*/
|
|
368
|
+
function injectRuntimeMetadata(response, timestamp, data) {
|
|
369
|
+
const rawState = response.state;
|
|
370
|
+
const identifier = rawState?.$identifier ||
|
|
371
|
+
data?.$identifier ||
|
|
372
|
+
data?.clauseId ||
|
|
373
|
+
data?.contractId ||
|
|
374
|
+
'state-1';
|
|
375
|
+
if (response.result && typeof response.result === 'object') {
|
|
376
|
+
response.result.$timestamp = timestamp;
|
|
377
|
+
}
|
|
378
|
+
if (response.state &&
|
|
379
|
+
typeof response.state === 'object' &&
|
|
380
|
+
Object.keys(response.state).length > 0) {
|
|
381
|
+
response.state.$identifier = identifier;
|
|
382
|
+
}
|
|
383
|
+
if (Array.isArray(response.events)) {
|
|
384
|
+
for (const event of response.events) {
|
|
385
|
+
if (event && typeof event === 'object')
|
|
386
|
+
event.$timestamp = timestamp;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return response;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Executes an Accord Project template's `init` / `trigger` operations using an
|
|
393
|
+
* LLM, deriving the request/response/state/event schemas from the template's own
|
|
394
|
+
* ModelManager. Used as a fallback when a template carries no executable logic,
|
|
395
|
+
* or when LLM execution is explicitly forced.
|
|
396
|
+
*/
|
|
397
|
+
class LLMExecutor {
|
|
398
|
+
/**
|
|
399
|
+
* Creates an executor for a template.
|
|
400
|
+
* @param template - template to execute
|
|
401
|
+
* @param config - LLM configuration
|
|
402
|
+
*/
|
|
403
|
+
constructor(template, config) {
|
|
404
|
+
this.template = template;
|
|
405
|
+
this.config = config;
|
|
406
|
+
this.reasoner = (0, Reasoners_1.createReasoner)(config.provider);
|
|
407
|
+
this.fullSchema = config.provider.isStructuredOutputSupported ?? false;
|
|
408
|
+
this.stateless = isStatelessTemplate(template);
|
|
409
|
+
const roots = getTemplateRoots(template);
|
|
410
|
+
this.roots = roots;
|
|
411
|
+
const rootFqns = [
|
|
412
|
+
...roots.requests,
|
|
413
|
+
...roots.responses,
|
|
414
|
+
...roots.states,
|
|
415
|
+
...roots.events,
|
|
416
|
+
];
|
|
417
|
+
const { definitions } = rootFqns.length
|
|
418
|
+
? (0, ModelManagerSchema_1.treeShakeModel)(template, rootFqns)
|
|
419
|
+
: { definitions: {} };
|
|
420
|
+
const stateDef = resolveUnionSchema(definitions, roots.states);
|
|
421
|
+
const resultDef = resolveUnionSchema(definitions, roots.responses);
|
|
422
|
+
const requestDef = resolveUnionSchema(definitions, roots.requests);
|
|
423
|
+
const eventDefs = roots.events.map(fqn => resolveTypeSchema(definitions, fqn));
|
|
424
|
+
if (this.fullSchema) {
|
|
425
|
+
this.initSchema = buildInitSchema(true, stateDef, this.stateless);
|
|
426
|
+
this.triggerSchema = buildTriggerSchema(true, resultDef, stateDef, eventDefs, this.stateless);
|
|
427
|
+
this.promptSchema = null;
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
this.initSchema = buildInitSchema(false, null, this.stateless);
|
|
431
|
+
this.triggerSchema = buildTriggerSchema(false, null, null, null, this.stateless);
|
|
432
|
+
this.promptSchema = {
|
|
433
|
+
request: requestDef,
|
|
434
|
+
response: resultDef,
|
|
435
|
+
state: this.stateless ? null : stateDef,
|
|
436
|
+
events: eventDefs.length ? eventDefs : null,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
if (config.verbose) {
|
|
440
|
+
console.log(`[LLMExecutor] provider=${config.provider.provider} fullSchema=${this.fullSchema} stateless=${this.stateless}`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Builds the shared prompt context.
|
|
445
|
+
* @returns prompt context
|
|
446
|
+
*/
|
|
447
|
+
buildSharedContext() {
|
|
448
|
+
const metadata = this.template.getMetadata?.();
|
|
449
|
+
const templateModel = this.template.getTemplateModel?.();
|
|
450
|
+
return {
|
|
451
|
+
templateName: metadata?.getName?.() ?? 'unknown-template',
|
|
452
|
+
templateVersion: metadata?.getVersion?.() ?? null,
|
|
453
|
+
contractText: this.template.getTemplate?.() ?? '',
|
|
454
|
+
templateModelType: templateModel?.getFullyQualifiedName?.() ?? null,
|
|
455
|
+
requestTypes: this.roots.requests,
|
|
456
|
+
responseTypes: this.roots.responses,
|
|
457
|
+
stateTypes: this.roots.states,
|
|
458
|
+
emitTypes: this.roots.events,
|
|
459
|
+
...(this.promptSchema ? { schema: this.promptSchema } : {}),
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Sends a request to the active reasoner with retries.
|
|
464
|
+
* @param messages - the chat messages to send
|
|
465
|
+
* @param schema - the JSON Schema the response must satisfy
|
|
466
|
+
* @returns the model response content
|
|
467
|
+
* @throws the last error if every attempt fails
|
|
468
|
+
*/
|
|
469
|
+
async ask(messages, schema) {
|
|
470
|
+
const retries = this.config.provider.retries ?? 1;
|
|
471
|
+
let lastError;
|
|
472
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
473
|
+
try {
|
|
474
|
+
if (this.config.verbose && attempt > 0) {
|
|
475
|
+
console.log(`[LLMExecutor] Retry attempt ${attempt}/${retries}`);
|
|
476
|
+
}
|
|
477
|
+
return await this.reasoner.complete(messages, schema);
|
|
478
|
+
}
|
|
479
|
+
catch (err) {
|
|
480
|
+
lastError = err;
|
|
481
|
+
if (this.config.verbose) {
|
|
482
|
+
console.warn(`[LLMExecutor] attempt ${attempt} failed:`, err);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
throw lastError;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Computes the initial contract state.
|
|
490
|
+
* @param data - the data for the template
|
|
491
|
+
* @param currentTime - the current time, defaults to now
|
|
492
|
+
* @param utcOffset - the UTC offset, defaults to zero
|
|
493
|
+
* @returns the new state
|
|
494
|
+
*/
|
|
495
|
+
async init(data, currentTime, utcOffset) {
|
|
496
|
+
if (this.config.verbose)
|
|
497
|
+
console.log('[LLMExecutor] INIT called');
|
|
498
|
+
const context = this.buildSharedContext();
|
|
499
|
+
const timestamp = currentTime ?? new Date().toISOString();
|
|
500
|
+
const isStateless = this.stateless;
|
|
501
|
+
const systemPrompt = isStateless
|
|
502
|
+
? ` You are a generic Accord Project contract runtime executor.
|
|
503
|
+
This template is STATELESS — it carries no persistent state between executions.
|
|
504
|
+
|
|
505
|
+
Task:
|
|
506
|
+
Return the initial (empty) state for this contract.
|
|
507
|
+
`.trim()
|
|
508
|
+
: `
|
|
509
|
+
You are a generic Accord Project contract runtime executor.
|
|
510
|
+
You will receive:
|
|
511
|
+
- contract text
|
|
512
|
+
- Concerto model definitions
|
|
513
|
+
- template data
|
|
514
|
+
|
|
515
|
+
Task:
|
|
516
|
+
Compute the initial state of the contract.
|
|
517
|
+
`.trim();
|
|
518
|
+
const userPrompt = JSON.stringify({
|
|
519
|
+
operation: 'init',
|
|
520
|
+
currentTime: timestamp,
|
|
521
|
+
utcOffset: utcOffset ?? 0,
|
|
522
|
+
data,
|
|
523
|
+
context,
|
|
524
|
+
});
|
|
525
|
+
const response = await this.ask([
|
|
526
|
+
{ role: 'system', content: systemPrompt },
|
|
527
|
+
{ role: 'user', content: userPrompt },
|
|
528
|
+
], this.initSchema);
|
|
529
|
+
const parsed = extractJson(response.content);
|
|
530
|
+
assertInitShape(parsed);
|
|
531
|
+
return injectRuntimeMetadata(parsed, timestamp, data);
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Evaluates a trigger request.
|
|
535
|
+
*
|
|
536
|
+
* Stateful templates (`!this.stateless`) must always be evaluated against
|
|
537
|
+
* `priorState` — the state produced by a prior call to {@link init} (or by
|
|
538
|
+
* a prior call to `trigger`) — since there is no implicit "empty" state for
|
|
539
|
+
* a template that declares custom State fields. Stateless templates ignore
|
|
540
|
+
* `priorState` entirely.
|
|
541
|
+
* @param data - the data for the template
|
|
542
|
+
* @param request - the request to send to the contract logic
|
|
543
|
+
* @param priorState - the state to evaluate the request against. Required
|
|
544
|
+
* for stateful templates (must originate from init() or a previous
|
|
545
|
+
* trigger()); ignored for stateless templates.
|
|
546
|
+
* @param currentTime - the current time. Only used when the request carries
|
|
547
|
+
* no `$timestamp`, which always takes precedence; defaults to now
|
|
548
|
+
* @param utcOffset - the UTC offset, defaults to zero
|
|
549
|
+
* @returns the response, updated state, and any events
|
|
550
|
+
* @throws {Error} if the template is stateful and no priorState is supplied
|
|
551
|
+
*/
|
|
552
|
+
async trigger(data, request, priorState, currentTime, utcOffset) {
|
|
553
|
+
if (this.config.verbose)
|
|
554
|
+
console.log('[LLMExecutor] TRIGGER called');
|
|
555
|
+
if (!this.stateless && (!priorState || Object.keys(priorState).length === 0)) {
|
|
556
|
+
throw new Error('Stateful templates require priorState: call init() first and pass its ' +
|
|
557
|
+
'returned state (or the state returned by a previous trigger()) as priorState.');
|
|
558
|
+
}
|
|
559
|
+
const context = this.buildSharedContext();
|
|
560
|
+
// The request's own `$timestamp` wins, then currentTime, then now.
|
|
561
|
+
const timestamp = getRequestTimestamp(request) ?? currentTime ?? new Date().toISOString();
|
|
562
|
+
const isStateless = this.stateless;
|
|
563
|
+
const systemPrompt = isStateless
|
|
564
|
+
? ` You are a generic Accord Project contract runtime executor.
|
|
565
|
+
This template is STATELESS — outputs depend only on the current request and template model.
|
|
566
|
+
|
|
567
|
+
Task:
|
|
568
|
+
Evaluate contract behavior for this request.
|
|
569
|
+
`.trim()
|
|
570
|
+
: `
|
|
571
|
+
You are a generic Accord Project contract runtime executor.
|
|
572
|
+
You will receive:
|
|
573
|
+
- contract text
|
|
574
|
+
- Concerto model definitions
|
|
575
|
+
- template data
|
|
576
|
+
- priorState (the state produced by init(), or by the previous trigger())
|
|
577
|
+
- incoming request/transaction
|
|
578
|
+
|
|
579
|
+
Task:
|
|
580
|
+
Evaluate contract behavior for this request, starting from priorState,
|
|
581
|
+
and return the updated state.
|
|
582
|
+
|
|
583
|
+
`.trim();
|
|
584
|
+
const userPrompt = JSON.stringify({
|
|
585
|
+
operation: 'trigger',
|
|
586
|
+
currentTime: timestamp,
|
|
587
|
+
utcOffset: utcOffset ?? 0,
|
|
588
|
+
data,
|
|
589
|
+
request,
|
|
590
|
+
priorState: priorState ?? {},
|
|
591
|
+
context,
|
|
592
|
+
});
|
|
593
|
+
const response = await this.ask([
|
|
594
|
+
{ role: 'system', content: systemPrompt },
|
|
595
|
+
{ role: 'user', content: userPrompt },
|
|
596
|
+
], this.triggerSchema);
|
|
597
|
+
const parsed = extractJson(response.content);
|
|
598
|
+
assertTriggerShape(parsed, this.stateless);
|
|
599
|
+
return injectRuntimeMetadata(parsed, timestamp, data);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
exports.LLMExecutor = LLMExecutor;
|
|
603
|
+
//# sourceMappingURL=LLMExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMExecutor.js","sourceRoot":"","sources":["../../src/llm/LLMExecutor.ts"],"names":[],"mappings":";;;AAeA,2CAAoF;AAEpF,6DAAsD;AA0BtD;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,QAAkB;IAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;IAC5C,MAAM,SAAS,GAAG,QAAQ,CAAC,gBAAgB,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,EAAE,CAAC;IACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;IACvC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,QAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;AAChC,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,gCAAgC,CAAC,MAA2B;IACnE,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAClD,MAAM,CAAC,oBAAoB,GAAG,KAAK,CAAC;QACpC,IAAI,MAAM,CAAC,UAAU,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AM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;QACnC,MAAM,YAAY,GAAG,WAAW;YAC9B,CAAC,CAAC;;;;;WAKG,CAAC,IAAI,EAAE;YACF,CAAC,CAAC;;;;;;;;;;;;;WAaP,CAAC,IAAI,EAAE,CAAC;QAEf,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;YAChC,SAAS,EAAE,SAAS;YACpB,WAAW,EAAE,SAAS;YACtB,SAAS,EAAE,SAAS,IAAI,CAAC;YACzB,IAAI;YACJ,OAAO;YACP,UAAU,EAAE,UAAU,IAAI,EAAE;YAC5B,OAAO;SACR,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAC7B;YACE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;YACzC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE;SACtC,EACD,IAAI,CAAC,aAAa,CACnB,CAAC;QAEF,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7C,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,OAAO,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;CACF;AAxQD,kCAwQC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface TreeShakenModel {
|
|
2
|
+
/** JSON Schema `definitions` map, keyed by fully-qualified type name,
|
|
3
|
+
* containing only the types reachable from the supplied roots. */
|
|
4
|
+
definitions: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Tree-shake a template's ModelManager down to only the declarations reachable
|
|
8
|
+
* from `roots`, returning both the JSON Schema definitions and the reduced
|
|
9
|
+
* model files.
|
|
10
|
+
*
|
|
11
|
+
* @param template a cicero-core Template
|
|
12
|
+
* @param roots fully-qualified type names to keep (and their dependencies)
|
|
13
|
+
*/
|
|
14
|
+
export declare function treeShakeModel(template: any, roots: string[]): TreeShakenModel;
|