@accordproject/template-engine 4.0.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.
Files changed (37) hide show
  1. package/lib/TemplateArchiveProcessor.d.ts +93 -3
  2. package/lib/TemplateArchiveProcessor.js +322 -27
  3. package/lib/TemplateArchiveProcessor.js.map +1 -1
  4. package/lib/TypeScriptCompilationContext.d.ts +27 -0
  5. package/lib/TypeScriptCompilationContext.js +116 -3
  6. package/lib/TypeScriptCompilationContext.js.map +1 -1
  7. package/lib/drafting/MonetaryAmount/formatTokens.d.ts +13 -0
  8. package/lib/drafting/MonetaryAmount/formatTokens.js +44 -0
  9. package/lib/drafting/MonetaryAmount/formatTokens.js.map +1 -0
  10. package/lib/drafting/MonetaryAmount/index.js +2 -18
  11. package/lib/drafting/MonetaryAmount/index.js.map +1 -1
  12. package/lib/drafting/PreciseAmount/index.d.ts +17 -0
  13. package/lib/drafting/PreciseAmount/index.js +113 -0
  14. package/lib/drafting/PreciseAmount/index.js.map +1 -0
  15. package/lib/drafting/index.js +24 -4
  16. package/lib/drafting/index.js.map +1 -1
  17. package/lib/llm/LLMConfig.d.ts +121 -0
  18. package/lib/llm/LLMConfig.js +30 -0
  19. package/lib/llm/LLMConfig.js.map +1 -0
  20. package/lib/llm/LLMExecutor.d.ts +77 -0
  21. package/lib/llm/LLMExecutor.js +603 -0
  22. package/lib/llm/LLMExecutor.js.map +1 -0
  23. package/lib/llm/ModelManagerSchema.d.ts +14 -0
  24. package/lib/llm/ModelManagerSchema.js +67 -0
  25. package/lib/llm/ModelManagerSchema.js.map +1 -0
  26. package/lib/llm/Reasoners.d.ts +190 -0
  27. package/lib/llm/Reasoners.js +643 -0
  28. package/lib/llm/Reasoners.js.map +1 -0
  29. package/lib/runtime/declarations.d.ts +0 -1
  30. package/lib/runtime/declarations.js +1 -2
  31. package/lib/runtime/declarations.js.map +1 -1
  32. package/lib/utils.d.ts +29 -0
  33. package/lib/utils.js +51 -0
  34. package/lib/utils.js.map +1 -1
  35. package/package.json +11 -2
  36. package/umd/template-engine.js +4 -4
  37. package/umd/template-engine.js.LICENSE.txt +1 -1
@@ -29,22 +29,135 @@ class TypeScriptCompilationContext {
29
29
  });
30
30
  return result;
31
31
  }
32
+ /**
33
+ * Builds a TypeScript union type over the concrete types assignable to a runtime
34
+ * base type (the base itself, when concrete, plus its subclasses), along with the
35
+ * imports required to reference them. Because the base is included, using the bare
36
+ * base type or any subclass type-checks. A plain concept that does not extend the
37
+ * base is still rejected structurally where the base carries a distinguishing member
38
+ * (Response/Event require `$timestamp`); State carries only `$identifier`, so a
39
+ * concept-shaped state is admitted here and instead enforced nominally at runtime
40
+ * (see TemplateArchiveProcessor.assertRuntimeHierarchy). When the base type is absent
41
+ * the union is `never`.
42
+ * @param {string} baseFqn the fully-qualified name of the runtime base type
43
+ * @param {string} aliasPrefix a unique prefix for the imported type aliases
44
+ * @returns {{imports: string, union: string}} the import statements and union type
45
+ */
46
+ buildRuntimeUnion(baseFqn, aliasPrefix) {
47
+ const types = (0, utils_1.getAssignableConcreteTypes)(this.modelManager, baseFqn);
48
+ if (types.length === 0) {
49
+ return { imports: '', union: 'never' };
50
+ }
51
+ const imports = [];
52
+ const members = [];
53
+ types.forEach((decl, index) => {
54
+ const alias = `${aliasPrefix}${index}`;
55
+ imports.push(`import type { I${decl.getName()} as ${alias} } from './generated/${decl.getNamespace()}';`);
56
+ members.push(alias);
57
+ });
58
+ return { imports: imports.join('\n'), union: members.join(' | ') };
59
+ }
60
+ /**
61
+ * Emits the runtime SmartLegalContract declarations (IConcept, TemplateLogic, etc.)
62
+ * with the State / Request / Response / Event type positions bound to the model-derived
63
+ * Runtime* unions (the concrete base type plus its subclasses; see buildRuntimeUnion).
64
+ * Because the concrete base is included, using the bare base type or a subclass
65
+ * type-checks. Types that are structurally incompatible with the base still fail here
66
+ * (Response/Event require `$timestamp`); State carries only `$identifier`, so a
67
+ * concept-shaped state type-checks and is instead enforced nominally at runtime (see
68
+ * TemplateArchiveProcessor.assertRuntimeHierarchy).
69
+ * @returns {string} the runtime declarations, as a TypeScript source string
70
+ */
71
+ getRuntimeDeclarations() {
72
+ const state = this.buildRuntimeUnion(utils_1.RUNTIME_STATE_FQN, '__RtState');
73
+ const request = this.buildRuntimeUnion(utils_1.RUNTIME_REQUEST_FQN, '__RtRequest');
74
+ const response = this.buildRuntimeUnion(utils_1.RUNTIME_RESPONSE_FQN, '__RtResponse');
75
+ const event = this.buildRuntimeUnion(utils_1.BASE_EVENT_FQN, '__RtEvent');
76
+ return `
77
+ ${state.imports}
78
+ ${request.imports}
79
+ ${response.imports}
80
+ ${event.imports}
81
+
82
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
83
+ // Runtime declarations injected by the template engine. The Runtime* unions are
84
+ // derived from the template's Concerto model so that the type checker enforces the
85
+ // runtime State / Request / Response / Event class hierarchies.
86
+ interface IConcept {
87
+ $class: string;
88
+ }
89
+ interface ITransaction extends IConcept {
90
+ $timestamp: Date;
91
+ }
92
+ interface IEvent extends IConcept {
93
+ $timestamp: Date;
94
+ }
95
+ interface IState {
96
+ $identifier: string;
97
+ }
98
+ interface IRequest extends ITransaction {
99
+ }
100
+ interface IResponse extends ITransaction {
101
+ }
102
+ interface IAsset extends IConcept {
103
+ $identifier: string;
104
+ }
105
+ interface IContract extends IAsset {
106
+ contractId: string;
107
+ }
108
+ interface IClause extends IAsset {
109
+ clauseId: string;
110
+ }
111
+
112
+ // The concrete types assignable to each runtime base (the base itself, when concrete,
113
+ // plus its subclasses; never when the base is absent). Used as the state type-parameter
114
+ // bound, the request parameter, the result type and the emitted event type: a type that is
115
+ // structurally incompatible with the base (e.g. a plain concept lacking $timestamp used as
116
+ // a response/event) fails to compile. State is enforced nominally at runtime instead.
117
+ type RuntimeState = ${state.union};
118
+ type RuntimeRequest = ${request.union};
119
+ type RuntimeResponse = ${response.union};
120
+ type RuntimeEvent = ${event.union};
121
+
122
+ interface EngineResponse<S extends RuntimeState> {
123
+ state?: S;
124
+ events?: Array<RuntimeEvent>
125
+ }
126
+ interface TriggerResponse<S extends RuntimeState = RuntimeState> extends EngineResponse<S> {
127
+ result: RuntimeResponse;
128
+ }
129
+ interface InitResponse<S extends RuntimeState> extends EngineResponse<S> {}
130
+
131
+ type TemplateData = IContract|IClause;
132
+
133
+ abstract class TemplateLogic<T extends TemplateData, S extends RuntimeState = RuntimeState> {
134
+ abstract trigger(data: T, request: RuntimeRequest, state:S) : Promise<TriggerResponse<S>>;
135
+ // A concrete (stub) implementation so the class emits runtime JS (user logic does
136
+ // \`extends TemplateLogic\`) and does not raise TS2391 for a missing body.
137
+ init(data: T) : Promise<InitResponse<S>|undefined> { return Promise.resolve(undefined); }
138
+ }
139
+ `;
140
+ }
32
141
  getCompilationContext() {
33
142
  const files = this.getTypeScriptFiles();
34
143
  let result = '';
144
+ // Emit the generated model files under a `generated/` folder so that the
145
+ // template logic's own `./generated/<namespace>` imports resolve inside the
146
+ // twoslash virtual filesystem. Without this the model types resolve to `any`
147
+ // and no type checking (including the State/Obligation hierarchy) can occur.
35
148
  Object.keys(files).forEach(key => {
36
149
  const content = files[key];
37
150
  result += `
38
- // @filename: ${key}
151
+ // @filename: generated/${key}
39
152
  ${content}
40
153
  `;
41
154
  });
42
155
  result += `
43
156
  // @filename: code.ts
44
- import * as TemplateModel from './${this.templateClass.getNamespace()}';
157
+ import * as TemplateModel from './generated/${this.templateClass.getNamespace()}';
45
158
  import dayjs from 'dayjs';
46
159
  import jp from 'jsonpath';
47
-
160
+ ${this.getRuntimeDeclarations()}
48
161
  type GenerationOptions = {
49
162
  now?:string,
50
163
  locale?:string
@@ -1 +1 @@
1
- {"version":3,"file":"TypeScriptCompilationContext.js","sourceRoot":"","sources":["../src/TypeScriptCompilationContext.ts"],"names":[],"mappings":";;;AAcA,sEAA0D;AAC1D,gEAA8D;AAC9D,mCAAsD;AAEtD;;;;;;GAMG;AACH,MAAa,4BAA4B;IAKrC,YAAY,YAAyB,EAAC,kBAA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AC,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 currencycode_1 = require("./currencycode");
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;;AAuDH,wCAMC;AA3DD,6CAAmD;AACnD,6CAAqD;AAErD,iDAA8C;AAO9C;;;;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;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,CAAQ;IACxB,MAAM,KAAK,GAAW,MAAM,CAAC,IAAI,CAAC,2BAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;I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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,C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AAC;SAAM,CAAC;QACJ,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;AACL,CAAC"}
@@ -25,17 +25,37 @@ const Integer_1 = __importDefault(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.3.0.MonetaryAmount': return MonetaryAmount_1.default;
37
- case 'org.accordproject.time@0.3.0.Duration': return Duration_1.default;
38
- case 'org.accordproject.time@0.3.0.Period': return Duration_1.default;
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;;;;;AAcH,gCAaC;AAzBD,uDAAuD;AAEvD,wDAAuC;AACvC,0DAAyC;AACzC,sDAAqC;AACrC,wDAAuC;AACvC,0DAAyC;AACzC,kDAAiC;AACjC,sEAAqD;AAErD,sDAAqC;AAErC,SAAgB,UAAU,CAAC,QAAgB;IACvC,QAAO,QAAQ,EAAE,CAAC;QAClB,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,8CAA8C,CAAC,CAAC,OAAO,wBAAqB,CAAC;QAClF,KAAK,uCAAuC,CAAC,CAAC,OAAO,kBAAe,CAAC;QACrE,KAAK,qCAAqC,CAAC,CAAC,OAAO,kBAAe,CAAC;QACnE,KAAK,QAAQ,CAAC,CAAC,OAAO,gBAAa,CAAC;QACpC,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC;IACrB,CAAC;AACL,CAAC"}
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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BAAa,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"}