@memberjunction/ai-openrouter 6.2.0-edge.3 → 6.2.0-edge.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -91,6 +91,33 @@ AI_VENDOR_API_KEY__OPENROUTERDECISION=sk-or-... # the same OpenRouter key as A
91
91
  Without a key the runner skips Jev and falls back to the next decision model (`LLM Decision`), and
92
92
  logs that once per process.
93
93
 
94
+ A bound AI Credential reaches the driver as its values in JSON (`{"apiKey":"…"}`). The driver sends
95
+ that credential's `apiKey` as the bearer token; a raw key from the environment variable is sent as
96
+ given.
97
+
98
+ **Kev-4B.** OpenRouter also serves Jared Palmer's Kev-4B (`jaredpalmer/kev-4b-20260924`, hosted by
99
+ SiliconFlow) through the same Decisions API, so the `Kev-4B` model's OpenRouter row uses
100
+ `OpenRouterDecision` and the same key. Its other route, a self-hosted Kev server, uses
101
+ `SystemOneDecision` in [`@memberjunction/ai-systemone`](../SystemOne/README.md).
102
+ `Default Decision` does not bind Kev-4B, but as an active Decision model it is one of the
103
+ power-matched fallbacks, after Jev and `LLM Decision`, for any host that has this key.
104
+
105
+ **Mercury Decide.** OpenRouter also serves it through the same Decisions API, in the System One format,
106
+ so the model's OpenRouter row uses `OpenRouterDecision` and the same key, with a pinned slug:
107
+ `inception/mercury-decide-20260930`, served by Inception, 65,536-token context, text only. Its own
108
+ vendor route, `InceptionDecision` in [`@memberjunction/ai-inception`](../Inception/README.md), has the
109
+ higher priority. The free variant (`inception/mercury-decide:free`) is not in the catalog: it has its
110
+ own rate limits and data policy.
111
+
112
+ It is a `Default Decision` power-matched fallback for a host with this key, among the last, because the
113
+ fallbacks follow PowerRank distance from `Default Decision`'s target rank.
114
+
115
+ **The wire format.** Jev and Kev speak the System One decisions format. `OpenRouterDecision` extends
116
+ `BaseSystemOneDecision` (`@memberjunction/ai`), which owns the request and answer mapping; this class
117
+ supplies only the endpoint and the default model. Cloudflare's Clef models speak the same format on
118
+ Workers AI, through `CloudflareDecision` in
119
+ [`@memberjunction/ai-cloudflare`](../Cloudflare/README.md).
120
+
94
121
  ## How It Works
95
122
 
96
123
  `OpenRouterLLM` is a thin subclass of `OpenAILLM` that redirects all API calls to OpenRouter's endpoint at `https://openrouter.ai/api/v1`. Since OpenRouter implements an OpenAI-compatible API, all chat, streaming, and parameter handling logic is inherited from the OpenAI provider.
@@ -1,10 +1,13 @@
1
- import { BaseDecision, DecisionParams, DecisionResult } from '@memberjunction/ai';
1
+ import { BaseSystemOneDecision } from '@memberjunction/ai';
2
2
  /**
3
3
  * A `BaseDecision` driver for OpenRouter's Decisions API, which serves TypeSafe's Jev decision
4
4
  * model. The API returns typed answers, so nothing is parsed from prose. Choice and Score
5
5
  * distributions are renormalised, because the API rounds each probability to two decimals.
6
+ *
7
+ * The wire mapping is the System One format's, in {@link BaseSystemOneDecision}; this class supplies
8
+ * the endpoint and the default model.
6
9
  */
7
- export declare class OpenRouterDecision extends BaseDecision {
10
+ export declare class OpenRouterDecision extends BaseSystemOneDecision {
8
11
  /** The OpenRouter Decisions API endpoint. */
9
12
  static readonly DEFAULT_ENDPOINT = "https://openrouter.ai/api/alpha/decisions";
10
13
  /** The model used when DecisionParams.Model is empty. */
@@ -13,30 +16,9 @@ export declare class OpenRouterDecision extends BaseDecision {
13
16
  constructor(apiKey: string, endpointURL?: string);
14
17
  /** The configured Decisions API endpoint URL. */
15
18
  get EndpointURL(): string;
16
- /**
17
- * Sends the questions to the Decisions API and maps its typed answers. An HTTP or network error
18
- * is thrown, carrying the HTTP `status`, so `Decide()` classifies it and rate limits and
19
- * server errors become failover-eligible.
20
- */
21
- protected DoDecide(params: DecisionParams): Promise<DecisionResult>;
22
- /** POSTs the request and returns the parsed JSON body. Throws on a non-2xx status. */
23
- private postRequest;
24
- /** Records the dated model version and usage, whenever the response carries them. */
25
- private recordTelemetry;
26
- /**
27
- * Marks the result failed because the response could not be mapped. Another model may still
28
- * answer, so the failure allows failover (and is not 'Fatal', which would stop the failover loop).
29
- */
30
- private fail;
31
- private buildRequestBody;
32
- /** Maps one question onto the wire: a Choice's options as `{ value: description }`, a Score's levels as an array. */
33
- private buildQuestion;
34
- private mapAnswer;
35
- /** Checks the answer's wire type, when the API sends one. */
36
- private typeMismatch;
37
- private mapLikelihood;
38
- private mapChoice;
39
- /** A Score's probabilities come keyed by level index ("0", "1", …); MJ keys them by level name. */
40
- private mapScore;
19
+ protected get ServiceName(): string;
20
+ protected get DefaultModel(): string;
21
+ /** The one endpoint, whatever the model: the model travels in the body. */
22
+ protected GetEndpointURL(_model: string): string;
41
23
  }
42
24
  //# sourceMappingURL=openRouterDecision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openRouterDecision.d.ts","sourceRoot":"","sources":["../../src/models/openRouterDecision.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAGZ,cAAc,EAEd,cAAc,EAGjB,MAAM,oBAAoB,CAAC;AAc5B;;;;GAIG;AACH,qBACa,kBAAmB,SAAQ,YAAY;IAChD,6CAA6C;IAC7C,gBAAuB,gBAAgB,+CAA+C;IAEtF,yDAAyD;IACzD,gBAAuB,aAAa,0BAA0B;IAE9D,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;IAOhD,iDAAiD;IACjD,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED;;;;OAIG;cACa,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAqBzE,sFAAsF;YACxE,WAAW;IAoBzB,qFAAqF;IACrF,OAAO,CAAC,eAAe;IAkBvB;;;OAGG;IACH,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,gBAAgB;IAQxB,qHAAqH;IACrH,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,SAAS;IAejB,6DAA6D;IAC7D,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,SAAS;IAkBjB,mGAAmG;IACnG,OAAO,CAAC,QAAQ;CAmBnB"}
1
+ {"version":3,"file":"openRouterDecision.d.ts","sourceRoot":"","sources":["../../src/models/openRouterDecision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGzE;;;;;;;GAOG;AACH,qBACa,kBAAmB,SAAQ,qBAAqB;IACzD,6CAA6C;IAC7C,gBAAuB,gBAAgB,+CAA+C;IAEtF,yDAAyD;IACzD,gBAAuB,aAAa,0BAA0B;IAE9D,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;IAOhD,iDAAiD;IACjD,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,SAAS,KAAK,WAAW,IAAI,MAAM,CAElC;IAED,SAAS,KAAK,YAAY,IAAI,MAAM,CAEnC;IAED,2EAA2E;IAC3E,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAGnD"}
@@ -8,19 +8,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  var OpenRouterDecision_1;
11
- import { BaseDecision, DecisionResult, ModelUsage, } from '@memberjunction/ai';
11
+ import { BaseDecision, BaseSystemOneDecision } from '@memberjunction/ai';
12
12
  import { RegisterClass } from '@memberjunction/global';
13
- /**
14
- * The Decisions API's name for a Likelihood question. It is both the wire `type` of the question
15
- * and the property that carries the answer's probability. The vendor's word stays at this boundary.
16
- */
17
- const WIRE_LIKELIHOOD = 'noul';
18
13
  /**
19
14
  * A `BaseDecision` driver for OpenRouter's Decisions API, which serves TypeSafe's Jev decision
20
15
  * model. The API returns typed answers, so nothing is parsed from prose. Choice and Score
21
16
  * distributions are renormalised, because the API rounds each probability to two decimals.
17
+ *
18
+ * The wire mapping is the System One format's, in {@link BaseSystemOneDecision}; this class supplies
19
+ * the endpoint and the default model.
22
20
  */
23
- let OpenRouterDecision = class OpenRouterDecision extends BaseDecision {
21
+ let OpenRouterDecision = class OpenRouterDecision extends BaseSystemOneDecision {
24
22
  static { OpenRouterDecision_1 = this; }
25
23
  /** The OpenRouter Decisions API endpoint. */
26
24
  static { this.DEFAULT_ENDPOINT = 'https://openrouter.ai/api/alpha/decisions'; }
@@ -36,166 +34,15 @@ let OpenRouterDecision = class OpenRouterDecision extends BaseDecision {
36
34
  get EndpointURL() {
37
35
  return this._endpointURL;
38
36
  }
39
- /**
40
- * Sends the questions to the Decisions API and maps its typed answers. An HTTP or network error
41
- * is thrown, carrying the HTTP `status`, so `Decide()` classifies it and rate limits and
42
- * server errors become failover-eligible.
43
- */
44
- async DoDecide(params) {
45
- const startTime = new Date();
46
- const model = params.Model && params.Model.trim().length > 0 ? params.Model.trim() : OpenRouterDecision_1.DEFAULT_MODEL;
47
- const response = await this.postRequest(this.buildRequestBody(model, params), params.CancellationToken);
48
- const result = new DecisionResult(true, startTime, new Date());
49
- this.recordTelemetry(result, response);
50
- const answers = isObject(response) ? response['answers'] : undefined;
51
- if (!isObject(answers)) {
52
- return this.fail(result, 'The Decisions API response has no answers object');
53
- }
54
- for (const [key, question] of Object.entries(params.Questions)) {
55
- const mapped = this.mapAnswer(key, question, answers);
56
- if ('errorMessage' in mapped) {
57
- return this.fail(result, mapped.errorMessage);
58
- }
59
- result.Answers[key] = mapped.answer;
60
- }
61
- return result;
62
- }
63
- /** POSTs the request and returns the parsed JSON body. Throws on a non-2xx status. */
64
- async postRequest(body, signal) {
65
- const res = await fetch(this.EndpointURL, {
66
- method: 'POST',
67
- headers: { Authorization: `Bearer ${this.apiKey}`, 'Content-Type': 'application/json' },
68
- body: JSON.stringify(body),
69
- signal,
70
- });
71
- if (!res.ok) {
72
- const snippet = (await res.text().catch(() => '')).slice(0, 500);
73
- const err = new Error(`OpenRouter Decisions API returned HTTP ${res.status}${snippet ? `: ${snippet}` : ''}`);
74
- err.status = res.status;
75
- throw err;
76
- }
77
- try {
78
- return await res.json();
79
- }
80
- catch (err) {
81
- throw new Error(`The OpenRouter Decisions API response is not JSON: ${err instanceof Error ? err.message : String(err)}`);
82
- }
83
- }
84
- /** Records the dated model version and usage, whenever the response carries them. */
85
- recordTelemetry(result, response) {
86
- if (!isObject(response)) {
87
- return;
88
- }
89
- if (typeof response['model'] === 'string') {
90
- result.ResolvedModel = response['model'];
91
- }
92
- const usage = response['usage'];
93
- if (isObject(usage)) {
94
- result.Usage = new ModelUsage(finiteOr(usage['input_tokens'], 0), finiteOr(usage['output_tokens'], 0), typeof usage['cost'] === 'number' ? usage['cost'] : undefined, 'USD');
95
- }
96
- }
97
- /**
98
- * Marks the result failed because the response could not be mapped. Another model may still
99
- * answer, so the failure allows failover (and is not 'Fatal', which would stop the failover loop).
100
- */
101
- fail(result, message) {
102
- result.success = false;
103
- result.errorMessage = message;
104
- result.errorInfo = { errorType: 'ModelError', severity: 'Retriable', canFailover: true };
105
- result.Answers = {};
106
- return result;
107
- }
108
- buildRequestBody(model, params) {
109
- const questions = {};
110
- for (const [key, question] of Object.entries(params.Questions)) {
111
- questions[key] = this.buildQuestion(question);
112
- }
113
- return { model, state: params.State, questions };
114
- }
115
- /** Maps one question onto the wire: a Choice's options as `{ value: description }`, a Score's levels as an array. */
116
- buildQuestion(question) {
117
- switch (question.Kind) {
118
- case 'Likelihood':
119
- return { type: WIRE_LIKELIHOOD, instructions: question.Instructions };
120
- case 'Choice': {
121
- const criteria = {};
122
- for (const option of question.Options) {
123
- criteria[option.Value] = option.Description;
124
- }
125
- return { type: 'choice', instructions: question.Instructions, criteria };
126
- }
127
- case 'Score':
128
- return { type: 'score', instructions: question.Instructions, criteria: [...question.Levels] };
129
- }
37
+ get ServiceName() {
38
+ return 'OpenRouter Decisions API';
130
39
  }
131
- mapAnswer(key, question, answers) {
132
- const answer = Object.prototype.hasOwnProperty.call(answers, key) ? answers[key] : undefined;
133
- if (!isObject(answer)) {
134
- return { success: false, errorMessage: `Question '${key}': the response has no answer object for it` };
135
- }
136
- switch (question.Kind) {
137
- case 'Likelihood':
138
- return this.mapLikelihood(key, answer);
139
- case 'Choice':
140
- return this.mapChoice(key, question, answer);
141
- case 'Score':
142
- return this.mapScore(key, question, answer);
143
- }
40
+ get DefaultModel() {
41
+ return OpenRouterDecision_1.DEFAULT_MODEL;
144
42
  }
145
- /** Checks the answer's wire type, when the API sends one. */
146
- typeMismatch(key, answer, expected) {
147
- const type = answer['type'];
148
- return type === undefined || type === expected
149
- ? undefined
150
- : `Question '${key}': expected an answer of type '${expected}', got '${String(type)}'`;
151
- }
152
- mapLikelihood(key, answer) {
153
- const mismatch = this.typeMismatch(key, answer, WIRE_LIKELIHOOD);
154
- if (mismatch) {
155
- return { success: false, errorMessage: mismatch };
156
- }
157
- const probability = answer[WIRE_LIKELIHOOD];
158
- if (typeof probability !== 'number' || !Number.isFinite(probability)) {
159
- return { success: false, errorMessage: `Question '${key}': the Likelihood probability is not a finite number` };
160
- }
161
- return { success: true, answer: { Kind: 'Likelihood', Probability: clamp(probability, 0, 1) } };
162
- }
163
- mapChoice(key, question, answer) {
164
- const mismatch = this.typeMismatch(key, answer, 'choice');
165
- if (mismatch) {
166
- return { success: false, errorMessage: mismatch };
167
- }
168
- const values = question.Options.map(o => o.Value);
169
- const choice = answer['choice'];
170
- if (typeof choice !== 'string' || !values.includes(choice)) {
171
- return { success: false, errorMessage: `Question '${key}': the choice '${String(choice)}' is not one of the options (${values.join(', ')})` };
172
- }
173
- const raw = isObject(answer['probabilities']) ? answer['probabilities'] : {};
174
- const probabilities = normalize(values.map(value => [value, raw[value]]));
175
- if (!probabilities) {
176
- return { success: false, errorMessage: `Question '${key}': the Choice probabilities sum to 0` };
177
- }
178
- return { success: true, answer: { Kind: 'Choice', Value: choice, Probabilities: probabilities, Confidence: readConfidence(answer, probabilities) } };
179
- }
180
- /** A Score's probabilities come keyed by level index ("0", "1", …); MJ keys them by level name. */
181
- mapScore(key, question, answer) {
182
- const mismatch = this.typeMismatch(key, answer, 'score');
183
- if (mismatch) {
184
- return { success: false, errorMessage: mismatch };
185
- }
186
- const score = answer['score'];
187
- if (typeof score !== 'number' || !Number.isFinite(score)) {
188
- return { success: false, errorMessage: `Question '${key}': the Score value is not a finite number` };
189
- }
190
- const raw = isObject(answer['probabilities']) ? answer['probabilities'] : {};
191
- const probabilities = normalize(question.Levels.map((level, i) => [level, raw[String(i)]]));
192
- if (!probabilities) {
193
- return { success: false, errorMessage: `Question '${key}': the Score probabilities sum to 0` };
194
- }
195
- return {
196
- success: true,
197
- answer: { Kind: 'Score', Value: clamp(score, 0, question.Levels.length - 1), Probabilities: probabilities, Confidence: readConfidence(answer, probabilities) },
198
- };
43
+ /** The one endpoint, whatever the model: the model travels in the body. */
44
+ GetEndpointURL(_model) {
45
+ return this.EndpointURL;
199
46
  }
200
47
  };
201
48
  OpenRouterDecision = OpenRouterDecision_1 = __decorate([
@@ -203,36 +50,4 @@ OpenRouterDecision = OpenRouterDecision_1 = __decorate([
203
50
  __metadata("design:paramtypes", [String, String])
204
51
  ], OpenRouterDecision);
205
52
  export { OpenRouterDecision };
206
- function isObject(value) {
207
- return typeof value === 'object' && value !== null && !Array.isArray(value);
208
- }
209
- function clamp(value, min, max) {
210
- return Math.max(min, Math.min(max, value));
211
- }
212
- function finiteOr(value, fallback) {
213
- return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
214
- }
215
- /**
216
- * Builds a distribution over the given keys, in order. A missing, negative or non-numeric entry
217
- * counts as 0. Returns undefined when the entries sum to 0.
218
- */
219
- function normalize(entries) {
220
- const values = entries.map(([name, raw]) => [name, Math.max(0, finiteOr(raw, 0))]);
221
- const sum = values.reduce((total, [, p]) => total + p, 0);
222
- if (sum <= 0) {
223
- return undefined;
224
- }
225
- const result = {};
226
- for (const [name, p] of values) {
227
- result[name] = p / sum;
228
- }
229
- return result;
230
- }
231
- /** The API's own confidence, clamped; when it sends none, the top probability. */
232
- function readConfidence(answer, probabilities) {
233
- const confidence = answer['confidence'];
234
- return typeof confidence === 'number' && Number.isFinite(confidence)
235
- ? clamp(confidence, 0, 1)
236
- : Math.max(...Object.values(probabilities));
237
- }
238
53
  //# sourceMappingURL=openRouterDecision.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"openRouterDecision.js","sourceRoot":"","sources":["../../src/models/openRouterDecision.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EACH,YAAY,EAKZ,cAAc,EACd,UAAU,GAEb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;GAGG;AACH,MAAM,eAAe,GAAG,MAAM,CAAC;AAO/B;;;;GAIG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,YAAY;;IAChD,6CAA6C;aACtB,qBAAgB,GAAG,2CAA2C,AAA9C,CAA+C;IAEtF,yDAAyD;aAClC,kBAAa,GAAG,sBAAsB,AAAzB,CAA0B;IAI9D,YAAY,MAAc,EAAE,WAAoB;QAC5C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,YAAY,GAAG,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YAC5D,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE;YACpB,CAAC,CAAC,oBAAkB,CAAC,gBAAgB,CAAC;IAC9C,CAAC;IAED,iDAAiD;IACjD,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,QAAQ,CAAC,MAAsB;QAC3C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,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Ac,YAAY;QACtB,OAAO,oBAAkB,CAAC,aAAa,CAAC;IAC5C,CAAC;IAED,2EAA2E;IACjE,cAAc,CAAC,MAAc;QACnC,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;;AAhCQ,kBAAkB;IAD9B,aAAa,CAAC,YAAY,EAAE,oBAAoB,CAAC;;GACrC,kBAAkB,CAiC9B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/ai-openrouter",
3
3
  "type": "module",
4
- "version": "6.2.0-edge.3",
4
+ "version": "6.2.0-edge.5",
5
5
  "description": "MemberJunction Wrapper for OpenRouter AI inference services",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -11,14 +11,14 @@
11
11
  "author": "MemberJunction.com",
12
12
  "license": "BUSL-1.1",
13
13
  "devDependencies": {
14
- "@memberjunction/unit-testing": "6.2.0-edge.3",
14
+ "@memberjunction/unit-testing": "6.2.0-edge.5",
15
15
  "ts-node-dev": "^2.0.0",
16
16
  "typescript": "^5.9.3"
17
17
  },
18
18
  "dependencies": {
19
- "@memberjunction/ai": "6.2.0-edge.3",
20
- "@memberjunction/ai-openai": "6.2.0-edge.3",
21
- "@memberjunction/global": "6.2.0-edge.3"
19
+ "@memberjunction/ai": "6.2.0-edge.5",
20
+ "@memberjunction/ai-openai": "6.2.0-edge.5",
21
+ "@memberjunction/global": "6.2.0-edge.5"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",