@skein-js/express 0.1.0 → 0.2.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 +49 -17
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
Part of **[skein-js](https://github.com/mainawycliffe/skein)** — 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
|
|
|
@@ -8,11 +8,13 @@ Part of **[skein-js](https://github.com/mainawycliffe/skein)** — a TypeScript
|
|
|
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
|
|
|
@@ -20,19 +22,23 @@ Thin transport shim over [`@skein-js/agent-protocol`](../agent-protocol); adds n
|
|
|
20
22
|
pnpm add @skein-js/express
|
|
21
23
|
```
|
|
22
24
|
|
|
25
|
+
Peer dependencies (install both in your project): **`express`** (`>=4.18`) and
|
|
26
|
+
**`@langchain/langgraph`**.
|
|
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,36 @@ 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 seam:
|
|
49
56
|
|
|
50
57
|
```ts
|
|
51
58
|
const { router } = await skeinRouter({ deps: myProtocolDeps });
|
|
52
59
|
```
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
## API
|
|
62
|
+
|
|
63
|
+
- **`createExpressServer(options): Promise<SkeinExpressServer>`** — `SkeinExpressServer` =
|
|
64
|
+
`{ app, runtime, listen(port?, host?), close() }`. `listen` defaults to port `2024`, host
|
|
65
|
+
`"localhost"`, resolves the Node `Server` once bound; `close()` stops the run worker then the HTTP
|
|
66
|
+
server (idempotent).
|
|
67
|
+
- **`skeinRouter(options): Promise<SkeinRouter>`** — `SkeinRouter` = `{ router, runtime }`.
|
|
68
|
+
- **`SkeinRouterOptions`** — common `{ logger?, cors?, warm? }` **plus** either `{ config, importModule? }`
|
|
69
|
+
(in-memory runtime from a `langgraph.json`) **or** `{ deps }` (bring-your-own `ProtocolDeps`).
|
|
70
|
+
`warm: true` eagerly loads graphs at startup; `logger` mounts per-request logging.
|
|
71
|
+
- **`createHandlerRouter(handlers, options?)`** / **`skeinRoutes`** — the pure route table, for
|
|
72
|
+
composing your own routing over an existing `ProtocolHandlers`.
|
|
73
|
+
- **`corsFromHttpConfig(http)`** / **`toCorsOptions(config)`** — map a `langgraph.json` `http.cors`
|
|
74
|
+
block onto `cors` options (`LanggraphCorsConfig`).
|
|
75
|
+
- **`loadInMemoryRuntime` / `loadReloadableInMemoryRuntime`** — the in-memory `ProtocolDeps` loaders
|
|
76
|
+
(the reloadable one adds `reloadGraphs` / `snapshotState` / `hydrateState`, powering `skein dev`).
|
|
77
|
+
- Low-level mappers: `toProtocolRequest`, `sendProtocolResponse`, `sendErrorResponse`.
|
|
78
|
+
|
|
79
|
+
## CORS
|
|
80
|
+
|
|
81
|
+
Browser clients (Agent Chat UI, React `useStream`) run on a different origin. CORS is **off by
|
|
82
|
+
default** (non-permissive) and driven by the `http.cors` block of `langgraph.json`, matching the
|
|
83
|
+
LangGraph CLI:
|
|
57
84
|
|
|
58
85
|
```jsonc
|
|
59
86
|
{
|
|
@@ -62,13 +89,18 @@ Browser clients (Agent Chat UI, React `useStream`) run on a different origin. CO
|
|
|
62
89
|
}
|
|
63
90
|
```
|
|
64
91
|
|
|
65
|
-
Override in code with the `cors` option: pass [`CorsOptions`](https://github.com/expressjs/cors#configuration-options)
|
|
92
|
+
Override in code with the `cors` option: pass [`CorsOptions`](https://github.com/expressjs/cors#configuration-options)
|
|
93
|
+
to restrict origins, `true` for permissive dev, or `false` to force it off.
|
|
94
|
+
|
|
95
|
+
## Reuse
|
|
96
|
+
|
|
97
|
+
Thin transport shim over [`@skein-js/agent-protocol`](../agent-protocol); adds no protocol logic of
|
|
98
|
+
its own.
|
|
66
99
|
|
|
67
100
|
## Learn more
|
|
68
101
|
|
|
69
|
-
- [
|
|
70
|
-
- [Reuse-first architecture](../../docs/reuse.md)
|
|
71
|
-
- [Roadmap](../../docs/roadmap.md)
|
|
102
|
+
- [Agent Protocol surface](../../docs/agent-protocol.md) · [Streaming (SSE)](../../docs/streaming.md) · [React SDK / `useStream`](../../docs/react-sdk.md)
|
|
103
|
+
- [skein-js overview](../../docs/index.md) · [Reuse-first architecture](../../docs/reuse.md)
|
|
72
104
|
|
|
73
105
|
## License
|
|
74
106
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skein-js/express",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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/
|
|
44
|
-
"@skein-js/
|
|
45
|
-
"@skein-js/
|
|
46
|
-
"@skein-js/
|
|
44
|
+
"@skein-js/config": "0.2.0",
|
|
45
|
+
"@skein-js/core": "0.2.0",
|
|
46
|
+
"@skein-js/storage-memory": "0.2.0",
|
|
47
|
+
"@skein-js/agent-protocol": "0.2.0"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
50
|
"@langchain/langgraph": "^1.4.0",
|