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