@kanzo-tech/llm 0.19.0 → 0.21.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/README.md CHANGED
@@ -24,7 +24,9 @@ import { ToolLoopAgent, DirectChatTransport, tool, Output, streamText } from "@k
24
24
  `/api/v1/ai` — and a relative one is resolved against the page. Two things a host would otherwise
25
25
  repeat happen here: a model that reasons inline in `<think>…</think>` (Hermes, DeepSeek, Qwen)
26
26
  gets that lifted into the SDK's `reasoning` part, and structured output is on, so `Output.array`
27
- asks the gateway for a JSON schema rather than prose to parse.
27
+ asks the gateway for a JSON schema rather than prose to parse. And a streaming request that sends
28
+ nothing for 30 s — no headers, or no chunk since the last — is aborted and fails as an `AiError`
29
+ coded `ai/silent`.
28
30
  - **Re-exports** of the AI SDK surface a host needs — the agent, the transport, `tool`, `Output`,
29
31
  `streamText`, and the message and part types — so a host never imports `ai` itself.
30
32
  `@ai-sdk/openai-compatible` is not among them: `createGateway` is the only way to a model.
package/dist/gateway.d.ts CHANGED
@@ -11,6 +11,17 @@ export interface GatewaySettings {
11
11
  /** The request function, for a host that routes through its own client. */
12
12
  fetch?: typeof globalThis.fetch;
13
13
  }
14
+ /** The one failure this package names: the model stopped sending without closing the stream. */
15
+ export declare class AiError extends Error {
16
+ readonly code: "ai/silent";
17
+ readonly data: {
18
+ readonly after?: number;
19
+ };
20
+ readonly name = "AiError";
21
+ constructor(code: "ai/silent", message: string, data?: {
22
+ readonly after?: number;
23
+ }, options?: ErrorOptions);
24
+ }
14
25
  /** A model behind the gateway, by alias. */
15
26
  export type Gateway = (alias: string) => LanguageModel;
16
27
  /**
@@ -18,8 +29,12 @@ export type Gateway = (alias: string) => LanguageModel;
18
29
  * Which upstream answers it is the gateway's configuration, so a host's code is the same in dev,
19
30
  * where a local model answers, and in prod.
20
31
  *
21
- * Two things a host would otherwise repeat are done here, once:
32
+ * Three things a host would otherwise repeat are done here, once:
22
33
  *
34
+ * - **A stream that goes silent ends, as `ai/silent`.** Its headers are due within 30 s and each
35
+ * chunk of its body within 30 s of the last; past that the request is aborted and the caller sees
36
+ * an {@link AiError}. A request that does not stream is not bounded: its headers wait on the whole
37
+ * answer, which is work on the far side, not silence.
23
38
  * - **A model that reasons in tags gets its reasoning back as reasoning.** Open-weight models
24
39
  * (Hermes, DeepSeek, Qwen) write it inline as `<think>…</think>` because the chat completions
25
40
  * protocol has no field for it; the middleware lifts it into the SDK's `reasoning` part, which is
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,aAAa,EAAqB,MAAM,IAAI,CAAC;AAEvF,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,4CAA4C;AAC5C,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAWhE"}
1
+ {"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,aAAa,EAAmD,MAAM,IAAI,CAAC;AAErH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAKD,gGAAgG;AAChG,qBAAa,OAAQ,SAAQ,KAAK;IAG9B,QAAQ,CAAC,IAAI,EAAE,WAAW;IAE1B,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAJ5C,SAAkB,IAAI,aAAa;gBAExB,IAAI,EAAE,WAAW,EAC1B,OAAO,EAAE,MAAM,EACN,IAAI,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,EAC/C,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED,4CAA4C;AAC5C,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAWhE"}
package/dist/gateway.js CHANGED
@@ -1,12 +1,29 @@
1
1
  import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
2
2
  import { extractReasoningMiddleware, wrapLanguageModel } from "ai";
3
+ /** How long a model's stream may send nothing, its headers included: fossil's figure for a stream's next chunk. */
4
+ const SILENT_AFTER = 30_000;
5
+ /** The one failure this package names: the model stopped sending without closing the stream. */
6
+ export class AiError extends Error {
7
+ code;
8
+ data;
9
+ name = "AiError";
10
+ constructor(code, message, data = {}, options) {
11
+ super(message, options);
12
+ this.code = code;
13
+ this.data = data;
14
+ }
15
+ }
3
16
  /**
4
17
  * The one door to a model: name an **alias** (`chat`, `complete`), never a provider.
5
18
  * Which upstream answers it is the gateway's configuration, so a host's code is the same in dev,
6
19
  * where a local model answers, and in prod.
7
20
  *
8
- * Two things a host would otherwise repeat are done here, once:
21
+ * Three things a host would otherwise repeat are done here, once:
9
22
  *
23
+ * - **A stream that goes silent ends, as `ai/silent`.** Its headers are due within 30 s and each
24
+ * chunk of its body within 30 s of the last; past that the request is aborted and the caller sees
25
+ * an {@link AiError}. A request that does not stream is not bounded: its headers wait on the whole
26
+ * answer, which is work on the far side, not silence.
10
27
  * - **A model that reasons in tags gets its reasoning back as reasoning.** Open-weight models
11
28
  * (Hermes, DeepSeek, Qwen) write it inline as `<think>…</think>` because the chat completions
12
29
  * protocol has no field for it; the middleware lifts it into the SDK's `reasoning` part, which is
@@ -20,13 +37,46 @@ export function createGateway(settings) {
20
37
  name: "gateway",
21
38
  baseURL: absolute(settings.baseURL),
22
39
  headers: settings.headers,
23
- fetch: settings.fetch,
40
+ fetch: bounded(settings.fetch ?? ((...args) => globalThis.fetch(...args))),
24
41
  includeUsage: true,
25
42
  supportsStructuredOutputs: true,
26
43
  });
27
44
  const reasoning = extractReasoningMiddleware({ tagName: "think" });
28
- return (alias) => wrapLanguageModel({ model: provider(alias), middleware: reasoning });
45
+ return (alias) => wrapLanguageModel({ model: provider(alias), middleware: [silence, reasoning] });
29
46
  }
47
+ /**
48
+ * The provider wraps a body that fails mid-way in an `APICallError`, so a silence after the first
49
+ * chunk would reach the caller as that error's `cause`. It is handed back as itself instead, by the
50
+ * SDK's own path for a stream that fails: an `error` part, which `streamText` gives `onError`.
51
+ */
52
+ const silence = {
53
+ wrapStream: async ({ doStream }) => {
54
+ const { stream, ...rest } = await doStream();
55
+ const reader = stream.getReader();
56
+ return {
57
+ ...rest,
58
+ stream: new ReadableStream({
59
+ async pull(controller) {
60
+ try {
61
+ const { done, value } = await reader.read();
62
+ if (done)
63
+ controller.close();
64
+ else
65
+ controller.enqueue(value);
66
+ }
67
+ catch (e) {
68
+ const cause = e?.cause;
69
+ if (!(cause instanceof AiError))
70
+ throw e;
71
+ controller.enqueue({ type: "error", error: cause });
72
+ controller.close();
73
+ }
74
+ },
75
+ cancel: (reason) => reader.cancel(reason),
76
+ }),
77
+ };
78
+ },
79
+ };
30
80
  /**
31
81
  * The provider builds `new URL(baseURL + path)` with no base, so the BFF's own path — the one a
32
82
  * host is told to pass — would throw `Invalid URL` in the browser too. Resolved against the page,
@@ -36,4 +86,80 @@ function absolute(baseURL) {
36
86
  const page = globalThis.location?.href;
37
87
  return page ? new URL(baseURL, page).toString().replace(/\/$/, "") : baseURL;
38
88
  }
89
+ /**
90
+ * `fetch`, with a streaming request's headers due within {@link SILENT_AFTER} and each body chunk
91
+ * within as long of the last. The caller's signal still aborts as itself. The error is not named
92
+ * `AbortError` or `TimeoutError`: the SDK reads those as a stop, not a failure.
93
+ */
94
+ function bounded(fetch) {
95
+ return async (input, init) => {
96
+ if (!streaming(init?.body))
97
+ return fetch(input, init);
98
+ const outer = init?.signal;
99
+ const controller = new AbortController();
100
+ const forward = () => controller.abort(outer?.reason);
101
+ if (outer?.aborted)
102
+ forward();
103
+ else
104
+ outer?.addEventListener("abort", forward, { once: true });
105
+ const release = () => outer?.removeEventListener("abort", forward);
106
+ // Raced as well as aborted, so a fetch that ignores its signal is cut all the same.
107
+ const heard = (pending) => {
108
+ const { signal } = controller;
109
+ const timer = setTimeout(() => controller.abort(new AiError("ai/silent", `The model sent nothing for ${SILENT_AFTER} ms`, { after: SILENT_AFTER })), SILENT_AFTER);
110
+ let stop = () => { };
111
+ const aborted = new Promise((_, reject) => {
112
+ stop = () => reject(signal.reason);
113
+ if (signal.aborted)
114
+ stop();
115
+ else
116
+ signal.addEventListener("abort", stop, { once: true });
117
+ });
118
+ return Promise.race([pending, aborted])
119
+ .catch((e) => {
120
+ release();
121
+ throw signal.aborted ? signal.reason : e;
122
+ })
123
+ .finally(() => {
124
+ clearTimeout(timer);
125
+ signal.removeEventListener("abort", stop);
126
+ });
127
+ };
128
+ const response = await heard(fetch(input, { ...init, signal: controller.signal }));
129
+ if (!response.body) {
130
+ release();
131
+ return response;
132
+ }
133
+ const reader = response.body.getReader();
134
+ const body = new ReadableStream({
135
+ async pull(stream) {
136
+ const chunk = await heard(reader.read()).catch((e) => {
137
+ void reader.cancel(e).catch(() => { }); // the stream is already failing with `e`
138
+ throw e;
139
+ });
140
+ if (chunk.done) {
141
+ release();
142
+ stream.close();
143
+ }
144
+ else
145
+ stream.enqueue(chunk.value);
146
+ },
147
+ cancel(reason) {
148
+ release();
149
+ return reader.cancel(reason);
150
+ },
151
+ });
152
+ return new Response(body, { status: response.status, statusText: response.statusText, headers: response.headers });
153
+ };
154
+ }
155
+ function streaming(body) {
156
+ if (typeof body !== "string")
157
+ return false;
158
+ try {
159
+ return JSON.parse(body).stream === true;
160
+ }
161
+ catch {
162
+ return false;
163
+ }
164
+ }
39
165
  //# sourceMappingURL=gateway.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAsB,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAkBvF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAAC,QAAyB;IACrD,MAAM,QAAQ,GAAG,sBAAsB,CAAC;QACtC,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;QACnC,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,YAAY,EAAE,IAAI;QAClB,yBAAyB,EAAE,IAAI;KAChC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,0BAA0B,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACnE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;AACzF,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,OAAe;IAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC;IACvC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CA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K,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,yCAAyC;oBAChF,MAAM,CAAC,CAAC;gBACV,CAAC,CAAC,CAAC;gBACH,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;oBACf,OAAO,EAAE,CAAC;oBACV,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,CAAC;;oBAAM,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;YACD,MAAM,CAAC,MAAM;gBACX,OAAO,EAAE,CAAC;gBACV,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC,CAAC;QACH,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACrH,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAiC;IAClD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3C,IAAI,CAAC;QACH,OAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAA0B,CAAC,MAAM,KAAK,IAAI,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,6 +8,6 @@
8
8
  * is the easy outcome.
9
9
  */
10
10
  export { DirectChatTransport, Output, ToolLoopAgent, getToolName, isToolUIPart, jsonSchema, stepCountIs, streamText, tool, type ChatStatus, type DynamicToolUIPart, type InferAgentUIMessage, type LanguageModel, type ReasoningUIPart, type ToolUIPart, type UIMessage, } from "ai";
11
- /** Ours: the one door to a model. */
12
- export { createGateway, type Gateway, type GatewaySettings } from "./gateway.js";
11
+ /** Ours: the one door to a model, and the failure it names. */
12
+ export { AiError, createGateway, type Gateway, type GatewaySettings } from "./gateway.js";
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,IAAI,CAAC;AAEZ,qCAAqC;AACrC,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,IAAI,CAAC;AAEZ,+DAA+D;AAC/D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -8,6 +8,6 @@
8
8
  * is the easy outcome.
9
9
  */
10
10
  export { DirectChatTransport, Output, ToolLoopAgent, getToolName, isToolUIPart, jsonSchema, stepCountIs, streamText, tool, } from "ai";
11
- /** Ours: the one door to a model. */
12
- export { createGateway } from "./gateway.js";
11
+ /** Ours: the one door to a model, and the failure it names. */
12
+ export { AiError, createGateway } from "./gateway.js";
13
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,GAQL,MAAM,IAAI,CAAC;AAEZ,qCAAqC;AACrC,OAAO,EAAE,aAAa,EAAsC,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,GAQL,MAAM,IAAI,CAAC;AAEZ,+DAA+D;AAC/D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAsC,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanzo-tech/llm",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "The model conversation, without React — the AI SDK re-exported as one surface, plus `createGateway`, the one door to models behind a AI gateway.",
5
5
  "type": "module",
6
6
  "license": "MIT",