@memberjunction/ai 6.1.4 → 6.2.0-edge.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 (52) hide show
  1. package/dist/generic/baseDecision.d.ts +125 -0
  2. package/dist/generic/baseDecision.d.ts.map +1 -0
  3. package/dist/generic/baseDecision.js +387 -0
  4. package/dist/generic/baseDecision.js.map +1 -0
  5. package/dist/generic/baseImage.js +10 -10
  6. package/dist/generic/baseImage.js.map +1 -1
  7. package/dist/generic/baseLLM.d.ts +55 -1
  8. package/dist/generic/baseLLM.d.ts.map +1 -1
  9. package/dist/generic/baseLLM.js +44 -2
  10. package/dist/generic/baseLLM.js.map +1 -1
  11. package/dist/generic/baseModel.js +3 -3
  12. package/dist/generic/baseModel.js.map +1 -1
  13. package/dist/generic/baseRealtimeChannelServer.d.ts +1 -1
  14. package/dist/generic/baseRealtimeChannelServer.js +1 -1
  15. package/dist/generic/chat.types.d.ts +28 -0
  16. package/dist/generic/chat.types.d.ts.map +1 -1
  17. package/dist/generic/chat.types.js +51 -11
  18. package/dist/generic/chat.types.js.map +1 -1
  19. package/dist/generic/classify.types.d.ts +11 -0
  20. package/dist/generic/classify.types.d.ts.map +1 -1
  21. package/dist/generic/classify.types.js +11 -0
  22. package/dist/generic/classify.types.js.map +1 -1
  23. package/dist/generic/decision.types.d.ts +201 -0
  24. package/dist/generic/decision.types.d.ts.map +1 -0
  25. package/dist/generic/decision.types.js +29 -0
  26. package/dist/generic/decision.types.js.map +1 -0
  27. package/dist/generic/errorAnalyzer.d.ts +2 -0
  28. package/dist/generic/errorAnalyzer.d.ts.map +1 -1
  29. package/dist/generic/errorAnalyzer.js +17 -8
  30. package/dist/generic/errorAnalyzer.js.map +1 -1
  31. package/dist/generic/linearTextScan.d.ts +18 -0
  32. package/dist/generic/linearTextScan.d.ts.map +1 -0
  33. package/dist/generic/linearTextScan.js +70 -0
  34. package/dist/generic/linearTextScan.js.map +1 -0
  35. package/dist/generic/modelConfiguration.d.ts +68 -3
  36. package/dist/generic/modelConfiguration.d.ts.map +1 -1
  37. package/dist/generic/modelConfiguration.js +26 -5
  38. package/dist/generic/modelConfiguration.js.map +1 -1
  39. package/dist/generic/openAICompatibleTools.d.ts +10 -0
  40. package/dist/generic/openAICompatibleTools.d.ts.map +1 -1
  41. package/dist/generic/openAICompatibleTools.js +27 -7
  42. package/dist/generic/openAICompatibleTools.js.map +1 -1
  43. package/dist/generic/summarize.types.d.ts +7 -0
  44. package/dist/generic/summarize.types.d.ts.map +1 -1
  45. package/dist/generic/summarize.types.js +7 -0
  46. package/dist/generic/summarize.types.js.map +1 -1
  47. package/dist/index.d.ts +2 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +2 -0
  50. package/dist/index.js.map +1 -1
  51. package/package.json +2 -2
  52. package/readme.md +8 -4
@@ -2,14 +2,25 @@ import { BaseResult } from "./baseModel.js";
2
2
  import { ChatParams } from "./chat.types.js";
3
3
  /**
4
4
  * Defined in order to have this type available for future use with additional properties beyond the BaseParams type.
5
+ *
6
+ * @deprecated Used only by the deprecated `BaseLLM.ClassifyText`. Will be removed in the next
7
+ * major version.
5
8
  */
6
9
  export declare class ClassifyParams extends ChatParams {
7
10
  }
11
+ /**
12
+ * @deprecated Used only by the deprecated `BaseLLM.ClassifyText`. Will be removed in the next
13
+ * major version.
14
+ */
8
15
  export declare class ClassifyTag {
9
16
  constructor(tag: string, confidence: number);
10
17
  tag: string;
11
18
  confidence: number;
12
19
  }
20
+ /**
21
+ * @deprecated Used only by the deprecated `BaseLLM.ClassifyText`. Will be removed in the next
22
+ * major version.
23
+ */
13
24
  export declare class ClassifyResult extends BaseResult {
14
25
  inputText: string;
15
26
  tags: ClassifyTag[];
@@ -1 +1 @@
1
- {"version":3,"file":"classify.types.d.ts","sourceRoot":"","sources":["../../src/generic/classify.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;CAC7C;AAED,qBAAa,WAAW;gBACR,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAI3C,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACrB;AAED,qBAAa,cAAe,SAAQ,UAAU;IAC1C,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACxB"}
1
+ {"version":3,"file":"classify.types.d.ts","sourceRoot":"","sources":["../../src/generic/classify.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,UAAU;CAC7C;AAED;;;GAGG;AACH,qBAAa,WAAW;gBACR,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAI3C,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC1C,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACxB"}
@@ -2,15 +2,26 @@ import { BaseResult } from "./baseModel.js";
2
2
  import { ChatParams } from "./chat.types.js";
3
3
  /**
4
4
  * Defined in order to have this type available for future use with additional properties beyond the BaseParams type.
5
+ *
6
+ * @deprecated Used only by the deprecated `BaseLLM.ClassifyText`. Will be removed in the next
7
+ * major version.
5
8
  */
6
9
  export class ClassifyParams extends ChatParams {
7
10
  }
11
+ /**
12
+ * @deprecated Used only by the deprecated `BaseLLM.ClassifyText`. Will be removed in the next
13
+ * major version.
14
+ */
8
15
  export class ClassifyTag {
9
16
  constructor(tag, confidence) {
10
17
  this.tag = tag;
11
18
  this.confidence = confidence;
12
19
  }
13
20
  }
21
+ /**
22
+ * @deprecated Used only by the deprecated `BaseLLM.ClassifyText`. Will be removed in the next
23
+ * major version.
24
+ */
14
25
  export class ClassifyResult extends BaseResult {
15
26
  }
16
27
  //# sourceMappingURL=classify.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"classify.types.js","sourceRoot":"","sources":["../../src/generic/classify.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;CAC7C;AAED,MAAM,OAAO,WAAW;IACpB,YAAY,GAAW,EAAE,UAAkB;QACvC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;CAGJ;AAED,MAAM,OAAO,cAAe,SAAQ,UAAU;CAI7C"}
1
+ {"version":3,"file":"classify.types.js","sourceRoot":"","sources":["../../src/generic/classify.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;CAC7C;AAED;;;GAGG;AACH,MAAM,OAAO,WAAW;IACpB,YAAY,GAAW,EAAE,UAAkB;QACvC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;CAGJ;AAED;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;CAI7C"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * @fileoverview Core type definitions for the MemberJunction AI Decision system.
3
+ *
4
+ * These types define the contract for typed decision operations across all providers
5
+ * (LLM-based, purpose-built decision models, etc.) and are used by the BaseDecision abstract class.
6
+ *
7
+ * @module @memberjunction/ai
8
+ */
9
+ import { BaseResult, ModelUsage } from './baseModel.js';
10
+ /**
11
+ * A decision question with a yes/no outcome, asking whether a statement is true.
12
+ * Returns a LikelihoodAnswer with a single probability in [0, 1].
13
+ * The probability is the confidence; there is no separate confidence field.
14
+ */
15
+ export interface LikelihoodQuestion {
16
+ /**
17
+ * Discriminator identifying this as a likelihood question.
18
+ */
19
+ Kind: 'Likelihood';
20
+ /**
21
+ * Instructions describing what statement is being evaluated.
22
+ * Question keys are identifiers for code, not instructions to the model.
23
+ */
24
+ Instructions: string;
25
+ }
26
+ /**
27
+ * An individual option for a ChoiceQuestion.
28
+ */
29
+ export interface ChoiceOption {
30
+ /**
31
+ * Identifier value for code. Option values are identifiers for code
32
+ * and carry no meaning to the model.
33
+ */
34
+ Value: string;
35
+ /**
36
+ * Description read by the model explaining what this option represents.
37
+ */
38
+ Description: string;
39
+ }
40
+ /**
41
+ * A decision question selecting one label from an enumerated set of options.
42
+ * Requires at least 2 options with unique, non-empty values and non-empty descriptions.
43
+ */
44
+ export interface ChoiceQuestion {
45
+ /**
46
+ * Discriminator identifying this as a choice question.
47
+ */
48
+ Kind: 'Choice';
49
+ /**
50
+ * Instructions describing the selection criteria.
51
+ * Question keys are identifiers for code, not instructions to the model.
52
+ */
53
+ Instructions: string;
54
+ /**
55
+ * Candidate options to choose from (minimum 2).
56
+ */
57
+ Options: ChoiceOption[];
58
+ }
59
+ /**
60
+ * A decision question placing the state on an ordered rubric scale.
61
+ * Requires at least 2 levels ordered from lowest to highest.
62
+ */
63
+ export interface ScoreQuestion {
64
+ /**
65
+ * Discriminator identifying this as a score question.
66
+ */
67
+ Kind: 'Score';
68
+ /**
69
+ * Instructions describing the scoring rubric.
70
+ * Question keys are identifiers for code, not instructions to the model.
71
+ */
72
+ Instructions: string;
73
+ /**
74
+ * Ordered rubric levels from lowest to highest (minimum 2).
75
+ */
76
+ Levels: string[];
77
+ }
78
+ /**
79
+ * Union of all supported decision question types.
80
+ */
81
+ export type DecisionQuestion = LikelihoodQuestion | ChoiceQuestion | ScoreQuestion;
82
+ /**
83
+ * Discriminator kind for decision questions ('Likelihood' | 'Choice' | 'Score').
84
+ */
85
+ export type DecisionQuestionKind = DecisionQuestion['Kind'];
86
+ /**
87
+ * Parameters for a decision operation.
88
+ */
89
+ export interface DecisionParams {
90
+ /**
91
+ * Provider API name (AIModelVendor.APIName) passed to the driver.
92
+ */
93
+ Model: string;
94
+ /**
95
+ * The state the questions are asked about. Keep it narrow to avoid state projection degradation.
96
+ * Can be a non-empty string or an object with at least one key.
97
+ */
98
+ State: string | Record<string, unknown>;
99
+ /**
100
+ * Named questions, answered in one call.
101
+ * Question keys identify answers in code and are NOT instructions to the model.
102
+ */
103
+ Questions: Record<string, DecisionQuestion>;
104
+ /**
105
+ * Optional signal for cancelling the request. The driver is responsible for honoring it:
106
+ * `BaseDecision.Decide()` does not check it and calls the driver even when it is already
107
+ * aborted, as `BaseLLM` does with `ChatParams.cancellationToken`. A driver that stops because
108
+ * the signal fired either returns a failed result or throws; in both cases `Decide()`
109
+ * resolves with `success: false` and empty `Answers`.
110
+ */
111
+ CancellationToken?: AbortSignal;
112
+ }
113
+ /**
114
+ * Answer to a LikelihoodQuestion.
115
+ */
116
+ export interface LikelihoodAnswer {
117
+ /**
118
+ * Discriminator identifying this as a likelihood answer.
119
+ */
120
+ Kind: 'Likelihood';
121
+ /**
122
+ * Probability that the statement is true, in [0, 1].
123
+ * The probability is the confidence; there is no separate confidence field.
124
+ */
125
+ Probability: number;
126
+ }
127
+ /**
128
+ * Answer to a ChoiceQuestion.
129
+ */
130
+ export interface ChoiceAnswer {
131
+ /**
132
+ * Discriminator identifying this as a choice answer.
133
+ */
134
+ Kind: 'Choice';
135
+ /**
136
+ * The selected option value (matches one of the ChoiceOption.Value identifiers).
137
+ */
138
+ Value: string;
139
+ /**
140
+ * Probability distribution keyed by option Value.
141
+ * Probabilities must sum to 1 within +-0.01.
142
+ */
143
+ Probabilities: Record<string, number>;
144
+ /**
145
+ * Confidence score in [0, 1] for the choice.
146
+ */
147
+ Confidence: number;
148
+ }
149
+ /**
150
+ * Answer to a ScoreQuestion.
151
+ */
152
+ export interface ScoreAnswer {
153
+ /**
154
+ * Discriminator identifying this as a score answer.
155
+ */
156
+ Kind: 'Score';
157
+ /**
158
+ * Continuous position from 0 (the first level) to Levels.length - 1 (the last level).
159
+ * Drivers map any vendor scale onto this.
160
+ */
161
+ Value: number;
162
+ /**
163
+ * Probability distribution keyed by level name.
164
+ * Probabilities must sum to 1 within +-0.01.
165
+ */
166
+ Probabilities: Record<string, number>;
167
+ /**
168
+ * Confidence score in [0, 1] for the score.
169
+ */
170
+ Confidence: number;
171
+ }
172
+ /**
173
+ * Union of all supported decision answer types.
174
+ */
175
+ export type DecisionAnswer = LikelihoodAnswer | ChoiceAnswer | ScoreAnswer;
176
+ /**
177
+ * Result of a decision operation, extending BaseResult with decision answers and telemetry.
178
+ */
179
+ export declare class DecisionResult extends BaseResult {
180
+ /**
181
+ * Map of answers matching the input Questions by key.
182
+ * Empty on failure so consumers never act on partial or malformed answers.
183
+ */
184
+ Answers: Record<string, DecisionAnswer>;
185
+ /**
186
+ * Optional token or unit usage details for cost tracking.
187
+ */
188
+ Usage?: ModelUsage;
189
+ /**
190
+ * The vendor's dated or concrete model identifier when the request used an alias.
191
+ */
192
+ ResolvedModel?: string;
193
+ /**
194
+ * Creates a new DecisionResult instance.
195
+ * @param success Whether the decision operation was successful.
196
+ * @param startTime Execution start timestamp.
197
+ * @param endTime Execution end timestamp.
198
+ */
199
+ constructor(success: boolean, startTime: Date, endTime: Date);
200
+ }
201
+ //# sourceMappingURL=decision.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.types.d.ts","sourceRoot":"","sources":["../../src/generic/decision.types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,M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ED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IAEd;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,YAAY,GAAG,WAAW,CAAC;AAE3E;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC1C;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAM;IAE7C;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;gBACS,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI;CAG/D"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fileoverview Core type definitions for the MemberJunction AI Decision system.
3
+ *
4
+ * These types define the contract for typed decision operations across all providers
5
+ * (LLM-based, purpose-built decision models, etc.) and are used by the BaseDecision abstract class.
6
+ *
7
+ * @module @memberjunction/ai
8
+ */
9
+ import { BaseResult } from './baseModel.js';
10
+ /**
11
+ * Result of a decision operation, extending BaseResult with decision answers and telemetry.
12
+ */
13
+ export class DecisionResult extends BaseResult {
14
+ /**
15
+ * Creates a new DecisionResult instance.
16
+ * @param success Whether the decision operation was successful.
17
+ * @param startTime Execution start timestamp.
18
+ * @param endTime Execution end timestamp.
19
+ */
20
+ constructor(success, startTime, endTime) {
21
+ super(success, startTime, endTime);
22
+ /**
23
+ * Map of answers matching the input Questions by key.
24
+ * Empty on failure so consumers never act on partial or malformed answers.
25
+ */
26
+ this.Answers = {};
27
+ }
28
+ }
29
+ //# sourceMappingURL=decision.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.types.js","sourceRoot":"","sources":["../../src/generic/decision.types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAmMrD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAiB1C;;;;;OAKG;IACH,YAAY,OAAgB,EAAE,SAAe,EAAE,OAAa;QACxD,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAvBvC;;;WAGG;QACH,YAAO,GAAmC,EAAE,CAAC;IAoB7C,CAAC;CACJ"}
@@ -36,6 +36,8 @@ export declare class ErrorAnalyzer {
36
36
  * console.log(`Can retry: ${errorInfo.severity !== 'Fatal'}`);
37
37
  * ```
38
38
  */
39
+ static AnalyzeError(error: any, providerName?: string): AIErrorInfo;
40
+ /** @deprecated Use {@link AnalyzeError}. */
39
41
  static analyzeError(error: any, providerName?: string): AIErrorInfo;
40
42
  /**
41
43
  * Extracts HTTP status code from various error object structures.
@@ -1 +1 @@
1
- {"version":3,"file":"errorAnalyzer.d.ts","sourceRoot":"","sources":["../../src/generic/errorAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA8B,MAAM,iBAAiB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAa;IACtB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW;IAqDnE;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAUpC;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IA0IjC;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA0BhC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAyBlC;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA4BhC;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;CA6B1C"}
1
+ {"version":3,"file":"errorAnalyzer.d.ts","sourceRoot":"","sources":["../../src/generic/errorAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA8B,MAAM,iBAAiB,CAAC;AAG1E;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAa;IACtB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW;IAqDnE,4CAA4C;IAC5C,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW;IAInE;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAUpC;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IA6IjC;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA0BhC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAyBlC;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA4BhC;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;CA8B1C"}
@@ -1,3 +1,4 @@
1
+ import { ContainsInOrderOnOneLine, FirstBraceSpanOnOneLine } from './linearTextScan.js';
1
2
  /**
2
3
  * Utility class for analyzing errors from various AI providers and mapping them to standardized error information.
3
4
  * This class provides a consistent way to interpret errors across different provider SDKs.
@@ -35,7 +36,7 @@ export class ErrorAnalyzer {
35
36
  * console.log(`Can retry: ${errorInfo.severity !== 'Fatal'}`);
36
37
  * ```
37
38
  */
38
- static analyzeError(error, providerName) {
39
+ static AnalyzeError(error, providerName) {
39
40
  // Extract HTTP status code if available
40
41
  const httpStatusCode = this.extractHttpStatusCode(error);
41
42
  // Determine error type based on status code and error properties
@@ -80,6 +81,10 @@ export class ErrorAnalyzer {
80
81
  }
81
82
  };
82
83
  }
84
+ /** @deprecated Use {@link AnalyzeError}. */
85
+ static analyzeError(error, providerName) {
86
+ return this.AnalyzeError(error, providerName);
87
+ }
83
88
  /**
84
89
  * Extracts HTTP status code from various error object structures.
85
90
  * Different provider SDKs store status codes in different locations.
@@ -131,6 +136,7 @@ export class ErrorAnalyzer {
131
136
  errorString.includes('payment') || // Payment required errors
132
137
  errorString.includes('insufficient funds') ||
133
138
  errorString.includes('quota exceeded') ||
139
+ errorString.includes('usage limits') || // Anthropic spend cap — sent as a 400 invalid_request_error, which the status fallback would misread as a malformed request
134
140
  errorString.includes('balance') || // Account balance issues
135
141
  errorString.includes('no funds')) {
136
142
  return 'NoCredit';
@@ -178,9 +184,11 @@ export class ErrorAnalyzer {
178
184
  if (errorString.includes('required') ||
179
185
  errorString.includes('validation') ||
180
186
  errorString.includes('schema') ||
181
- /\w+\s+is\s+required/.test(errorString) || // Matches "X is required"
182
- /missing.*(?:field|property)/.test(errorString) || // Matches "missing field/property X"
183
- /(?:field|property).*missing/.test(errorString) || // Matches "field/property X missing"
187
+ // "X is required" is already covered by includes('required') above.
188
+ // Linear scans rather than /missing.*(?:field|property)/ and its reverse, which are polynomial
189
+ // on provider-controlled text (CodeQL js/polynomial-redos).
190
+ ContainsInOrderOnOneLine(errorString, ['missing'], ['field', 'property']) || // "missing field/property X"
191
+ ContainsInOrderOnOneLine(errorString, ['field', 'property'], ['missing']) || // "field/property X missing"
184
192
  /must\s+(?:be|have|contain)/.test(errorString)) { // Matches "X must be/have/contain Y"
185
193
  return 'VendorValidationError';
186
194
  }
@@ -352,10 +360,11 @@ export class ErrorAnalyzer {
352
360
  const errorMessage = error?.message || error?.errorMessage || '';
353
361
  if (errorMessage.includes('{') && errorMessage.includes('}')) {
354
362
  try {
355
- // Extract JSON from error message
356
- const jsonMatch = errorMessage.match(/\{.*\}/);
357
- if (jsonMatch) {
358
- const parsed = JSON.parse(jsonMatch[0]);
363
+ // Extract JSON from error message: a linear scan rather than /\{.*\}/, which is polynomial
364
+ // on provider-controlled text (CodeQL js/polynomial-redos).
365
+ const jsonSpan = FirstBraceSpanOnOneLine(errorMessage);
366
+ if (jsonSpan) {
367
+ const parsed = JSON.parse(jsonSpan);
359
368
  return parsed?.error?.code || parsed?.code || undefined;
360
369
  }
361
370
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errorAnalyzer.js","sourceRoot":"","sources":["../../src/generic/errorAnalyzer.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,aAAa;IACtB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,YAAY,CAAC,KAAU,EAAE,YAAqB;QACjD,wCAAwC;QACxC,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAEzD,iEAAiE;QACjE,MAAM,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAEjE,qBAAqB;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAEnD,mCAAmC;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAExD,mCAAmC;QACnC,MAAM,0BAA0B,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAEjE,8BAA8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,CAAC;oBACpC,OAAO,MAAM,EAAE,KAAK,EAAE,IAAI,IAAI,MAAM,EAAE,IAAI,IAAI,SAAS,CAAC;gBAC5D,CAAC;YACL,CAAC;YAAC,OAAO,UAAU,EAAE,CAAC;gBAClB,iDAAiD;YACrD,CAAC;QACL,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Linear-time replacements for regular expressions that CodeQL flags as polynomial
3
+ * (`js/polynomial-redos`) because they run over provider error text we don't control.
4
+ *
5
+ * Each function keeps the exact semantics of the expression it replaces, including that
6
+ * `.` in a JavaScript regex never crosses a line terminator (`\n`, `\r`, `\u2028`, `\u2029`).
7
+ */
8
+ /**
9
+ * True when some line of `text` contains one of `befores` followed, later on the same line,
10
+ * by one of `afters`. Equivalent to `/(?:b1|b2).*(?:a1|a2)/.test(text)`.
11
+ */
12
+ export declare function ContainsInOrderOnOneLine(text: string, befores: readonly string[], afters: readonly string[]): boolean;
13
+ /**
14
+ * The first `{…}` span on one line: from the leftmost `{` that has a `}` after it on the same
15
+ * line, through the last `}` on that line. Equivalent to `text.match(/\{.*\}/)?.[0] ?? null`.
16
+ */
17
+ export declare function FirstBraceSpanOnOneLine(text: string): string | null;
18
+ //# sourceMappingURL=linearTextScan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linearTextScan.d.ts","sourceRoot":"","sources":["../../src/generic/linearTextScan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAoBrH;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmBnE"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Linear-time replacements for regular expressions that CodeQL flags as polynomial
3
+ * (`js/polynomial-redos`) because they run over provider error text we don't control.
4
+ *
5
+ * Each function keeps the exact semantics of the expression it replaces, including that
6
+ * `.` in a JavaScript regex never crosses a line terminator (`\n`, `\r`, `\u2028`, `\u2029`).
7
+ */
8
+ /** True for the four characters a regex `.` refuses to match. */
9
+ function isLineTerminator(ch) {
10
+ return ch === '\n' || ch === '\r' || ch === '\u2028' || ch === '\u2029';
11
+ }
12
+ /** Index of the next line terminator at or after `from`, or `text.length` when there is none. */
13
+ function lineEndFrom(text, from) {
14
+ for (let i = from; i < text.length; i++) {
15
+ if (isLineTerminator(text[i])) {
16
+ return i;
17
+ }
18
+ }
19
+ return text.length;
20
+ }
21
+ /**
22
+ * True when some line of `text` contains one of `befores` followed, later on the same line,
23
+ * by one of `afters`. Equivalent to `/(?:b1|b2).*(?:a1|a2)/.test(text)`.
24
+ */
25
+ export function ContainsInOrderOnOneLine(text, befores, afters) {
26
+ let lineStart = 0;
27
+ while (lineStart <= text.length) {
28
+ const lineEnd = lineEndFrom(text, lineStart);
29
+ const line = text.slice(lineStart, lineEnd);
30
+ for (const before of befores) {
31
+ // The earliest occurrence leaves the most room for an `after`, so it is the only one to check.
32
+ const at = line.indexOf(before);
33
+ if (at < 0) {
34
+ continue;
35
+ }
36
+ for (const after of afters) {
37
+ if (line.indexOf(after, at + before.length) >= 0) {
38
+ return true;
39
+ }
40
+ }
41
+ }
42
+ lineStart = lineEnd + 1;
43
+ }
44
+ return false;
45
+ }
46
+ /**
47
+ * The first `{…}` span on one line: from the leftmost `{` that has a `}` after it on the same
48
+ * line, through the last `}` on that line. Equivalent to `text.match(/\{.*\}/)?.[0] ?? null`.
49
+ */
50
+ export function FirstBraceSpanOnOneLine(text) {
51
+ let searchFrom = 0;
52
+ while (searchFrom < text.length) {
53
+ const open = text.indexOf('{', searchFrom);
54
+ if (open < 0) {
55
+ return null;
56
+ }
57
+ const lineEnd = lineEndFrom(text, open);
58
+ // Search only this line. An unbounded lastIndexOf would scan back through every earlier
59
+ // line on each line with a `{` but no `}`, which is quadratic on multi-line input.
60
+ const line = text.slice(open, lineEnd);
61
+ const close = line.lastIndexOf('}');
62
+ if (close > 0) {
63
+ return line.slice(0, close + 1);
64
+ }
65
+ // No `}` after this `{` on its line, so none after any later `{` on that line either.
66
+ searchFrom = lineEnd + 1;
67
+ }
68
+ return null;
69
+ }
70
+ //# sourceMappingURL=linearTextScan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linearTextScan.js","sourceRoot":"","sources":["../../src/generic/linearTextScan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iEAAiE;AACjE,SAAS,gBAAgB,CAAC,EAAU;IAChC,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,QAAQ,CAAC;AAC5E,CAAC;AAED,iGAAiG;AACjG,SAAS,WAAW,CAAC,IAAY,EAAE,IAAY;IAC3C,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,CAAC;QACb,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY,EAAE,OAA0B,EAAE,MAAyB;IACxG,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,OAAO,SAAS,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAA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@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * The canonical AI configuration shapes + the pure cascade resolvers.
3
3
  *
4
- * The AI stack carries `nvarchar(max)` JSONType configuration bags at five levels, in two cascades.
4
+ * The AI stack carries `nvarchar(max)` JSONType configuration bags at six levels, in two cascades.
5
5
  * The MODEL CATALOG cascade describes the model:
6
6
  *
7
7
  * ```
8
8
  * MJ: AI Model Types . ModelConfiguration (type-wide default — e.g. every Realtime model)
9
9
  * < MJ: AI Models . ModelConfiguration (per-model)
10
- * < MJ: AI Model Vendors . ModelConfiguration (per model-on-this-provider — the winner)
10
+ * < MJ: AI Vendors . Configuration.ModelDefaults (host-wide default for every model this vendor serves)
11
+ * < MJ: AI Model Vendors . ModelConfiguration (per model-on-this-provider — the tie-breaker, wins)
11
12
  * ```
12
13
  *
13
14
  * The PROMPT cascade describes what a given prompt asks for, and layers on top of the catalog:
@@ -246,6 +247,25 @@ export interface LLMConfigurationSettings {
246
247
  * only when the gate resolves native.
247
248
  */
248
249
  NativeToolResults?: boolean | null;
250
+ /**
251
+ * **Catalog layers only.** Whether this serving path's prompt cache is an exact BYTE-PREFIX match:
252
+ * it reuses a prior request only when that request's entire prompt is a prefix of the new one
253
+ * (OpenAI's automatic cache, xAI). Per-iteration framework state must then be appended, never
254
+ * replaced, or the reusable prefix ends at the system prompt. Absent or `false` means a block or
255
+ * segment cache (Anthropic's explicit breakpoints, Gemini's implicit cache, Cerebras's sliding
256
+ * cache), where a trailing per-iteration message can be replaced in place — the safe default,
257
+ * since replace-in-place costs a block-cache provider nothing whereas append-only only grows the
258
+ * context.
259
+ *
260
+ * Set `true` under `Configuration.ModelDefaults` on the VENDOR row of a prefix-cache provider so
261
+ * every model it serves inherits it (the vendor default beats the model's own bag); a MODEL-VENDOR
262
+ * row overrides it, so a host that serves many models (Fireworks, Cerebras, Azure, Bedrock) can
263
+ * carry a per-model answer that differs from the vendor default.
264
+ *
265
+ * Consumed by the loop agent's trailing runtime-state layout: see `TrailingStateMode` in
266
+ * `@memberjunction/ai-agents`.
267
+ */
268
+ PrefixPromptCache?: boolean | null;
249
269
  }
250
270
  /** Vision knobs. Reserved — no consumers yet. */
251
271
  export interface VisionConfigurationSettings {
@@ -255,6 +275,24 @@ export interface VisionConfigurationSettings {
255
275
  export interface AudioConfigurationSettings {
256
276
  [key: string]: unknown;
257
277
  }
278
+ /**
279
+ * Typed-decision knobs, consumed at call time by the decision runner. They declare what a decision
280
+ * model accepts, so an oversized request can be refused with a clear message before the call,
281
+ * instead of being truncated or rejected by the provider. Each is a limit of the model itself: set
282
+ * it on the catalog layers (`MJ: AI Models`, `MJ: AI Model Vendors`). Absent means no limit is
283
+ * declared. A decision always needs at least two Choice options or Score levels; that minimum
284
+ * belongs to `BaseDecision`, not to this bag.
285
+ */
286
+ export interface DecisionConfigurationSettings {
287
+ /** The most questions one call may carry. */
288
+ MaxQuestionsPerCall?: number | null;
289
+ /** The most options one Choice question may list. */
290
+ MaxChoiceOptions?: number | null;
291
+ /** The most levels one Score question may list. */
292
+ MaxScoreLevels?: number | null;
293
+ /** The largest state the model reads, in tokens. */
294
+ MaxStateTokens?: number | null;
295
+ }
258
296
  /**
259
297
  * The per-modality bag common to every AI configuration column. Sections are optional and
260
298
  * per-modality so one row can configure everything the thing it describes does.
@@ -268,6 +306,8 @@ export interface AIConfigurationSections {
268
306
  Vision?: VisionConfigurationSettings | null;
269
307
  /** Audio (TTS/STT) knobs. Reserved. */
270
308
  Audio?: AudioConfigurationSettings | null;
309
+ /** Typed-decision limits. Honored at the catalog layers. */
310
+ Decision?: DecisionConfigurationSettings | null;
271
311
  }
272
312
  /**
273
313
  * The `ModelConfiguration` column on `MJ: AI Model Types`, `MJ: AI Models` and
@@ -297,9 +337,27 @@ export type LLMModelConfigurationSection = LLMConfigurationSettings;
297
337
  * @returns The parsed configuration, or `null` when the layer contributes nothing.
298
338
  */
299
339
  export declare function ParseModelConfiguration(json: string | null | undefined): AIModelConfiguration | null;
340
+ /**
341
+ * `MJ: AI Vendors . Configuration` — the vendor's own configuration bag (lockstep with
342
+ * `IAIVendorConfiguration` in the metadata interface). General-purpose; its first key,
343
+ * {@link AIVendorConfiguration.ModelDefaults}, is the vendor layer of the model-configuration cascade.
344
+ */
345
+ export interface AIVendorConfiguration {
346
+ /**
347
+ * The default model configuration for every model this vendor serves. Resolved ABOVE the
348
+ * model's own bag and BELOW the model-vendor row (the tie-breaker); merged per key, so it only
349
+ * touches the keys it sets.
350
+ */
351
+ ModelDefaults?: AIModelConfiguration | null;
352
+ }
353
+ /**
354
+ * Tolerant parse of one `AIVendor.Configuration` column value — the same contract as
355
+ * {@link ParseModelConfiguration}: absent, blank, malformed or non-object JSON contributes nothing.
356
+ */
357
+ export declare function ParseVendorConfiguration(json: string | null | undefined): AIVendorConfiguration | null;
300
358
  /**
301
359
  * Resolves the EFFECTIVE model configuration by deep-merging the catalog layers, base first —
302
- * type default < model < model-vendor. Merge semantics are identical to the realtime config
360
+ * type default < model < vendor default < model-vendor. Merge semantics are identical to the realtime config
303
361
  * cascade (`DeepMergeConfigs` in `@memberjunction/ai-agents` — duplicated here because package
304
362
  * layering runs the other way):
305
363
  *
@@ -312,4 +370,11 @@ export declare function ParseModelConfiguration(json: string | null | undefined)
312
370
  * @returns The merged configuration, or `null` when every layer is absent/empty.
313
371
  */
314
372
  export declare function ResolveEffectiveModelConfiguration(...layers: Array<AIModelConfiguration | null | undefined>): AIModelConfiguration | null;
373
+ /**
374
+ * Whether an effective model configuration declares a byte-prefix prompt cache
375
+ * (`LLM.PrefixPromptCache === true`). Absent, `null` or `false` all mean a block cache. Read through
376
+ * {@link ResolveEffectiveModelConfiguration} (or `AIEngineBase.GetEffectiveModelConfiguration`) so
377
+ * the most specific layer's answer wins.
378
+ */
379
+ export declare function IsPrefixPromptCache(config: AIModelConfiguration | null | undefined): boolean;
315
380
  //# sourceMappingURL=modelConfiguration.d.ts.map