@molecule/api-ai-decisions-intern-decision 1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Intern-Decision implementation of `AIDecisionsProvider`.
3
+ *
4
+ * Talks to a self-hosted Intern-Decision FastAPI service over its
5
+ * `POST /v1/decisions` route, so the open-weights Intern-Decision models
6
+ * answer typed decisions about text and images on your own hardware.
7
+ *
8
+ * @module
9
+ */
10
+ import './secrets.js';
11
+ import type { AIDecisionsProvider } from '@molecule/api-ai-decisions';
12
+ import type { InternDecisionConfig } from './types.js';
13
+ /** The service's default bind (`scripts/demo.sh`: `DEMO_HOST` 127.0.0.1, `DEMO_PORT` 7860). */
14
+ export declare const DEFAULT_INTERN_DECISION_URL = "http://127.0.0.1:7860";
15
+ /** The service's request limits (`src/inference/pipeline.py`, `src/service/uploads.py`). */
16
+ export declare const INTERN_DECISION_LIMITS: {
17
+ /** Questions per request. */
18
+ readonly maxQuestions: 16;
19
+ /** Options per `choice` / levels per `score` (one answer symbol each: A–Z, a–z, 0–9). */
20
+ readonly maxOptions: 62;
21
+ /** Images per request. */
22
+ readonly maxImages: 8;
23
+ /** Decoded bytes per image. */
24
+ readonly maxImageBytes: number;
25
+ /** Decoded bytes across all images. */
26
+ readonly maxTotalImageBytes: number;
27
+ };
28
+ /** Image media types the service decodes (GIFs must be still). */
29
+ export declare const INTERN_DECISION_IMAGE_TYPES: readonly string[];
30
+ /**
31
+ * Creates an Intern-Decision decisions provider.
32
+ *
33
+ * @param config - Base URL and optional proxy API key.
34
+ * @returns An `AIDecisionsProvider` backed by an Intern-Decision service.
35
+ */
36
+ export declare function createProvider(config?: InternDecisionConfig): AIDecisionsProvider;
37
+ /**
38
+ * The provider implementation — lazy, so env vars are read on first use.
39
+ */
40
+ export declare const provider: AIDecisionsProvider;
41
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EACV,mBAAmB,EAKpB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAGtD,+FAA+F;AAC/F,eAAO,MAAM,2BAA2B,0BAA0B,CAAA;AAElE,4FAA4F;AAC5F,eAAO,MAAM,sBAAsB;IACjC,6BAA6B;;IAE7B,yFAAyF;;IAEzF,0BAA0B;;IAE1B,+BAA+B;;IAE/B,uCAAuC;;CAE/B,CAAA;AAEV,kEAAkE;AAClE,eAAO,MAAM,2BAA2B,EAAE,SAAS,MAAM,EAKxD,CAAA;AA2HD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,mBAAmB,CAEjF;AAGD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,mBASrB,CAAA"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Intern-Decision implementation of `AIDecisionsProvider`.
3
+ *
4
+ * Talks to a self-hosted Intern-Decision FastAPI service over its
5
+ * `POST /v1/decisions` route, so the open-weights Intern-Decision models
6
+ * answer typed decisions about text and images on your own hardware.
7
+ *
8
+ * @module
9
+ */
10
+ // Side-effect import: registers this bond's secret definitions.
11
+ import './secrets.js';
12
+ import { fromWireResponse, postDecisions, toWireQuestions } from './wire.js';
13
+ /** The service's default bind (`scripts/demo.sh`: `DEMO_HOST` 127.0.0.1, `DEMO_PORT` 7860). */
14
+ export const DEFAULT_INTERN_DECISION_URL = 'http://127.0.0.1:7860';
15
+ /** The service's request limits (`src/inference/pipeline.py`, `src/service/uploads.py`). */
16
+ export const INTERN_DECISION_LIMITS = {
17
+ /** Questions per request. */
18
+ maxQuestions: 16,
19
+ /** Options per `choice` / levels per `score` (one answer symbol each: A–Z, a–z, 0–9). */
20
+ maxOptions: 62,
21
+ /** Images per request. */
22
+ maxImages: 8,
23
+ /** Decoded bytes per image. */
24
+ maxImageBytes: 12 * 1024 * 1024,
25
+ /** Decoded bytes across all images. */
26
+ maxTotalImageBytes: 32 * 1024 * 1024,
27
+ };
28
+ /** Image media types the service decodes (GIFs must be still). */
29
+ export const INTERN_DECISION_IMAGE_TYPES = [
30
+ 'image/png',
31
+ 'image/jpeg',
32
+ 'image/webp',
33
+ 'image/gif',
34
+ ];
35
+ /**
36
+ * Decoded byte length of a base64 string, without decoding it.
37
+ *
38
+ * @param data - Base64 text.
39
+ * @returns The byte count it decodes to.
40
+ */
41
+ const base64Bytes = (data) => {
42
+ const clean = data.replace(/\s+/g, '');
43
+ const padding = clean.endsWith('==') ? 2 : clean.endsWith('=') ? 1 : 0;
44
+ return Math.floor((clean.length * 3) / 4) - padding;
45
+ };
46
+ /**
47
+ * Refuses, before any request, what the service would reject with a bare 422.
48
+ *
49
+ * @param questions - The questions keyed by id.
50
+ * @param images - The images, if any.
51
+ */
52
+ function checkLimits(questions, images) {
53
+ const { maxQuestions, maxOptions, maxImages, maxImageBytes, maxTotalImageBytes } = INTERN_DECISION_LIMITS;
54
+ const count = Object.keys(questions).length;
55
+ if (count > maxQuestions) {
56
+ throw new Error(`ai-decisions-intern-decision: ${count} questions passed; Intern-Decision answers at most ${maxQuestions} per request. Split them across calls.`);
57
+ }
58
+ for (const [id, q] of Object.entries(questions)) {
59
+ if (q.type === 'yesNo')
60
+ continue;
61
+ const options = q.type === 'choice' ? Object.keys(q.criteria ?? {}).length : (q.criteria?.length ?? 0);
62
+ if (options < 1 || options > maxOptions) {
63
+ throw new Error(`ai-decisions-intern-decision: question "${id}" has ${options} options; Intern-Decision answers 1–${maxOptions}.`);
64
+ }
65
+ }
66
+ if (images.length > maxImages) {
67
+ throw new Error(`ai-decisions-intern-decision: ${images.length} images passed; the service accepts at most ${maxImages}.`);
68
+ }
69
+ let total = 0;
70
+ for (const image of images) {
71
+ if (!INTERN_DECISION_IMAGE_TYPES.includes(image.mimeType)) {
72
+ throw new Error(`ai-decisions-intern-decision: image type "${image.mimeType}" is not supported; use ${INTERN_DECISION_IMAGE_TYPES.join(', ')}.`);
73
+ }
74
+ const bytes = base64Bytes(image.data);
75
+ if (bytes < 1 || bytes > maxImageBytes) {
76
+ throw new Error(`ai-decisions-intern-decision: each image must be 1 byte to 12 MB (got ${bytes} bytes).`);
77
+ }
78
+ total += bytes;
79
+ }
80
+ if (total > maxTotalImageBytes) {
81
+ throw new Error(`ai-decisions-intern-decision: images total ${total} bytes; the service accepts at most 32 MB per request.`);
82
+ }
83
+ }
84
+ /**
85
+ * Intern-Decision decisions provider over HTTP.
86
+ */
87
+ class InternDecisionProvider {
88
+ name = 'intern-decision';
89
+ baseUrl;
90
+ apiKey;
91
+ /**
92
+ * Creates the provider.
93
+ *
94
+ * @param config - Provider configuration; env vars fill anything omitted.
95
+ */
96
+ constructor(config = {}) {
97
+ this.baseUrl = (config.baseUrl ||
98
+ process.env.INTERN_DECISION_URL ||
99
+ DEFAULT_INTERN_DECISION_URL).replace(/\/+$/, '');
100
+ this.apiKey = config.apiKey ?? (process.env.INTERN_DECISION_API_KEY || undefined);
101
+ }
102
+ /**
103
+ * Answers every question about `input.state` (and `input.images`) in one request.
104
+ *
105
+ * @param input - The state, questions, images and options. `model` is
106
+ * ignored: the service answers with the one checkpoint it loaded.
107
+ * @returns One typed answer per question id.
108
+ */
109
+ async decide(input) {
110
+ if (input.state === undefined || input.state === null) {
111
+ throw new Error('ai-decisions: decide() requires a `state`');
112
+ }
113
+ if (!input.questions || Object.keys(input.questions).length === 0) {
114
+ throw new Error('ai-decisions: decide() requires at least one question');
115
+ }
116
+ const images = input.images ?? [];
117
+ checkLimits(input.questions, images);
118
+ const body = await postDecisions({
119
+ url: `${this.baseUrl}/v1/decisions`,
120
+ apiKey: this.apiKey,
121
+ body: {
122
+ state: input.state,
123
+ questions: toWireQuestions(input.questions),
124
+ ...(images.length
125
+ ? { images: images.map((image) => ({ type: image.mimeType, data: image.data })) }
126
+ : {}),
127
+ },
128
+ signal: input.signal,
129
+ label: 'Intern-Decision',
130
+ });
131
+ return fromWireResponse(input.questions, body, input.minConfidence);
132
+ }
133
+ }
134
+ /**
135
+ * Creates an Intern-Decision decisions provider.
136
+ *
137
+ * @param config - Base URL and optional proxy API key.
138
+ * @returns An `AIDecisionsProvider` backed by an Intern-Decision service.
139
+ */
140
+ export function createProvider(config) {
141
+ return new InternDecisionProvider(config);
142
+ }
143
+ let _provider = null;
144
+ /**
145
+ * The provider implementation — lazy, so env vars are read on first use.
146
+ */
147
+ export const provider = new Proxy({}, {
148
+ get(_, prop, receiver) {
149
+ if (!_provider)
150
+ _provider = createProvider();
151
+ return Reflect.get(_provider, prop, receiver);
152
+ },
153
+ set(_, prop, value) {
154
+ if (!_provider)
155
+ _provider = createProvider();
156
+ return Reflect.set(_provider, prop, value);
157
+ },
158
+ });
159
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gEAAgE;AAChE,OAAO,cAAc,CAAA;AAWrB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE5E,+FAA+F;AAC/F,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAA;AAElE,4FAA4F;AAC5F,MAAM,CAAC,MAAM,sBAAsB,GAAG;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2
+ * Intern-Decision secret definitions — self-registered at import time so the
3
+ * runtime secrets registry (`@molecule/api-secrets`) can drive boot-time
4
+ * configuration reports and actionable "not configured" errors.
5
+ *
6
+ * @module
7
+ */
8
+ import type { SecretDefinition } from '@molecule/api-secrets';
9
+ /** Secret definitions used by the Intern-Decision decisions bond. */
10
+ export declare const aiDecisionsInternDecisionSecretDefinitions: SecretDefinition[];
11
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,qEAAqE;AACrE,eAAO,MAAM,0CAA0C,EAAE,gBAAgB,EAiBxE,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Intern-Decision secret definitions — self-registered at import time so the
3
+ * runtime secrets registry (`@molecule/api-secrets`) can drive boot-time
4
+ * configuration reports and actionable "not configured" errors.
5
+ *
6
+ * @module
7
+ */
8
+ import { registerSecrets } from '@molecule/api-secrets';
9
+ /** Secret definitions used by the Intern-Decision decisions bond. */
10
+ export const aiDecisionsInternDecisionSecretDefinitions = [
11
+ {
12
+ key: 'INTERN_DECISION_URL',
13
+ description: 'Intern-Decision server URL — The base URL of your Intern-Decision service (clone github.com/internlm/Intern-Decision, pip install -r requirements-inference.txt, set MODEL_CHECKPOINT, then bash scripts/demo.sh), or of an authenticating proxy in front of it. Defaults to http://127.0.0.1:7860.',
14
+ helpUrl: 'https://github.com/internlm/Intern-Decision#readme',
15
+ required: false,
16
+ example: 'http://127.0.0.1:7860',
17
+ },
18
+ {
19
+ key: 'INTERN_DECISION_API_KEY',
20
+ description: 'Intern-Decision proxy API key — The bearer token your authenticating proxy in front of the Intern-Decision service requires. The service itself has no authentication.',
21
+ helpUrl: 'https://github.com/internlm/Intern-Decision#readme',
22
+ required: false,
23
+ example: 'a-long-random-string',
24
+ },
25
+ ];
26
+ registerSecrets(aiDecisionsInternDecisionSecretDefinitions);
27
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,qEAAqE;AACrE,MAAM,CAAC,MAAM,0CAA0C,GAAuB;IAC5E;QACE,GAAG,EAAE,qBAAqB;QAC1B,WAAW,EACT,qSAAqS;QACvS,OAAO,EAAE,oDAAoD;QAC7D,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,uBAAuB;KACjC;IACD;QACE,GAAG,EAAE,yBAAyB;QAC9B,WAAW,EACT,wKAAwK;QAC1K,OAAO,EAAE,oDAAoD;QAC7D,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,sBAAsB;KAChC;CACF,CAAA;AAED,eAAe,CAAC,0CAA0C,CAAC,CAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Intern-Decision decisions provider configuration.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Configuration for the Intern-Decision decisions provider.
8
+ */
9
+ export interface InternDecisionConfig {
10
+ /**
11
+ * Base URL of the Intern-Decision service (or of an authenticating proxy in
12
+ * front of it). Defaults to `INTERN_DECISION_URL`, then `http://127.0.0.1:7860`.
13
+ */
14
+ baseUrl?: string;
15
+ /**
16
+ * Bearer token for a proxy in front of the service. The service itself has
17
+ * no authentication. Defaults to the `INTERN_DECISION_API_KEY` env var.
18
+ */
19
+ apiKey?: string;
20
+ }
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Intern-Decision decisions provider configuration.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/dist/wire.d.ts ADDED
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The Intern-Decision service's `POST /v1/decisions` wire protocol (a Jev-style
3
+ * `/v1/systemone` variant) ↔ the `@molecule/api-ai-decisions` types.
4
+ *
5
+ * Wire facts (github.com/internlm/Intern-Decision `src/service/app.py`,
6
+ * `src/service/uploads.py`, `src/inference/pipeline.py`, `engine.py`,
7
+ * `src/inputs/schema.py`): request `{ state, questions: { <id>: { type: 'choice'|'score'|'noul', instructions, criteria } }, images? }`
8
+ * with 1–16 questions and 1–62 options each; `images` is up to 8
9
+ * `{ type: <mime>, data: <base64> }`. The response keeps the answers under
10
+ * `answers`: `choice` + `probabilities` keyed by label, `score` (expected
11
+ * level) + `probabilities` keyed `"0".."k-1"`, or `noul` (P(yes)) with
12
+ * `probabilities` keyed `no`/`yes`; plus `model`, `usage`, `request_id`,
13
+ * `timing`. Vendor `confidence` fields are ignored: the core defines
14
+ * `confidence` as the probability of the reported answer, computed here from
15
+ * the distribution.
16
+ *
17
+ * @module
18
+ */
19
+ import type { DecideResult, DecisionAnswer, DecisionQuestion } from '@molecule/api-ai-decisions';
20
+ /** One question as sent on the wire. */
21
+ export interface WireQuestion {
22
+ type: 'choice' | 'score' | 'noul';
23
+ instructions: string;
24
+ criteria?: Record<string, string> | string[];
25
+ }
26
+ /** One answer as received on the wire (only the fields we read). */
27
+ export interface WireAnswer {
28
+ type?: string;
29
+ choice?: string;
30
+ score?: number;
31
+ noul?: number;
32
+ probabilities?: Record<string, number>;
33
+ }
34
+ /** The response body (only the fields we read). */
35
+ export interface WireResponse {
36
+ model?: string;
37
+ answers?: Record<string, WireAnswer>;
38
+ usage?: {
39
+ input_tokens?: number;
40
+ output_tokens?: number;
41
+ };
42
+ }
43
+ /**
44
+ * Converts the core's questions into wire questions (`yesNo` → `noul`).
45
+ *
46
+ * @param questions - The questions keyed by id.
47
+ * @returns The wire `questions` object.
48
+ */
49
+ export declare function toWireQuestions(questions: Record<string, DecisionQuestion>): Record<string, WireQuestion>;
50
+ /**
51
+ * Converts one wire answer into the core's answer for `question`.
52
+ *
53
+ * @param id - The question id (for error messages).
54
+ * @param question - The question that was asked.
55
+ * @param wire - The wire answer.
56
+ * @param minConfidence - Optional low-confidence threshold.
57
+ * @returns The typed answer.
58
+ */
59
+ export declare function fromWireAnswer(id: string, question: DecisionQuestion, wire: WireAnswer | undefined, minConfidence?: number): DecisionAnswer;
60
+ /**
61
+ * Converts a whole wire response into the core's result.
62
+ *
63
+ * @param questions - The questions that were asked.
64
+ * @param body - The parsed response body.
65
+ * @param minConfidence - Optional low-confidence threshold.
66
+ * @returns The typed result.
67
+ */
68
+ export declare function fromWireResponse<Q extends Record<string, DecisionQuestion>>(questions: Q, body: WireResponse, minConfidence?: number): DecideResult<Q>;
69
+ /** Options for {@link postDecisions}. */
70
+ export interface PostOptions {
71
+ /** Full endpoint URL. */
72
+ url: string;
73
+ /** Bearer token, if any. */
74
+ apiKey?: string;
75
+ /** Request body. */
76
+ body: Record<string, unknown>;
77
+ /** Abort signal. */
78
+ signal?: AbortSignal;
79
+ /** Label for error messages (`'Intern-Decision'`). */
80
+ label: string;
81
+ /** Max retries on a retryable status (default 3). */
82
+ maxRetries?: number;
83
+ }
84
+ /**
85
+ * POSTs a decision request with retry on 429/5xx-busy, honouring
86
+ * `Retry-After`. Throws an Error carrying `status` on a non-2xx response.
87
+ *
88
+ * @param opts - Request options.
89
+ * @returns The parsed response body.
90
+ */
91
+ export declare function postDecisions(opts: PostOptions): Promise<WireResponse>;
92
+ //# sourceM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,EAAE,MAAM,GACrB,cAAc,CAiDhB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACzE,SAAS,EAAE,CAAC,EACZ,IAAI,EAAE,YAAY,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,YAAY,CAAC,CAAC,CAAC,CAiBjB;AAKD,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,oBAAoB;IACpB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CA8C5E"}
package/dist/wire.js ADDED
@@ -0,0 +1,199 @@
1
+ /**
2
+ * The Intern-Decision service's `POST /v1/decisions` wire protocol (a Jev-style
3
+ * `/v1/systemone` variant) ↔ the `@molecule/api-ai-decisions` types.
4
+ *
5
+ * Wire facts (github.com/internlm/Intern-Decision `src/service/app.py`,
6
+ * `src/service/uploads.py`, `src/inference/pipeline.py`, `engine.py`,
7
+ * `src/inputs/schema.py`): request `{ state, questions: { <id>: { type: 'choice'|'score'|'noul', instructions, criteria } }, images? }`
8
+ * with 1–16 questions and 1–62 options each; `images` is up to 8
9
+ * `{ type: <mime>, data: <base64> }`. The response keeps the answers under
10
+ * `answers`: `choice` + `probabilities` keyed by label, `score` (expected
11
+ * level) + `probabilities` keyed `"0".."k-1"`, or `noul` (P(yes)) with
12
+ * `probabilities` keyed `no`/`yes`; plus `model`, `usage`, `request_id`,
13
+ * `timing`. Vendor `confidence` fields are ignored: the core defines
14
+ * `confidence` as the probability of the reported answer, computed here from
15
+ * the distribution.
16
+ *
17
+ * @module
18
+ */
19
+ /**
20
+ * Converts the core's questions into wire questions (`yesNo` → `noul`).
21
+ *
22
+ * @param questions - The questions keyed by id.
23
+ * @returns The wire `questions` object.
24
+ */
25
+ export function toWireQuestions(questions) {
26
+ const out = {};
27
+ for (const [id, q] of Object.entries(questions)) {
28
+ if (q.type === 'choice') {
29
+ out[id] = { type: 'choice', instructions: q.instructions, criteria: q.criteria };
30
+ }
31
+ else if (q.type === 'score') {
32
+ out[id] = { type: 'score', instructions: q.instructions, criteria: q.criteria };
33
+ }
34
+ else if (q.type === 'yesNo') {
35
+ const criteria = {};
36
+ if (q.criteria?.yes)
37
+ criteria.true = q.criteria.yes;
38
+ if (q.criteria?.no)
39
+ criteria.false = q.criteria.no;
40
+ out[id] = {
41
+ type: 'noul',
42
+ instructions: q.instructions,
43
+ ...(Object.keys(criteria).length ? { criteria } : {}),
44
+ };
45
+ }
46
+ else {
47
+ throw new Error(`ai-decisions: question "${id}" has unknown type "${q.type}"`);
48
+ }
49
+ }
50
+ return out;
51
+ }
52
+ const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
53
+ const clamp01 = (v) => Math.max(0, Math.min(1, v));
54
+ /**
55
+ * Converts one wire answer into the core's answer for `question`.
56
+ *
57
+ * @param id - The question id (for error messages).
58
+ * @param question - The question that was asked.
59
+ * @param wire - The wire answer.
60
+ * @param minConfidence - Optional low-confidence threshold.
61
+ * @returns The typed answer.
62
+ */
63
+ export function fromWireAnswer(id, question, wire, minConfidence) {
64
+ if (!wire || typeof wire !== 'object') {
65
+ throw new Error(`ai-decisions: the provider returned no answer for question "${id}"`);
66
+ }
67
+ let answer;
68
+ if (question.type === 'choice') {
69
+ const labels = Object.keys(question.criteria);
70
+ const probabilities = {};
71
+ for (const label of labels)
72
+ probabilities[label] = clamp01(num(wire.probabilities?.[label]));
73
+ let top = labels[0] ?? '';
74
+ for (const label of labels)
75
+ if (probabilities[label] > probabilities[top])
76
+ top = label;
77
+ const choice = typeof wire.choice === 'string' && labels.includes(wire.choice) ? wire.choice : top;
78
+ answer = {
79
+ type: 'choice',
80
+ choice,
81
+ probabilities,
82
+ confidence: probabilities[choice] ?? 0,
83
+ };
84
+ }
85
+ else if (question.type === 'score') {
86
+ const probabilities = question.criteria.map((_, i) => clamp01(num(wire.probabilities?.[String(i)])));
87
+ let level = 0;
88
+ probabilities.forEach((p, i) => {
89
+ if (p > probabilities[level])
90
+ level = i;
91
+ });
92
+ const expected = probabilities.reduce((sum, p, i) => sum + p * i, 0);
93
+ answer = {
94
+ type: 'score',
95
+ score: typeof wire.score === 'number' && Number.isFinite(wire.score) ? wire.score : expected,
96
+ level,
97
+ probabilities,
98
+ confidence: probabilities[level] ?? 0,
99
+ };
100
+ }
101
+ else {
102
+ if (typeof wire.noul !== 'number' || !Number.isFinite(wire.noul)) {
103
+ throw new Error(`ai-decisions: the provider's answer to "${id}" has no noul probability`);
104
+ }
105
+ const probability = clamp01(wire.noul);
106
+ answer = {
107
+ type: 'yesNo',
108
+ probability,
109
+ answer: probability >= 0.5,
110
+ confidence: Math.max(probability, 1 - probability),
111
+ };
112
+ }
113
+ if (typeof minConfidence === 'number')
114
+ answer.lowConfidence = answer.confidence < minConfidence;
115
+ return answer;
116
+ }
117
+ /**
118
+ * Converts a whole wire response into the core's result.
119
+ *
120
+ * @param questions - The questions that were asked.
121
+ * @param body - The parsed response body.
122
+ * @param minConfidence - Optional low-confidence threshold.
123
+ * @returns The typed result.
124
+ */
125
+ export function fromWireResponse(questions, body, minConfidence) {
126
+ const answers = {};
127
+ for (const [id, q] of Object.entries(questions)) {
128
+ answers[id] = fromWireAnswer(id, q, body.answers?.[id], minConfidence);
129
+ }
130
+ return {
131
+ answers: answers,
132
+ ...(typeof body.model === 'string' ? { model: body.model } : {}),
133
+ ...(body.usage
134
+ ? {
135
+ usage: {
136
+ inputTokens: num(body.usage.input_tokens),
137
+ outputTokens: num(body.usage.output_tokens),
138
+ },
139
+ }
140
+ : {}),
141
+ };
142
+ }
143
+ /** Statuses worth retrying: rate limit, gateway errors and not-ready (503) from the service or a proxy in front of it. */
144
+ const RETRYABLE = new Set([429, 502, 503, 504, 529]);
145
+ /**
146
+ * POSTs a decision request with retry on 429/5xx-busy, honouring
147
+ * `Retry-After`. Throws an Error carrying `status` on a non-2xx response.
148
+ *
149
+ * @param opts - Request options.
150
+ * @returns The parsed response body.
151
+ */
152
+ export async function postDecisions(opts) {
153
+ const { url, apiKey, body, signal, label, maxRetries = 3 } = opts;
154
+ const headers = { 'content-type': 'application/json' };
155
+ if (apiKey)
156
+ headers.authorization = `Bearer ${apiKey}`;
157
+ for (let attempt = 0;; attempt++) {
158
+ const response = await fetch(url, {
159
+ method: 'POST',
160
+ headers,
161
+ body: JSON.stringify(body),
162
+ signal,
163
+ });
164
+ if (response.ok)
165
+ return (await response.json());
166
+ if (RETRYABLE.has(response.status) && attempt < maxRetries) {
167
+ const retryAfter = Number(response.headers.get('retry-after'));
168
+ const waitMs = Number.isFinite(retryAfter) && retryAfter > 0
169
+ ? Math.min(retryAfter * 1000, 10_000)
170
+ : 250 * 2 ** attempt;
171
+ await new Promise((r) => setTimeout(r, waitMs));
172
+ continue;
173
+ }
174
+ const text = await response.text().catch(() => '');
175
+ let detail = text.length > 0 && text.length < 300 ? text : `HTTP ${response.status}`;
176
+ try {
177
+ const parsed = JSON.parse(text);
178
+ if (typeof parsed.detail === 'string')
179
+ detail = parsed.detail;
180
+ else if (Array.isArray(parsed.detail)) {
181
+ // FastAPI request validation: [{ loc, msg, type }, …]
182
+ detail = parsed.detail
183
+ .map((item) => [Array.isArray(item.loc) ? item.loc.join('.') : '', item.msg]
184
+ .filter(Boolean)
185
+ .join(': '))
186
+ .join('; ');
187
+ }
188
+ else if (typeof parsed.error?.message === 'string')
189
+ detail = parsed.error.message;
190
+ }
191
+ catch (_error) {
192
+ // Not JSON — keep the raw text (or the status) as the detail.
193
+ }
194
+ throw Object.assign(new Error(`${label} decision request failed (${response.status}): ${detail}`), {
195
+ status: response.status,
196
+ });
197
+ }
198
+ }
199
+ //# sourceMappingURL=wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAkCH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,SAA2C;IAE3C,MAAM,GAAG,GAAiC,EAAE,CAAA;IAC5C,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAChD,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACxB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;QAClF,CAAC;aAAM,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC9B,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;QACjF,CAAC;aAAM,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAA2B,EAAE,CAAA;YAC3C,IAAI,CAAC,CAAC,QAAQ,EAAE,GAAG;gBAAE,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAA;YACnD,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAAE,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAA;YAClD,GAAG,CAAC,EAAE,CA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