llmshim 0.1.23
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 +98 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +222 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +148 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# llmshim
|
|
2
|
+
|
|
3
|
+
Thin, **dependency-free** TypeScript/JavaScript client for the [llmshim](https://crates.io/crates/llmshim) proxy.
|
|
4
|
+
|
|
5
|
+
It is pure HTTP: it talks to a **running** llmshim proxy over the network (default `http://localhost:3000`). Unlike the Python package, it does not bundle or spawn the Rust binary — start the proxy yourself:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
llmshim proxy # requires a build with --features proxy
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- Zero runtime dependencies (built-in `fetch` + `ReadableStream`, Node 18+).
|
|
12
|
+
- Faithful to the proxy's OpenAPI contract (`api/openapi.yaml`).
|
|
13
|
+
- Typed responses and a typed `StreamEvent` union.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install llmshim
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 30-second quickstart
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { Client } from "llmshim";
|
|
25
|
+
|
|
26
|
+
const client = new Client(); // defaults to http://localhost:3000
|
|
27
|
+
|
|
28
|
+
// Non-streaming
|
|
29
|
+
const res = await client.chat({
|
|
30
|
+
model: "anthropic/claude-sonnet-4-6",
|
|
31
|
+
messages: [{ role: "user", content: "What is Rust in one sentence?" }],
|
|
32
|
+
});
|
|
33
|
+
console.log(res.message.content);
|
|
34
|
+
|
|
35
|
+
// Streaming — an async iterator of typed events
|
|
36
|
+
for await (const ev of client.stream({
|
|
37
|
+
model: "gpt-5.5",
|
|
38
|
+
messages: [{ role: "user", content: "Write a haiku about the ocean." }],
|
|
39
|
+
})) {
|
|
40
|
+
if (ev.type === "reasoning") process.stdout.write(`\x1b[2m${ev.text}\x1b[0m`);
|
|
41
|
+
if (ev.type === "content") process.stdout.write(ev.text);
|
|
42
|
+
if (ev.type === "error") throw new Error(ev.message);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Discovery
|
|
46
|
+
console.log(await client.models());
|
|
47
|
+
console.log(await client.health());
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
new Client({
|
|
54
|
+
baseUrl: "http://localhost:3000", // proxy URL
|
|
55
|
+
headers: { authorization: "Bearer …" }, // sent on every request
|
|
56
|
+
fetch: myFetch, // custom fetch (optional; defaults to global fetch)
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`createClient(options)` is also exported as an equivalent factory.
|
|
61
|
+
|
|
62
|
+
## Errors
|
|
63
|
+
|
|
64
|
+
Non-2xx responses throw a typed `LlmshimError` carrying `status`, `code`, and `message`
|
|
65
|
+
(parsed from the proxy's `{ error: { code, message } }` envelope):
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { LlmshimError } from "llmshim";
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
await client.chat({ model: "", messages: [] });
|
|
72
|
+
} catch (err) {
|
|
73
|
+
if (err instanceof LlmshimError) {
|
|
74
|
+
console.error(err.status, err.code, err.message);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## API
|
|
80
|
+
|
|
81
|
+
| Method | Endpoint | Returns |
|
|
82
|
+
| --------------------- | ---------------------- | ------------------------------------ |
|
|
83
|
+
| `client.chat(req)` | `POST /v1/chat` | `Promise<ChatResponse>` |
|
|
84
|
+
| `client.stream(req)` | `POST /v1/chat/stream` | `AsyncGenerator<StreamEvent>` |
|
|
85
|
+
| `client.models()` | `GET /v1/models` | `Promise<ModelsResponse>` |
|
|
86
|
+
| `client.health()` | `GET /health` | `Promise<HealthResponse>` |
|
|
87
|
+
|
|
88
|
+
All request/response schemas are exported as TypeScript types (`ChatRequest`,
|
|
89
|
+
`Message`, `Config`, `ChatResponse`, `ResponseMessage`, `ToolCall`, `Usage`,
|
|
90
|
+
`StreamEvent`, `ModelsResponse`, `HealthResponse`, `ErrorResponse`, …).
|
|
91
|
+
|
|
92
|
+
## Develop
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm install
|
|
96
|
+
npm run build # tsc → dist/
|
|
97
|
+
npm test # node --test, fully mocked (no network, no API cost)
|
|
98
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llmshim TypeScript client.
|
|
3
|
+
*
|
|
4
|
+
* A thin, dependency-free HTTP client for the llmshim proxy. Talks to a running
|
|
5
|
+
* proxy over HTTP (default http://localhost:3000). It does NOT spawn or bundle
|
|
6
|
+
* the Rust binary — start the proxy separately with `llmshim proxy`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { Client } from "llmshim";
|
|
10
|
+
* const client = new Client();
|
|
11
|
+
* const res = await client.chat({
|
|
12
|
+
* model: "anthropic/claude-sonnet-4-6",
|
|
13
|
+
* messages: [{ role: "user", content: "Hello!" }],
|
|
14
|
+
* });
|
|
15
|
+
* console.log(res.message.content);
|
|
16
|
+
*/
|
|
17
|
+
export * from "./types.js";
|
|
18
|
+
import type { ChatRequest, ChatResponse, HealthResponse, ModelsResponse, StreamEvent } from "./types.js";
|
|
19
|
+
/** A `fetch` implementation. Defaults to the global `fetch` (Node 18+). */
|
|
20
|
+
export type FetchLike = typeof fetch;
|
|
21
|
+
/** Options for constructing a {@link Client}. */
|
|
22
|
+
export interface ClientOptions {
|
|
23
|
+
/** Base URL of the running proxy. Defaults to `http://localhost:3000`. */
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
26
|
+
fetch?: FetchLike;
|
|
27
|
+
/** Extra headers sent with every request. */
|
|
28
|
+
headers?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when the proxy returns a non-2xx response.
|
|
32
|
+
* Carries the HTTP status plus the `code`/`message` from the ErrorResponse body.
|
|
33
|
+
*/
|
|
34
|
+
export declare class LlmshimError extends Error {
|
|
35
|
+
/** HTTP status code. */
|
|
36
|
+
readonly status: number;
|
|
37
|
+
/** Machine-readable error code from the proxy (empty if unavailable). */
|
|
38
|
+
readonly code: string;
|
|
39
|
+
constructor(status: number, code: string, message: string);
|
|
40
|
+
}
|
|
41
|
+
/** HTTP client for the llmshim proxy. */
|
|
42
|
+
export declare class Client {
|
|
43
|
+
private readonly baseUrl;
|
|
44
|
+
private readonly fetchImpl;
|
|
45
|
+
private readonly headers;
|
|
46
|
+
constructor(options?: ClientOptions);
|
|
47
|
+
/**
|
|
48
|
+
* Send a chat completion request to POST /v1/chat.
|
|
49
|
+
* Non-streaming by default; if `req.stream` is true the proxy streams instead,
|
|
50
|
+
* so prefer {@link Client.stream} for streaming.
|
|
51
|
+
*/
|
|
52
|
+
chat(req: ChatRequest): Promise<ChatResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Send a streaming chat request to POST /v1/chat/stream.
|
|
55
|
+
* Returns an async iterator of typed {@link StreamEvent}s.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* for await (const ev of client.stream({ model, messages })) {
|
|
59
|
+
* if (ev.type === "content") process.stdout.write(ev.text);
|
|
60
|
+
* }
|
|
61
|
+
*/
|
|
62
|
+
stream(req: ChatRequest): AsyncGenerator<StreamEvent, void, unknown>;
|
|
63
|
+
/** List available models via GET /v1/models. */
|
|
64
|
+
models(): Promise<ModelsResponse>;
|
|
65
|
+
/** Health check via GET /health. */
|
|
66
|
+
health(): Promise<HealthResponse>;
|
|
67
|
+
private post;
|
|
68
|
+
private get;
|
|
69
|
+
}
|
|
70
|
+
/** Convenience factory mirroring `new Client(options)`. */
|
|
71
|
+
export declare function createClient(options?: ClientOptions): Client;
|
|
72
|
+
/**
|
|
73
|
+
* Parse an SSE byte stream into typed {@link StreamEvent}s.
|
|
74
|
+
*
|
|
75
|
+
* Handles CRLF/LF line endings, multi-line `data:` fields (joined with "\n"),
|
|
76
|
+
* comment lines, and `[DONE]` termination. The `type` discriminant is taken
|
|
77
|
+
* from the SSE `event:` field, falling back to a `type` key inside the JSON.
|
|
78
|
+
*/
|
|
79
|
+
export declare function parseSse(body: ReadableStream<Uint8Array>): AsyncGenerator<StreamEvent, void, unknown>;
|
|
80
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAEZ,cAAc,EACd,cAAc,EACd,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC,iDAAiD;AACjD,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAM1D;AAED,yCAAyC;AACzC,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;gBAErC,OAAO,GAAE,aAAkB;IAavC;;;;OAIG;IACG,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAMnD;;;;;;;;OAQG;IACI,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;IAS3E,gDAAgD;IAC1C,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAMvC,oCAAoC;IAC9B,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAMvC,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,GAAG;CAMZ;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAE5D;AAwBD;;;;;;GAMG;AACH,wBAAuB,QAAQ,CAC7B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAC/B,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CA+B5C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llmshim TypeScript client.
|
|
3
|
+
*
|
|
4
|
+
* A thin, dependency-free HTTP client for the llmshim proxy. Talks to a running
|
|
5
|
+
* proxy over HTTP (default http://localhost:3000). It does NOT spawn or bundle
|
|
6
|
+
* the Rust binary — start the proxy separately with `llmshim proxy`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { Client } from "llmshim";
|
|
10
|
+
* const client = new Client();
|
|
11
|
+
* const res = await client.chat({
|
|
12
|
+
* model: "anthropic/claude-sonnet-4-6",
|
|
13
|
+
* messages: [{ role: "user", content: "Hello!" }],
|
|
14
|
+
* });
|
|
15
|
+
* console.log(res.message.content);
|
|
16
|
+
*/
|
|
17
|
+
export * from "./types.js";
|
|
18
|
+
/**
|
|
19
|
+
* Error thrown when the proxy returns a non-2xx response.
|
|
20
|
+
* Carries the HTTP status plus the `code`/`message` from the ErrorResponse body.
|
|
21
|
+
*/
|
|
22
|
+
export class LlmshimError extends Error {
|
|
23
|
+
/** HTTP status code. */
|
|
24
|
+
status;
|
|
25
|
+
/** Machine-readable error code from the proxy (empty if unavailable). */
|
|
26
|
+
code;
|
|
27
|
+
constructor(status, code, message) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.name = "LlmshimError";
|
|
30
|
+
this.status = status;
|
|
31
|
+
this.code = code;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** HTTP client for the llmshim proxy. */
|
|
35
|
+
export class Client {
|
|
36
|
+
baseUrl;
|
|
37
|
+
fetchImpl;
|
|
38
|
+
headers;
|
|
39
|
+
constructor(options = {}) {
|
|
40
|
+
this.baseUrl = (options.baseUrl ?? "http://localhost:3000").replace(/\/+$/, "");
|
|
41
|
+
const f = options.fetch ?? globalThis.fetch;
|
|
42
|
+
if (typeof f !== "function") {
|
|
43
|
+
throw new Error("No fetch implementation available. Use Node 18+ or pass `fetch` in ClientOptions.");
|
|
44
|
+
}
|
|
45
|
+
// Bind to preserve `this` for the global fetch.
|
|
46
|
+
this.fetchImpl = f === globalThis.fetch ? f.bind(globalThis) : f;
|
|
47
|
+
this.headers = { ...options.headers };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Send a chat completion request to POST /v1/chat.
|
|
51
|
+
* Non-streaming by default; if `req.stream` is true the proxy streams instead,
|
|
52
|
+
* so prefer {@link Client.stream} for streaming.
|
|
53
|
+
*/
|
|
54
|
+
async chat(req) {
|
|
55
|
+
const res = await this.post("/v1/chat", req);
|
|
56
|
+
await throwIfError(res);
|
|
57
|
+
return (await res.json());
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Send a streaming chat request to POST /v1/chat/stream.
|
|
61
|
+
* Returns an async iterator of typed {@link StreamEvent}s.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* for await (const ev of client.stream({ model, messages })) {
|
|
65
|
+
* if (ev.type === "content") process.stdout.write(ev.text);
|
|
66
|
+
* }
|
|
67
|
+
*/
|
|
68
|
+
async *stream(req) {
|
|
69
|
+
const res = await this.post("/v1/chat/stream", { ...req, stream: true });
|
|
70
|
+
await throwIfError(res);
|
|
71
|
+
if (!res.body) {
|
|
72
|
+
throw new LlmshimError(res.status, "no_body", "Streaming response had no body");
|
|
73
|
+
}
|
|
74
|
+
yield* parseSse(res.body);
|
|
75
|
+
}
|
|
76
|
+
/** List available models via GET /v1/models. */
|
|
77
|
+
async models() {
|
|
78
|
+
const res = await this.get("/v1/models");
|
|
79
|
+
await throwIfError(res);
|
|
80
|
+
return (await res.json());
|
|
81
|
+
}
|
|
82
|
+
/** Health check via GET /health. */
|
|
83
|
+
async health() {
|
|
84
|
+
const res = await this.get("/health");
|
|
85
|
+
await throwIfError(res);
|
|
86
|
+
return (await res.json());
|
|
87
|
+
}
|
|
88
|
+
post(path, body) {
|
|
89
|
+
return this.fetchImpl(this.baseUrl + path, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
"content-type": "application/json",
|
|
93
|
+
accept: "application/json, text/event-stream",
|
|
94
|
+
...this.headers,
|
|
95
|
+
},
|
|
96
|
+
body: JSON.stringify(body),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
get(path) {
|
|
100
|
+
return this.fetchImpl(this.baseUrl + path, {
|
|
101
|
+
method: "GET",
|
|
102
|
+
headers: { accept: "application/json", ...this.headers },
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Convenience factory mirroring `new Client(options)`. */
|
|
107
|
+
export function createClient(options) {
|
|
108
|
+
return new Client(options);
|
|
109
|
+
}
|
|
110
|
+
/** Throw a {@link LlmshimError} for non-2xx responses, parsing ErrorResponse when present. */
|
|
111
|
+
async function throwIfError(res) {
|
|
112
|
+
if (res.ok)
|
|
113
|
+
return;
|
|
114
|
+
let code = "";
|
|
115
|
+
let message = `HTTP ${res.status}`;
|
|
116
|
+
const text = await res.text().catch(() => "");
|
|
117
|
+
if (text) {
|
|
118
|
+
try {
|
|
119
|
+
const parsed = JSON.parse(text);
|
|
120
|
+
if (parsed.error) {
|
|
121
|
+
code = parsed.error.code ?? "";
|
|
122
|
+
message = parsed.error.message ?? message;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
message = text;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
message = text;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
throw new LlmshimError(res.status, code, message);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Parse an SSE byte stream into typed {@link StreamEvent}s.
|
|
136
|
+
*
|
|
137
|
+
* Handles CRLF/LF line endings, multi-line `data:` fields (joined with "\n"),
|
|
138
|
+
* comment lines, and `[DONE]` termination. The `type` discriminant is taken
|
|
139
|
+
* from the SSE `event:` field, falling back to a `type` key inside the JSON.
|
|
140
|
+
*/
|
|
141
|
+
export async function* parseSse(body) {
|
|
142
|
+
const decoder = new TextDecoder();
|
|
143
|
+
const reader = body.getReader();
|
|
144
|
+
let buffer = "";
|
|
145
|
+
try {
|
|
146
|
+
while (true) {
|
|
147
|
+
const { done, value } = await reader.read();
|
|
148
|
+
if (value)
|
|
149
|
+
buffer += decoder.decode(value, { stream: true });
|
|
150
|
+
if (done) {
|
|
151
|
+
buffer += decoder.decode();
|
|
152
|
+
}
|
|
153
|
+
// SSE events are separated by a blank line. Support both \n\n and \r\n\r\n.
|
|
154
|
+
let sep;
|
|
155
|
+
while ((sep = indexOfEventBoundary(buffer)) !== -1) {
|
|
156
|
+
const rawEvent = buffer.slice(0, sep);
|
|
157
|
+
buffer = buffer.slice(sep + boundaryLength(buffer, sep));
|
|
158
|
+
const parsed = parseEventBlock(rawEvent);
|
|
159
|
+
if (parsed)
|
|
160
|
+
yield parsed;
|
|
161
|
+
}
|
|
162
|
+
if (done)
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
// Flush any trailing event that wasn't terminated by a blank line.
|
|
166
|
+
const parsed = parseEventBlock(buffer);
|
|
167
|
+
if (parsed)
|
|
168
|
+
yield parsed;
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
reader.releaseLock();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** Find the index of the next blank-line event boundary, or -1. */
|
|
175
|
+
function indexOfEventBoundary(buf) {
|
|
176
|
+
const lf = buf.indexOf("\n\n");
|
|
177
|
+
const crlf = buf.indexOf("\r\n\r\n");
|
|
178
|
+
if (lf === -1)
|
|
179
|
+
return crlf;
|
|
180
|
+
if (crlf === -1)
|
|
181
|
+
return lf;
|
|
182
|
+
return Math.min(lf, crlf);
|
|
183
|
+
}
|
|
184
|
+
/** Length of the boundary sequence at position `sep`. */
|
|
185
|
+
function boundaryLength(buf, sep) {
|
|
186
|
+
return buf.startsWith("\r\n\r\n", sep) ? 4 : 2;
|
|
187
|
+
}
|
|
188
|
+
/** Parse a single SSE event block into a StreamEvent, or null if it carries no data. */
|
|
189
|
+
function parseEventBlock(block) {
|
|
190
|
+
let eventType = "";
|
|
191
|
+
const dataLines = [];
|
|
192
|
+
for (const rawLine of block.split(/\r\n|\n|\r/)) {
|
|
193
|
+
const line = rawLine;
|
|
194
|
+
if (line === "" || line.startsWith(":"))
|
|
195
|
+
continue; // blank or comment
|
|
196
|
+
const colon = line.indexOf(":");
|
|
197
|
+
const field = colon === -1 ? line : line.slice(0, colon);
|
|
198
|
+
// Per SSE spec, a single leading space after the colon is stripped.
|
|
199
|
+
let val = colon === -1 ? "" : line.slice(colon + 1);
|
|
200
|
+
if (val.startsWith(" "))
|
|
201
|
+
val = val.slice(1);
|
|
202
|
+
if (field === "event")
|
|
203
|
+
eventType = val;
|
|
204
|
+
else if (field === "data")
|
|
205
|
+
dataLines.push(val);
|
|
206
|
+
}
|
|
207
|
+
if (dataLines.length === 0)
|
|
208
|
+
return null;
|
|
209
|
+
const data = dataLines.join("\n");
|
|
210
|
+
if (data === "[DONE]")
|
|
211
|
+
return { type: "done" };
|
|
212
|
+
let payload;
|
|
213
|
+
try {
|
|
214
|
+
payload = JSON.parse(data);
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
const type = eventType || (typeof payload.type === "string" ? payload.type : "");
|
|
220
|
+
return { ...payload, type };
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,YAAY,CAAC;AAwB3B;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,wBAAwB;IACf,MAAM,CAAS;IACxB,yEAAyE;IAChE,IAAI,CAAS;IAEtB,YAAY,MAAc,EAAE,IAAY,EAAE,OAAe;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,yCAAyC;AACzC,MAAM,OAAO,MAAM;IACA,OAAO,CAAS;IAChB,SAAS,CAAY;IACrB,OAAO,CAAyB;IAEjD,YAAY,UAAyB,EAAE;QACrC,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,uBAAuB,CAAC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G,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,IAAI,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjF,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI,EAAiB,CAAC;AAC7C,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript types mirroring the llmshim proxy OpenAPI schema (api/openapi.yaml).
|
|
3
|
+
*/
|
|
4
|
+
/** Reasoning/thinking depth, applied across all providers. */
|
|
5
|
+
export type ReasoningEffort = "low" | "medium" | "high";
|
|
6
|
+
/** Role of a conversation message. */
|
|
7
|
+
export type Role = "system" | "user" | "assistant" | "tool" | "developer";
|
|
8
|
+
/** A tool call made by the assistant. */
|
|
9
|
+
export interface ToolCall {
|
|
10
|
+
id?: string;
|
|
11
|
+
type?: "function";
|
|
12
|
+
function?: {
|
|
13
|
+
name?: string;
|
|
14
|
+
/** JSON-encoded arguments. */
|
|
15
|
+
arguments?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** A conversation message sent to the proxy. */
|
|
19
|
+
export interface Message {
|
|
20
|
+
role: Role;
|
|
21
|
+
/** Text content, an array of content blocks, or null. */
|
|
22
|
+
content?: string | Array<Record<string, unknown>> | null;
|
|
23
|
+
/** For `tool` role messages, the ID of the tool call being responded to. */
|
|
24
|
+
tool_call_id?: string;
|
|
25
|
+
/** Tool calls made by the assistant. */
|
|
26
|
+
tool_calls?: ToolCall[];
|
|
27
|
+
}
|
|
28
|
+
/** Provider-agnostic configuration. */
|
|
29
|
+
export interface Config {
|
|
30
|
+
/** Maximum output tokens. */
|
|
31
|
+
max_tokens?: number;
|
|
32
|
+
/** Sampling temperature (0–2). */
|
|
33
|
+
temperature?: number;
|
|
34
|
+
top_p?: number;
|
|
35
|
+
top_k?: number;
|
|
36
|
+
stop?: string[];
|
|
37
|
+
/** Controls reasoning/thinking depth across all providers. */
|
|
38
|
+
reasoning_effort?: ReasoningEffort;
|
|
39
|
+
}
|
|
40
|
+
/** Request body for POST /v1/chat and POST /v1/chat/stream. */
|
|
41
|
+
export interface ChatRequest {
|
|
42
|
+
/**
|
|
43
|
+
* Model identifier. Use "provider/model" (e.g. "anthropic/claude-sonnet-4-6")
|
|
44
|
+
* or just the model name for auto-detection (e.g. "claude-sonnet-4-6").
|
|
45
|
+
*/
|
|
46
|
+
model: string;
|
|
47
|
+
/** Conversation messages. */
|
|
48
|
+
messages: Message[];
|
|
49
|
+
/** If true on /v1/chat, returns an SSE stream instead of JSON. */
|
|
50
|
+
stream?: boolean;
|
|
51
|
+
/** Provider-agnostic configuration. */
|
|
52
|
+
config?: Config;
|
|
53
|
+
/** Raw provider-specific JSON merged into the underlying request. */
|
|
54
|
+
provider_config?: Record<string, unknown>;
|
|
55
|
+
/** Ordered list of fallback model IDs tried on retryable errors. */
|
|
56
|
+
fallback?: string[];
|
|
57
|
+
}
|
|
58
|
+
/** Token usage reported by the provider. */
|
|
59
|
+
export interface Usage {
|
|
60
|
+
input_tokens?: number;
|
|
61
|
+
output_tokens?: number;
|
|
62
|
+
/** Reasoning/thinking tokens used (if applicable). */
|
|
63
|
+
reasoning_tokens?: number;
|
|
64
|
+
total_tokens?: number;
|
|
65
|
+
}
|
|
66
|
+
/** The assistant message inside a ChatResponse. */
|
|
67
|
+
export interface ResponseMessage {
|
|
68
|
+
role: string;
|
|
69
|
+
content: string | null;
|
|
70
|
+
tool_calls?: ToolCall[];
|
|
71
|
+
}
|
|
72
|
+
/** Response body from POST /v1/chat (non-streaming). */
|
|
73
|
+
export interface ChatResponse {
|
|
74
|
+
/** Response ID from the provider. */
|
|
75
|
+
id: string;
|
|
76
|
+
model: string;
|
|
77
|
+
/** Which provider handled the request. */
|
|
78
|
+
provider: string;
|
|
79
|
+
message: ResponseMessage;
|
|
80
|
+
/** Reasoning/thinking content if the model produced it. */
|
|
81
|
+
reasoning?: string | null;
|
|
82
|
+
usage: Usage;
|
|
83
|
+
/** End-to-end latency in milliseconds. */
|
|
84
|
+
latency_ms: number;
|
|
85
|
+
}
|
|
86
|
+
/** A chunk of answer text. */
|
|
87
|
+
export interface ContentEvent {
|
|
88
|
+
type: "content";
|
|
89
|
+
text: string;
|
|
90
|
+
}
|
|
91
|
+
/** A chunk of reasoning/thinking text. */
|
|
92
|
+
export interface ReasoningEvent {
|
|
93
|
+
type: "reasoning";
|
|
94
|
+
text: string;
|
|
95
|
+
}
|
|
96
|
+
/** A tool call emitted during streaming. */
|
|
97
|
+
export interface ToolCallEvent {
|
|
98
|
+
type: "tool_call";
|
|
99
|
+
id?: string;
|
|
100
|
+
name?: string;
|
|
101
|
+
/** JSON-encoded arguments. */
|
|
102
|
+
arguments?: string;
|
|
103
|
+
}
|
|
104
|
+
/** Final token usage, emitted near the end of a stream. */
|
|
105
|
+
export interface UsageEvent {
|
|
106
|
+
type: "usage";
|
|
107
|
+
input_tokens?: number;
|
|
108
|
+
output_tokens?: number;
|
|
109
|
+
reasoning_tokens?: number;
|
|
110
|
+
total_tokens?: number;
|
|
111
|
+
}
|
|
112
|
+
/** Terminal event signalling the stream is complete. */
|
|
113
|
+
export interface DoneEvent {
|
|
114
|
+
type: "done";
|
|
115
|
+
}
|
|
116
|
+
/** An error surfaced mid-stream. */
|
|
117
|
+
export interface ErrorEvent {
|
|
118
|
+
type: "error";
|
|
119
|
+
message: string;
|
|
120
|
+
}
|
|
121
|
+
/** Discriminated union of all SSE events emitted during streaming. */
|
|
122
|
+
export type StreamEvent = ContentEvent | ReasoningEvent | ToolCallEvent | UsageEvent | DoneEvent | ErrorEvent;
|
|
123
|
+
/** A single entry in the /v1/models response. */
|
|
124
|
+
export interface ModelInfo {
|
|
125
|
+
/** Full model identifier (provider/name). */
|
|
126
|
+
id: string;
|
|
127
|
+
provider: string;
|
|
128
|
+
/** Model name without provider prefix. */
|
|
129
|
+
name: string;
|
|
130
|
+
}
|
|
131
|
+
/** Response body from GET /v1/models. */
|
|
132
|
+
export interface ModelsResponse {
|
|
133
|
+
models: ModelInfo[];
|
|
134
|
+
}
|
|
135
|
+
/** Response body from GET /health. */
|
|
136
|
+
export interface HealthResponse {
|
|
137
|
+
status: string;
|
|
138
|
+
/** List of configured providers. */
|
|
139
|
+
providers: string[];
|
|
140
|
+
}
|
|
141
|
+
/** Error envelope returned on non-2xx responses. */
|
|
142
|
+
export interface ErrorResponse {
|
|
143
|
+
error: {
|
|
144
|
+
code: string;
|
|
145
|
+
message: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAExD,sCAAsC;AACtC,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,WAAW,CAAC;AAE1E,yCAAyC;AACzC,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,8BAA8B;QAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,gDAAgD;AAChD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAA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AAM,WAAW,SAAS;IACxB,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "llmshim",
|
|
3
|
+
"version": "0.1.23",
|
|
4
|
+
"description": "Thin, dependency-free TypeScript client for the llmshim proxy (multi-provider LLM API).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"test": "node --test",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"llm",
|
|
29
|
+
"llmshim",
|
|
30
|
+
"openai",
|
|
31
|
+
"anthropic",
|
|
32
|
+
"gemini",
|
|
33
|
+
"xai",
|
|
34
|
+
"proxy",
|
|
35
|
+
"sse"
|
|
36
|
+
],
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/sanjay920/llmshim.git",
|
|
41
|
+
"directory": "clients/typescript"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^5.4.0"
|
|
45
|
+
}
|
|
46
|
+
}
|