@silverprotocol/core 0.1.0 → 0.2.0-beta.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 +77 -22
- package/package.json +15 -2
package/README.md
CHANGED
|
@@ -1,7 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://silverprotocol.io/hero.png" width="200" alt="A glass prism splitting a beam of white light into a rainbow" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
<h1 align="center">@silverprotocol/core</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<b>AgJSON</b> — the open, neutral, typed transport for normalized agent-framework I/O.<br/>
|
|
9
|
+
The core package: the typed schema, the <code>Normalizer</code> contract, and the normative <code>reduce()</code>.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/@silverprotocol/core"><img src="https://img.shields.io/npm/v/%40silverprotocol%2Fcore?color=0a7"></a>
|
|
14
|
+
<a href="https://github.com/silverprotocol/AgJSON/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue"></a>
|
|
15
|
+
<a href="https://silverprotocol.io/AgJSON"><img src="https://img.shields.io/badge/spec-1.0.0--draft.1-6ee7ff"></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Every agent framework — Claude Agent SDK, OpenAI Agents SDK, Google ADK, LangGraph,
|
|
21
|
+
Vercel AI SDK — streams its own shape of events. Build a client, a UI, or a tool
|
|
22
|
+
that works across more than one and you end up writing a bespoke adapter per
|
|
23
|
+
framework.
|
|
24
|
+
|
|
25
|
+
**AgJSON is the wire format that ends that.** It normalizes any framework's native
|
|
26
|
+
event stream into one typed, versioned, forward-compatible shape — so a client
|
|
27
|
+
written once works with every framework a normalizer exists for.
|
|
28
|
+
|
|
29
|
+
## What's in `core`
|
|
30
|
+
|
|
31
|
+
- **The schema** — `AgInput`, `AgEvent`, `AgMessage`, `AgReduceResult`, all as
|
|
32
|
+
discriminated unions (typed, never `any`) with Zod validators.
|
|
33
|
+
- **The `Normalizer` contract** — the stateful, per-invoke
|
|
34
|
+
`push(native): AgEvent[]` / `flush(): AgEvent[]` interface every
|
|
35
|
+
`@silverprotocol/<framework>` package implements.
|
|
36
|
+
- **`reduce()`** — the normative fold from an `AgEvent` stream into the
|
|
37
|
+
messages / turns / artifacts object graph your client renders.
|
|
5
38
|
|
|
6
39
|
## Install
|
|
7
40
|
|
|
@@ -9,34 +42,56 @@ the `Normalizer` interface, and the normative `reduce()`.
|
|
|
9
42
|
npm install @silverprotocol/core
|
|
10
43
|
```
|
|
11
44
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
45
|
+
To actually **produce** AgJSON from a framework, add its normalizer:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install @silverprotocol/claude-agent-sdk
|
|
49
|
+
# or @silverprotocol/openai-agents / @silverprotocol/google-adk
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Consume AgJSON
|
|
15
53
|
|
|
16
|
-
|
|
54
|
+
`core` is the consumer side — validate an incoming event stream and fold it into
|
|
55
|
+
the object graph, with the same code regardless of which framework produced it:
|
|
17
56
|
|
|
18
57
|
```ts
|
|
19
58
|
import { ingestAgEvents, Reducer, AGJSON_VERSION } from "@silverprotocol/core";
|
|
20
59
|
|
|
21
|
-
const
|
|
22
|
-
{ type: "turn.start", seq: 0, threadId: "th1", turnId: "t1" },
|
|
23
|
-
{ type: "message.start", seq: 1, id: "m1", role: "assistant", turnId: "t1", threadId: "th1" },
|
|
24
|
-
{ type: "message.end", seq: 2, id: "m1" },
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
const events = ingestAgEvents(raw); // parse-known-else-skip (consumer posture)
|
|
60
|
+
const events = ingestAgEvents(rawWireObjects); // parse-known-else-skip
|
|
28
61
|
|
|
29
62
|
const reducer = new Reducer();
|
|
30
63
|
for (const ev of events) reducer.push(ev);
|
|
31
|
-
const result = reducer.result(); // { messages, turns, artifacts, memory }
|
|
32
64
|
|
|
33
|
-
|
|
65
|
+
const { messages, turns, artifacts, memory } = reducer.result();
|
|
66
|
+
console.log(AGJSON_VERSION, messages);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`ingestAgEvents` validates raw wire objects against `AgEvent` and drops anything
|
|
70
|
+
unparseable (the consumer posture); `Reducer` folds the validated stream into the
|
|
71
|
+
normative snapshot; `AGJSON_VERSION` is the wire version this build implements
|
|
72
|
+
(`1.0.0-draft.1`).
|
|
73
|
+
|
|
74
|
+
## Produce AgJSON
|
|
75
|
+
|
|
76
|
+
Turn a framework's native stream into AgJSON with its normalizer — the output is
|
|
77
|
+
framework-neutral, ready to send over the wire, persist, or feed straight to the
|
|
78
|
+
`Reducer` above:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { createClaudeNormalizer } from "@silverprotocol/claude-agent-sdk";
|
|
82
|
+
|
|
83
|
+
const n = createClaudeNormalizer();
|
|
84
|
+
const agEvents = [];
|
|
85
|
+
for await (const native of claudeStream) agEvents.push(...n.push(native));
|
|
86
|
+
agEvents.push(...n.flush());
|
|
34
87
|
```
|
|
35
88
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
89
|
+
## Learn more
|
|
90
|
+
|
|
91
|
+
- **Spec & docs** — [silverprotocol.io/AgJSON](https://silverprotocol.io/AgJSON)
|
|
92
|
+
- **Flagship, examples & discussion** — [github.com/silverprotocol/AgJSON](https://github.com/silverprotocol/AgJSON)
|
|
93
|
+
- **This SDK** — [github.com/silverprotocol/typescript-sdk](https://github.com/silverprotocol/typescript-sdk)
|
|
94
|
+
|
|
95
|
+
## License
|
|
40
96
|
|
|
41
|
-
|
|
42
|
-
release); wire version `1.0.0-draft.1`.
|
|
97
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silverprotocol/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta.0",
|
|
4
4
|
"description": "AgJSON core — the typed schema (AgInput / AgEvent / AgMessage), the Normalizer interface, and the normative reduce().",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -8,10 +8,23 @@
|
|
|
8
8
|
"url": "git+https://github.com/silverprotocol/typescript-sdk.git",
|
|
9
9
|
"directory": "packages/core"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://silverprotocol.io/AgJSON",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/silverprotocol/typescript-sdk/issues"
|
|
14
14
|
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"agjson",
|
|
17
|
+
"agent",
|
|
18
|
+
"agents",
|
|
19
|
+
"ai",
|
|
20
|
+
"llm",
|
|
21
|
+
"normalizer",
|
|
22
|
+
"protocol",
|
|
23
|
+
"streaming",
|
|
24
|
+
"mcp",
|
|
25
|
+
"claude",
|
|
26
|
+
"openai"
|
|
27
|
+
],
|
|
15
28
|
"publishConfig": {
|
|
16
29
|
"access": "public"
|
|
17
30
|
},
|