@silverprotocol/claude-agent-sdk 0.2.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.
- package/README.md +28 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
1
|
# @silverprotocol/claude-agent-sdk
|
|
2
2
|
|
|
3
3
|
AgJSON normalizer for the Claude Agent SDK (`SDKMessage` → `AgEvent[]`) — the
|
|
4
|
-
live path.
|
|
4
|
+
live path. It **sits on top of your Claude Agent SDK run** and translates its
|
|
5
|
+
native event stream into framework-neutral AgJSON; it doesn't replace or wrap
|
|
6
|
+
the SDK you already use.
|
|
5
7
|
|
|
6
8
|
## Install
|
|
7
9
|
|
|
8
10
|
```sh
|
|
9
|
-
npm install @silverprotocol/claude-agent-sdk
|
|
11
|
+
npm install @silverprotocol/claude-agent-sdk @anthropic-ai/claude-agent-sdk
|
|
10
12
|
```
|
|
11
13
|
|
|
12
|
-
`@silverprotocol/core` is a required peer (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
`@silverprotocol/core` is a required peer (pulled in automatically).
|
|
15
|
+
`@anthropic-ai/claude-agent-sdk` is the Claude Agent SDK itself — you need it
|
|
16
|
+
to *produce* the stream. (The normalizer guards `SDKMessage` structurally, so
|
|
17
|
+
if you only ever feed it already-captured events it's just a type-level peer.)
|
|
16
18
|
|
|
17
19
|
## Usage
|
|
18
20
|
|
|
19
21
|
```ts
|
|
22
|
+
// `query` is the Claude Agent SDK's own streaming call — you keep using
|
|
23
|
+
// your framework as-is; this package only normalizes what it emits.
|
|
24
|
+
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
20
25
|
import { createClaudeNormalizer } from "@silverprotocol/claude-agent-sdk";
|
|
21
26
|
|
|
22
27
|
const n = createClaudeNormalizer();
|
|
23
28
|
const events = [];
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
|
|
30
|
+
for await (const native of query({ prompt: "call the echo tool" })) {
|
|
31
|
+
events.push(...n.push(native)); // one SDKMessage → 0+ AgEvents
|
|
32
|
+
}
|
|
33
|
+
events.push(...n.flush()); // seal anything still open at end-of-stream
|
|
26
34
|
```
|
|
27
35
|
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
never throws — it routes through the lossless
|
|
32
|
-
channel instead.
|
|
36
|
+
`push()` returns the `AgEvent[]` synthesized from each native `SDKMessage`;
|
|
37
|
+
`flush()` drains buffered end-of-stream state. Any async/sync iterable of
|
|
38
|
+
`SDKMessage` works — a live `query()` run, or messages you captured earlier.
|
|
39
|
+
Malformed input never throws — it routes through the lossless
|
|
40
|
+
`ext.anthropic.unparsed` channel instead.
|
|
41
|
+
|
|
42
|
+
Then fold the resulting `AgEvent`s into messages and turns with
|
|
43
|
+
`@silverprotocol/core`'s `reduce()` — the same client code regardless of which
|
|
44
|
+
framework produced the stream.
|
|
33
45
|
|
|
34
|
-
Spec:
|
|
35
|
-
|
|
46
|
+
Spec: [silverprotocol.io/AgJSON](https://silverprotocol.io/AgJSON) — canonical
|
|
47
|
+
in [silverprotocol/AgJSON](https://github.com/silverprotocol/AgJSON); wire
|
|
48
|
+
version `1.0.0-draft.1`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silverprotocol/claude-agent-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "AgJSON normalizer for the Claude Agent SDK (SDKMessage → AgEvent[]) — the live path.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"!dist/**/*.test.*"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@silverprotocol/core": "0.2.
|
|
34
|
+
"@silverprotocol/core": "0.2.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@anthropic-ai/claude-agent-sdk": ">=0.2.76 <0.4"
|