@silverprotocol/openai-agents 0.2.0-beta.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 +29 -14
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,33 +1,48 @@
1
1
  # @silverprotocol/openai-agents
2
2
 
3
3
  AgJSON normalizer for the OpenAI Agents SDK (`RunItemStreamEvent` / Responses
4
- streaming → `AgEvent[]`) — fixture-tested.
4
+ streaming → `AgEvent[]`) — fixture-tested. It **sits on top of your OpenAI
5
+ Agents run** and translates its native stream into framework-neutral AgJSON;
6
+ it doesn't replace the SDK you already use.
5
7
 
6
8
  ## Install
7
9
 
8
10
  ```sh
9
- npm install @silverprotocol/openai-agents
11
+ npm install @silverprotocol/openai-agents @openai/agents
10
12
  ```
11
13
 
12
- `@silverprotocol/core` is a required peer (installed automatically as a
13
- dependency). `@openai/agents` is an OPTIONAL peer — only needed if you want
14
- its native stream-event types; it is not required at import time.
14
+ `@silverprotocol/core` is a required peer (pulled in automatically).
15
+ `@openai/agents` is the OpenAI Agents SDK itself — you need it to *produce* the
16
+ stream. (The normalizer handles the native events structurally, so if you only
17
+ feed it already-captured events it's just a type-level peer.)
15
18
 
16
19
  ## Usage
17
20
 
18
21
  ```ts
22
+ import { Agent, run } from "@openai/agents";
19
23
  import { createOpenaiNormalizer } from "@silverprotocol/openai-agents";
20
24
 
25
+ const agent = new Agent({ name: "Assistant", instructions: "Use the echo tool." });
21
26
  const n = createOpenaiNormalizer();
22
- const events = [];
23
- for (const native of stream) events.push(...n.push(native));
24
- events.push(...n.flush());
27
+ const agEvents = [];
28
+
29
+ // `run(..., { stream: true })` is the OpenAI Agents SDK's own streamed run —
30
+ // you keep using your framework as-is; this package normalizes what it emits.
31
+ const stream = await run(agent, "call the echo tool", { stream: true });
32
+ for await (const native of stream) agEvents.push(...n.push(native));
33
+ await stream.completed; // let the run finish
34
+ agEvents.push(...n.flush()); // seal anything still open
25
35
  ```
26
36
 
27
- `stream` is whatever async/sync iterable of native OpenAI Agents SDK stream
28
- events your run yields (`RunItemStreamEvent`s or raw Responses-API streaming
29
- events, both are handled). `push()` returns the `AgEvent[]` synthesized from
30
- that native event; `flush()` drains any buffered end-of-stream state.
37
+ `push()` returns the `AgEvent[]` synthesized from each native stream event
38
+ (`RunItemStreamEvent`s or raw Responses-API events — both handled); `flush()`
39
+ drains buffered end-of-stream state. Any async/sync iterable of those native
40
+ events works — a live streamed run, or events you captured earlier.
31
41
 
32
- Spec: `SPEC.md` at the repo root of [silverprotocol/typescript-sdk](https://github.com/silverprotocol/typescript-sdk) (published with the first
33
- release); wire version `1.0.0-draft.1`.
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.
45
+
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/openai-agents",
3
- "version": "0.2.0-beta.0",
3
+ "version": "0.2.1",
4
4
  "description": "AgJSON normalizer for the OpenAI Agents SDK (RunItemStreamEvent / Responses streaming → AgEvent[]) — fixture-tested.",
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.0-beta.0"
34
+ "@silverprotocol/core": "0.2.1"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@openai/agents": ">=0.2.0 <0.13"