@skein-js/express 0.1.0 → 0.2.1
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 +61 -20
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -1,38 +1,44 @@
|
|
|
1
1
|
# @skein-js/express
|
|
2
2
|
|
|
3
|
-
> Express adapter for skein-js — mount the Agent Protocol on an Express Router
|
|
3
|
+
> Express adapter for skein-js — mount the Agent Protocol on an Express `Router`.
|
|
4
4
|
|
|
5
|
-
Part of **[skein-js](
|
|
5
|
+
Part of **[skein-js](../../README.md)** — a TypeScript [Agent Protocol](https://github.com/langchain-ai/agent-protocol) server for [LangGraph.js](https://github.com/langchain-ai/langgraphjs), and a drop-in replacement for the LangGraph CLI.
|
|
6
6
|
|
|
7
7
|
**Status:** 🚧 Pre-alpha — implemented; the v1 framework adapter.
|
|
8
8
|
|
|
9
9
|
## What it does
|
|
10
10
|
|
|
11
|
-
Converts Express `req`/`res` into [`@skein-js/agent-protocol`](../agent-protocol)'s normalized
|
|
11
|
+
Converts Express `req`/`res` into [`@skein-js/agent-protocol`](../agent-protocol)'s normalized
|
|
12
|
+
request, dispatches to its handler table, and pipes JSON / `204` / `text/event-stream` responses back
|
|
13
|
+
out. It adds **no protocol logic of its own** — it's a thin transport shim. It ships:
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
- **`createExpressServer`** — a zero-setup server (reads a `langgraph.json`, wires in-memory drivers).
|
|
16
|
+
- **`skeinRouter`** — a mountable `Router` for an existing Express app.
|
|
17
|
+
- **`createHandlerRouter`** — the pure shim for callers wiring their own `ProtocolDeps`.
|
|
16
18
|
|
|
17
19
|
## Install
|
|
18
20
|
|
|
19
21
|
```bash
|
|
20
|
-
pnpm add @skein-js/express
|
|
22
|
+
pnpm add @skein-js/express @langchain/langgraph
|
|
21
23
|
```
|
|
22
24
|
|
|
25
|
+
**`express`** (`>=4.18`) and **`@langchain/langgraph`** are peer dependencies. `express` is almost
|
|
26
|
+
always already in your app; add it too if not (`pnpm add express`).
|
|
27
|
+
|
|
23
28
|
## Usage
|
|
24
29
|
|
|
25
|
-
The zero-setup server — reads a `langgraph.json`, wires in-memory drivers, and serves the
|
|
30
|
+
The zero-setup server — reads a `langgraph.json`, wires in-memory drivers, and serves the protocol:
|
|
26
31
|
|
|
27
32
|
```ts
|
|
28
33
|
import { createExpressServer } from "@skein-js/express";
|
|
29
34
|
|
|
30
35
|
const server = await createExpressServer({ config: "./langgraph.json" });
|
|
31
|
-
await server.listen(2024);
|
|
32
|
-
//
|
|
36
|
+
await server.listen(2024); // defaults: port 2024, host "localhost"
|
|
37
|
+
// …later:
|
|
38
|
+
await server.close();
|
|
33
39
|
```
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
Mount the router on an existing Express app:
|
|
36
42
|
|
|
37
43
|
```ts
|
|
38
44
|
import express from "express";
|
|
@@ -45,15 +51,45 @@ app.listen(2024);
|
|
|
45
51
|
// runtime.worker.stop() to drain background runs on shutdown.
|
|
46
52
|
```
|
|
47
53
|
|
|
48
|
-
Bring your own persistent drivers (e.g. Postgres + Redis
|
|
54
|
+
Bring your own persistent drivers (e.g. Postgres + Redis, assembled by
|
|
55
|
+
[`@skein-js/runtime`](../runtime)) through the same `deps` seam:
|
|
49
56
|
|
|
50
57
|
```ts
|
|
51
|
-
|
|
58
|
+
import { skeinRouter } from "@skein-js/express";
|
|
59
|
+
import { buildRuntime } from "@skein-js/runtime";
|
|
60
|
+
|
|
61
|
+
const runtime = await buildRuntime({
|
|
62
|
+
configPath: "./langgraph.json",
|
|
63
|
+
store: "postgres",
|
|
64
|
+
queue: "redis",
|
|
65
|
+
});
|
|
66
|
+
const { router } = await skeinRouter({ deps: runtime.deps, cors: runtime.cors });
|
|
67
|
+
app.use(router);
|
|
52
68
|
```
|
|
53
69
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
## API
|
|
71
|
+
|
|
72
|
+
- **`createExpressServer(options): Promise<SkeinExpressServer>`** — `SkeinExpressServer` =
|
|
73
|
+
`{ app, runtime, listen(port?, host?), close() }`. `listen` defaults to port `2024`, host
|
|
74
|
+
`"localhost"`, resolves the Node `Server` once bound; `close()` stops the run worker then the HTTP
|
|
75
|
+
server (idempotent).
|
|
76
|
+
- **`skeinRouter(options): Promise<SkeinRouter>`** — `SkeinRouter` = `{ router, runtime }`.
|
|
77
|
+
- **`SkeinRouterOptions`** — common `{ logger?, cors?, warm? }` **plus** either `{ config, importModule? }`
|
|
78
|
+
(in-memory runtime from a `langgraph.json`) **or** `{ deps }` (bring-your-own `ProtocolDeps`).
|
|
79
|
+
`warm: true` eagerly loads graphs at startup; `logger` mounts per-request logging.
|
|
80
|
+
- **`createHandlerRouter(handlers, options?)`** / **`skeinRoutes`** — the pure route table, for
|
|
81
|
+
composing your own routing over an existing `ProtocolHandlers`.
|
|
82
|
+
- **`corsFromHttpConfig(http)`** / **`toCorsOptions(config)`** — map a `langgraph.json` `http.cors`
|
|
83
|
+
block onto `cors` options (`LanggraphCorsConfig`).
|
|
84
|
+
- **`loadInMemoryRuntime` / `loadReloadableInMemoryRuntime`** — the in-memory `ProtocolDeps` loaders
|
|
85
|
+
(the reloadable one adds `reloadGraphs` / `snapshotState` / `hydrateState`, powering `skein dev`).
|
|
86
|
+
- Low-level mappers: `toProtocolRequest`, `sendProtocolResponse`, `sendErrorResponse`.
|
|
87
|
+
|
|
88
|
+
## CORS
|
|
89
|
+
|
|
90
|
+
Browser clients (Agent Chat UI, React `useStream`) run on a different origin. CORS is **off by
|
|
91
|
+
default** (non-permissive) and driven by the `http.cors` block of `langgraph.json`, matching the
|
|
92
|
+
LangGraph CLI:
|
|
57
93
|
|
|
58
94
|
```jsonc
|
|
59
95
|
{
|
|
@@ -62,13 +98,18 @@ Browser clients (Agent Chat UI, React `useStream`) run on a different origin. CO
|
|
|
62
98
|
}
|
|
63
99
|
```
|
|
64
100
|
|
|
65
|
-
Override in code with the `cors` option: pass [`CorsOptions`](https://github.com/expressjs/cors#configuration-options)
|
|
101
|
+
Override in code with the `cors` option: pass [`CorsOptions`](https://github.com/expressjs/cors#configuration-options)
|
|
102
|
+
to restrict origins, `true` for permissive dev, or `false` to force it off.
|
|
103
|
+
|
|
104
|
+
## Reuse
|
|
105
|
+
|
|
106
|
+
Thin transport shim over [`@skein-js/agent-protocol`](../agent-protocol); adds no protocol logic of
|
|
107
|
+
its own.
|
|
66
108
|
|
|
67
109
|
## Learn more
|
|
68
110
|
|
|
69
|
-
- [
|
|
70
|
-
- [Reuse-first architecture](../../docs/reuse.md)
|
|
71
|
-
- [Roadmap](../../docs/roadmap.md)
|
|
111
|
+
- [Agent Protocol surface](../../docs/agent-protocol.md) · [Streaming (SSE)](../../docs/streaming.md) · [React SDK / `useStream`](../../docs/react-sdk.md)
|
|
112
|
+
- [skein-js overview](../../docs/index.md) · [Reuse-first architecture](../../docs/reuse.md) · [Root README](../../README.md)
|
|
72
113
|
|
|
73
114
|
## License
|
|
74
115
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skein-js/express",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Express adapter for skein-js — mount the Agent Protocol on an Express Router.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Maina Wycliffe <wmmaina7@gmail.com>",
|
|
7
|
-
"homepage": "https://github.com/mainawycliffe/skein/tree/main/packages/server-express#readme",
|
|
7
|
+
"homepage": "https://github.com/mainawycliffe/skein-js/tree/main/packages/server-express#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/mainawycliffe/skein.git",
|
|
10
|
+
"url": "git+https://github.com/mainawycliffe/skein-js.git",
|
|
11
11
|
"directory": "packages/server-express"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/mainawycliffe/skein/issues"
|
|
14
|
+
"url": "https://github.com/mainawycliffe/skein-js/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
|
+
"typescript",
|
|
17
18
|
"express",
|
|
18
19
|
"langgraph",
|
|
19
20
|
"agent-protocol",
|
|
@@ -40,10 +41,10 @@
|
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"cors": "^2.8.5",
|
|
43
|
-
"@skein-js/agent-protocol": "0.1
|
|
44
|
-
"@skein-js/
|
|
45
|
-
"@skein-js/
|
|
46
|
-
"@skein-js/
|
|
44
|
+
"@skein-js/agent-protocol": "0.2.1",
|
|
45
|
+
"@skein-js/core": "0.2.1",
|
|
46
|
+
"@skein-js/storage-memory": "0.2.1",
|
|
47
|
+
"@skein-js/config": "0.2.1"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
50
|
"@langchain/langgraph": "^1.4.0",
|