@skein-js/agent-protocol 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.
Files changed (2) hide show
  1. package/README.md +65 -22
  2. package/package.json +7 -6
package/README.md CHANGED
@@ -1,17 +1,19 @@
1
1
  # @skein-js/agent-protocol
2
2
 
3
- A framework-agnostic implementation of LangChain's [**Agent
4
- Protocol**](https://github.com/langchain-ai/agent-protocol) for [LangGraph.js](https://langchain-ai.github.io/langgraphjs/).
5
-
6
- This package is the **run engine + protocol handler table + SSE mapping**, and nothing else. It has
7
- no opinion about your HTTP framework, your database, your queue, or your CLI — every collaborator is
8
- **injected**. Give it a store, a queue, an event bus, a checkpointer, and a way to resolve graphs,
9
- and it will serve assistants, threads, the three run modes (wait / stream / background), the store,
10
- and human-in-the-loop interrupt/resume — wire-compatible with the official `@langchain/langgraph-sdk`
11
- client.
3
+ > The framework-agnostic Agent Protocol **engine** — run engine, handler table, and SSE mapping. The heart of skein-js.
4
+
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.
12
6
 
13
- It powers [skein-js](https://github.com/mainawycliffe/skein), but it depends only on the `@skein-js/core`
14
- contracts and is designed to be consumed on its own.
7
+ **Status:** 🚧 Pre-alpha implemented. Depends only on the [`@skein-js/core`](../core) contracts and is designed to be consumed on its own.
8
+
9
+ ## What it does
10
+
11
+ The **run engine + protocol handler table + SSE mapping**, and nothing else. It has no opinion about
12
+ your HTTP framework, your database, your queue, or your CLI — every collaborator is **injected**.
13
+ Give it a store, a queue, an event bus, a checkpointer, and a way to resolve graphs, and it serves
14
+ assistants, threads, the three run modes (wait / stream / background), the store, and
15
+ human-in-the-loop interrupt/resume — wire-compatible with the official `@langchain/langgraph-sdk`
16
+ client.
15
17
 
16
18
  ## Install
17
19
 
@@ -19,6 +21,9 @@ contracts and is designed to be consumed on its own.
19
21
  npm install @skein-js/agent-protocol @skein-js/core @langchain/langgraph @langchain/langgraph-sdk
20
22
  ```
21
23
 
24
+ `@langchain/langgraph` and `@langchain/langgraph-sdk` are peer dependencies; `@skein-js/core` is a
25
+ regular dependency you should pin alongside.
26
+
22
27
  ## Usage
23
28
 
24
29
  ```ts
@@ -26,10 +31,11 @@ import { createProtocolRuntime } from "@skein-js/agent-protocol";
26
31
 
27
32
  const runtime = createProtocolRuntime({
28
33
  store, // a SkeinStore (e.g. @skein-js/storage-memory, @skein-js/storage-postgres)
29
- graphs, // a GraphResolver — load(graphId) + schemas(graphId) (e.g. @skein-js/config's registry)
34
+ graphs, // a GraphResolver — ids + load(id) + schemas(id) (e.g. @skein-js/config's registry)
30
35
  queue, // a RunQueue for background runs
31
36
  bus, // a RunEventBus for streaming fan-out
32
37
  checkpointer, // a LangGraph BaseCheckpointSaver (MemorySaver in dev)
38
+ // optional: auth, logger, clock, logRunActivity, runTimeoutMs
33
39
  });
34
40
 
35
41
  // One-time startup: register an assistant per graph, then start processing background runs.
@@ -51,22 +57,59 @@ runtime.worker.start();
51
57
 
52
58
  `createProtocolRuntime` builds the service, handlers, and background worker over **one shared
53
59
  context**, so cancelling a run through the service actually aborts it in the worker. Use the
54
- individual `createProtocolService` / `createProtocolHandlers` factories only when you don't run a
55
- worker in the same process.
60
+ individual `createProtocolService` / `createProtocolHandlers` / `createRunWorker` factories only when
61
+ you don't run a worker in the same process.
56
62
 
57
63
  ### The injected contract (`ProtocolDeps`)
58
64
 
59
- | Dependency | Contract (from `@skein-js/core`) | Responsibility |
60
- | -------------- | ---------------------------------------------- | ------------------------------------------------------ |
61
- | `store` | `SkeinStore` | Protocol resource rows (assistants/threads/runs/store) |
62
- | `graphs` | `GraphResolver` | Resolve a `graph_id` to a compiled graph + schemas |
63
- | `queue` | `RunQueue` | Hand background runs to a worker |
64
- | `bus` | `RunEventBus` | Fan run frames out to streaming clients |
65
- | `checkpointer` | `BaseCheckpointSaver` (`@langchain/langgraph`) | Graph state, history, and interrupt/resume |
65
+ | Dependency | Type | Responsibility |
66
+ | ----------------- | ---------------------------------------------- | ------------------------------------------------------------------------ |
67
+ | `store` | `SkeinStore` (core) | Protocol resource rows (assistants/threads/runs/store) |
68
+ | `graphs` | `GraphResolver` (this package) | Resolve a `graph_id` to a compiled graph + schemas |
69
+ | `queue` | `RunQueue` (core) | Hand background runs to a worker |
70
+ | `bus` | `RunEventBus` (core) | Fan run frames out to streaming clients |
71
+ | `checkpointer` | `BaseCheckpointSaver` (`@langchain/langgraph`) | Graph state, history, and interrupt/resume |
72
+ | `auth?` | `AuthEngine` (core) | Per-request 401/403 + ownership filtering; absent = all allowed |
73
+ | `logger?` | `Logger` (this package) | Structured logging; default no-op |
74
+ | `clock?` | `Clock` | Time source; default `() => new Date()` |
75
+ | `logRunActivity?` | `boolean` | Log per-run start/finish, tool calls, interrupts (`skein dev --verbose`) |
76
+ | `runTimeoutMs?` | `number` | Optional per-run wall-clock timeout → `"timeout"` |
66
77
 
67
78
  Graph **state, history, and interrupt/resume are 100% LangGraph-native** via the checkpointer. The
68
79
  `SkeinStore` owns only the protocol resource rows — it is deliberately not the checkpointer.
69
80
 
81
+ ## API
82
+
83
+ - **Entry points:** `createProtocolRuntime(deps, options?)` → `{ service, handlers, worker }`;
84
+ `createProtocolService` / `buildProtocolService`; `createProtocolHandlers`; `createContext`;
85
+ `createRunWorker(ctx, options?)` (`RunWorkerOptions`: `maxConcurrency`, `shutdownGraceMs`).
86
+ - **Service surface** (`runtime.service`): `assistants` (`registerGraphAssistants`, `get`, `list`,
87
+ `search`, `schemas`), `threads` (`create`/`get`/`list`/`patch`/`delete`/`history`/`getState`),
88
+ `threadStream` (`stream` / `joinStream` / `command` — HIL resume, requires status `interrupted`),
89
+ `runs` (`createWait`/`createStream`/`createBackground`/`get`/`listByThread`/`cancel`/`delete`/`join`/`finalStatus`),
90
+ `store` (`put`/`get`/`delete`/`search`/`listNamespaces`).
91
+ - **Transport types:** `ProtocolRequest`, `ProtocolResponse` (`json` | `empty` | `sse`),
92
+ `ProtocolHandler`, `ProtocolHandlers`.
93
+ - **`SkeinBaseStore`** — bridges a `StoreRepo` into a LangGraph `BaseStore`, so graph nodes reach
94
+ long-term memory via `getStore()`. The engine attaches one to every run.
95
+ - **SSE helpers** (for adapters writing the stream themselves): `SSE_HEADERS`, `encodeFrame`,
96
+ `encodeTerminal`, `toSseEvents`, `parseAfterSeq`.
97
+
98
+ > **Note on duplicate type names.** `GraphResolver`, `CompiledGraphFactory`, `ResolvedGraph`, and
99
+ > `GraphSchemas` are exported here _and_ (structurally compatible copies) by [`@skein-js/config`](../config).
100
+ > `config`'s `GraphRegistry` satisfies this package's `GraphResolver` at wire-up time.
101
+
102
+ ## Reuse
103
+
104
+ Runs graphs through `@langchain/langgraph` (`invoke`/`stream`, interrupts/resume) and uses the
105
+ injected `BaseCheckpointSaver` for state/history — never a reimplemented runtime. Wire types come
106
+ from `@langchain/langgraph-sdk` via [`@skein-js/core`](../core).
107
+
108
+ ## Learn more
109
+
110
+ - [Agent Protocol surface](../../docs/agent-protocol.md) · [Streaming (SSE)](../../docs/streaming.md) · [Runs & Redis](../../docs/runs-and-redis.md)
111
+ - [skein-js overview](../../docs/index.md) · [Reuse-first architecture](../../docs/reuse.md)
112
+
70
113
  ## License
71
114
 
72
- Apache-2.0
115
+ [Apache-2.0](../../LICENSE)
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@skein-js/agent-protocol",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Framework-agnostic Agent Protocol engine for LangGraph.js — run engine, handlers, and SSE, driven entirely by injected dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Maina Wycliffe <wmmaina7@gmail.com>",
7
- "homepage": "https://github.com/mainawycliffe/skein/tree/main/packages/agent-protocol#readme",
7
+ "homepage": "https://github.com/mainawycliffe/skein-js/tree/main/packages/agent-protocol#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/agent-protocol"
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
  "langgraph",
18
19
  "agent-protocol",
19
20
  "agents",
@@ -43,14 +44,14 @@
43
44
  },
44
45
  "dependencies": {
45
46
  "zod": "^3.25.76",
46
- "@skein-js/core": "0.1.0"
47
+ "@skein-js/core": "0.2.0"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "@langchain/langgraph": "^1.4.0",
50
51
  "@langchain/langgraph-sdk": "^1.9.0"
51
52
  },
52
53
  "devDependencies": {
53
- "@skein-js/storage-memory": "0.1.0"
54
+ "@skein-js/storage-memory": "0.2.0"
54
55
  },
55
56
  "publishConfig": {
56
57
  "access": "public"