@skein-js/server-kit 0.18.0 → 0.20.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
@@ -4,7 +4,9 @@
4
4
 
5
5
  > Shared, framework-agnostic building blocks for skein-js HTTP adapters.
6
6
 
7
- Part of **[skein-js](../../README.md)** — the open-source alternative to LangGraph Platform for TypeScript: a self-hosted [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.
7
+ Part of **[skein-js](https://github.com/skein-js/skein-js)** — the open-source alternative to LangGraph Platform for TypeScript: a self-hosted [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.
8
+
9
+ 📖 **Docs:** [Building an adapter](https://skein-js.github.io/skein-js/building-an-adapter)
8
10
 
9
11
  This package is the common ground the framework adapters ([`@skein-js/express`](../server-express),
10
12
  [`@skein-js/fastify`](../server-fastify), [`@skein-js/nestjs`](../server-nestjs),
@@ -24,7 +26,7 @@ handler table.
24
26
  - **In-code embedding** — `embedInMemoryGraphs` / `graphMapToResolver`: build a `ProtocolDeps` around a
25
27
  compiled graph (or map of them) you already hold — **no `langgraph.json`, no CLI** — then pass
26
28
  `{ deps }` to any adapter. `overrides` swaps in production drivers/auth. See
27
- [docs/embedding.md](../../docs/embedding.md).
29
+ [docs/embedding.md](https://skein-js.github.io/skein-js/embedding).
28
30
  - **LangGraph dev-state import** — `readLanggraphDevState` / `loadSnapshotIntoStore` /
29
31
  `describeSnapshot`, from the **`@skein-js/server-kit/dev` subpath**: read an existing
30
32
  `.langgraph_api/` directory and reconstruct skein's own `DevStateSnapshot`, so adopting skein carries
@@ -71,7 +73,7 @@ await server.listen(2024);
71
73
  ```
72
74
 
73
75
  Pass `overrides` to swap in production drivers or an auth engine while keeping the rest in-memory. See
74
- [docs/embedding.md](../../docs/embedding.md).
76
+ [docs/embedding.md](https://skein-js.github.io/skein-js/embedding).
75
77
 
76
78
  ## API
77
79
 
@@ -103,7 +105,7 @@ Pass `overrides` to swap in production drivers or an auth engine while keeping t
103
105
  adapter has to remember it. Free when no logger is configured — it schedules nothing.
104
106
  - **`checkHeapHeadroom(): HeapHeadroom`** — the boot-time counterpart: compares V8's ceiling with the
105
107
  container's cgroup limit and warns when the automatic sizing does not fit (see
106
- [deploy.md](../../docs/deploy.md)).
108
+ [deploy.md](https://skein-js.github.io/skein-js/deploy)).
107
109
  - **`describePoolPressure(runConcurrency, poolMax): string | undefined`** — warns when the worker can
108
110
  execute more runs at once than the Postgres pool can serve.
109
111
  - **`resolveMaxPageSize(explicit?, env?): number`** — the same chain for the store page bound:
@@ -133,7 +135,7 @@ Pass `overrides` to swap in production drivers or an auth engine while keeping t
133
135
  keeping them on the root barrel put a filesystem snapshot deserializer into every adapter's module
134
136
  graph. There is deliberately no root re-export — a re-export is still a static import. The
135
137
  `DevStateCounts` _type_ remains exported from the root, since `export type` is erased. See
136
- [docs/bundling.md](../../docs/bundling.md).
138
+ [docs/bundling.md](https://skein-js.github.io/skein-js/bundling).
137
139
 
138
140
  - **CORS** — `corsFromHttpConfig` / `toCorsOptions` map a `langgraph.json` `http.cors` block to
139
141
  `cors`-style options; `allowedOrigin` / `corsResponseHeaders` / `applyNodeCors` / `sendNodePreflight`
@@ -147,8 +149,8 @@ Pass `overrides` to swap in production drivers or an auth engine while keeping t
147
149
 
148
150
  ## Learn more
149
151
 
150
- - [Building your own adapter](../../docs/building-an-adapter.md)
151
- - [skein-js overview](../../docs/index.md)
152
+ - [Building your own adapter](https://skein-js.github.io/skein-js/building-an-adapter)
153
+ - [skein-js overview](https://skein-js.github.io/skein-js/)
152
154
 
153
155
  ## License
154
156
 
@@ -100,7 +100,11 @@ function resolveIdempotency(raw) {
100
100
 
101
101
  // src/in-memory-deps.ts
102
102
  import { MemorySaver } from "@langchain/langgraph";
103
- import { cloneLangGraphCheckpoint, langGraphResolver, SkeinBaseStore } from "@skein-js/langgraph";
103
+ import {
104
+ cloneLangGraphCheckpoint,
105
+ normalizeEmbeddableGraphs,
106
+ SkeinBaseStore
107
+ } from "@skein-js/langgraph";
104
108
  import { MemoryRunEventBus, MemoryRunQueue, MemorySkeinStore } from "@skein-js/storage-memory";
105
109
 
106
110
  // src/max-page-size.ts
@@ -186,30 +190,10 @@ function resolveWebhooks(raw, options = {}) {
186
190
  }
187
191
 
188
192
  // src/in-memory-deps.ts
189
- function isGraphResolver(graphs) {
190
- const candidate = graphs;
191
- return Array.isArray(candidate.ids) && typeof candidate.load === "function";
192
- }
193
- function normalizeEmbeddableGraphs(graphs) {
194
- return langGraphResolver(isGraphResolver(graphs) ? graphs : graphMapToResolver(graphs));
195
- }
196
- function graphMapToResolver(graphs) {
197
- const ids = Object.keys(graphs);
198
- return {
199
- ids,
200
- load: async (graphId) => {
201
- const graph = graphs[graphId];
202
- if (graph == null) {
203
- const known = ids.join(", ") || "none";
204
- throw new Error(
205
- ids.includes(graphId) ? `Graph "${graphId}" resolved to ${String(graph)} \u2014 check its export/factory (known: ${known}).` : `Unknown graph "${graphId}" (known: ${known}).`
206
- );
207
- }
208
- return graph;
209
- },
210
- schemas: async (graphId) => ({ [graphId]: { graph_id: graphId } })
211
- };
212
- }
193
+ import {
194
+ graphMapToResolver,
195
+ normalizeEmbeddableGraphs as normalizeEmbeddableGraphs2
196
+ } from "@skein-js/langgraph";
213
197
  function embedInMemoryGraphs(graphs, overrides = {}) {
214
198
  const webhooks = resolveWebhooks(void 0);
215
199
  return {
@@ -361,10 +345,10 @@ export {
361
345
  resolveMaxPageSize,
362
346
  resolveMemoryBusLimits,
363
347
  resolveWebhooks,
364
- normalizeEmbeddableGraphs,
365
- graphMapToResolver,
366
348
  embedInMemoryGraphs,
367
349
  createInMemoryDeps,
350
+ graphMapToResolver,
351
+ normalizeEmbeddableGraphs2 as normalizeEmbeddableGraphs,
368
352
  resolveThreadTtl,
369
353
  resolveStoreTtl,
370
354
  loadInMemoryRuntime,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  loadInMemoryRuntime,
3
3
  loadReloadableInMemoryRuntime
4
- } from "./chunk-5Q3G665D.js";
4
+ } from "./chunk-UJZBVPYI.js";
5
5
  import "./chunk-JUBBCC7R.js";
6
6
  export {
7
7
  loadInMemoryRuntime,
package/dist/index.d.ts CHANGED
@@ -7,7 +7,8 @@ import { MemoryRunEventBusOptions } from '@skein-js/storage-memory';
7
7
  import { D as DevStateSnapshot } from './dev-Zz4VRv7T.js';
8
8
  export { a as DevStateCounts } from './dev-Zz4VRv7T.js';
9
9
  import { StoreTtlConfig, ThreadTtlConfig } from '@skein-js/core';
10
- import { CompiledGraph } from '@langchain/langgraph';
10
+ import { EmbeddableGraph } from '@skein-js/langgraph';
11
+ export { EmbeddableGraph, graphMapToResolver, normalizeEmbeddableGraphs } from '@skein-js/langgraph';
11
12
  import { ServerResponse } from 'node:http';
12
13
 
13
14
  interface SkeinRuntimeCommonOptions {
@@ -532,46 +533,6 @@ declare function resolveWebhooks(raw: RawWebhooks | undefined, options?: {
532
533
  warn?: (message: string) => void;
533
534
  }): WebhookDeliveryConfig | undefined;
534
535
 
535
- type AnyCompiledGraph = CompiledGraph<any>;
536
- /**
537
- * The surface the engine actually drives, stated structurally.
538
- *
539
- * `CompiledGraph` is not the right bound here even though every graph is one. LangChain's own
540
- * `createAgent` returns a `ReactAgent`, which is graph-*like* — it streams and it has state — but is
541
- * not structurally a `CompiledGraph`, so requiring that type rejected the blessed way to build an
542
- * agent. The engine never needed it: `langGraphResolver` casts whatever it is to an `AgentGraph`, and
543
- * `AgentGraph` requires exactly these two methods.
544
- *
545
- * Kept narrow enough to still catch a mistake — an object with neither method is not a graph — while
546
- * accepting anything the runtime can genuinely drive.
547
- */
548
- interface EmbeddableAgentSurface {
549
- stream(input: any, options?: any): any;
550
- getState(config: any): any;
551
- }
552
- /**
553
- * A graph you can embed in code: any compiled LangGraph.js graph, anything `createAgent` returns, or a
554
- * factory that builds one per run (called with the run's `configurable`). Keys of a graph map become
555
- * graph ids.
556
- */
557
- type EmbeddableGraph = AnyCompiledGraph | EmbeddableAgentSurface | ((config: {
558
- configurable?: Record<string, unknown>;
559
- }) => AnyCompiledGraph | EmbeddableAgentSurface | Promise<AnyCompiledGraph | EmbeddableAgentSurface>);
560
- /**
561
- * Accept either a ready {@link GraphResolver} or a plain graph map and return a `GraphResolver` either
562
- * way — the normalization every in-code embedding helper shares (`embedInMemoryGraphs` here,
563
- * `embedPostgresGraphs` in `@skein-js/runtime`), so the {@link isGraphResolver} discriminator lives in
564
- * exactly one place.
565
- */
566
- declare function normalizeEmbeddableGraphs(graphs: GraphResolver | Record<string, EmbeddableGraph>): GraphResolver;
567
- /**
568
- * Turn a map of compiled graphs (or per-config factories) into a {@link GraphResolver}. Keys become the
569
- * graph ids — one auto-registered assistant each. `schemas()` returns a minimal `{ graph_id }` stub:
570
- * enough for the assistants introspection endpoints and everything `useStream` / Agent Chat UI render.
571
- * Real input/output/state schema extraction stays a `langgraph.json`/config feature — it needs static
572
- * TypeScript analysis of the graph source, which a compiled graph object no longer carries.
573
- */
574
- declare function graphMapToResolver(graphs: Record<string, EmbeddableGraph>): GraphResolver;
575
536
  /**
576
537
  * Build a `ProtocolDeps` backed by fresh in-process drivers (store, queue, bus, checkpointer) around
577
538
  * graphs you already hold in code — no `langgraph.json`, no CLI. Pass a map of compiled graphs (or
@@ -755,4 +716,4 @@ type RuntimeGlobal = typeof globalThis & {
755
716
  /** Detect Node, Bun, or Deno without importing a runtime-specific module. */
756
717
  declare function detectRuntimeCapabilities(scope?: RuntimeGlobal): RuntimeCapabilities;
757
718
 
758
- export { type ConsoleLogLevel, type ConsoleLoggerOptions, type CorsSetting, DEFAULT_HEAP_SAMPLE_MS, DEFAULT_HEAP_WARN_PERCENT, DevStateSnapshot, type EmbeddableGraph, type FileReader, HEAP_REARM_MARGIN_PERCENT, HEAP_REARM_PERCENT, type HeapHeadroom, type HeapPressureContext, type HeapPressureMonitor, type HeapPressureMonitorOptions, type InMemoryRuntimeConfig, type IntervalHandle, type LanggraphCorsConfig, type RawIdempotency, type RawStoreTtl, type RawThreadTtl, type RawWebhooks, type ReloadableInMemoryRuntime, type ResolvedMemoryBusLimits, type ResolvedProtocolRuntime, type ResolvedRuntimeDeps, type RuntimeCapabilities, type RuntimeMemorySnapshot, type RuntimeSignalSubscription, type SkeinRuntimeCommonOptions, type SkeinRuntimeOptions, allowedOrigin, applyNodeCors, checkHeapHeadroom, consoleMountFromHttpConfig, corsFromHttpConfig, corsPreflightHeaders, corsResponseHeaders, createConsoleLogger, createInMemoryDeps, describeError, describeHeapHeadroom, describePoolPressure, detectRuntimeCapabilities, disabledRoutesFromHttpConfig, embedInMemoryGraphs, formatLogMeta, graphMapToResolver, joinList, loadInMemoryRuntime, loadReloadableInMemoryRuntime, normalizeEmbeddableGraphs, readContainerMemoryLimit, resolveCronTickMs, resolveHeapPressureOptions, resolveIdempotency, resolveMaxPageSize, resolveMemoryBusLimits, resolveProtocolRuntime, resolveRunConcurrency, resolveRunTimeoutMs, resolveRuntimeDeps, resolveShutdownGraceMs, resolveStoreTtl, resolveThreadTtl, resolveWebhooks, routeMatcherFor, routesFromHttpConfig, runFailureIdentity, sendNodeError, sendNodePreflight, sendNodeResponse, startHeapPressureMonitor, stripBasePath, toCorsOptions };
719
+ export { type ConsoleLogLevel, type ConsoleLoggerOptions, type CorsSetting, DEFAULT_HEAP_SAMPLE_MS, DEFAULT_HEAP_WARN_PERCENT, DevStateSnapshot, type FileReader, HEAP_REARM_MARGIN_PERCENT, HEAP_REARM_PERCENT, type HeapHeadroom, type HeapPressureContext, type HeapPressureMonitor, type HeapPressureMonitorOptions, type InMemoryRuntimeConfig, type IntervalHandle, type LanggraphCorsConfig, type RawIdempotency, type RawStoreTtl, type RawThreadTtl, type RawWebhooks, type ReloadableInMemoryRuntime, type ResolvedMemoryBusLimits, type ResolvedProtocolRuntime, type ResolvedRuntimeDeps, type RuntimeCapabilities, type RuntimeMemorySnapshot, type RuntimeSignalSubscription, type SkeinRuntimeCommonOptions, type SkeinRuntimeOptions, allowedOrigin, applyNodeCors, checkHeapHeadroom, consoleMountFromHttpConfig, corsFromHttpConfig, corsPreflightHeaders, corsResponseHeaders, createConsoleLogger, createInMemoryDeps, describeError, describeHeapHeadroom, describePoolPressure, detectRuntimeCapabilities, disabledRoutesFromHttpConfig, embedInMemoryGraphs, formatLogMeta, joinList, loadInMemoryRuntime, loadReloadableInMemoryRuntime, readContainerMemoryLimit, resolveCronTickMs, resolveHeapPressureOptions, resolveIdempotency, resolveMaxPageSize, resolveMemoryBusLimits, resolveProtocolRuntime, resolveRunConcurrency, resolveRunTimeoutMs, resolveRuntimeDeps, resolveShutdownGraceMs, resolveStoreTtl, resolveThreadTtl, resolveWebhooks, routeMatcherFor, routesFromHttpConfig, runFailureIdentity, sendNodeError, sendNodePreflight, sendNodeResponse, startHeapPressureMonitor, stripBasePath, toCorsOptions };
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  resolveWebhooks,
19
19
  routesFromHttpConfig,
20
20
  toCorsOptions
21
- } from "./chunk-5Q3G665D.js";
21
+ } from "./chunk-UJZBVPYI.js";
22
22
  import "./chunk-JUBBCC7R.js";
23
23
 
24
24
  // src/resolve-runtime.ts
@@ -168,7 +168,7 @@ function resolveLogger(option, injected, frameworkLogger) {
168
168
  return option ?? frameworkLogger;
169
169
  }
170
170
  async function resolveRuntimeDeps(options, frameworkLogger) {
171
- const loaded = options.deps ? { deps: options.deps, cors: void 0, routes: skeinRoutes, channels: options.channels } : await (await import("./in-memory-runtime-N3GPWIA5.js")).loadInMemoryRuntime(options.config, options.importModule);
171
+ const loaded = options.deps ? { deps: options.deps, cors: void 0, routes: skeinRoutes, channels: options.channels } : await (await import("./in-memory-runtime-IOQZUNLV.js")).loadInMemoryRuntime(options.config, options.importModule);
172
172
  const logger = resolveLogger(options.logger, loaded.deps.logger, frameworkLogger);
173
173
  if (logger && !loaded.deps.logger) loaded.deps.logger = logger;
174
174
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skein-js/server-kit",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Shared, framework-agnostic building blocks for skein-js HTTP adapters — in-memory dev runtime, LangGraph dev-state import, and langgraph.json CORS mapping.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Maina Wycliffe <wmmaina7@gmail.com>",
@@ -49,22 +49,22 @@
49
49
  "cors": "^2.8.5",
50
50
  "superjson": "^2.2.6",
51
51
  "zod": "^3.25.76",
52
- "@skein-js/agent-protocol": "0.18.0",
53
- "@skein-js/config": "0.18.0",
54
- "@skein-js/core": "0.18.0",
55
- "@skein-js/langgraph": "0.18.0",
56
- "@skein-js/storage-memory": "0.18.0"
52
+ "@skein-js/agent-protocol": "0.20.0",
53
+ "@skein-js/config": "0.20.0",
54
+ "@skein-js/core": "0.20.0",
55
+ "@skein-js/langgraph": "0.20.0",
56
+ "@skein-js/storage-memory": "0.20.0"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@langchain/langgraph": "^1.4.0",
60
- "@skein-js/channels": "0.18.0"
60
+ "@skein-js/channels": "0.20.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@langchain/core": "^1.2.9",
64
64
  "@langchain/langgraph": "^1.4.0",
65
65
  "@langchain/langgraph-sdk": "^1.9.0",
66
66
  "@types/cors": "^2.8.17",
67
- "@skein-js/channels": "0.18.0"
67
+ "@skein-js/channels": "0.20.0"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public"