@raindrop-ai/openai-managed-agents 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Raindrop AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # Raindrop for the OpenAI Agents API
2
+
3
+ Capture the managed Agents API (`openai.beta.agents.sessions`) in Raindrop.
4
+ This package uses `openai`, the OpenAI TypeScript SDK. For the separate,
5
+ in-process `@openai/agents` framework, use `@raindrop-ai/openai-agents`.
6
+
7
+ Requires Node.js 22+ and OpenAI SDK 7.15.x–7.x.
8
+
9
+ ```sh
10
+ pnpm add @raindrop-ai/openai-managed-agents openai
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ts
16
+ import OpenAI from "openai";
17
+ import { createRaindropOpenAIManagedAgents } from "@raindrop-ai/openai-managed-agents";
18
+
19
+ const raindrop = createRaindropOpenAIManagedAgents({
20
+ writeKey: process.env.RAINDROP_WRITE_KEY,
21
+ userId: "user_123",
22
+ properties: { feature: "world_builder" },
23
+ });
24
+ const client = raindrop.wrap(new OpenAI());
25
+
26
+ try {
27
+ const events = await client.beta.agents.sessions.create({
28
+ agent: { model: "gpt-6-astra", instructions: "Help build a simulation World." },
29
+ environment: { type: "openai_hosted" },
30
+ input: "Describe the files needed for a simulation World.",
31
+ stream: true,
32
+ });
33
+ try {
34
+ for await (const event of events) {
35
+ if (event.type === "agent.session.turn.output_text.delta") process.stdout.write(event.delta);
36
+ if (event.type === "agent.session.idle") break;
37
+ }
38
+ } finally {
39
+ events.controller.abort();
40
+ }
41
+ } finally {
42
+ await raindrop.shutdown();
43
+ }
44
+ ```
45
+
46
+ Use an OpenAI application key with the [Agents API permissions](https://developers.openai.com/api/docs/guides/agents-api/quickstart).
47
+ No OpenTelemetry setup is required. Missing or blank Raindrop keys disable cloud
48
+ shipping. Set `localWorkshopUrl: false` to disable local Workshop mirroring.
49
+
50
+ ## Capture
51
+
52
+ - One partial event per turn, completed when the native turn reaches a terminal state.
53
+ - Session model, user input, completed final answer, per-turn usage, and provider attribution.
54
+ - A root turn span and child command, function, MCP, search, and subagent-control tool spans.
55
+ - Session and turn IDs in properties. By default, the session ID is the conversation ID.
56
+ - Original OpenAI results, events, request options, abort controls, and response helpers.
57
+
58
+ The wrapper observes `sessions.create`, `sessions.retrieve`,
59
+ `sessions.events.create`, `sessions.events.stream`, and `sessions.stream`.
60
+ Use `raindrop.wrap(client, { userId, convoId, eventName, properties })` for context
61
+ on sessions created or retrieved through that wrapper. Use a single wrapper for
62
+ each native client. Retrieve an existing session before following its events to
63
+ capture its model. Reading raw bodies with `asResponse()` bypasses capture.
64
+
65
+ ## Reconnecting runners and stored history
66
+
67
+ For a runner that reconnects streams, use the public typed handler with an
68
+ unwrapped native client. Keep one Raindrop client for the runner's lifetime:
69
+
70
+ ```ts
71
+ raindrop.handler.onSession(session);
72
+ raindrop.handler.onInput(session.id, userInput); // after successful submission
73
+ // Recover missed item events before completing recovered turns.
74
+ for await (const item of client.beta.agents.sessions.items.list(session.id, { order: "asc" })) {
75
+ raindrop.handler.onItem(session.id, item);
76
+ }
77
+ for await (const turn of client.beta.agents.sessions.turns.list(session.id, { order: "asc" })) {
78
+ raindrop.handler.onTurn(turn);
79
+ }
80
+ for await (const event of events) raindrop.handler.onEvent(event);
81
+ await raindrop.flush();
82
+ // After all streams/recovery work are stopped:
83
+ raindrop.handler.forgetSession(session.id);
84
+ await raindrop.shutdown();
85
+ ```
86
+
87
+ Open the stream before recovery so it can buffer live updates. Recover stored
88
+ items, then stored turns, before consuming buffered events.
89
+
90
+ `onInputEvents(sessionId, events)` records accepted message/tool-result submissions.
91
+ Repeated terminal turns and tool receipts are deduplicated within this client.
92
+ Turn deduplication retains the latest 10,000 completed turns. Across process
93
+ restarts, provide a stable `eventId: (turnId) => ...` and replay items before turns.
94
+ No session or item listing is intercepted automatically.
95
+
96
+ The wrapper closes unfinished captures in the iterator's `finally`, including
97
+ early exit and transport failure. This marks capture interruption; it does not
98
+ cancel the backend turn. Session model and context remain available for later
99
+ streams; the previous input is cleared. Metadata retains the latest 10,000 idle
100
+ sessions plus sessions with active turns. Call `forgetSession` when
101
+ the session is no longer needed. Use the callback path when an unfinished turn
102
+ must survive a reconnection.
103
+
104
+ ## Options and enrichment
105
+
106
+ Options include `writeKey`, `endpoint`, `projectId`, `userId`, `convoId`,
107
+ `eventName`, `properties`, `appGit`, `debug`, `localWorkshopUrl`,
108
+ `maxTextFieldChars`, `eventId(turnId)`, and `redact(text)`.
109
+ Text uses the shared core bounds. `redact` applies to captured prompts, answers,
110
+ tool payloads, and errors. Caller-supplied properties/attachments are the caller's
111
+ responsibility.
112
+
113
+ `events.patch`, `events.finish`, `events.addAttachments`, `events.setProperties`,
114
+ `users.identify`, and `signals.track` expose the shared core enrichment API.
115
+ `flush()` ships current buffers; `shutdown()` also closes unfinished captures.
116
+
117
+ ## Limits
118
+
119
+ The service does not expose individual inference requests. Captures represent
120
+ turns, rather than each hidden model call. Usage comes only from `Turn.usage`;
121
+ missing usage stays missing. Session-wide cumulative counters are never used as
122
+ turn usage. Usage is best effort and later revisions after the first terminal
123
+ receipt are not applied.
124
+
125
+ Span timing reflects observed lifecycle events, including recovery; native turn
126
+ timestamps are recorded as `openai.turn.*` attributes. Command duration is available
127
+ in the native item. Image contents, reasoning text, intermediate commentary,
128
+ agent-to-agent messages, and streaming text deltas are not automatically
129
+ captured. Final text is read from completed final-answer items. Subagent turns
130
+ are grouped by session and identified by subagent ID; no cross-turn parent
131
+ hierarchy is inferred. Coordinator model identity is available from the session
132
+ configuration. Subagent model and inherited coordinator input stay absent unless
133
+ their own input is recorded.
134
+
135
+ See [RELEASING.md](RELEASING.md) for first-publication and verification steps.
136
+ See the [integration docs](https://docs.raindrop.ai/integrations/openai-managed-agents)
137
+ for configuration details.
package/RELEASING.md ADDED
@@ -0,0 +1,41 @@
1
+ # First publication
2
+
3
+ The first release is bootstrapped locally as 0.0.1 using the reviewed integration
4
+ branch. Its initial patch changeset is consumed before building, so source,
5
+ bundled telemetry version, and registry version match.
6
+
7
+ 1. Confirm the integration PR's build, fault, and prod gates pass. OpenAI 7
8
+ requires Node 22+. The release and PR harness pins must match.
9
+ 2. Build the package, inspect `pnpm pack`, and publish the 0.0.1 tarball with an
10
+ authorized npm organization login. Do not publish development version 0.0.0.
11
+ 3. A package-specific trusted publisher requires the package to exist first
12
+ ([npm trust prerequisites](https://docs.npmjs.com/cli/v11/commands/npm-trust/)).
13
+ 4. Configure the new package's npm trusted publisher for
14
+ `raindrop-ai/raindrop-js`, workflow `publish.yml`, using the organization’s
15
+ normal release settings. Do not change repository npm security settings.
16
+ 5. Confirm registry metadata, exports, and installation in a fresh Node 22
17
+ application. Run the example with an Agents-enabled application key.
18
+ 6. Update the companion Raindrop PR's worker dependency to 0.0.1 and regenerate
19
+ its pnpm lockfile from npm. Merge the Astra consumer after publication.
20
+
21
+ ## Subsequent releases
22
+
23
+ Add a patch or minor changeset for package changes. After the integration PR is
24
+ merged, merge the normal Changesets version PR. The existing `publish.yml`
25
+ workflow detects the consumed changeset and version bump, runs its conformance
26
+ gate, builds, and publishes through npm's GitHub Actions trusted publisher.
27
+ The initial release is already registered, so merging it does not republish
28
+ 0.0.1. Do not merge the initial integration until its trusted publisher is set.
29
+
30
+ ## Conformance
31
+
32
+ Driver: `conformance/openai-managed-agents-driver.mjs`.
33
+ Run the pinned cross-SDK harness fault lane locally, and its prod lane with
34
+ write/query credentials. The driver uses public session/turn callbacks and
35
+ real Raindrop core shipping. It does not make an OpenAI model request.
36
+ The native OpenAI HTTP/SSE path is covered separately by MSW integration tests.
37
+ Live Astra inference and Query API readback remain distinct release checks.
38
+
39
+ Use the repository's [conformance instructions](../../conformance/README.md).
40
+ Known gaps have ticket-linked entries in
41
+ `conformance/openai-managed-agents-failures.txt`. No workflow is bypassed.