llmshim 0.1.23 → 0.1.24
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 +25 -10
- package/dist/index.d.ts +22 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -10
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +18 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +188 -0
- package/dist/server.js.map +1 -0
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
# llmshim
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Zero-runtime-dependency** TypeScript/JavaScript client for the [llmshim](https://crates.io/crates/llmshim) proxy.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Like the Python package, it bundles a prebuilt proxy binary for your platform and auto-starts it on the first request — nothing to run yourself. Pass an explicit `baseUrl` instead if you'd rather point it at a proxy you're already running (Docker, a shared server, `llmshim proxy` in another terminal).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
- Zero runtime dependencies (built-in `fetch` + `ReadableStream`, Node 18+).
|
|
7
|
+
- Bundles a prebuilt binary per platform (macOS/Linux/Windows, x64/arm64) via `optionalDependencies` — the same pattern esbuild/swc/Turborepo use. No native dependency, no postinstall scripts.
|
|
8
|
+
- Zero runtime dependencies otherwise (built-in `fetch` + `ReadableStream` + Node builtins for the auto-spawn, Node 18+).
|
|
12
9
|
- Faithful to the proxy's OpenAPI contract (`api/openapi.yaml`).
|
|
13
10
|
- Typed responses and a typed `StreamEvent` union.
|
|
14
11
|
|
|
@@ -23,7 +20,7 @@ npm install llmshim
|
|
|
23
20
|
```ts
|
|
24
21
|
import { Client } from "llmshim";
|
|
25
22
|
|
|
26
|
-
const client = new Client(); //
|
|
23
|
+
const client = new Client(); // no baseUrl -> auto-starts the bundled proxy on first request
|
|
27
24
|
|
|
28
25
|
// Non-streaming
|
|
29
26
|
const res = await client.chat({
|
|
@@ -51,13 +48,21 @@ console.log(await client.health());
|
|
|
51
48
|
|
|
52
49
|
```ts
|
|
53
50
|
new Client({
|
|
54
|
-
baseUrl: "http://localhost:3000", // proxy
|
|
51
|
+
baseUrl: "http://localhost:3000", // connect to a proxy you're already running — disables auto-spawn
|
|
55
52
|
headers: { authorization: "Bearer …" }, // sent on every request
|
|
56
53
|
fetch: myFetch, // custom fetch (optional; defaults to global fetch)
|
|
57
54
|
});
|
|
58
55
|
```
|
|
59
56
|
|
|
60
|
-
`createClient(options)` is also exported as an equivalent factory.
|
|
57
|
+
Omit `baseUrl` to auto-spawn the bundled binary instead (see below). `createClient(options)` is also exported as an equivalent factory — both are fully synchronous; the auto-spawn happens lazily inside the first `chat`/`stream`/`models`/`health` call, not at construction time.
|
|
58
|
+
|
|
59
|
+
## How the bundled binary works
|
|
60
|
+
|
|
61
|
+
`npm install llmshim` also installs one of five tiny `optionalDependencies` — `llmshim-darwin-arm64`, `llmshim-darwin-x64`, `llmshim-linux-x64`, `llmshim-linux-arm64`, or `@sanjay920/llmshim-win32-x64` (the Windows one is scoped to sidestep npm's spam filter on unscoped `*-win32-*` names) — npm resolves the one matching your platform automatically via each package's `os`/`cpu` fields, so only ~8MB for your actual platform ever downloads. Each contains nothing but the prebuilt `llmshim` binary.
|
|
62
|
+
|
|
63
|
+
On the first `chat`/`stream`/`models`/`health` call on a `Client` constructed without `baseUrl`, the client finds that bundled binary (falling back to `PATH`, e.g. a `cargo install llmshim`), starts `llmshim proxy` on a free local port, waits for it to accept connections, and reuses that same process for every subsequent call in the same Node process — mirroring the Python client's `_server.py`. It's stopped automatically on process exit.
|
|
64
|
+
|
|
65
|
+
If no bundled binary is found and nothing is on `PATH`, the first request throws a clear error explaining how to install one or pass an explicit `baseUrl`.
|
|
61
66
|
|
|
62
67
|
## Errors
|
|
63
68
|
|
|
@@ -96,3 +101,13 @@ npm install
|
|
|
96
101
|
npm run build # tsc → dist/
|
|
97
102
|
npm test # node --test, fully mocked (no network, no API cost)
|
|
98
103
|
```
|
|
104
|
+
|
|
105
|
+
`scripts/manual-smoke-check.mjs` is a manual (not automated) end-to-end check of the auto-spawn path against a real binary — see the comment at the top of that file for how to run it. It's excluded from `npm test`'s auto-discovery and from the published package.
|
|
106
|
+
|
|
107
|
+
## Publishing (maintainers)
|
|
108
|
+
|
|
109
|
+
Six packages publish together on every release, all via npm's OIDC trusted publishing (no tokens stored): the five platform binary packages (`clients/typescript/packages/*`) and this root package. Each needs a one-time Trusted Publisher configured at `npmjs.com/package/<name>/access` with:
|
|
110
|
+
|
|
111
|
+
- Repository owner: `sanjay920`, repository: `llmshim`, workflow filename: `release.yml`, environment: `release`.
|
|
112
|
+
|
|
113
|
+
See `.github/workflows/release.yml` (`npm-macos-binaries`, `npm-linux-x64-binary`, `npm-linux-arm64-binary`, `npm-windows-binary`, `npm` jobs) and `.claude/skills/release/SKILL.md`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* llmshim TypeScript client.
|
|
3
3
|
*
|
|
4
|
-
* A
|
|
5
|
-
*
|
|
6
|
-
* the
|
|
4
|
+
* A dependency-free HTTP client for the llmshim proxy. If you don't pass a
|
|
5
|
+
* `baseUrl`, it bundles and auto-starts a prebuilt proxy binary for your
|
|
6
|
+
* platform (like the Python client) — nothing to run yourself. Pass an
|
|
7
|
+
* explicit `baseUrl` to talk to a proxy you're already running instead.
|
|
7
8
|
*
|
|
8
9
|
* @example
|
|
9
10
|
* import { Client } from "llmshim";
|
|
10
|
-
* const client = new Client();
|
|
11
|
+
* const client = new Client(); // auto-starts the bundled proxy on first request
|
|
11
12
|
* const res = await client.chat({
|
|
12
13
|
* model: "anthropic/claude-sonnet-4-6",
|
|
13
14
|
* messages: [{ role: "user", content: "Hello!" }],
|
|
@@ -15,12 +16,17 @@
|
|
|
15
16
|
* console.log(res.message.content);
|
|
16
17
|
*/
|
|
17
18
|
export * from "./types.js";
|
|
19
|
+
export { ensureServer, platformPackageName } from "./server.js";
|
|
18
20
|
import type { ChatRequest, ChatResponse, HealthResponse, ModelsResponse, StreamEvent } from "./types.js";
|
|
19
21
|
/** A `fetch` implementation. Defaults to the global `fetch` (Node 18+). */
|
|
20
22
|
export type FetchLike = typeof fetch;
|
|
21
23
|
/** Options for constructing a {@link Client}. */
|
|
22
24
|
export interface ClientOptions {
|
|
23
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Base URL of a proxy you're already running. If omitted, the client
|
|
27
|
+
* bundles and auto-starts a prebuilt proxy binary on the first request
|
|
28
|
+
* (see {@link ensureServer}) instead of assuming a fixed default.
|
|
29
|
+
*/
|
|
24
30
|
baseUrl?: string;
|
|
25
31
|
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
26
32
|
fetch?: FetchLike;
|
|
@@ -40,10 +46,20 @@ export declare class LlmshimError extends Error {
|
|
|
40
46
|
}
|
|
41
47
|
/** HTTP client for the llmshim proxy. */
|
|
42
48
|
export declare class Client {
|
|
43
|
-
|
|
49
|
+
/** Set only when an explicit `baseUrl` was passed at construction. */
|
|
50
|
+
private readonly explicitBaseUrl;
|
|
51
|
+
/** Memoized auto-start resolution, shared across calls on this instance. */
|
|
52
|
+
private autoBaseUrl;
|
|
44
53
|
private readonly fetchImpl;
|
|
45
54
|
private readonly headers;
|
|
46
55
|
constructor(options?: ClientOptions);
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the base URL to use for the next request: the explicit `baseUrl`
|
|
58
|
+
* if one was given at construction, otherwise the bundled proxy's URL
|
|
59
|
+
* (starting it on first call). Memoized so the bundled proxy is only
|
|
60
|
+
* started once per `Client` instance.
|
|
61
|
+
*/
|
|
62
|
+
private resolveBaseUrl;
|
|
47
63
|
/**
|
|
48
64
|
* Send a chat completion request to POST /v1/chat.
|
|
49
65
|
* Non-streaming by default; if `req.stream` is true the proxy streams instead,
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAEZ,cAAc,EACd,cAAc,EACd,WAAW,EACZ,MAAM,YAAY,CAAC;AAGpB,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC,iDAAiD;AACjD,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,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,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IACrD,4EAA4E;IAC5E,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;gBAErC,OAAO,GAAE,aAAkB;IAavC;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAMtB;;;;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;YAMzB,IAAI;YAaJ,GAAG;CAOlB;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
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* llmshim TypeScript client.
|
|
3
3
|
*
|
|
4
|
-
* A
|
|
5
|
-
*
|
|
6
|
-
* the
|
|
4
|
+
* A dependency-free HTTP client for the llmshim proxy. If you don't pass a
|
|
5
|
+
* `baseUrl`, it bundles and auto-starts a prebuilt proxy binary for your
|
|
6
|
+
* platform (like the Python client) — nothing to run yourself. Pass an
|
|
7
|
+
* explicit `baseUrl` to talk to a proxy you're already running instead.
|
|
7
8
|
*
|
|
8
9
|
* @example
|
|
9
10
|
* import { Client } from "llmshim";
|
|
10
|
-
* const client = new Client();
|
|
11
|
+
* const client = new Client(); // auto-starts the bundled proxy on first request
|
|
11
12
|
* const res = await client.chat({
|
|
12
13
|
* model: "anthropic/claude-sonnet-4-6",
|
|
13
14
|
* messages: [{ role: "user", content: "Hello!" }],
|
|
@@ -15,6 +16,8 @@
|
|
|
15
16
|
* console.log(res.message.content);
|
|
16
17
|
*/
|
|
17
18
|
export * from "./types.js";
|
|
19
|
+
export { ensureServer, platformPackageName } from "./server.js";
|
|
20
|
+
import { ensureServer } from "./server.js";
|
|
18
21
|
/**
|
|
19
22
|
* Error thrown when the proxy returns a non-2xx response.
|
|
20
23
|
* Carries the HTTP status plus the `code`/`message` from the ErrorResponse body.
|
|
@@ -33,11 +36,14 @@ export class LlmshimError extends Error {
|
|
|
33
36
|
}
|
|
34
37
|
/** HTTP client for the llmshim proxy. */
|
|
35
38
|
export class Client {
|
|
36
|
-
baseUrl
|
|
39
|
+
/** Set only when an explicit `baseUrl` was passed at construction. */
|
|
40
|
+
explicitBaseUrl;
|
|
41
|
+
/** Memoized auto-start resolution, shared across calls on this instance. */
|
|
42
|
+
autoBaseUrl;
|
|
37
43
|
fetchImpl;
|
|
38
44
|
headers;
|
|
39
45
|
constructor(options = {}) {
|
|
40
|
-
this.
|
|
46
|
+
this.explicitBaseUrl = options.baseUrl?.replace(/\/+$/, "");
|
|
41
47
|
const f = options.fetch ?? globalThis.fetch;
|
|
42
48
|
if (typeof f !== "function") {
|
|
43
49
|
throw new Error("No fetch implementation available. Use Node 18+ or pass `fetch` in ClientOptions.");
|
|
@@ -46,6 +52,19 @@ export class Client {
|
|
|
46
52
|
this.fetchImpl = f === globalThis.fetch ? f.bind(globalThis) : f;
|
|
47
53
|
this.headers = { ...options.headers };
|
|
48
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the base URL to use for the next request: the explicit `baseUrl`
|
|
57
|
+
* if one was given at construction, otherwise the bundled proxy's URL
|
|
58
|
+
* (starting it on first call). Memoized so the bundled proxy is only
|
|
59
|
+
* started once per `Client` instance.
|
|
60
|
+
*/
|
|
61
|
+
resolveBaseUrl() {
|
|
62
|
+
if (this.explicitBaseUrl)
|
|
63
|
+
return Promise.resolve(this.explicitBaseUrl);
|
|
64
|
+
if (!this.autoBaseUrl)
|
|
65
|
+
this.autoBaseUrl = ensureServer();
|
|
66
|
+
return this.autoBaseUrl;
|
|
67
|
+
}
|
|
49
68
|
/**
|
|
50
69
|
* Send a chat completion request to POST /v1/chat.
|
|
51
70
|
* Non-streaming by default; if `req.stream` is true the proxy streams instead,
|
|
@@ -85,8 +104,9 @@ export class Client {
|
|
|
85
104
|
await throwIfError(res);
|
|
86
105
|
return (await res.json());
|
|
87
106
|
}
|
|
88
|
-
post(path, body) {
|
|
89
|
-
|
|
107
|
+
async post(path, body) {
|
|
108
|
+
const baseUrl = await this.resolveBaseUrl();
|
|
109
|
+
return this.fetchImpl(baseUrl + path, {
|
|
90
110
|
method: "POST",
|
|
91
111
|
headers: {
|
|
92
112
|
"content-type": "application/json",
|
|
@@ -96,8 +116,9 @@ export class Client {
|
|
|
96
116
|
body: JSON.stringify(body),
|
|
97
117
|
});
|
|
98
118
|
}
|
|
99
|
-
get(path) {
|
|
100
|
-
|
|
119
|
+
async get(path) {
|
|
120
|
+
const baseUrl = await this.resolveBaseUrl();
|
|
121
|
+
return this.fetchImpl(baseUrl + path, {
|
|
101
122
|
method: "GET",
|
|
102
123
|
headers: { accept: "application/json", ...this.headers },
|
|
103
124
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAUhE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmB3C;;;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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QACzD,oEAAoE;QACpE,IAAI,GAAG,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACpD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE5C,IAAI,KAAK,KAAK,OAAO;YAAE,SAAS,GAAG,GAAG,CAAC;aAClC,IAAI,KAAK,KAAK,MAAM;YAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAE/C,IAAI,OAAgC,CAAC;IACrC,IAAI,CAAC;QACH,OAAO,GAAG,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/server.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-managed llmshim proxy server.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python client's `_server.py`: finds the platform-specific binary
|
|
5
|
+
* bundled via an `optionalDependencies` package (e.g. `llmshim-darwin-arm64`),
|
|
6
|
+
* starts it on a free port, waits for it to be ready, and stops it on process
|
|
7
|
+
* exit. The server is a singleton shared by every {@link Client} in the same
|
|
8
|
+
* process that didn't specify an explicit `baseUrl`.
|
|
9
|
+
*/
|
|
10
|
+
/** Maps Node's `process.platform`/`process.arch` to the optional-dependency package name. */
|
|
11
|
+
export declare function platformPackageName(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Ensure the bundled proxy is running, starting it if necessary. Returns its
|
|
14
|
+
* base URL. Safe to call repeatedly and concurrently — the server is started
|
|
15
|
+
* at most once per process.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ensureServer(): Promise<string>;
|
|
18
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,6FAA6F;AAC7F,wBAAgB,mBAAmB,IAAI,MAAM,CAkB5C;AA+GD;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAyC9C"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-managed llmshim proxy server.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python client's `_server.py`: finds the platform-specific binary
|
|
5
|
+
* bundled via an `optionalDependencies` package (e.g. `llmshim-darwin-arm64`),
|
|
6
|
+
* starts it on a free port, waits for it to be ready, and stops it on process
|
|
7
|
+
* exit. The server is a singleton shared by every {@link Client} in the same
|
|
8
|
+
* process that didn't specify an explicit `baseUrl`.
|
|
9
|
+
*/
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
|
+
import { accessSync, constants as fsConstants } from "node:fs";
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
import { createServer, createConnection } from "node:net";
|
|
14
|
+
import { delimiter, join } from "node:path";
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
let serverProcess = null;
|
|
17
|
+
let serverPort = null;
|
|
18
|
+
let starting = null;
|
|
19
|
+
/** Maps Node's `process.platform`/`process.arch` to the optional-dependency package name. */
|
|
20
|
+
export function platformPackageName() {
|
|
21
|
+
const plat = process.platform;
|
|
22
|
+
const arch = process.arch;
|
|
23
|
+
const key = `${plat}-${arch}`;
|
|
24
|
+
const known = {
|
|
25
|
+
"darwin-arm64": "llmshim-darwin-arm64",
|
|
26
|
+
"darwin-x64": "llmshim-darwin-x64",
|
|
27
|
+
"linux-x64": "llmshim-linux-x64",
|
|
28
|
+
"linux-arm64": "llmshim-linux-arm64",
|
|
29
|
+
// Scoped to dodge npm's spam filter, which flags unscoped `*-win32-*`
|
|
30
|
+
// names (the darwin/linux siblings publish unscoped fine).
|
|
31
|
+
"win32-x64": "@sanjay920/llmshim-win32-x64",
|
|
32
|
+
};
|
|
33
|
+
const pkg = known[key];
|
|
34
|
+
if (!pkg) {
|
|
35
|
+
throw new Error(`No prebuilt llmshim binary is published for ${key}.`);
|
|
36
|
+
}
|
|
37
|
+
return pkg;
|
|
38
|
+
}
|
|
39
|
+
/** Locate the binary bundled via the platform-specific optional dependency, if installed. */
|
|
40
|
+
function findBundledBinary() {
|
|
41
|
+
let pkgName;
|
|
42
|
+
try {
|
|
43
|
+
pkgName = platformPackageName();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
// Resolves to the platform package's package.json; its directory contains bin/.
|
|
50
|
+
const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
|
|
51
|
+
const binName = process.platform === "win32" ? "llmshim.exe" : "llmshim";
|
|
52
|
+
const binPath = join(pkgJsonPath, "..", "bin", binName);
|
|
53
|
+
accessSync(binPath, fsConstants.X_OK);
|
|
54
|
+
return binPath;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Locate an `llmshim` executable on PATH (e.g. `cargo install llmshim`). */
|
|
61
|
+
function findOnPath() {
|
|
62
|
+
const pathEnv = process.env.PATH ?? process.env.Path ?? "";
|
|
63
|
+
const binNames = process.platform === "win32" ? ["llmshim.exe", "llmshim.cmd"] : ["llmshim"];
|
|
64
|
+
for (const dir of pathEnv.split(delimiter)) {
|
|
65
|
+
if (!dir)
|
|
66
|
+
continue;
|
|
67
|
+
for (const bin of binNames) {
|
|
68
|
+
const candidate = join(dir, bin);
|
|
69
|
+
try {
|
|
70
|
+
accessSync(candidate, fsConstants.X_OK);
|
|
71
|
+
return candidate;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// not here, keep looking
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
/** Find the llmshim binary: bundled platform package first, then PATH. */
|
|
81
|
+
function findBinary() {
|
|
82
|
+
const bundled = findBundledBinary();
|
|
83
|
+
if (bundled)
|
|
84
|
+
return bundled;
|
|
85
|
+
const onPath = findOnPath();
|
|
86
|
+
if (onPath)
|
|
87
|
+
return onPath;
|
|
88
|
+
throw new Error("llmshim binary not found. Install one of:\n" +
|
|
89
|
+
" npm install llmshim (includes a prebuilt binary for your platform)\n" +
|
|
90
|
+
" cargo install llmshim (from crates.io, puts it on PATH)\n" +
|
|
91
|
+
" cargo build --release --features proxy (from source)\n" +
|
|
92
|
+
"Or pass an explicit `baseUrl` to connect to a proxy you're already running.");
|
|
93
|
+
}
|
|
94
|
+
/** Find a free TCP port on localhost. */
|
|
95
|
+
function findFreePort() {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
const srv = createServer();
|
|
98
|
+
srv.unref();
|
|
99
|
+
srv.on("error", reject);
|
|
100
|
+
srv.listen(0, "127.0.0.1", () => {
|
|
101
|
+
const address = srv.address();
|
|
102
|
+
if (address && typeof address === "object") {
|
|
103
|
+
const port = address.port;
|
|
104
|
+
srv.close(() => resolve(port));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
srv.close();
|
|
108
|
+
reject(new Error("Could not determine a free port"));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/** Poll until something is accepting TCP connections on `port`, or time out. */
|
|
114
|
+
function waitForServer(port, timeoutMs = 10_000) {
|
|
115
|
+
const deadline = Date.now() + timeoutMs;
|
|
116
|
+
return new Promise((resolve) => {
|
|
117
|
+
const attempt = () => {
|
|
118
|
+
const socket = createConnection({ port, host: "127.0.0.1" });
|
|
119
|
+
socket.once("connect", () => {
|
|
120
|
+
socket.end();
|
|
121
|
+
resolve(true);
|
|
122
|
+
});
|
|
123
|
+
socket.once("error", () => {
|
|
124
|
+
socket.destroy();
|
|
125
|
+
if (Date.now() >= deadline) {
|
|
126
|
+
resolve(false);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
setTimeout(attempt, 100);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
attempt();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function stopServer() {
|
|
137
|
+
if (serverProcess) {
|
|
138
|
+
try {
|
|
139
|
+
serverProcess.kill();
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// already gone
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
serverProcess = null;
|
|
146
|
+
serverPort = null;
|
|
147
|
+
starting = null;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Ensure the bundled proxy is running, starting it if necessary. Returns its
|
|
151
|
+
* base URL. Safe to call repeatedly and concurrently — the server is started
|
|
152
|
+
* at most once per process.
|
|
153
|
+
*/
|
|
154
|
+
export function ensureServer() {
|
|
155
|
+
if (serverProcess && serverPort !== null) {
|
|
156
|
+
return Promise.resolve(`http://127.0.0.1:${serverPort}`);
|
|
157
|
+
}
|
|
158
|
+
if (starting)
|
|
159
|
+
return starting;
|
|
160
|
+
starting = (async () => {
|
|
161
|
+
const binary = findBinary();
|
|
162
|
+
const port = await findFreePort();
|
|
163
|
+
const child = spawn(binary, ["proxy"], {
|
|
164
|
+
env: { ...process.env, LLMSHIM_HOST: "127.0.0.1", LLMSHIM_PORT: String(port) },
|
|
165
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
166
|
+
});
|
|
167
|
+
let stderr = "";
|
|
168
|
+
child.stderr?.on("data", (chunk) => {
|
|
169
|
+
stderr += chunk.toString();
|
|
170
|
+
});
|
|
171
|
+
process.once("exit", stopServer);
|
|
172
|
+
const ready = await waitForServer(port);
|
|
173
|
+
if (!ready) {
|
|
174
|
+
stopServer();
|
|
175
|
+
if (stderr.includes("No API keys found")) {
|
|
176
|
+
throw new Error("No API keys configured. Set them via environment variables " +
|
|
177
|
+
"(OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, XAI_API_KEY) " +
|
|
178
|
+
"or `llmshim configure`.");
|
|
179
|
+
}
|
|
180
|
+
throw new Error(`llmshim proxy failed to start on port ${port}.\nBinary: ${binary}\nstderr: ${stderr}`);
|
|
181
|
+
}
|
|
182
|
+
serverProcess = child;
|
|
183
|
+
serverPort = port;
|
|
184
|
+
return `http://127.0.0.1:${port}`;
|
|
185
|
+
})();
|
|
186
|
+
return starting;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO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EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE;YAC9E,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;SACpC,CAAC,CAAC;QAEH,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YACzC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAEjC,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,UAAU,EAAE,CAAC;YACb,IAAI,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CACb,6DAA6D;oBAC3D,mEAAmE;oBACnE,yBAAyB,CAC5B,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,cAAc,MAAM,aAAa,MAAM,EAAE,CAAC,CAAC;QAC1G,CAAC;QAED,aAAa,GAAG,KAAK,CAAC;QACtB,UAAU,GAAG,IAAI,CAAC;QAClB,OAAO,oBAAoB,IAAI,EAAE,CAAC;IACpC,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llmshim",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.24",
|
|
4
|
+
"description": "TypeScript client for the llmshim proxy (multi-provider LLM API) — bundles a prebuilt binary and auto-starts it, or connects to a proxy you run yourself.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=18"
|
|
21
21
|
},
|
|
22
|
+
"optionalDependencies": {
|
|
23
|
+
"llmshim-darwin-arm64": "0.1.24",
|
|
24
|
+
"llmshim-darwin-x64": "0.1.24",
|
|
25
|
+
"llmshim-linux-x64": "0.1.24",
|
|
26
|
+
"llmshim-linux-arm64": "0.1.24",
|
|
27
|
+
"@sanjay920/llmshim-win32-x64": "0.1.24"
|
|
28
|
+
},
|
|
22
29
|
"scripts": {
|
|
23
30
|
"build": "tsc -p tsconfig.json",
|
|
24
31
|
"test": "node --test",
|
|
@@ -41,6 +48,7 @@
|
|
|
41
48
|
"directory": "clients/typescript"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {
|
|
44
|
-
"typescript": "^5.4.0"
|
|
51
|
+
"typescript": "^5.4.0",
|
|
52
|
+
"@types/node": "^22.0.0"
|
|
45
53
|
}
|
|
46
54
|
}
|