@skein-js/core 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.
Files changed (2) hide show
  1. package/README.md +73 -18
  2. package/package.json +5 -4
package/README.md CHANGED
@@ -1,44 +1,99 @@
1
1
  # @skein-js/core
2
2
 
3
- > Framework-agnostic Agent Protocol engine for LangGraph.js — the heart of skein-js.
3
+ > The shared Agent Protocol **contract** for skein-js — wire types, the `SkeinStore` interface, the queue / bus / auth seams, and the edge error type.
4
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.
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 run engine, handler table, and SSE mapping that build on this contract live in [`@skein-js/agent-protocol`](../agent-protocol).
8
8
 
9
- ## What it does
9
+ ## Contents
10
+
11
+ - [What it does](#what-it-does)
12
+ - [Install](#install)
13
+ - [Usage](#usage)
14
+ - [API](#api)
15
+ - [Reuse](#reuse)
16
+ - [Learn more](#learn-more)
17
+ - [License](#license)
10
18
 
11
- Holds the Agent Protocol _contract_ once, against _normalized_ types, so behavior is identical across every framework adapter and storage driver. Everything downstream imports it:
19
+ ## What it does
12
20
 
13
- - **Wire types** re-exported from `@langchain/langgraph-sdk` (`Assistant`, `Thread`, `Run`, `RunStatus`, `Config`, `Metadata`, `Item`, `StreamMode`, …) — the single seam that pins the protocol version.
14
- - **`SkeinStore`** the persistence interface for protocol resources (`assistants` / `threads` / `runs` / `store`), including the `hasActiveRun` concurrency guard and `isTerminalRunStatus`.
15
- - **`RunQueue` / `RunEventBus`** — the run queue + streaming pub/sub seams.
21
+ Holds the Agent Protocol _contract_ once, against _normalized_ types, so behavior is identical across
22
+ every framework adapter and storage driver. It **defines interfaces; it implements nothing** the
23
+ drivers ([`storage-memory`](../storage-memory), [`storage-postgres`](../storage-postgres),
24
+ [`redis`](../runtime-redis)) implement these interfaces and the [engine](../agent-protocol) consumes
25
+ them. Everything downstream imports it:
26
+
27
+ - **Wire types** re-exported from `@langchain/langgraph-sdk` (`Assistant`, `Thread`, `Run`,
28
+ `RunStatus`, `Config`, `Metadata`, `Item`, `StreamMode`, `Interrupt`, …) — the single seam that
29
+ pins the protocol version. skein-js never redefines them.
30
+ - **`SkeinStore`** — the persistence interface for protocol resources (`assistants` / `threads` /
31
+ `runs` / `store`), including the `hasActiveRun` concurrency guard and `isTerminalRunStatus`.
32
+ - **`RunQueue` / `RunEventBus` / `RunFrame`** — the background-run queue and streaming pub/sub seams.
33
+ - **`AuthEngine`** — the authentication + authorization contract (LangGraph-style custom auth),
34
+ consulted per request by the engine when present.
16
35
  - **`SkeinHttpError`** — the typed edge error carrying an HTTP status.
36
+ - **`serializeWireJson`** — flattens LangChain messages to the Agent Protocol wire shape for output.
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ pnpm add @skein-js/core
42
+ ```
43
+
44
+ Peer dependencies (install once in your project): `@langchain/langgraph` and
45
+ `@langchain/langgraph-sdk`. `core` bundles nothing itself.
17
46
 
18
47
  ## Usage
19
48
 
49
+ You rarely import `core` directly — you get it transitively. You reach for it when **implementing a
50
+ driver** or **handling errors at the HTTP edge**:
51
+
20
52
  ```ts
21
53
  import { type SkeinStore, SkeinHttpError, isTerminalRunStatus } from "@skein-js/core";
22
54
 
23
- // Storage drivers implement SkeinStore; adapters catch SkeinHttpError at the HTTP edge.
55
+ // Storage drivers implement SkeinStore
56
+ export class MyStore implements SkeinStore {
57
+ /* assistants / threads / runs / store repos */
58
+ }
59
+
60
+ // …and adapters throw/catch SkeinHttpError at the HTTP edge.
24
61
  throw SkeinHttpError.notFound(`Thread "${id}" not found.`);
25
62
  ```
26
63
 
27
- ## Reuse
64
+ ## API
65
+
66
+ - **Wire types** (re-exported from `@langchain/langgraph-sdk`): `Assistant`, `AssistantBase`,
67
+ `AssistantGraph`, `Checkpoint`, `Config`, `DefaultValues`, `GraphSchema`, `Interrupt`, `Item`,
68
+ `Metadata`, `Run`, `SearchItem`, `StreamMode`, `Thread`, `ThreadState`, `ThreadStatus`,
69
+ `ThreadTask`; plus `RunStatus` and `MultitaskStrategy` derived from `Run`.
70
+ - **`interface SkeinStore`** — `{ assistants: AssistantRepo; threads: ThreadRepo; runs: RunRepo; store: StoreRepo }`.
71
+ Each repo exposes CRUD + list/search; `RunRepo.hasActiveRun(threadId)` is the concurrency guard
72
+ (`true` while a run is `pending`/`running`). Input types: `AssistantCreate`, `ThreadCreate`,
73
+ `ThreadUpdate`, `RunCreate`, `RunKwargs`, `StoreSearchQuery`.
74
+ - **`TERMINAL_RUN_STATUSES`** / **`isTerminalRunStatus(status)`** — `success` / `error` / `timeout` /
75
+ `interrupted` are terminal (a resume arrives as a fresh run).
76
+ - **`interface RunQueue`** — `enqueue(run)` + `consume(process, options?)` → `RunConsumer`.
77
+ **`interface RunEventBus`** — `publish` / `close` / `subscribe(runId, afterSeq?)`. **`RunFrame`** =
78
+ `{ seq, event, data }` (monotonic `seq` per run). Plus `QueuedRun`, `RunProcessor`, `RunConsumer`,
79
+ `RunConsumerOptions`.
80
+ - **`interface AuthEngine`** — `authenticate(request)` (→ `AuthContext`, throws 401) + `authorize({ resource, action, value, context })` (→ `{ filters?, value }`, throws 403) + `matchesFilters(...)`. Plus `AuthContext`, `AuthUser`, `AuthResource`, `AuthAction`, `AuthFilters`, `AuthFilterValue`.
81
+ - **`class SkeinHttpError`** — `new SkeinHttpError(status, message, options?)` and the static helpers
82
+ `badRequest` (400) / `unauthorized` (401) / `forbidden` (403) / `notFound` (404) / `conflict` (409);
83
+ `isSkeinHttpError(value)` narrows it.
84
+ - **`serializeWireJson(value): string`** — `JSON.stringify` replacement that flattens LangChain
85
+ `BaseMessage`s to the wire shape the SDK / `useStream` / Agent Chat UI expect.
28
86
 
29
- Reuses `@langchain/langgraph-sdk` TypeScript types as the wire contract rather than redefining them. Graphs run through `@langchain/langgraph` (`CompiledStateGraph.invoke`/`.stream`, interrupts/resume) in [`@skein-js/agent-protocol`](../agent-protocol) — never a reimplemented runtime.
30
-
31
- ## Install
87
+ ## Reuse
32
88
 
33
- ```bash
34
- pnpm add @skein-js/core
35
- ```
89
+ Reuses `@langchain/langgraph-sdk` TypeScript types as the wire contract rather than redefining them.
90
+ Graphs run through `@langchain/langgraph` (`CompiledStateGraph.invoke`/`.stream`, interrupts/resume)
91
+ in [`@skein-js/agent-protocol`](../agent-protocol) — never a reimplemented runtime.
36
92
 
37
93
  ## Learn more
38
94
 
39
- - [skein-js overview](../../docs/index.md)
40
- - [Reuse-first architecture](../../docs/reuse.md)
41
- - [Roadmap](../../docs/roadmap.md)
95
+ - [Agent Protocol surface](../../docs/agent-protocol.md) · [Storage](../../docs/storage.md)
96
+ - [skein-js overview](../../docs/index.md) · [Reuse-first architecture](../../docs/reuse.md) · [Root README](../../README.md)
42
97
 
43
98
  ## License
44
99
 
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@skein-js/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Framework-agnostic Agent Protocol engine for LangGraph.js — the heart of skein-js.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Maina Wycliffe <wmmaina7@gmail.com>",
7
- "homepage": "https://github.com/mainawycliffe/skein/tree/main/packages/core#readme",
7
+ "homepage": "https://github.com/mainawycliffe/skein-js/tree/main/packages/core#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/core"
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",