@accordproject/template-engine 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/JavaScriptEvaluator.js +14 -17
- package/lib/JavaScriptEvaluator.js.map +1 -1
- package/lib/TemplateArchiveProcessor.d.ts +93 -3
- package/lib/TemplateArchiveProcessor.js +322 -27
- package/lib/TemplateArchiveProcessor.js.map +1 -1
- package/lib/TypeScriptCompilationContext.d.ts +27 -0
- package/lib/TypeScriptCompilationContext.js +116 -3
- package/lib/TypeScriptCompilationContext.js.map +1 -1
- 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.js +2 -18
- package/lib/drafting/MonetaryAmount/index.js.map +1 -1
- 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/index.js +24 -4
- package/lib/drafting/index.js.map +1 -1
- 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@1.0.0.d.ts +2 -2
- package/lib/runtime/declarations.d.ts +0 -1
- package/lib/runtime/declarations.js +1 -2
- package/lib/runtime/declarations.js.map +1 -1
- package/lib/slc/model-gen/concerto@1.0.0.d.ts +2 -2
- package/lib/utils.d.ts +29 -0
- package/lib/utils.js +51 -0
- package/lib/utils.js.map +1 -1
- package/package.json +19 -9
- package/umd/template-engine.js +8 -8
- package/umd/template-engine.js.LICENSE.txt +1 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptCompilationContext.js","sourceRoot":"","sources":["../src/TypeScriptCompilationContext.ts"],"names":[],"mappings":";;;AAcA,sEAA0D;AAC1D,gEAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"TypeScriptCompilationContext.js","sourceRoot":"","sources":["../src/TypeScriptCompilationContext.ts"],"names":[],"mappings":";;;AAcA,sEAA0D;AAC1D,gEAA8D;AAC9D,mCAOiB;AAEjB;;;;;;GAMG;AACH,MAAa,4BAA4B;IAKrC,YAAY,YAAyB,EAAC,kBAA2B;QAC7D,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,IAAA,mCAA2B,EAAC,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;IAC5F,CAAC;IAED,kBAAkB;QACd,MAAM,MAAM,GAAyB,EAAE,CAAC;QAExC,MAAM,OAAO,GAAG,IAAI,0BAAO,CAAC,iBAAiB,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,8BAAc,EAAE,CAAC;QAEpC,MAAM,MAAM,GAAG;YACX,UAAU,EAAE,MAAM;SACrB,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAE,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE;YAC9D,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACK,iBAAiB,CAAC,OAAe,EAAE,WAAmB;QAC1D,MA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AAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAqCO,KAAK,CAAC,KAAK;wBACT,OAAO,CAAC,KAAK;yBACZ,QAAQ,CAAC,KAAK;sBACjB,KAAK,CAAC,KAAK;;;;;;;;;;;;;;;;;;;CAmBhC,CAAC;IACE,CAAC;IAED,qBAAqB;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAExC,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,yEAAyE;QACzE,4EAA4E;QAC5E,6EAA6E;QAC7E,6EAA6E;QAC7E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAE,GAAG,CAAC,EAAE;YAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3B,MAAM,IAAI;0BACI,GAAG;EAC3B,OAAO;CACR,CAAC;QACM,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI;;8CAE4B,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;;;EAG7E,IAAI,CAAC,sBAAsB,EAAE;;;;;CAK9B,CAAC;QACM,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAxKD,oEAwKC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbol from a currency code
|
|
3
|
+
* @param {string} c - the currency code
|
|
4
|
+
* @returns {string} the symbol
|
|
5
|
+
*/
|
|
6
|
+
export declare function codeSymbol(c: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Replaces currency tokens (K for symbol, CCC for code) in a format string
|
|
9
|
+
* @param {string} format - the format string
|
|
10
|
+
* @param {string} code - the currency code
|
|
11
|
+
* @returns {string} the format string with tokens replaced
|
|
12
|
+
*/
|
|
13
|
+
export declare function replaceCurrencyTokens(format: string, code: string): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.codeSymbol = codeSymbol;
|
|
17
|
+
exports.replaceCurrencyTokens = replaceCurrencyTokens;
|
|
18
|
+
const currencycode_1 = require("./currencycode");
|
|
19
|
+
/**
|
|
20
|
+
* Symbol from a currency code
|
|
21
|
+
* @param {string} c - the currency code
|
|
22
|
+
* @returns {string} the symbol
|
|
23
|
+
*/
|
|
24
|
+
function codeSymbol(c) {
|
|
25
|
+
const index = Object.keys(currencycode_1.CurrencyCode).indexOf(c);
|
|
26
|
+
if (index >= 0) {
|
|
27
|
+
return Object.values(currencycode_1.CurrencyCode)[index];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return c;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Replaces currency tokens (K for symbol, CCC for code) in a format string
|
|
35
|
+
* @param {string} format - the format string
|
|
36
|
+
* @param {string} code - the currency code
|
|
37
|
+
* @returns {string} the format string with tokens replaced
|
|
38
|
+
*/
|
|
39
|
+
function replaceCurrencyTokens(format, code) {
|
|
40
|
+
return format
|
|
41
|
+
.replace(/K/gi, codeSymbol(code))
|
|
42
|
+
.replace(/CCC/gi, code);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=formatTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatTokens.js","sourceRoot":"","sources":["../../../src/drafting/MonetaryAmount/formatTokens.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AASH,gCAQC;AAQD,sDAIC;AA3BD,iDAA8C;AAE9C;;;;GAIG;AACH,SAAgB,UAAU,CAAC,CAAQ;IAC/B,MAAM,KAAK,GAAW,MAAM,CAAC,IAAI,CAAC,2BAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAG,KAAK,IAAG,CAAC,EAAE,CAAC;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAY,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;SACI,CAAC;QACF,OAAO,CAAC,CAAC;IACb,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,MAAc,EAAE,IAAY;IAC9D,OAAO,MAAM;SACR,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;SAChC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.default = monetaryAmountDrafter;
|
|
17
17
|
const format_1 = require("../Double/format");
|
|
18
18
|
const format_2 = require("../Double/format");
|
|
19
|
-
const
|
|
19
|
+
const formatTokens_1 = require("./formatTokens");
|
|
20
20
|
/**
|
|
21
21
|
* Creates a drafter for monetary amount with no format
|
|
22
22
|
* @param {object} value the monetary amount
|
|
@@ -25,20 +25,6 @@ const currencycode_1 = require("./currencycode");
|
|
|
25
25
|
function monetaryAmountDefaultDrafter(value) {
|
|
26
26
|
return '' + (0, format_1.draftDoubleIEEE)(value.doubleValue) + ' ' + value.currencyCode;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Symbol from a currency code
|
|
30
|
-
* @param {string} c - the currency code
|
|
31
|
-
* @returns {string} the symbol
|
|
32
|
-
*/
|
|
33
|
-
function codeSymbol(c) {
|
|
34
|
-
const index = Object.keys(currencycode_1.CurrencyCode).indexOf(c);
|
|
35
|
-
if (index >= 0) {
|
|
36
|
-
return Object.values(currencycode_1.CurrencyCode)[index];
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return c;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
28
|
/**
|
|
43
29
|
* Creates a drafter for monetary amount with a given format
|
|
44
30
|
* @param {object} value the monetary amount
|
|
@@ -46,9 +32,7 @@ function codeSymbol(c) {
|
|
|
46
32
|
* @returns {string} the text
|
|
47
33
|
*/
|
|
48
34
|
function monetaryAmountFormatDrafter(value, format) {
|
|
49
|
-
return (0, format_2.draftDoubleFormat)(value.doubleValue, format
|
|
50
|
-
.replace(/K/gi, codeSymbol(value.currencyCode))
|
|
51
|
-
.replace(/CCC/gi, value.currencyCode));
|
|
35
|
+
return (0, format_2.draftDoubleFormat)(value.doubleValue, (0, formatTokens_1.replaceCurrencyTokens)(format, value.currencyCode));
|
|
52
36
|
}
|
|
53
37
|
/**
|
|
54
38
|
* Creates a drafter for a monetary amount
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/MonetaryAmount/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/MonetaryAmount/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAsCH,wCAMC;AA1CD,6CAAmD;AACnD,6CAAqD;AAErD,iDAAuD;AAOvD;;;;GAIG;AACH,SAAS,4BAA4B,CAAC,KAAoB;IACtD,OAAO,EAAE,GAAG,IAAA,wBAAe,EAAC,KAAK,CAAC,WAAW,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC;AAC9E,CAAC;AAGD;;;;;GAKG;AACH,SAAS,2BAA2B,CAAC,KAAoB,EAAC,MAA2B;IACjF,OAAO,IAAA,0BAAiB,EAAC,KAAK,CAAC,WAAW,EAAE,IAAA,oCAAqB,EAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;AACnG,CAAC;AAED;;;;;GAKG;AACH,SAAwB,qBAAqB,CAAC,KAAoB,EAAC,MAA4B;IAC3F,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,2BAA2B,CAAC,KAAK,EAAC,MAAM,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACJ,OAAO,4BAA4B,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MonetaryAmountFormat } from '../DraftFormat';
|
|
2
|
+
export type PreciseAmount = {
|
|
3
|
+
unscaledValue: string;
|
|
4
|
+
unit: {
|
|
5
|
+
code: string;
|
|
6
|
+
scheme?: string;
|
|
7
|
+
identifier?: string;
|
|
8
|
+
scale: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Creates a drafter for a precise amount
|
|
13
|
+
* @param {object} value the precise amount
|
|
14
|
+
* @param {string} format the format
|
|
15
|
+
* @returns {string} the text
|
|
16
|
+
*/
|
|
17
|
+
export default function preciseAmountDrafter(value: PreciseAmount, format?: MonetaryAmountFormat): string;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = preciseAmountDrafter;
|
|
17
|
+
const formatTokens_1 = require("../MonetaryAmount/formatTokens");
|
|
18
|
+
/**
|
|
19
|
+
* Helper to reconstruct the decimal string representation of a PreciseAmount
|
|
20
|
+
* without losing precision via JavaScript floats.
|
|
21
|
+
*/
|
|
22
|
+
function reconstructDecimalString(value, scale) {
|
|
23
|
+
if (scale === 0)
|
|
24
|
+
return value;
|
|
25
|
+
let isNegative = false;
|
|
26
|
+
let absValue = value;
|
|
27
|
+
if (absValue.startsWith('-')) {
|
|
28
|
+
isNegative = true;
|
|
29
|
+
absValue = absValue.substring(1);
|
|
30
|
+
}
|
|
31
|
+
if (absValue.length <= scale) {
|
|
32
|
+
absValue = absValue.padStart(scale + 1, '0');
|
|
33
|
+
}
|
|
34
|
+
const insertPos = absValue.length - scale;
|
|
35
|
+
const integerPart = absValue.substring(0, insertPos);
|
|
36
|
+
const decimalPart = absValue.substring(insertPos);
|
|
37
|
+
let result = `${integerPart}.${decimalPart}`;
|
|
38
|
+
if (isNegative) {
|
|
39
|
+
result = '-' + result;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a drafter for precise amount with no format
|
|
45
|
+
* @param {object} value the precise amount
|
|
46
|
+
* @returns {string} the text
|
|
47
|
+
*/
|
|
48
|
+
function preciseAmountDefaultDrafter(value) {
|
|
49
|
+
return reconstructDecimalString(value.unscaledValue, value.unit.scale) + ' ' + value.unit.code;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a drafter for precise amount with a given format
|
|
53
|
+
* @param {object} value the precise amount
|
|
54
|
+
* @param {string} format the format
|
|
55
|
+
* @returns {string} the text
|
|
56
|
+
*/
|
|
57
|
+
function preciseAmountFormatDrafter(value, format) {
|
|
58
|
+
const strValue = reconstructDecimalString(value.unscaledValue, value.unit.scale);
|
|
59
|
+
const formatWithTokens = (0, formatTokens_1.replaceCurrencyTokens)(format, value.unit.code);
|
|
60
|
+
return formatWithTokens.replace(/0(.)0((.)(0+))?/gi, function (_a, sep1, _b, sep2, digits) {
|
|
61
|
+
const len = digits ? digits.length : 0;
|
|
62
|
+
const parts = strValue.split('.');
|
|
63
|
+
let integerPart = parts[0];
|
|
64
|
+
let decimalPart = parts.length > 1 ? parts[1] : '';
|
|
65
|
+
// Adjust decimal part to 'len' digits
|
|
66
|
+
if (len === 0) {
|
|
67
|
+
decimalPart = '';
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (decimalPart.length > len) {
|
|
71
|
+
// Truncate without rounding (to preserve strict string handling without complex BigInt math)
|
|
72
|
+
decimalPart = decimalPart.substring(0, len);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
decimalPart = decimalPart.padEnd(len, '0');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
let res = '';
|
|
79
|
+
if (sep2 && len > 0) {
|
|
80
|
+
res += sep2 + decimalPart;
|
|
81
|
+
}
|
|
82
|
+
let isNegative = false;
|
|
83
|
+
if (integerPart.startsWith('-')) {
|
|
84
|
+
isNegative = true;
|
|
85
|
+
integerPart = integerPart.substring(1);
|
|
86
|
+
}
|
|
87
|
+
// Apply grouping (sep1)
|
|
88
|
+
while (integerPart.length > 3) {
|
|
89
|
+
res = sep1 + integerPart.substring(integerPart.length - 3) + res;
|
|
90
|
+
integerPart = integerPart.substring(0, integerPart.length - 3);
|
|
91
|
+
}
|
|
92
|
+
res = integerPart + res;
|
|
93
|
+
if (isNegative) {
|
|
94
|
+
res = '-' + res;
|
|
95
|
+
}
|
|
96
|
+
return res;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Creates a drafter for a precise amount
|
|
101
|
+
* @param {object} value the precise amount
|
|
102
|
+
* @param {string} format the format
|
|
103
|
+
* @returns {string} the text
|
|
104
|
+
*/
|
|
105
|
+
function preciseAmountDrafter(value, format) {
|
|
106
|
+
if (format) {
|
|
107
|
+
return preciseAmountFormatDrafter(value, format);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return preciseAmountDefaultDrafter(value);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/PreciseAmount/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAmHH,uCAMC;AAtHD,iEAAuE;AAavE;;;GAGG;AACH,SAAS,wBAAwB,CAAC,KAAa,EAAE,KAAa;IAC1D,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE9B,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,UAAU,GAAG,IAAI,CAAC;QAClB,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;QAC3B,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;IAC1C,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAElD,IAAI,MAAM,GAAG,GAAG,WAAW,IAAI,WAAW,EAAE,CAAC;IAC7C,IAAI,UAAU,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;IAC1B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ault(require("./Integer"));
|
|
|
25
25
|
const Duration_1 = __importDefault(require("./Duration"));
|
|
26
26
|
const Long_1 = __importDefault(require("./Long"));
|
|
27
27
|
const MonetaryAmount_1 = __importDefault(require("./MonetaryAmount"));
|
|
28
|
+
const PreciseAmount_1 = __importDefault(require("./PreciseAmount"));
|
|
28
29
|
const String_1 = __importDefault(require("./String"));
|
|
30
|
+
const concerto_core_1 = require("@accordproject/concerto-core");
|
|
31
|
+
function drafterKey(fqn) {
|
|
32
|
+
if (concerto_core_1.ModelUtil.isPrimitiveType(fqn)) {
|
|
33
|
+
return fqn; // Boolean, String, Integer, ...
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const ns = concerto_core_1.ModelUtil.getNamespace(fqn);
|
|
37
|
+
const name = concerto_core_1.ModelUtil.getShortName(fqn);
|
|
38
|
+
const { name: nsName, version } = concerto_core_1.ModelUtil.parseNamespace(ns);
|
|
39
|
+
const major = version ? version.split('.')[0] : '';
|
|
40
|
+
return `${nsName}@${major}.${name}`;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Not a versioned namespace type (e.g. user-defined concept without a version).
|
|
44
|
+
// Return as-is so it hits the default: null branch in getDrafter.
|
|
45
|
+
return fqn;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
29
48
|
function getDrafter(typeName) {
|
|
30
|
-
switch (typeName) {
|
|
49
|
+
switch (drafterKey(typeName)) {
|
|
31
50
|
case 'Boolean': return Boolean_1.default;
|
|
32
51
|
case 'DateTime': return DateTime_1.default;
|
|
33
52
|
case 'Double': return Double_1.default;
|
|
34
53
|
case 'Integer': return Integer_1.default;
|
|
35
54
|
case 'Long': return Long_1.default;
|
|
36
|
-
case 'org.accordproject.money@0.
|
|
37
|
-
case 'org.accordproject.
|
|
38
|
-
case 'org.accordproject.time@0.
|
|
55
|
+
case 'org.accordproject.money@0.MonetaryAmount': return MonetaryAmount_1.default;
|
|
56
|
+
case 'org.accordproject.money@1.PreciseAmount': return PreciseAmount_1.default;
|
|
57
|
+
case 'org.accordproject.time@0.Duration': return Duration_1.default;
|
|
58
|
+
case 'org.accordproject.time@0.Period': return Duration_1.default;
|
|
39
59
|
case 'String': return String_1.default;
|
|
40
60
|
default: return null;
|
|
41
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/drafting/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/drafting/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;AAiCH,gCAcC;AA7CD,uDAAuD;AAEvD,wDAAuC;AACvC,0DAAyC;AACzC,sDAAqC;AACrC,wDAAuC;AACvC,0DAAyC;AACzC,kDAAiC;AACjC,sEAAqD;AACrD,oEAAmD;AAEnD,sDAAqC;AACrC,gEAAyD;AAEzD,SAAS,UAAU,CAAC,GAAW;IAC3B,IAAI,yBAAS,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC,CAAC,gCAAgC;IAChD,CAAC;IACD,IAAI,CAAC;QACD,MAAM,EAAE,GAAG,yBAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,yBAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,yBAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,OAAO,GAAG,MAAM,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACL,gFAAgF;QAChF,kEAAkE;QAClE,OAAO,GAAG,CAAC;IACf,CAAC;AACL,CAAC;AAED,SAAgB,UAAU,CAAC,QAAgB;IACvC,QAAO,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,KAAK,SAAS,CAAC,CAAC,OAAO,iBAAc,CAAC;QACtC,KAAK,UAAU,CAAC,CAAC,OAAO,kBAAe,CAAC;QACxC,KAAK,QAAQ,CAAC,CAAC,OAAO,gBAAa,CAAC;QACpC,KAAK,SAAS,CAAC,CAAC,OAAO,iBAAc,CAAC;QACtC,KAAK,MAAM,CAAC,CAAC,OAAO,cAAW,CAAC;QAChC,KAAK,0CAA0C,CAAC,CAAC,OAAO,wBAAqB,CAAC;QAC9E,KAAK,yCAAyC,CAAC,CAAC,OAAO,uBAAoB,CAAC;QAC5E,KAAK,mCAAmC,CAAC,CAAC,OAAO,kBAAe,CAAC;QACjE,KAAK,iCAAiC,CAAC,CAAC,OAAO,kBAAe,CAAC;QAC/D,KAAK,QAAQ,CAAC,CAAC,OAAO,gBAAa,CAAC;QACpC,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC;IACrB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export type LLMMode = 'disabled' | 'fallback' | 'force';
|
|
2
|
+
/** Effort levels the Groq API accepts. */
|
|
3
|
+
export declare const GROQ_EFFORT_LEVELS: readonly ["none", "low", "medium", "high"];
|
|
4
|
+
export type GroqEffort = (typeof GROQ_EFFORT_LEVELS)[number];
|
|
5
|
+
/**
|
|
6
|
+
* Effort levels the OpenAI Chat Completions API accepts. Only reasoning models
|
|
7
|
+
* take the parameter at all — a non-reasoning model (e.g. `gpt-4o`) rejects it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const OPENAI_EFFORT_LEVELS: readonly ["minimal", "low", "medium", "high"];
|
|
10
|
+
export type OpenAIEffort = (typeof OPENAI_EFFORT_LEVELS)[number];
|
|
11
|
+
/**
|
|
12
|
+
* Effort levels the Anthropic Messages API accepts (GA, no beta header).
|
|
13
|
+
* Supported on Opus 4.5+ and Sonnet 5; `xhigh` arrived with Opus 4.7, and
|
|
14
|
+
* Sonnet 4.5 / Haiku 4.5 reject the parameter entirely.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ANTHROPIC_EFFORT_LEVELS: readonly ["low", "medium", "high", "xhigh", "max"];
|
|
17
|
+
export type AnthropicEffort = (typeof ANTHROPIC_EFFORT_LEVELS)[number];
|
|
18
|
+
/** Union of every effort level any supported provider accepts. */
|
|
19
|
+
export type ReasoningEffort = GroqEffort | OpenAIEffort | AnthropicEffort;
|
|
20
|
+
/**
|
|
21
|
+
* Shared provider settings.
|
|
22
|
+
*/
|
|
23
|
+
export interface BaseProviderConfig {
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
model: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the provider supports native structured output.
|
|
28
|
+
*/
|
|
29
|
+
isStructuredOutputSupported?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Sampling temperature. Only honoured by the `groq` provider — reasoning
|
|
32
|
+
* models reject sampling parameters, so use `effort` instead where available.
|
|
33
|
+
*/
|
|
34
|
+
temperature?: number;
|
|
35
|
+
maxTokens?: number;
|
|
36
|
+
topP?: number;
|
|
37
|
+
retries?: number;
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for Groq models.
|
|
42
|
+
*/
|
|
43
|
+
export interface GroqProviderConfig extends BaseProviderConfig {
|
|
44
|
+
provider: 'groq';
|
|
45
|
+
/** @default 'https://api.groq.com/openai/v1' */
|
|
46
|
+
baseUrl?: string;
|
|
47
|
+
/** How much reasoning the model should spend on a request. */
|
|
48
|
+
effort?: GroqEffort;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for OpenAI models.
|
|
52
|
+
*/
|
|
53
|
+
export interface OpenAIProviderConfig extends BaseProviderConfig {
|
|
54
|
+
provider: 'openai';
|
|
55
|
+
/**
|
|
56
|
+
* How much reasoning the model should spend on a request. Reasoning models
|
|
57
|
+
* only — a non-reasoning model such as `gpt-4o` rejects the parameter.
|
|
58
|
+
*/
|
|
59
|
+
effort?: OpenAIEffort;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Configuration for Anthropic models.
|
|
63
|
+
*/
|
|
64
|
+
export interface AnthropicProviderConfig extends BaseProviderConfig {
|
|
65
|
+
provider: 'anthropic';
|
|
66
|
+
/**
|
|
67
|
+
* How much reasoning the model should spend on a request. Only has an effect
|
|
68
|
+
* when {@link AnthropicProviderConfig.thinking} is left on.
|
|
69
|
+
*/
|
|
70
|
+
effort?: AnthropicEffort;
|
|
71
|
+
/**
|
|
72
|
+
* Whether to run with adaptive extended thinking, which improves accuracy on
|
|
73
|
+
* the arithmetic these templates do. Defaults to `true`. Opus 4.6+ /
|
|
74
|
+
* Sonnet 4.6+ only; older models reject it with an HTTP 400. Thinking tokens
|
|
75
|
+
* count against {@link BaseProviderConfig.maxTokens}, so keep that generous.
|
|
76
|
+
*/
|
|
77
|
+
thinking?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Configuration for Google models.
|
|
81
|
+
*/
|
|
82
|
+
export interface GoogleProviderConfig extends BaseProviderConfig {
|
|
83
|
+
provider: 'google';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Configuration for Mistral models.
|
|
87
|
+
*/
|
|
88
|
+
export interface MistralProviderConfig extends BaseProviderConfig {
|
|
89
|
+
provider: 'mistral';
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Configuration for OpenRouter models.
|
|
93
|
+
*/
|
|
94
|
+
export interface OpenRouterProviderConfig extends BaseProviderConfig {
|
|
95
|
+
provider: 'openrouter';
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Configuration for Ollama models.
|
|
99
|
+
*/
|
|
100
|
+
export interface OllamaProviderConfig extends BaseProviderConfig {
|
|
101
|
+
provider: 'ollama';
|
|
102
|
+
/** @default 'http://localhost:11434/v1' */
|
|
103
|
+
baseUrl?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Configuration for OpenAI-compatible providers.
|
|
107
|
+
*/
|
|
108
|
+
export interface OpenAICompatibleProviderConfig extends BaseProviderConfig {
|
|
109
|
+
provider: 'openai-compatible';
|
|
110
|
+
/** Base URL of the OpenAI-compatible API. */
|
|
111
|
+
customEndpoint: string;
|
|
112
|
+
}
|
|
113
|
+
export type LLMProviderConfig = GroqProviderConfig | OpenAIProviderConfig | AnthropicProviderConfig | GoogleProviderConfig | MistralProviderConfig | OpenRouterProviderConfig | OllamaProviderConfig | OpenAICompatibleProviderConfig;
|
|
114
|
+
/**
|
|
115
|
+
* Runtime configuration for the LLM executor.
|
|
116
|
+
*/
|
|
117
|
+
export interface LLMExecutorConfig {
|
|
118
|
+
mode: LLMMode;
|
|
119
|
+
provider: LLMProviderConfig;
|
|
120
|
+
verbose?: boolean;
|
|
121
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ANTHROPIC_EFFORT_LEVELS = exports.OPENAI_EFFORT_LEVELS = exports.GROQ_EFFORT_LEVELS = void 0;
|
|
17
|
+
/** Effort levels the Groq API accepts. */
|
|
18
|
+
exports.GROQ_EFFORT_LEVELS = ['none', 'low', 'medium', 'high'];
|
|
19
|
+
/**
|
|
20
|
+
* Effort levels the OpenAI Chat Completions API accepts. Only reasoning models
|
|
21
|
+
* take the parameter at all — a non-reasoning model (e.g. `gpt-4o`) rejects it.
|
|
22
|
+
*/
|
|
23
|
+
exports.OPENAI_EFFORT_LEVELS = ['minimal', 'low', 'medium', 'high'];
|
|
24
|
+
/**
|
|
25
|
+
* Effort levels the Anthropic Messages API accepts (GA, no beta header).
|
|
26
|
+
* Supported on Opus 4.5+ and Sonnet 5; `xhigh` arrived with Opus 4.7, and
|
|
27
|
+
* Sonnet 4.5 / Haiku 4.5 reject the parameter entirely.
|
|
28
|
+
*/
|
|
29
|
+
exports.ANTHROPIC_EFFORT_LEVELS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
30
|
+
//# sourceMappingURL=LLMConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMConfig.js","sourceRoot":"","sources":["../../src/llm/LLMConfig.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAIH,0CAA0C;AAC7B,QAAA,kBAAkB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAI7E;;;GAGG;AACU,QAAA,oBAAoB,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAIlF;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Template } from '@accordproject/cicero-core';
|
|
2
|
+
import { LLMExecutorConfig } from './LLMConfig';
|
|
3
|
+
import type { TriggerResponse, InitResponse } from '../TemplateArchiveProcessor';
|
|
4
|
+
/**
|
|
5
|
+
* Executes an Accord Project template's `init` / `trigger` operations using an
|
|
6
|
+
* LLM, deriving the request/response/state/event schemas from the template's own
|
|
7
|
+
* ModelManager. Used as a fallback when a template carries no executable logic,
|
|
8
|
+
* or when LLM execution is explicitly forced.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LLMExecutor {
|
|
11
|
+
/** The template being executed. */
|
|
12
|
+
private readonly template;
|
|
13
|
+
private readonly config;
|
|
14
|
+
private readonly reasoner;
|
|
15
|
+
private readonly fullSchema;
|
|
16
|
+
/**
|
|
17
|
+
* True when the schema defines no custom State type (only the base runtime
|
|
18
|
+
* State). Stateless templates return `{}` from init and omit `state` from
|
|
19
|
+
* trigger responses entirely.
|
|
20
|
+
*/
|
|
21
|
+
private readonly stateless;
|
|
22
|
+
/** Schema instances are per-executor so the object reference is stable for
|
|
23
|
+
* Anthropic's 24-hour grammar cache (same object = cache hit).
|
|
24
|
+
* For full-schema providers the defs are derived from the template's own
|
|
25
|
+
* ModelManager via tree-shaking — no external schema.json required. */
|
|
26
|
+
private readonly initSchema;
|
|
27
|
+
private readonly triggerSchema;
|
|
28
|
+
private readonly roots;
|
|
29
|
+
private readonly promptSchema;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an executor for a template.
|
|
32
|
+
* @param template - template to execute
|
|
33
|
+
* @param config - LLM configuration
|
|
34
|
+
*/
|
|
35
|
+
constructor(template: Template, config: LLMExecutorConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Builds the shared prompt context.
|
|
38
|
+
* @returns prompt context
|
|
39
|
+
*/
|
|
40
|
+
private buildSharedContext;
|
|
41
|
+
/**
|
|
42
|
+
* Sends a request to the active reasoner with retries.
|
|
43
|
+
* @param messages - the chat messages to send
|
|
44
|
+
* @param schema - the JSON Schema the response must satisfy
|
|
45
|
+
* @returns the model response content
|
|
46
|
+
* @throws the last error if every attempt fails
|
|
47
|
+
*/
|
|
48
|
+
private ask;
|
|
49
|
+
/**
|
|
50
|
+
* Computes the initial contract state.
|
|
51
|
+
* @param data - the data for the template
|
|
52
|
+
* @param currentTime - the current time, defaults to now
|
|
53
|
+
* @param utcOffset - the UTC offset, defaults to zero
|
|
54
|
+
* @returns the new state
|
|
55
|
+
*/
|
|
56
|
+
init(data: any, currentTime?: string, utcOffset?: number): Promise<InitResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Evaluates a trigger request.
|
|
59
|
+
*
|
|
60
|
+
* Stateful templates (`!this.stateless`) must always be evaluated against
|
|
61
|
+
* `priorState` — the state produced by a prior call to {@link init} (or by
|
|
62
|
+
* a prior call to `trigger`) — since there is no implicit "empty" state for
|
|
63
|
+
* a template that declares custom State fields. Stateless templates ignore
|
|
64
|
+
* `priorState` entirely.
|
|
65
|
+
* @param data - the data for the template
|
|
66
|
+
* @param request - the request to send to the contract logic
|
|
67
|
+
* @param priorState - the state to evaluate the request against. Required
|
|
68
|
+
* for stateful templates (must originate from init() or a previous
|
|
69
|
+
* trigger()); ignored for stateless templates.
|
|
70
|
+
* @param currentTime - the current time. Only used when the request carries
|
|
71
|
+
* no `$timestamp`, which always takes precedence; defaults to now
|
|
72
|
+
* @param utcOffset - the UTC offset, defaults to zero
|
|
73
|
+
* @returns the response, updated state, and any events
|
|
74
|
+
* @throws {Error} if the template is stateful and no priorState is supplied
|
|
75
|
+
*/
|
|
76
|
+
trigger(data: any, request: any, priorState?: any, currentTime?: string, utcOffset?: number): Promise<TriggerResponse>;
|
|
77
|
+
}
|