@kindgi/adapter-model-shared 0.0.0-stage → 0.1.6-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/errors.js ADDED
@@ -0,0 +1,57 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ /**
4
+ * A failed call. Its message is the vendor's own words, after the HTTP status when there is
5
+ * one (`401 {"message":"…"}`), as other adapters' errors read in a failed call's record.
6
+ */
7
+ export class ModelProviderError extends Error {
8
+ kind;
9
+ status;
10
+ constructor(kind, status, message, options) {
11
+ super(message, options);
12
+ this.kind = kind;
13
+ this.status = status;
14
+ this.name = 'ModelProviderError';
15
+ }
16
+ }
17
+ /**
18
+ * The vendors' own words for a prompt too long for the model (OpenAI and Azure's
19
+ * `context_length_exceeded` / "maximum context length", Anthropic's "prompt is too long",
20
+ * Bedrock's "Input is too long", Gemini's "exceeds the maximum number of tokens"), not any
21
+ * mention of "context" or "exceeds" (`Invalid value for 'context'` is a bad request).
22
+ */
23
+ const CONTEXT_TOO_LONG = /context[_ -]?length|context window|maximum context|prompt is too long|input is too long|too many tokens|token limit|exceeds the maximum (number of )?(input )?tokens|input token count/i;
24
+ const CONTENT_FILTER = /content.?filter|filtered|content management|safety|responsible ?ai|content_policy|blocked/i;
25
+ /** The statuses whose body says why a request was refused: the words decide among them. */
26
+ const WORDED = new Set([400, 413, 422]);
27
+ /**
28
+ * The kind of a failure: by status first, then by the vendor's words for a 400, 413 or 422.
29
+ * A 408 is the vendor timing out (Bedrock's `ModelTimeoutException`: "took too long"), never a
30
+ * context that's too long.
31
+ */
32
+ export function kindOf(failure) {
33
+ const { status, words } = failure;
34
+ if (failure.kind !== undefined)
35
+ return failure.kind;
36
+ if (status === undefined)
37
+ return 'network';
38
+ if (status === 401 || status === 403)
39
+ return 'auth';
40
+ if (status === 429)
41
+ return 'rate-limited';
42
+ // 408: the vendor timed out; 409: a conflict it says to retry; 424: the model failed
43
+ // (Bedrock's ModelErrorException). None is the caller's request at fault.
44
+ if (status === 408 || status === 409 || status === 424 || status >= 500)
45
+ return 'unavailable';
46
+ if (WORDED.has(status) && CONTEXT_TOO_LONG.test(words))
47
+ return 'context-too-long';
48
+ if (WORDED.has(status) && CONTENT_FILTER.test(words))
49
+ return 'content-filter';
50
+ return 'invalid-request';
51
+ }
52
+ /** The typed error for a failure. */
53
+ export function modelProviderError(failure, cause) {
54
+ const { status, words } = failure;
55
+ return new ModelProviderError(kindOf(failure), status, status !== undefined ? `${status} ${words}` : words, { cause });
56
+ }
57
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAiBjC;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEhC;IACA;IAFX,YACW,IAA4B,EAC5B,MAA0B,EACnC,OAAe,EACf,OAA6B;QAE7B,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QALf,SAAI,GAAJ,IAAI,CAAwB;QAC5B,WAAM,GAAN,MAAM,CAAoB;QAKnC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAeD;;;;;GAKG;AACH,MAAM,gBAAgB,GACpB,yLAAyL,CAAC;AAC5L,MAAM,cAAc,GAClB,4FAA4F,CAAC;AAE/F,2FAA2F;AAC3F,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,OAAuB;IAC5C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAClC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC;IACpD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,MAAM,CAAC;IACpD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC;IAC1C,qFAAqF;IACrF,0EAA0E;IAC1E,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,aAAa,CAAC;IAC9F,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,kBAAkB,CAAC;IAClF,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,gBAAgB,CAAC;IAC9E,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,kBAAkB,CAAC,OAAuB,EAAE,KAAc;IACxE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAClC,OAAO,IAAI,kBAAkB,CAC3B,MAAM,CAAC,OAAO,CAAC,EACf,MAAM,EACN,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,EACnD,EAAE,KAAK,EAAE,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared plumbing for Kindgi's model adapters, in Kindgi's terms. The engine that sends the
3
+ * requests (today the AI SDK's provider packages) is behind `@kindgi/adapter-model-shared/ai-sdk`.
4
+ */
5
+ export { type FailedResponse, ModelProviderError, type ModelProviderErrorKind, kindOf, modelProviderError, } from './errors.js';
6
+ export { MAX_VENDOR_WAIT_MS, backoffMs, type RetryPolicy, type RetryableFailure, vendorWaitMs, withRetries, } from './retries.js';
7
+ export { type TokenCostOptions, tokenCostUsd } from './cost.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,OAAO,EACL,KAAK,cAAc,EACnB,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,MAAM,EACN,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,YAAY,EACZ,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,gBAAgB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ /**
4
+ * Shared plumbing for Kindgi's model adapters, in Kindgi's terms. The engine that sends the
5
+ * requests (today the AI SDK's provider packages) is behind `@kindgi/adapter-model-shared/ai-sdk`.
6
+ */
7
+ export { ModelProviderError, kindOf, modelProviderError, } from './errors.js';
8
+ export { MAX_VENDOR_WAIT_MS, backoffMs, vendorWaitMs, withRetries, } from './retries.js';
9
+ export { tokenCostUsd } from './cost.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC;;;GAGG;AACH,OAAO,EAEL,kBAAkB,EAElB,MAAM,EACN,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,SAAS,EAGT,YAAY,EACZ,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Our retry policy around one send that makes one HTTP attempt: retryable failures (408, 409,
3
+ * 429, 5xx, no response) are retried up to `attempts` in all, waiting what the vendor asks
4
+ * (`retry-after-ms`, `retry-after`) or backing off exponentially with jitter. A vendor asking
5
+ * for more than 60 s ends the call at once, its wait in the message. An abort, in flight or
6
+ * during a wait, rejects with the caller's reason. Library-free: the engine says what a
7
+ * failure looks like (`describe`).
8
+ */
9
+ import type { FailedResponse } from './errors.js';
10
+ /** A failure as the policy needs it. */
11
+ export interface RetryableFailure extends FailedResponse {
12
+ readonly retryable: boolean;
13
+ /** Attempts in all for this failure, when fewer than the policy's (an unreadable answer: 2). */
14
+ readonly maxAttempts?: number;
15
+ /** Response headers, for `retry-after(-ms)`. */
16
+ readonly headers?: Readonly<Record<string, string | undefined>>;
17
+ }
18
+ /** `F`: the engine's own description of a failure, handed back to `toError` as `describe` made it. */
19
+ export interface RetryPolicy<F extends RetryableFailure = RetryableFailure> {
20
+ /** HTTP attempts in all. */
21
+ readonly attempts: number;
22
+ readonly signal?: AbortSignal;
23
+ /** What a thrown error was. */
24
+ readonly describe: (error: unknown) => F;
25
+ /** The error to throw once the policy gives up. */
26
+ readonly toError: (failure: F, error: unknown) => Error;
27
+ }
28
+ export declare function withRetries<T, F extends RetryableFailure = RetryableFailure>(send: () => PromiseLike<T>, policy: RetryPolicy<F>): Promise<T>;
29
+ /** The longest wait a vendor may ask for that's still worth a retry within the call. */
30
+ export declare const MAX_VENDOR_WAIT_MS = 60000;
31
+ /** What the vendor asked to wait (`retry-after-ms`, else `retry-after` in seconds), when it did. */
32
+ export declare function vendorWaitMs(headers: Readonly<Record<string, string | undefined>>): number | undefined;
33
+ /** What the vendor asked for, else exponential with jitter: 1–2 s, 2–4 s, … */
34
+ export declare function backoffMs(headers: Readonly<Record<string, string | undefined>>, attempt: number): number;
35
+ //# sourceMappingURL=retries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retries.d.ts","sourceRoot":"","sources":["../src/retries.ts"],"names":[],"mappings":"AAG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AAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACrD,OAAO,EAAE,MAAM,GACd,MAAM,CAIR"}
@@ -0,0 +1,69 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ export async function withRetries(send, policy) {
4
+ const { signal } = policy;
5
+ // A call, not a narrowed property: the signal can abort during any await.
6
+ const stopped = () => signal?.aborted === true;
7
+ for (let attempt = 1;; attempt += 1) {
8
+ // Stopped before this attempt (already, or during the wait): no attempt at all.
9
+ if (stopped())
10
+ throw signal?.reason;
11
+ try {
12
+ return await send();
13
+ }
14
+ catch (error) {
15
+ // Stopped by the caller: its reason, whether the abort landed in flight or between
16
+ // attempts.
17
+ if (stopped())
18
+ throw signal?.reason ?? error;
19
+ if (error?.name === 'AbortError')
20
+ throw error;
21
+ const failure = policy.describe(error);
22
+ const attempts = Math.min(policy.attempts, failure.maxAttempts ?? policy.attempts);
23
+ if (!failure.retryable || attempt >= attempts)
24
+ throw policy.toError(failure, error);
25
+ // A vendor that asks for longer than we wait: give up now, saying how long it asked,
26
+ // rather than retry early into a limit it named.
27
+ const asked = vendorWaitMs(failure.headers ?? {});
28
+ if (asked !== undefined && asked > MAX_VENDOR_WAIT_MS) {
29
+ const words = `${failure.words} (the vendor asks to wait ${Math.ceil(asked / 1000)} s)`;
30
+ throw policy.toError({ ...failure, words }, error);
31
+ }
32
+ await sleep(backoffMs(failure.headers ?? {}, attempt), signal);
33
+ }
34
+ }
35
+ }
36
+ /** The longest wait a vendor may ask for that's still worth a retry within the call. */
37
+ export const MAX_VENDOR_WAIT_MS = 60_000;
38
+ /** What the vendor asked to wait (`retry-after-ms`, else `retry-after` in seconds), when it did. */
39
+ export function vendorWaitMs(headers) {
40
+ const ms = Number(headers['retry-after-ms']);
41
+ if (headers['retry-after-ms'] !== undefined && Number.isFinite(ms) && ms >= 0)
42
+ return ms;
43
+ const s = Number(headers['retry-after']);
44
+ if (headers['retry-after'] !== undefined && Number.isFinite(s) && s >= 0)
45
+ return s * 1000;
46
+ return undefined;
47
+ }
48
+ /** What the vendor asked for, else exponential with jitter: 1–2 s, 2–4 s, … */
49
+ export function backoffMs(headers, attempt) {
50
+ const asked = vendorWaitMs(headers);
51
+ if (asked !== undefined && asked <= MAX_VENDOR_WAIT_MS)
52
+ return asked;
53
+ return 1000 * 2 ** (attempt - 1) * (1 + Math.random());
54
+ }
55
+ function sleep(ms, signal) {
56
+ return new Promise((resolve, reject) => {
57
+ const onAbort = () => {
58
+ clearTimeout(timer);
59
+ reject(signal?.reason);
60
+ };
61
+ // The listener goes when the wait ends, so a run-long signal doesn't gather one per wait.
62
+ const timer = setTimeout(() => {
63
+ signal?.removeEventListener('abort', onAbort);
64
+ resolve();
65
+ }, ms);
66
+ signal?.addEventListener('abort', onAbort, { once: true });
67
+ });
68
+ }
69
+ //# sourceMappingURL=retries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retries.js","sourceRoot":"","sources":["../src/retries.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAiCjC,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAA0B,EAC1B,MAAsB;IAEtB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1B,0EAA0E;IAC1E,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,KAAK,IAAI,OAAO,GAAG,CAAC,GAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QACrC,gFAAgF;QAChF,IAAI,OAAO,EAAE;YAAE,MAAM,MAAM,EAAE,MAAM,CAAC;QACpC,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,EAAE,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,mFAAmF;YACnF,YAAY;YACZ,IAAI,OAAO,EAAE;gBAAE,MAAM,MAAM,EAAE,MAAM,IAAI,KAAK,CAAC;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 +1,57 @@
1
1
  {
2
2
  "name": "@kindgi/adapter-model-shared",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.6-rc.0",
4
+ "description": "Shared plumbing for Kindgi's model adapters: retries with counted attempts, typed errors, the reasoning state across a pause, usage onto Kindgi's counters. Today's engine is the AI SDK's provider packages, behind one module.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/kindgi/kindgi-sdk.git",
9
+ "directory": "packages/adapters/model-shared"
10
+ },
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./ai-sdk": {
19
+ "types": "./dist/ai-sdk/index.d.ts",
20
+ "import": "./dist/ai-sdk/index.js",
21
+ "default": "./dist/ai-sdk/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "src",
27
+ "README.md"
28
+ ],
29
+ "dependencies": {
30
+ "@ai-sdk/provider": "4.0.25",
31
+ "@kindgi/capabilities": "0.1.6-rc.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^22.10.5",
35
+ "typescript": "^5.7.3",
36
+ "vitest": "^2.1.8"
37
+ },
38
+ "engines": {
39
+ "node": ">=22.12.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "provenance": true
44
+ },
45
+ "homepage": "https://github.com/kindgi/kindgi-sdk/tree/main/packages/adapters/model-shared#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/kindgi/kindgi-sdk/issues"
48
+ },
49
+ "main": "./dist/index.js",
50
+ "types": "./dist/index.d.ts",
51
+ "scripts": {
52
+ "build": "tsc -p tsconfig.build.json",
53
+ "typecheck": "tsc --noEmit",
54
+ "test": "vitest run",
55
+ "clean": "rm -rf dist *.tsbuildinfo"
56
+ }
6
57
  }
@@ -0,0 +1,12 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ /**
5
+ * Today's engine, the AI SDK's provider packages: where an adapter hands its provider in.
6
+ * The only entry point of this package whose types are a library's.
7
+ */
8
+ export {
9
+ type AiSdkModelProviderOptions,
10
+ attemptPrepared,
11
+ createAiSdkModelProvider,
12
+ } from './provider.js';