diff --git a/README.md b/README.md index be1f095..f4f7fa1 100644 --- a/README.md +++ b/README.md @@ -139,25 +139,26 @@ Streamed output is kept within fixed size limits that each provider package's RE Each integration links to its installation instructions and API coverage. The link text is the npm or PyPI package name. -| Integration | TypeScript | Python | -| ---------------------------- | ------------------------------------------------------ | -------------------------------------------------------- | -| Core SDK | [`@telemetry-dev/sdk`](packages/sdk) | [`telemetry-dev`](sdks/python) | -| Existing OpenTelemetry setup | [`@telemetry-dev/otel`](packages/otel) | [`telemetry-dev`](sdks/python) (`telemetry_dev.otel`) | -| OpenAI | [`@telemetry-dev/openai`](packages/openai) | [`telemetry-dev-openai`](sdks/python-openai) | -| Anthropic | [`@telemetry-dev/anthropic`](packages/anthropic) | [`telemetry-dev-anthropic`](sdks/python-anthropic) | -| Amazon Bedrock | [`@telemetry-dev/bedrock`](packages/bedrock) | [`telemetry-dev-bedrock`](sdks/python-bedrock) | -| Google GenAI | [`@telemetry-dev/google-genai`](packages/google-genai) | [`telemetry-dev-google-genai`](sdks/python-google-genai) | -| OpenRouter | [`@telemetry-dev/openrouter`](packages/openrouter) | [`telemetry-dev-openrouter`](sdks/python-openrouter) | -| Vercel AI SDK | [`@telemetry-dev/ai-sdk`](packages/ai) | | -| TanStack AI | [`@telemetry-dev/tanstack-ai`](packages/tanstack-ai) | | -| LangChain and LangGraph | [`@telemetry-dev/langchain`](packages/langchain) | | -| LiteLLM | | [`telemetry-dev-litellm`](sdks/python-litellm) | -| MCP | [`@telemetry-dev/mcp`](packages/mcp) | | -| Eve | [`@telemetry-dev/eve`](packages/eve) | | -| Cursor | [`@telemetry-dev/cursor`](packages/cursor) | | -| OpenCode | [`@telemetry-dev/opencode`](packages/opencode) | | -| Oh My Pi | [`@telemetry-dev/omp`](packages/omp) | | -| Pi | [`@telemetry-dev/pi`](packages/pi) | | +| Integration | TypeScript | Python | +| ---------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| Core SDK | [`@telemetry-dev/sdk`](packages/sdk) | [`telemetry-dev`](sdks/python) | +| Existing OpenTelemetry setup | [`@telemetry-dev/otel`](packages/otel) | [`telemetry-dev`](sdks/python) (`telemetry_dev.otel`) | +| OpenAI | [`@telemetry-dev/openai`](packages/openai) | [`telemetry-dev-openai`](sdks/python-openai) | +| Anthropic | [`@telemetry-dev/anthropic`](packages/anthropic) | [`telemetry-dev-anthropic`](sdks/python-anthropic) | +| Amazon Bedrock | [`@telemetry-dev/bedrock`](packages/bedrock) | [`telemetry-dev-bedrock`](sdks/python-bedrock) | +| Google GenAI | [`@telemetry-dev/google-genai`](packages/google-genai) | [`telemetry-dev-google-genai`](sdks/python-google-genai) | +| OpenRouter | [`@telemetry-dev/openrouter`](packages/openrouter) | [`telemetry-dev-openrouter`](sdks/python-openrouter) | +| Vercel AI SDK | [`@telemetry-dev/ai-sdk`](packages/ai) | | +| TanStack AI | [`@telemetry-dev/tanstack-ai`](packages/tanstack-ai) | | +| OpenAI Agents SDK | [`@telemetry-dev/openai-agents`](packages/openai-agents) | | +| LangChain and LangGraph | [`@telemetry-dev/langchain`](packages/langchain) | | +| LiteLLM | | [`telemetry-dev-litellm`](sdks/python-litellm) | +| MCP | [`@telemetry-dev/mcp`](packages/mcp) | | +| Eve | [`@telemetry-dev/eve`](packages/eve) | | +| Cursor | [`@telemetry-dev/cursor`](packages/cursor) | | +| OpenCode | [`@telemetry-dev/opencode`](packages/opencode) | | +| Oh My Pi | [`@telemetry-dev/omp`](packages/omp) | | +| Pi | [`@telemetry-dev/pi`](packages/pi) | | Some integrations need no package from this repository, because the tool exports OpenTelemetry itself or through a third-party library: Claude Code, Claude Platform, Claude SDK native spans, diff --git a/packages/openai-agents/LICENSE b/packages/openai-agents/LICENSE new file mode 100644 index 0000000..8592a25 --- /dev/null +++ b/packages/openai-agents/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 telemetry.dev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/openai-agents/README.md b/packages/openai-agents/README.md new file mode 100644 index 0000000..d6fd654 --- /dev/null +++ b/packages/openai-agents/README.md @@ -0,0 +1,117 @@ +# @telemetry-dev/openai-agents + +OpenAI Agents SDK integration for [telemetry.dev](https://telemetry.dev). It sends each agent run +to telemetry.dev: the agent and its turns, each model call with its token usage, each tool call, and +each command that a sandbox agent ran, with its exit code. + +How runs group into traces: + +- A run is one trace by default. +- A run that starts inside an active OpenTelemetry span, such as an HTTP request span, joins that + span's trace. +- Runs that share a `groupId` share a session: the processor sends the `groupId` as the session ID + (`gen_ai.conversation.id`). Runs inside the same + [`propagateAttributes({ sessionId })`](https://telemetry.dev/docs/sdk/typescript#add-user-session-and-metadata) + session (from `@telemetry-dev/sdk`) do too; a `groupId` takes precedence. Outside an active span, + the runs of a session land in + [one trace per session](https://telemetry.dev/docs/sdk/typescript#one-trace-per-session), each run + as a root span. +- With `telemetryDevProcessor({ sessionMode: "process" })`, runs without a session of their own + share the process's + [generated session](https://telemetry.dev/docs/sdk/typescript#process-sessions) in the same way. + Use this in a CLI or script that holds one conversation per process, not in a long-running server. + +## Install + +```sh +npm install @telemetry-dev/openai-agents @openai/agents +``` + +Requires `@openai/agents >=0.22.0 <1` and Node.js 22 or newer, the Agents SDK's minimum. + +## Environment + +| Variable | Required | Default | Notes | +| --------------------------- | -------- | --------------------------- | ----------------------------------------------------------------------- | +| `TELEMETRY_DEV_API_KEY` | yes | — | Ingest key (`td_live_…`). No key ⇒ the integration is a complete no-op. | +| `TELEMETRY_DEV_BASE_URL` | no | `https://api.telemetry.dev` | Trailing slashes are stripped. | +| `TELEMETRY_DEV_ENVIRONMENT` | no | `production` | Environment label on every trace. | +| `OTEL_SERVICE_NAME` | no | SDK default | Service name on every trace. | + +All four are also settable through the processor's options. + +## Usage + +Register the processor once, before the first run: + +```ts +import { addTraceProcessor, Agent, run } from "@openai/agents"; +import { telemetryDevProcessor } from "@telemetry-dev/openai-agents"; + +addTraceProcessor(telemetryDevProcessor({ serviceName: "support-agent" })); + +const agent = new Agent({ name: "Assistant", instructions: "Answer briefly." }); +await run(agent, "What is OpenTelemetry?"); +``` + +`addTraceProcessor` keeps the SDK's default exporter, so traces also reach the OpenAI Traces +dashboard. To send them only to telemetry.dev, replace the default exporter: + +```ts +import { setTraceProcessors } from "@openai/agents"; + +setTraceProcessors([telemetryDevProcessor({ serviceName: "support-agent" })]); +``` + +The processor takes the options of `init` from `@telemetry-dev/sdk`, such as `captureInput`, +`captureOutput`, and `mask`. Pass SDK options to the processor and don't also call `init()` +yourself: the first processor created in a process initializes the SDK and replaces a client that +`init()` made earlier. The options of later processors are ignored. + +The root span of a trace ends when the Agents trace ends. A run that throws before the SDK ends its +trace leaves it open, so the root also ends when the run's task or agent span ends with the error. +`forceFlush` and `shutdown` of the trace provider end the root of every trace that has no open span, +at the end of its last span. This covers traces that threw outside any span, such as a run that +failed before its first span. The flush covers every trace in the process, so it can also end the +root of another request's trace between two of its runs; that trace's later spans still nest under +the root. Spans that end after their root, such as those of a slower processor registered first, +nest under it while the processor holds it, which is for the 10,000 most recently active traces. +Call `getGlobalTraceProvider().forceFlush()` at the end of a request in short-lived runtimes. + +The Agents SDK shuts the trace provider down on `SIGTERM`, `SIGINT`, and unhandled rejections. The +processor then ends every open span so that nothing is lost if the process exits. A server that keeps +running to finish its requests still gets their later spans in the same traces, nested under the +trace's root, but a model call that was in progress at that moment is sent without its token usage. + +## Sandbox agents + +Sandbox runs need no extra setup. Each `sandbox.*` span of the Agents SDK, such as +`sandbox.create_session` and `sandbox.exec`, becomes a span with `sandbox.operation`. The spans that +create or resume a session also get `sandbox.backend` (for example `e2b` or `modal`). The +`exec_command` and `write_stdin` tool spans get `process.exit.code` once the command has exited. A +command that exits with a non-zero code is not marked as an error, because many commands, such as +`grep`, exit non-zero without failing. + +## Content and privacy + +- Model inputs and outputs, tool arguments and results, and the command and working directory of + `sandbox.exec` (`process.command_line`, `process.working_directory`) are content. They are sent + only when `captureInput` or `captureOutput` is on, and go through `mask`. +- Keep the Agents SDK's `traceIncludeSensitiveData` on, which is its default. With it off, the SDK + leaves model, token usage, and tool output off its spans, so telemetry.dev cannot price model + calls or read exit codes. Use `captureInput` and `captureOutput` to keep content out of + telemetry.dev instead. With `addTraceProcessor`, the OpenAI exporter still receives content; use + `setTraceProcessors` to stop that. +- With capture off, telemetry.dev still receives span names and timing, model names, token usage, + agent, tool, handoff, and guardrail names, the MCP server of a tool call, exit codes, sandbox + backends, error types, the session id (such as the trace's `groupId`, a + `propagateAttributes()` session, or the process session), the user id and metadata of + `propagateAttributes()`, and the string, number, and boolean values of trace metadata and of the + data of custom spans. Metadata does not go through `mask`. + +## Double counting + +Each model call already gets a `chat` span from this processor. Do not also instrument the OpenAI +client that the Agents SDK uses with `@telemetry-dev/openai`: neither pass a client wrapped with +`wrapOpenAI` to `setDefaultOpenAIClient`, nor call `instrumentOpenAI()`, which instruments every +client in the process. Each model call would then be counted twice. diff --git a/packages/openai-agents/package.json b/packages/openai-agents/package.json new file mode 100644 index 0000000..cf25284 --- /dev/null +++ b/packages/openai-agents/package.json @@ -0,0 +1,73 @@ +{ + "name": "@telemetry-dev/openai-agents", + "version": "0.1.0", + "description": "OpenAI Agents SDK telemetry integration for telemetry.dev: agent runs, model calls, tool calls, and sandbox commands as OpenTelemetry traces.", + "keywords": [ + "agents", + "genai", + "llm", + "observability", + "openai", + "openai-agents", + "opentelemetry", + "sandbox", + "telemetry", + "tracing" + ], + "homepage": "https://telemetry.dev", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/telemetry-dev/telemetry.git", + "directory": "packages/openai-agents" + }, + "files": [ + "dist", + "src" + ], + "type": "module", + "exports": { + ".": { + "bun": "./src/index.ts", + "types": "./src/index.ts", + "development": "./src/index.ts", + "default": "./dist/index.mjs" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public", + "exports": { + ".": { + "types": "./dist/index.d.mts", + "import": "./dist/index.mjs", + "default": "./dist/index.mjs" + }, + "./package.json": "./package.json" + } + }, + "scripts": { + "build": "pnpm exec vp pack", + "dev": "pnpm exec vp pack --watch", + "test": "vp test", + "check": "vp check", + "prepublishOnly": "vp run build" + }, + "dependencies": { + "@telemetry-dev/sdk": "workspace:^" + }, + "devDependencies": { + "@openai/agents": "0.22.0", + "@opentelemetry/sdk-trace-base": "catalog:", + "@types/node": "^25.5.0", + "@typescript/native-preview": "7.0.0-dev.20260328.1", + "openai": "7.60.0", + "typescript": "^6.0.2", + "vite-plus": "0.1.20", + "vitest": "catalog:", + "zod": "catalog:" + }, + "peerDependencies": { + "@openai/agents": ">=0.22.0 <1" + } +} diff --git a/packages/openai-agents/src/config.ts b/packages/openai-agents/src/config.ts new file mode 100644 index 0000000..c401ec1 --- /dev/null +++ b/packages/openai-agents/src/config.ts @@ -0,0 +1,28 @@ +import { type ClientOverrides, init, shutdown, type TelemetryOptions } from "@telemetry-dev/sdk"; + +/** Options accepted by `telemetryDevProcessor`; see `TelemetryOptions` of `@telemetry-dev/sdk`. */ +export type TelemetryDevOpenAIAgentsOptions = Omit; + +export type { ClientOverrides }; + +let initialized = false; + +/** + * Initializes the telemetry.dev SDK once per process for this integration; whichever processor is + * created first wins. The processor builds spans with the SDK's own tracer, so it does not need + * the global OpenTelemetry provider. + */ +export function ensureInit( + options: TelemetryDevOpenAIAgentsOptions = {}, + overrides?: ClientOverrides, +): void { + if (initialized) return; + initialized = true; + init({ ...options, sdkName: "@telemetry-dev/openai-agents" }, overrides); +} + +/** Test seam for unit tests that need a fresh SDK singleton. */ +export async function resetForTesting(): Promise { + initialized = false; + await shutdown(); +} diff --git a/packages/openai-agents/src/index.ts b/packages/openai-agents/src/index.ts new file mode 100644 index 0000000..eda4233 --- /dev/null +++ b/packages/openai-agents/src/index.ts @@ -0,0 +1,3 @@ +export type { ClientOverrides, TelemetryDevOpenAIAgentsOptions } from "./config.ts"; + +export { telemetryDevProcessor } from "./processor.ts"; diff --git a/packages/openai-agents/src/processor.ts b/packages/openai-agents/src/processor.ts new file mode 100644 index 0000000..5c4d7e8 --- /dev/null +++ b/packages/openai-agents/src/processor.ts @@ -0,0 +1,514 @@ +import type { Span, SpanData, Trace, TracingProcessor } from "@openai/agents"; +import { + captureEnabled, + flush, + type SpanFields, + type SpanHandle, + startSpan, + type StartSpanOptions, + type TokenUsage, +} from "@telemetry-dev/sdk"; + +import { + type ClientOverrides, + ensureInit, + type TelemetryDevOpenAIAgentsOptions, +} from "./config.ts"; + +type AgentsSpan = Span; + +type Attrs = NonNullable; + +// Bounds the processor's memory when a host never ends its spans; past the cap new spans are +// dropped, not exported. +const MAX_OPEN_SPANS = 10_000; + +// Bounds the trace roots kept so that spans arriving after their trace ended still find their root. +// Past the cap the root of the trace whose spans started or ended least recently is forgotten, and +// ended first if it is still open. +const MAX_TRACES = 10_000; + +// `formatExecResponse` in agents-core writes this line in the header of a shell tool's output, +// above `Output:`, once the command has exited. A command still running gets a session id line +// instead, and the command's own output below the header can contain any text. +const EXIT_CODE_LINE = /^Process exited with code (-?\d+)$/m; +const OUTPUT_MARKER = "\nOutput:"; + +const SANDBOX_COMMAND_TOOLS = new Set(["exec_command", "write_stdin"]); + +const SANDBOX_SPAN_PREFIX = "sandbox."; + +interface TraceState { + root: SpanHandle; + ended: boolean; + /** Latest observed span end, used to timestamp the root when the trace never ends. */ + lastEnd?: Date; +} + +interface OpenSpan { + handle: SpanHandle; + /** The root state the span started under; a later trace can reuse the same trace id. */ + trace?: TraceState; +} + +// The top-level spans of a run. Upstream ends them with the run's error even when the trace never +// ends; a failed custom span at the top level may be handled by the caller. +const RUN_SPAN_TYPES = new Set(["task", "agent"]); + +type JsonRecord = Record; + +const asRecord = (value: unknown): JsonRecord | undefined => + value !== null && typeof value === "object" && !Array.isArray(value) + ? (value as JsonRecord) + : undefined; + +const asString = (value: unknown): string | undefined => + typeof value === "string" && value.length > 0 ? value : undefined; + +const asNumber = (value: unknown): number | undefined => + typeof value === "number" && Number.isFinite(value) ? value : undefined; + +const toTime = (iso: string | null): Date | undefined => (iso ? new Date(iso) : undefined); + +const compact = (usage: TokenUsage): TokenUsage | undefined => + Object.values(usage).some((v) => v !== undefined) ? usage : undefined; + +/** + * Usage of a Responses API response (`input_tokens_details`), or of a `generation` span, whose + * adapters put token details under `details`. + */ +function usageOf(value: unknown): TokenUsage | undefined { + const usage = asRecord(value); + + if (!usage) return undefined; + const details = asRecord(usage.details); + const inputDetails = asRecord(usage.input_tokens_details) ?? details; + const outputDetails = asRecord(usage.output_tokens_details) ?? details; + + return compact({ + inputTokens: asNumber(usage.input_tokens), + outputTokens: asNumber(usage.output_tokens), + totalTokens: asNumber(usage.total_tokens), + cacheReadInputTokens: asNumber(inputDetails?.cached_tokens), + reasoningOutputTokens: asNumber(outputDetails?.reasoning_tokens), + }); +} + +/** Usage of a Chat Completions response, which a successful `generation` span keeps in its output. */ +function chatCompletionUsageOf(value: unknown): TokenUsage | undefined { + const usage = asRecord(value); + + if (!usage) return undefined; + + return compact({ + inputTokens: asNumber(usage.prompt_tokens), + outputTokens: asNumber(usage.completion_tokens), + totalTokens: asNumber(usage.total_tokens), + cacheReadInputTokens: asNumber(asRecord(usage.prompt_tokens_details)?.cached_tokens), + reasoningOutputTokens: asNumber(asRecord(usage.completion_tokens_details)?.reasoning_tokens), + }); +} + +function primitiveMetadata(value: unknown): Record | undefined { + const record = asRecord(value); + + if (!record) return undefined; + const out: Record = {}; + + for (const [key, v] of Object.entries(record)) { + if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") out[key] = v; + } + + return Object.keys(out).length > 0 ? out : undefined; +} + +/** Name and fields known when the span starts. */ +function startOf(data: SpanData): { name: string; options: StartSpanOptions } { + switch (data.type) { + case "agent": + return { + name: `invoke_agent ${data.name}`, + options: { type: "agent", agentName: data.name }, + }; + case "task": + return { name: `task ${data.name}`, options: {} }; + case "turn": + return { + name: `turn ${data.turn}`, + options: { attributes: { "openai_agents.turn": data.turn } }, + }; + case "response": + return { name: "chat", options: { type: "generation", provider: "openai" } }; + case "generation": + return { + name: data.model ? `chat ${data.model}` : "chat", + options: { type: "generation", model: data.model }, + }; + case "function": + return { + name: `execute_tool ${data.name}`, + options: { type: "tool", toolName: data.name }, + }; + case "handoff": + return { name: "handoff", options: {} }; + case "guardrail": + return { + name: `guardrail ${data.name}`, + options: { attributes: { "openai_agents.guardrail.name": data.name } }, + }; + case "mcp_tools": + return { name: data.server ? `mcp_tools ${data.server}` : "mcp_tools", options: {} }; + case "custom": + return { name: data.name, options: {} }; + default: + return { name: data.type, options: {} }; + } +} + +/** Fields known when the span ends, apart from sandbox attributes. */ +function endOf(data: SpanData): SpanFields { + switch (data.type) { + // The SDK fills the tool list once the agent's tools are resolved, after the span starts. + case "agent": + return { + attributes: { + ...(data.tools?.length ? { "openai_agents.agent.tools": data.tools } : {}), + ...(data.handoffs?.length ? { "openai_agents.agent.handoffs": data.handoffs } : {}), + ...(data.output_type ? { "openai_agents.agent.output_type": data.output_type } : {}), + }, + }; + case "response": { + const response = asRecord(data._response); + const model = asString(response?.model); + + return { + ...(model ? { name: `chat ${model}`, model } : {}), + responseModel: model, + responseId: data.response_id ?? asString(response?.id), + usage: usageOf(response?.usage), + input: data._input, + output: response?.output as SpanFields["output"], + }; + } + + // The Chat Completions model sets the model after the span starts, and on success leaves + // `usage` empty: the usage is only in the completion it stores as output. + case "generation": { + const completion = asRecord(data.output?.[0]); + const model = asString(data.model); + + return { + ...(model ? { name: `chat ${model}`, model } : {}), + responseModel: asString(completion?.model), + responseId: asString(completion?.id), + usage: usageOf(data.usage) ?? chatCompletionUsageOf(completion?.usage), + input: data.input as SpanFields["input"], + output: data.output as SpanFields["output"], + }; + } + + case "function": { + // `mcp_data` is typed as a string but holds `{ server }` at runtime. + const mcpServer = asString(asRecord(data.mcp_data)?.server) ?? asString(data.mcp_data); + + return { + input: data.input, + output: data.output, + ...(mcpServer ? { attributes: { "openai_agents.mcp.server": mcpServer } } : {}), + }; + } + + case "handoff": + return { + name: + data.from_agent && data.to_agent + ? `handoff ${data.from_agent} -> ${data.to_agent}` + : undefined, + attributes: { + ...(data.from_agent ? { "openai_agents.handoff.from": data.from_agent } : {}), + ...(data.to_agent ? { "openai_agents.handoff.to": data.to_agent } : {}), + }, + }; + case "guardrail": + return { attributes: { "openai_agents.guardrail.triggered": data.triggered } }; + case "mcp_tools": + return data.result + ? { attributes: { "openai_agents.mcp.tool_count": data.result.length } } + : {}; + case "custom": + return data.name.startsWith(SANDBOX_SPAN_PREFIX) + ? {} + : { metadata: primitiveMetadata(data.data) }; + default: + return {}; + } +} + +function errorOf(span: AgentsSpan): Error | undefined { + const error = span.error; + + if (!error) return undefined; + const sandboxError = + span.spanData.type === "custom" ? asRecord(span.spanData.data.error) : undefined; + const result = new Error(asString(sandboxError?.message) ?? error.message); + result.name = asString(sandboxError?.name) ?? "Error"; + + return result; +} + +function exitCodeOf(output: string | undefined): number | undefined { + if (!output) return undefined; + const marker = output.indexOf(OUTPUT_MARKER); + const header = marker < 0 ? output : output.slice(0, marker); + const code = EXIT_CODE_LINE.exec(header)?.[1]; + + return code === undefined ? undefined : Number(code); +} + +function mergeFields(...parts: SpanFields[]): SpanFields { + const merged: SpanFields = {}; + + for (const part of parts) { + const { attributes, ...rest } = part; + Object.assign(merged, rest); + + if (attributes) merged.attributes = { ...merged.attributes, ...attributes }; + } + + return merged; +} + +/** + * Sends OpenAI Agents SDK traces to telemetry.dev. Register it with `addTraceProcessor`, which + * keeps the SDK's default OpenAI exporter, or `setTraceProcessors([...])`, which replaces it. + * + * Each Agents trace gets one root span, and its spans keep their parents. Model calls are `chat` + * spans and the only spans with token usage; task, turn, and agent spans repeat the totals of their + * calls and carry none. Sandbox spans keep their `sandbox.*` names and get `sandbox.operation`; the + * spans that create or resume a session also get `sandbox.backend`. The `exec_command` and + * `write_stdin` tool spans get `process.exit.code` once the command has exited. Command text and + * working directory are input content: they are sent only when `captureInput` is on, and go + * through the mask. + * + * The root span ends when the trace ends. A run that throws before the SDK ends its trace leaves + * it open, so the root also ends when the run's task or agent span ends with an error, and + * `forceFlush` and `shutdown` end the root of every trace with no open span at the end of its last + * span. Spans that end after the root still nest under it while the processor holds the root (the + * `MAX_TRACES` most recently active traces): telemetry.dev takes a trace's start and end from all + * of its spans. + */ +export function telemetryDevProcessor( + options: TelemetryDevOpenAIAgentsOptions = {}, + overrides?: ClientOverrides, +): TracingProcessor { + const onError = options.onError; + + const report = (cause: unknown): void => { + try { + onError?.(cause instanceof Error ? cause : new Error(String(cause))); + } catch { + // A failing onError must not fail an agent run. + } + }; + + try { + ensureInit(options, overrides); + } catch (error) { + report(error); + } + + const traces = new Map(); + const spans = new Map(); + let reportedCap = false; + + function endRoot(state: TraceState, endTime?: Date): void { + if (state.ended) return; + state.ended = true; + state.root.end({ endTime }); + } + + /** Moves a trace to the end of the map, which eviction reads as least recently active first. */ + function touch(traceId: string, state: TraceState): void { + traces.delete(traceId); + traces.set(traceId, state); + } + + /** Ends, at their last span's end, the roots of traces that have no open span. */ + function endIdleRoots(): void { + const open = new Set(); + + for (const { trace } of spans.values()) open.add(trace); + + for (const state of traces.values()) { + if (!open.has(state)) endRoot(state, state.lastEnd); + } + } + + function sandboxSpanEnd(span: AgentsSpan, handle: SpanHandle): SpanFields { + const data = span.spanData; + + if (data.type !== "custom" || !data.name.startsWith(SANDBOX_SPAN_PREFIX)) return {}; + const backend = asString(data.data.backend_id); + const attributes: Attrs = { + "sandbox.operation": data.name.slice(SANDBOX_SPAN_PREFIX.length), + ...(backend ? { "sandbox.backend": backend } : {}), + }; + + if (data.name === "sandbox.exec" && captureEnabled("input")) { + const command = asString(data.data.cmd); + const workdir = asString(data.data.workdir); + const commandLine = command && handle.serializeContent?.(command, "process.command_line"); + const directory = workdir && handle.serializeContent?.(workdir, "process.working_directory"); + + if (commandLine) attributes["process.command_line"] = commandLine; + + if (directory) attributes["process.working_directory"] = directory; + } + + return { attributes }; + } + + function commandToolEnd(span: AgentsSpan): SpanFields { + const data = span.spanData; + + if (data.type !== "function" || !SANDBOX_COMMAND_TOOLS.has(data.name)) return {}; + const exitCode = exitCodeOf(data.output); + + // A non-zero exit is recorded, not raised: `grep` exits 1 when nothing matches. + return exitCode === undefined ? {} : { attributes: { "process.exit.code": exitCode } }; + } + + return { + async onTraceStart(trace: Trace) { + try { + // A trace id seen again, such as a resumed run's or a fixed `traceId`, keeps its root while + // the processor still holds it, even when that root has already ended. + if (traces.has(trace.traceId)) return; + + // Map order is least recently active first: span starts and ends move a trace to the end. + const oldest = traces.size >= MAX_TRACES ? traces.entries().next() : undefined; + + if (oldest && !oldest.done) { + const [oldestId, state] = oldest.value; + endRoot(state, state.lastEnd); + traces.delete(oldestId); + } + + const attributes: Attrs = { "openai_agents.trace_id": trace.traceId }; + + if (trace.groupId) attributes["gen_ai.conversation.id"] = trace.groupId; + const root = startSpan(trace.name, { + attributes, + metadata: primitiveMetadata(trace.metadata), + }); + traces.set(trace.traceId, { root, ended: false }); + } catch (error) { + report(error); + } + }, + + async onTraceEnd(trace: Trace) { + try { + const state = traces.get(trace.traceId); + + if (state) endRoot(state); + } catch (error) { + report(error); + } + }, + + async onSpanStart(span: AgentsSpan) { + try { + if (spans.size >= MAX_OPEN_SPANS) { + if (!reportedCap) { + reportedCap = true; + report(new Error(`more than ${MAX_OPEN_SPANS} open Agents spans; dropping new spans`)); + } + + return; + } + + const state = traces.get(span.traceId); + + if (state) touch(span.traceId, state); + + const { name, options } = startOf(span.spanData); + const parent = + (span.parentId ? spans.get(span.parentId)?.handle : undefined) ?? state?.root; + const handle = startSpan(name, { + ...options, + parent, + startTime: toTime(span.startedAt), + }); + spans.set(span.spanId, { handle, trace: state }); + } catch (error) { + report(error); + } + }, + + async onSpanEnd(span: AgentsSpan) { + try { + const open = spans.get(span.spanId); + + if (!open) return; + spans.delete(span.spanId); + const { handle, trace: state } = open; + + const fields = mergeFields( + endOf(span.spanData), + sandboxSpanEnd(span, handle), + commandToolEnd(span), + ); + const error = errorOf(span); + const endTime = toTime(span.endedAt); + + handle.end({ ...fields, ...(error ? { error } : {}), endTime }); + + if (!state) return; + const end = endTime ?? new Date(); + + if (!state.lastEnd || end > state.lastEnd) state.lastEnd = end; + + if (traces.get(span.traceId) === state) touch(span.traceId, state); + + // The top-level span of a run that throws (its task span, or its agent span without task + // spans) ends with the error, but the trace never ends. + if (error && !span.parentId && RUN_SPAN_TYPES.has(span.spanData.type)) endRoot(state, end); + } catch (error) { + report(error); + } + }, + + // Also ends the roots of traces that threw outside any span, such as a run that failed before + // its first span or a `withTrace` callback that threw after its run returned: no span carries + // the error, and the trace never ends. A trace between two of its runs is ended too; spans of + // the next run still nest under its root. + async forceFlush() { + try { + endIdleRoots(); + } catch (error) { + report(error); + } + + await flush(); + }, + + // The SDK also calls this on SIGTERM, SIGINT, and unhandled rejections, so a process that exits + // right after still exports what it recorded. Roots stay known: spans of a server that keeps + // draining requests still join their trace. + async shutdown() { + try { + endIdleRoots(); + + for (const { handle } of spans.values()) handle.end(); + spans.clear(); + + for (const state of traces.values()) endRoot(state); + } catch (error) { + report(error); + } + + await flush(); + }, + }; +} diff --git a/packages/openai-agents/tests/openai-agents.test.ts b/packages/openai-agents/tests/openai-agents.test.ts new file mode 100644 index 0000000..4adadf9 --- /dev/null +++ b/packages/openai-agents/tests/openai-agents.test.ts @@ -0,0 +1,720 @@ +import { + Agent, + type Model, + OpenAIChatCompletionsModel, + OpenAIResponsesModel, + Runner, + Span, + setTraceProcessors, + setTracingDisabled, + Trace, + type TracingProcessor, + withTrace, +} from "@openai/agents"; +import { SandboxAgent, shell } from "@openai/agents/sandbox"; +import { UnixLocalSandboxClient } from "@openai/agents/sandbox/local"; +import { InMemorySpanExporter, type ReadableSpan } from "@opentelemetry/sdk-trace-base"; +import { flush, propagateAttributes, startActiveSpan } from "@telemetry-dev/sdk"; +import OpenAI from "openai"; +import { afterEach, beforeEach, expect, test, vi } from "vitest"; + +import { resetForTesting } from "../src/config.ts"; +import { telemetryDevProcessor } from "../src/index.ts"; + +type Json = Record; + +let exporter: InMemorySpanExporter; + +type ProcessorOptions = Parameters[0]; + +function makeProcessor( + options: ProcessorOptions = {}, + before: TracingProcessor[] = [], +): TracingProcessor { + exporter = new InMemorySpanExporter(); + const processor = telemetryDevProcessor( + { + apiKey: "td_live_test", + environment: "test", + exportMode: "immediate", + logLevel: "silent", + fetch: async () => new Response(null, { status: 200 }), + ...options, + }, + { spanExporter: exporter }, + ); + setTraceProcessors([...before, processor]); + + return processor; +} + +beforeEach(() => { + // The Agents SDK turns tracing off when NODE_ENV is "test". + setTracingDisabled(false); +}); + +afterEach(async () => { + setTraceProcessors([]); + await resetForTesting(); +}); + +function functionCall(command: string, callId: string): Json { + return { + type: "function_call", + id: `fc_${callId}`, + call_id: callId, + name: "exec_command", + arguments: JSON.stringify({ cmd: command, login: false }), + status: "completed", + }; +} + +function message(text: string): Json { + return { + type: "message", + id: "msg_1", + role: "assistant", + status: "completed", + content: [{ type: "output_text", text, annotations: [] }], + }; +} + +function response(id: string, output: Json[], usage: Json): Json { + return { + id, + object: "response", + created_at: 0, + model: "gpt-5-mini", + status: "completed", + output, + usage, + }; +} + +/** An OpenAI client whose HTTP calls return `bodies` in order. */ +function scriptedClient(bodies: Json[], status = 200): OpenAI { + const queue = [...bodies]; + + return new OpenAI({ + apiKey: "sk-test", + maxRetries: 0, + fetch: async () => { + const body = queue.shift(); + + if (!body) throw new Error("no scripted response left"); + + return new Response(JSON.stringify(body), { + status, + headers: { "content-type": "application/json" }, + }); + }, + }); +} + +/** A Responses API model: the model asks for `command`, then answers "done". */ +function responsesModel(command: string): Model { + return new OpenAIResponsesModel( + scriptedClient([ + response("resp_1", [functionCall(command, "call_1")], { + input_tokens: 100, + output_tokens: 20, + total_tokens: 120, + input_tokens_details: { cached_tokens: 40 }, + output_tokens_details: { reasoning_tokens: 5 }, + }), + response("resp_2", [message("done")], { + input_tokens: 50, + output_tokens: 7, + total_tokens: 57, + }), + ]), + "gpt-5-mini", + ); +} + +function completion(id: string, message: Json, usage: Json): Json { + return { + id, + object: "chat.completion", + created: 0, + model: "gpt-4.1-mini-2025-04-14", + choices: [{ index: 0, message, finish_reason: "stop", logprobs: null }], + usage, + }; +} + +/** A Chat Completions model with the same script as `responsesModel`. */ +function chatCompletionsModel(command: string): Model { + return new OpenAIChatCompletionsModel( + scriptedClient([ + completion( + "chatcmpl_1", + { + role: "assistant", + content: null, + tool_calls: [ + { + id: "call_1", + type: "function", + function: { name: "exec_command", arguments: JSON.stringify({ cmd: command }) }, + }, + ], + }, + { + prompt_tokens: 100, + completion_tokens: 20, + total_tokens: 120, + prompt_tokens_details: { cached_tokens: 40 }, + completion_tokens_details: { reasoning_tokens: 5 }, + }, + ), + completion( + "chatcmpl_2", + { role: "assistant", content: "done" }, + { prompt_tokens: 50, completion_tokens: 7, total_tokens: 57 }, + ), + ]), + "gpt-4.1-mini", + ); +} + +/** One run of a sandbox agent with `model`, by default one that runs `command`. */ +async function runCommand( + command: string, + options: { + workflowName?: string; + model?: Model; + } = {}, +): Promise { + const agent = new SandboxAgent({ + name: "coder", + instructions: "Run the command.", + model: options.model ?? responsesModel(command), + capabilities: [shell()], + }); + + await new Runner({ workflowName: options.workflowName ?? "workflow" }).run(agent, "go", { + sandbox: { client: new UnixLocalSandboxClient() }, + }); +} + +async function exported(): Promise { + await flush(); + + return exporter.getFinishedSpans(); +} + +const parentOf = (span: ReadableSpan): string | undefined => span.parentSpanContext?.spanId; + +function only(spans: ReadableSpan[], predicate: (span: ReadableSpan) => boolean): ReadableSpan { + const matches = spans.filter(predicate); + expect(matches).toHaveLength(1); + + return matches[0]!; +} + +const named = (name: string) => (span: ReadableSpan) => span.name === name; + +test("a sandbox command becomes a tool span with its exit code, nested under its agent", async () => { + makeProcessor(); + await runCommand("sh -c 'exit 3'"); + const spans = await exported(); + + const root = only(spans, named("workflow")); + const tool = only(spans, named("execute_tool exec_command")); + const exec = only(spans, named("sandbox.exec")); + const turn = spans.find((span) => span.spanContext().spanId === parentOf(tool))!; + const agent = spans.find((span) => span.spanContext().spanId === parentOf(turn))!; + + expect(new Set(spans.map((span) => span.spanContext().traceId)).size).toBe(1); + expect(tool.attributes["gen_ai.operation.name"]).toBe("execute_tool"); + expect(tool.attributes["process.exit.code"]).toBe(3); + // A non-zero exit is not a failed tool call. + expect(tool.status.code).not.toBe(2); + expect(parentOf(exec)).toBe(tool.spanContext().spanId); + expect(exec.attributes["sandbox.operation"]).toBe("exec"); + expect(only(spans, named("sandbox.create_session")).attributes["sandbox.backend"]).toBe( + "unix_local", + ); + expect(exec.attributes["process.command_line"]).toBe("sh -c 'exit 3'"); + expect(turn.name).toMatch(/^turn /); + expect(agent.attributes["gen_ai.operation.name"]).toBe("invoke_agent"); + expect(agent.attributes["gen_ai.agent.name"]).toBe("coder"); + expect(spans.every((span) => span === root || parentOf(span) !== undefined)).toBe(true); +}); + +test("a command that exits 0 records exit code 0", async () => { + makeProcessor(); + await runCommand("true"); + + const tool = only(await exported(), named("execute_tool exec_command")); + expect(tool.attributes["process.exit.code"]).toBe(0); +}); + +test("only model-call spans carry token usage", async () => { + makeProcessor(); + await runCommand("true"); + const spans = await exported(); + + const chats = spans.filter((span) => span.attributes["gen_ai.operation.name"] === "chat"); + expect(chats.map((span) => span.name)).toEqual(["chat gpt-5-mini", "chat gpt-5-mini"]); + const sum = (key: string) => + chats.reduce((total, span) => total + Number(span.attributes[key] ?? 0), 0); + expect(sum("gen_ai.usage.input_tokens")).toBe(150); + expect(sum("gen_ai.usage.output_tokens")).toBe(27); + expect(sum("gen_ai.usage.cache_read.input_tokens")).toBe(40); + expect(sum("gen_ai.usage.reasoning.output_tokens")).toBe(5); + expect(new Set(chats.map((span) => span.attributes["gen_ai.response.id"]))).toEqual( + new Set(["resp_1", "resp_2"]), + ); + + const withUsage = spans.filter((span) => + Object.keys(span.attributes).some((key) => key.startsWith("gen_ai.usage.")), + ); + expect(withUsage).toEqual(chats); +}); + +test("with captureInput off, the command is not on the sandbox or tool spans", async () => { + makeProcessor({ captureInput: false }); + await runCommand("echo hello"); + const spans = await exported(); + + expect(only(spans, named("sandbox.exec")).attributes["process.command_line"]).toBeUndefined(); + expect( + only(spans, named("execute_tool exec_command")).attributes["gen_ai.tool.call.arguments"], + ).toBeUndefined(); +}); + +test("with capture off, no attribute contains the command or its output", async () => { + // The command is also the model's output (its function call) and the tool's output (the echo). + makeProcessor({ captureInput: false, captureOutput: false }); + const marker = "MARKER_4f2a9c"; + await runCommand(`echo ${marker}`); + const spans = await exported(); + + const leaked = spans.filter((span) => + Object.values(span.attributes).some((value) => JSON.stringify(value).includes(marker)), + ); + expect(leaked.map((span) => span.name)).toEqual([]); + expect(only(spans, named("execute_tool exec_command")).attributes["process.exit.code"]).toBe(0); +}); + +test("two concurrent runs produce two traces whose spans do not cross", async () => { + makeProcessor(); + await Promise.all([ + runCommand("echo run_a", { workflowName: "run a" }), + runCommand("echo run_b", { workflowName: "run b" }), + ]); + const spans = await exported(); + + for (const run of ["a", "b"]) { + const root = only(spans, named(`run ${run}`)); + const traceId = root.spanContext().traceId; + const commands = spans + .filter((span) => span.spanContext().traceId === traceId && span.name === "sandbox.exec") + .map((span) => span.attributes["process.command_line"]); + expect(commands).toEqual([`echo run_${run}`]); + } +}); + +/** One run of an agent that answers "done", with its root span named `workflowName`. */ +async function runAgent(workflowName: string, groupId?: string): Promise { + const model = new OpenAIResponsesModel( + scriptedClient([ + response("resp_1", [message("done")], { input_tokens: 1, output_tokens: 1, total_tokens: 2 }), + ]), + "gpt-5-mini", + ); + + await new Runner({ workflowName, groupId }).run(new Agent({ name: "assistant", model }), "go"); +} + +const traceOf = (span: ReadableSpan): string => span.spanContext().traceId; +const sessionOf = (span: ReadableSpan): unknown => span.attributes["gen_ai.conversation.id"]; + +test("runs that share a groupId land in one session trace", async () => { + makeProcessor(); + await runAgent("a1", "g1"); + await runAgent("a2", "g1"); + await runAgent("b", "g2"); + await runAgent("c"); + const spans = await exported(); + const [a1, a2, b, c] = ["a1", "a2", "b", "c"].map((name) => only(spans, named(name))); + + expect(traceOf(a2)).toBe(traceOf(a1)); + expect(new Set([a1, b, c].map(traceOf)).size).toBe(3); + expect([a1, a2, b, c].map(sessionOf)).toEqual(["g1", "g1", "g2", undefined]); + // Each run of a session is a root under one parent that is never exported. + expect(parentOf(a1)).toEqual(expect.any(String)); + expect(parentOf(a2)).toBe(parentOf(a1)); + expect(spans.map((span) => span.spanContext().spanId)).not.toContain(parentOf(a1)); + expect(parentOf(c)).toBeUndefined(); +}); + +test("a run inside an active span joins that span's trace, even with a groupId", async () => { + makeProcessor(); + await startActiveSpan("request", async () => { + await runAgent("a", "g1"); + await runAgent("b", "g1"); + }); + const spans = await exported(); + const request = only(spans, named("request")); + + for (const root of [only(spans, named("a")), only(spans, named("b"))]) { + expect(traceOf(root)).toBe(traceOf(request)); + expect(parentOf(root)).toBe(request.spanContext().spanId); + expect(sessionOf(root)).toBe("g1"); + } +}); + +test("runs share a propagateAttributes session, and a groupId takes precedence", async () => { + makeProcessor(); + await propagateAttributes({ sessionId: "s1" }, async () => { + await runAgent("a"); + await runAgent("b"); + await runAgent("c", "g1"); + await runAgent("d", "g1"); + }); + const spans = await exported(); + const [a, b, c, d] = ["a", "b", "c", "d"].map((name) => only(spans, named(name))); + + expect(traceOf(b)).toBe(traceOf(a)); + expect(traceOf(d)).toBe(traceOf(c)); + expect(traceOf(c)).not.toBe(traceOf(a)); + expect([a, b, c, d].map(sessionOf)).toEqual(["s1", "s1", "g1", "g1"]); + const groupTraceSpans = spans.filter((span) => traceOf(span) === traceOf(c)); + expect(new Set(groupTraceSpans.map(sessionOf))).toEqual(new Set(["g1"])); +}); + +test("process sessions group the runs that have no session of their own", async () => { + makeProcessor({ sessionMode: "process" }); + await runAgent("a"); + await runAgent("b"); + await runAgent("c", "g1"); + await runAgent("d", "g1"); + const spans = await exported(); + const [a, b, c, d] = ["a", "b", "c", "d"].map((name) => only(spans, named(name))); + + expect(traceOf(b)).toBe(traceOf(a)); + expect(traceOf(d)).toBe(traceOf(c)); + expect(traceOf(c)).not.toBe(traceOf(a)); + expect(sessionOf(a)).toEqual(expect.any(String)); + expect(sessionOf(b)).toBe(sessionOf(a)); + expect(sessionOf(c)).toBe("g1"); +}); + +test("a span whose parent is unknown nests under its trace root", async () => { + const processor = makeProcessor(); + const trace = new Trace({ traceId: "trace_0123456789abcdef0123456789abcdef", name: "manual" }); + await processor.onTraceStart(trace); + const span = new Span( + { + traceId: trace.traceId, + parentId: "span_missing", + data: { type: "custom", name: "step", data: { attempt: 2 } }, + }, + processor, + ); + span.start(); + span.end(); + await processor.onTraceEnd(trace); + const spans = await exported(); + + const root = only(spans, named("manual")); + const step = only(spans, named("step")); + expect(parentOf(step)).toBe(root.spanContext().spanId); + expect(step.attributes["td.metadata.attempt"]).toBe("2"); +}); + +test("a resumed session's span records its backend", async () => { + const processor = makeProcessor(); + const trace = new Trace({ traceId: "trace_77777777777777777777777777777777", name: "resume" }); + await processor.onTraceStart(trace); + const span = new Span( + { + traceId: trace.traceId, + data: { + type: "custom", + name: "sandbox.resume_session", + data: { agent_name: "coder", backend_id: "unix_local" }, + }, + }, + processor, + ); + span.start(); + span.end(); + await processor.onTraceEnd(trace); + + const resumed = only(await exported(), named("sandbox.resume_session")); + expect(resumed.attributes).toMatchObject({ + "sandbox.operation": "resume_session", + "sandbox.backend": "unix_local", + }); +}); + +test("a mask applies to the command before it is sent", async () => { + makeProcessor({ + mask: (value, { key }) => (key === "process.command_line" ? "[masked]" : value), + }); + await runCommand("echo secret"); + + const exec = only(await exported(), named("sandbox.exec")); + expect(exec.attributes["process.command_line"]).toBe("[masked]"); +}); + +test("Chat Completions model calls carry their model and usage", async () => { + makeProcessor(); + await runCommand("true", { model: chatCompletionsModel("true") }); + const spans = await exported(); + + const chats = spans.filter((span) => span.attributes["gen_ai.operation.name"] === "chat"); + expect(chats.map((span) => span.name)).toEqual(["chat gpt-4.1-mini", "chat gpt-4.1-mini"]); + const first = chats.find((span) => span.attributes["gen_ai.response.id"] === "chatcmpl_1")!; + expect(first.attributes).toMatchObject({ + "gen_ai.request.model": "gpt-4.1-mini", + "gen_ai.response.model": "gpt-4.1-mini-2025-04-14", + "gen_ai.usage.input_tokens": 100, + "gen_ai.usage.output_tokens": 20, + "gen_ai.usage.cache_read.input_tokens": 40, + "gen_ai.usage.reasoning.output_tokens": 5, + }); +}); + +/** Every exported span except the root has an exported parent. */ +function expectConnected(spans: ReadableSpan[], rootName: string): void { + const ids = new Set(spans.map((span) => span.spanContext().spanId)); + const root = only(spans, named(rootName)); + const orphans = spans.filter((span) => span !== root && !ids.has(parentOf(span) ?? "")); + expect(orphans.map((span) => span.name)).toEqual([]); +} + +test("a run that throws exports its root", async () => { + makeProcessor(); + const failing = new OpenAIResponsesModel( + scriptedClient([{ error: { message: "bad request", type: "invalid_request_error" } }], 400), + "gpt-5-mini", + ); + await expect(runCommand("true", { model: failing })).rejects.toThrow(); + const spans = await exported(); + + expectConnected(spans, "workflow"); + expect( + only(spans, (span) => span.attributes["gen_ai.operation.name"] === "chat").status.code, + ).toBe(2); + // The root ends with the run's top-level span, not with the failed model call inside it. + const task = only(spans, (span) => span.name.startsWith("task ")); + expect(only(spans, named("workflow")).endTime).toEqual(task.endTime); +}); + +test("spans that end after their trace still reach the root", async () => { + // A processor registered first that takes time to handle each span end, such as the default + // OpenAI exporter during an export, delays this processor's span ends past the trace end. + const slow: TracingProcessor = { + async onTraceStart() {}, + async onTraceEnd() {}, + async onSpanStart() {}, + async onSpanEnd() { + await new Promise((resolve) => setTimeout(resolve, 20)); + }, + async forceFlush() {}, + async shutdown() {}, + }; + makeProcessor({}, [slow]); + await runCommand("true"); + + await vi.waitFor(async () => + expect( + (await exported()).filter((span) => span.attributes["gen_ai.operation.name"] === "chat"), + ).toHaveLength(2), + ); + + expectConnected(await exported(), "workflow"); +}); + +test("an exit line in the output of a running command is not an exit code", async () => { + const processor = makeProcessor(); + const trace = new Trace({ traceId: "trace_fedcba9876543210fedcba9876543210", name: "manual" }); + await processor.onTraceStart(trace); + const span = new Span( + { + traceId: trace.traceId, + data: { + type: "function", + name: "write_stdin", + input: "{}", + output: [ + "Chunk ID: abc123", + "Wall time: 1.0000 seconds", + "Process running with session ID 3", + "Output:", + "Process exited with code 0", + ].join("\n"), + }, + }, + processor, + ); + span.start(); + span.end(); + await processor.onTraceEnd(trace); + + const tool = only(await exported(), named("execute_tool write_stdin")); + expect(tool.attributes["process.exit.code"]).toBeUndefined(); +}); + +/** Starts and ends a custom span of `trace` through `processor`, the way the SDK does. */ +function customSpan( + processor: TracingProcessor, + trace: Trace, + name: string, + parent?: Span, +): Span { + const span = new Span( + { + traceId: trace.traceId, + parentId: parent?.spanId, + data: { type: "custom", name, data: {} }, + }, + processor, + ) as Span; + span.start(); + + return span; +} + +test("a flush between two runs of one trace keeps them under one root", async () => { + const processor = makeProcessor(); + await withTrace("two runs", async () => { + await runCommand("echo first"); + await processor.forceFlush(); + await runCommand("echo second"); + }); + const spans = await exported(); + + expectConnected(spans, "two runs"); + expect(new Set(spans.map((span) => span.spanContext().traceId)).size).toBe(1); +}); + +test("spans that start after shutdown still join their trace", async () => { + const processor = makeProcessor(); + const trace = new Trace({ traceId: "trace_11111111111111111111111111111111", name: "draining" }); + await processor.onTraceStart(trace); + const inFlight = customSpan(processor, trace, "in flight"); + + // A server that drains on SIGTERM keeps running after the SDK calls shutdown. + await processor.shutdown(); + const atShutdown = await exported(); + expect(atShutdown.map((span) => span.name).sort()).toEqual(["draining", "in flight"]); + expectConnected(atShutdown, "draining"); + + const late = customSpan(processor, trace, "late", inFlight); + late.end(); + inFlight.end(); + await processor.onTraceEnd(trace); + const spans = await exported(); + + expectConnected(spans, "draining"); + expect(spans.map((span) => span.name).sort()).toEqual(["draining", "in flight", "late"]); + // Shutdown forgot the in-flight span, so the late span nests under the root. + expect(parentOf(only(spans, named("late")))).toBe( + only(spans, named("draining")).spanContext().spanId, + ); +}); + +test("a span after its trace ended joins the ended root", async () => { + const processor = makeProcessor(); + const trace = new Trace({ traceId: "trace_22222222222222222222222222222222", name: "ended" }); + await processor.onTraceStart(trace); + await processor.onTraceEnd(trace); + // Such as the memory spans that a sandbox agent writes after its run. + customSpan(processor, trace, "memory flush").end(); + const spans = await exported(); + + expectConnected(spans, "ended"); + expect(new Set(spans.map((span) => span.spanContext().traceId)).size).toBe(1); +}); + +test("past the trace cap, the least recently active root is exported and forgotten", async () => { + const processor = makeProcessor(); + const trace = (n: number) => + new Trace({ traceId: `trace_${n.toString(16).padStart(32, "0")}`, name: `t${n}` }); + await processor.onTraceStart(trace(0)); + await processor.onTraceStart(trace(1)); + // A span start makes t0 more recently active than t1, though t0 started first. + customSpan(processor, trace(0), "step").end(); + + for (let n = 2; n < 10_000; n++) await processor.onTraceStart(trace(n)); + expect((await exported()).filter(named("t1"))).toEqual([]); + + await processor.onTraceStart(trace(10_000)); + customSpan(processor, trace(0), "late").end(); + await processor.onTraceEnd(trace(0)); + const spans = await exported(); + + expect(spans.filter(named("t1"))).toHaveLength(1); + expectConnected( + spans.filter((span) => span.name !== "t1"), + "t0", + ); + + // t1 was forgotten, so its id starts a new root. + const reused = new Trace({ traceId: trace(1).traceId, name: "t1 again" }); + await processor.onTraceStart(reused); + await processor.onTraceEnd(reused); + expect((await exported()).filter(named("t1 again"))).toHaveLength(1); +}); + +test("a flush leaves the root of a trace with an open span", async () => { + const processor = makeProcessor(); + const busy = new Trace({ traceId: "trace_44444444444444444444444444444444", name: "busy" }); + const idle = new Trace({ traceId: "trace_55555555555555555555555555555555", name: "idle" }); + await processor.onTraceStart(busy); + await processor.onTraceStart(idle); + const step = customSpan(processor, busy, "step"); + customSpan(processor, idle, "done").end(); + + await processor.forceFlush(); + expect((await exported()).map((span) => span.name).sort()).toEqual(["done", "idle"]); + + step.end(); + await processor.forceFlush(); + expect((await exported()).filter(named("busy"))).toHaveLength(1); +}); + +test("a failed custom span at the top level leaves the root open", async () => { + const processor = makeProcessor(); + const trace = new Trace({ traceId: "trace_66666666666666666666666666666666", name: "handled" }); + await processor.onTraceStart(trace); + const failed = customSpan(processor, trace, "attempt"); + failed.setError({ message: "retrying" }); + failed.end(); + expect((await exported()).filter(named("handled"))).toEqual([]); + + await processor.onTraceEnd(trace); + expectConnected(await exported(), "handled"); +}); + +test.each(["forceFlush", "shutdown"] as const)( + "%s ends the root of a trace whose callback threw after its run", + async (method) => { + const processor = makeProcessor(); + await expect( + withTrace("after run", async () => { + await runAgent("ignored"); + throw new Error("post-processing failed"); + }), + ).rejects.toThrow("post-processing failed"); + expect((await exported()).filter(named("after run"))).toEqual([]); + + await new Promise((resolve) => setTimeout(resolve, 20)); + await processor[method](); + const spans = await exported(); + + expectConnected(spans, "after run"); + // The root ends with the run's last span, not at the flush. + const ms = ([seconds, nanos]: [number, number]) => seconds * 1e3 + nanos / 1e6; + const lastEnd = Math.max( + ...spans.filter((span) => span.name !== "after run").map((span) => ms(span.endTime)), + ); + expect(ms(only(spans, named("after run")).endTime)).toBe(lastEnd); + }, +); diff --git a/packages/openai-agents/tsconfig.json b/packages/openai-agents/tsconfig.json new file mode 100644 index 0000000..ff4adab --- /dev/null +++ b/packages/openai-agents/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "esnext", + "lib": ["es2023"], + "moduleDetection": "force", + "module": "nodenext", + "moduleResolution": "nodenext", + "resolveJsonModule": true, + "types": ["node"], + "strict": true, + "noUnusedLocals": true, + "declaration": true, + "noEmit": true, + "allowImportingTsExtensions": true, + "esModuleInterop": true, + "isolatedModules": true, + "verbatimModuleSyntax": true, + "skipLibCheck": true + } +} diff --git a/packages/openai-agents/vite.config.ts b/packages/openai-agents/vite.config.ts new file mode 100644 index 0000000..7123f89 --- /dev/null +++ b/packages/openai-agents/vite.config.ts @@ -0,0 +1,29 @@ +import { fileURLToPath } from "node:url"; + +import { defineConfig } from "vite-plus"; +import { customExports } from "../../scripts/package-exports.mjs"; + +export default defineConfig(({ mode }) => ({ + resolve: + mode === "test" + ? { + alias: { + "@telemetry-dev/sdk": fileURLToPath(new URL("../sdk/src/index.ts", import.meta.url)), + }, + } + : undefined, + pack: { + dts: true, + exports: { + devExports: "bun", + customExports, + }, + }, + lint: { + options: { + typeAware: true, + typeCheck: true, + }, + }, + fmt: {}, +})); diff --git a/packages/sdk/tests/propagate.test.ts b/packages/sdk/tests/propagate.test.ts index bb1a9f2..0318d40 100644 --- a/packages/sdk/tests/propagate.test.ts +++ b/packages/sdk/tests/propagate.test.ts @@ -1,4 +1,13 @@ -import { ROOT_CONTEXT, SpanKind, TraceFlags } from "@opentelemetry/api"; +import { AsyncLocalStorage } from "node:async_hooks"; + +import { + type Context, + context, + ROOT_CONTEXT, + SpanKind, + trace, + TraceFlags, +} from "@opentelemetry/api"; import { AlwaysOffSampler, AlwaysOnSampler, @@ -6,7 +15,7 @@ import { SamplingDecision, TraceIdRatioBasedSampler, } from "@opentelemetry/sdk-trace-base"; -import { sessionSpanContext } from "@telemetry-dev/otel"; +import { AlsContextManager, sessionSpanContext } from "@telemetry-dev/otel"; import { afterEach, expect, test } from "vitest"; import { TRUNCATION_MARKER } from "../src/capture.ts"; @@ -180,6 +189,30 @@ test("nested spans keep their real parent inside a session", async () => { expect(root.parentSpanContext?.spanId).toBe(sessionSpanContext("td_live_test", "s1").spanId); }); +test("a session root inside a span of the host's own context manager joins that span", async () => { + const { spans } = setup(); + // A host OTel setup (NodeSDK, HTTP instrumentation) keeps its spans in its own store, not ours. + const host = { + traceId: "0af7651916cd43dd8448eb211c80319c", + spanId: "b7ad6b7169203331", + traceFlags: TraceFlags.SAMPLED, + }; + const manager = new AlsContextManager(new AsyncLocalStorage()); + expect(context.setGlobalContextManager(manager)).toBe(true); + + try { + context.with(trace.setSpanContext(ROOT_CONTEXT, host), () => { + startSpan("run", { attributes: { "gen_ai.conversation.id": "s1" } }).end(); + }); + } finally { + context.disable(); + } + await flush(); + const run = spans.getFinishedSpans().find((s) => s.name === "run")!; + expect(run.spanContext().traceId).toBe(host.traceId); + expect(run.parentSpanContext?.spanId).toBe(host.spanId); +}); + test("spans without a session id keep separate random traces", async () => { const { spans } = setup(); startSpan("a").end(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8ab341d..7747eeb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -337,10 +337,10 @@ importers: devDependencies: '@langchain/core': specifier: 'catalog:' - version: 1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3) + version: 1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0) '@langchain/langgraph': specifier: 'catalog:' - version: 1.7.0(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3))(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(zod@4.4.3) + version: 1.7.0(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0))(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(zod@4.4.3) '@opentelemetry/api': specifier: 'catalog:' version: 1.9.1 @@ -452,10 +452,10 @@ importers: version: 10.1.0 openai: specifier: 'catalog:' - version: 7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3) + version: 7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) openai-v6: specifier: npm:openai@6.45.0 - version: openai@6.45.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(ws@8.21.3)(zod@4.4.3) + version: openai@6.45.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(ws@8.23.0)(zod@4.4.3) typescript: specifier: 'catalog:' version: 5.9.3 @@ -466,6 +466,40 @@ importers: specifier: npm:@voidzero-dev/vite-plus-test@0.1.20 version: '@voidzero-dev/vite-plus-test@0.1.20(@opentelemetry/api@1.9.1)(@types/node@25.6.0)(@voidzero-dev/vite-plus-core@0.1.20(@types/node@25.6.0)(esbuild@0.27.7)(jiti@2.7.0)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.9.0))(esbuild@0.27.7)(jiti@2.7.0)(jsdom@28.1.0(@noble/hashes@2.2.0))(tsx@4.21.0)(typescript@5.9.3)(yaml@2.9.0)' + packages/openai-agents: + dependencies: + '@telemetry-dev/sdk': + specifier: workspace:^ + version: link:../sdk + devDependencies: + '@openai/agents': + specifier: 0.22.0 + version: 0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + '@opentelemetry/sdk-trace-base': + specifier: 'catalog:' + version: 2.12.0(@opentelemetry/api@1.9.1) + '@types/node': + specifier: ^25.5.0 + version: 25.6.0 + '@typescript/native-preview': + specifier: 7.0.0-dev.20260328.1 + version: 7.0.0-dev.20260328.1 + openai: + specifier: 7.60.0 + version: 7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + typescript: + specifier: ^6.0.2 + version: 6.0.3 + vite-plus: + specifier: 0.1.20 + version: 0.1.20(@opentelemetry/api@1.9.1)(@types/node@25.6.0)(@voidzero-dev/vite-plus-core@0.1.20(@types/node@25.6.0)(esbuild@0.27.7)(jiti@2.7.0)(tsx@4.21.0)(typescript@6.0.3)(yaml@2.9.0))(esbuild@0.27.7)(jiti@2.7.0)(jsdom@28.1.0(@noble/hashes@2.2.0))(tsx@4.21.0)(typescript@6.0.3)(yaml@2.9.0) + vitest: + specifier: npm:@voidzero-dev/vite-plus-test@0.1.20 + version: '@voidzero-dev/vite-plus-test@0.1.20(@opentelemetry/api@1.9.1)(@types/node@25.6.0)(@voidzero-dev/vite-plus-core@0.1.20(@types/node@25.6.0)(esbuild@0.27.7)(jiti@2.7.0)(tsx@4.21.0)(typescript@6.0.3)(yaml@2.9.0))(esbuild@0.27.7)(jiti@2.7.0)(jsdom@28.1.0(@noble/hashes@2.2.0))(tsx@4.21.0)(typescript@6.0.3)(yaml@2.9.0)' + zod: + specifier: 'catalog:' + version: 4.4.3 + packages/opencode: dependencies: '@opentelemetry/api': @@ -588,7 +622,7 @@ importers: devDependencies: '@earendil-works/pi-coding-agent': specifier: 0.82.1 - version: 0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.21.3)(zod@4.4.3) + version: 0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.23.0)(zod@4.4.3) '@opentelemetry/sdk-logs': specifier: 'catalog:' version: 0.223.0(@opentelemetry/api@1.9.1) @@ -1351,6 +1385,10 @@ packages: cpu: [x64] os: [win32] + '@isaacs/fs-minipass@4.0.1': + resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==} + engines: {node: '>=18.0.0'} + '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} @@ -1651,6 +1689,29 @@ packages: resolution: {integrity: sha512-zjZfZfsVjQpQ3KML55G8MDY/HKnvZ/cPrjwcKQyyXzTk/rTGqT9KvQM3buhq8uSWIVugA/oEoC452vAa9xxQHQ==} engines: {bun: '>=1.3.14'} + '@openai/agents-core@0.22.0': + resolution: {integrity: sha512-gz7z2eIG+6mlScUdBG7v1k0w9SGC3KGBU5Wko9YXs8gMynBroQR6qnDGuKRzOgq2x8N9UJzn3b/KQpIAtvN9pA==} + peerDependencies: + zod: ^4.0.0 + peerDependenciesMeta: + zod: + optional: true + + '@openai/agents-openai@0.22.0': + resolution: {integrity: sha512-HJkhp6PkXfa9CIzZoMLuM16YQVV8H/zQOIc0dEcWeNe4VOoev+dJXjBzlFF8SZnlGEb+4u5XAbJ85YHYqFWr2g==} + peerDependencies: + zod: ^4.0.0 + + '@openai/agents-realtime@0.22.0': + resolution: {integrity: sha512-orY61QWNz6QaNfcu6RqPfaJ2QtXLB4Yw3ErVfOzIcMo/UxPRlZejrSiv5MqTyCNqy/J9s2tKgqdrrRGdjdnucg==} + peerDependencies: + zod: ^4.0.0 + + '@openai/agents@0.22.0': + resolution: {integrity: sha512-ytI0Bebtd3at00nq+vTzkafdCqxbdD/xHEsIPCFdTQfjrXpGfeYQM8pPfdOnp0K4fnLshovHXEeQ/xXfg+SCPQ==} + peerDependencies: + zod: ^4.0.0 + '@opencode-ai/plugin@1.18.9': resolution: {integrity: sha512-0kFX9Usj+3N+WupIe9VnEdDNzMNbW4/C5GeIzdj02/t5kQoXsNrFpW3Br9aABebazcaYsQEWdlaLV0zQISy3OA==} peerDependencies: @@ -2394,6 +2455,9 @@ packages: '@types/turndown@5.0.6': resolution: {integrity: sha512-ru00MoyeeouE5BX4gRL+6m/BsDfbRayOskWqUvh7CLGW+UXxHQItqALa38kKnOiZPqJrtzJUgAC2+F0rL1S4Pg==} + '@types/ws@8.18.2': + resolution: {integrity: sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==} + '@typescript/native-preview-darwin-arm64@7.0.0-dev.20260328.1': resolution: {integrity: sha512-BmJGDWC0bSQ2w5O/E+Mw9eTv9RklJ3vjshu7UdD92bUMxc4V4dkBhYj5r0qxbl4f+VFNX7fXvcDDI+9o+Kb6yw==} cpu: [arm64] @@ -2739,6 +2803,10 @@ packages: resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} engines: {node: '>= 20.19.0'} + chownr@3.0.0: + resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==} + engines: {node: '>=18'} + chromium-bidi@16.0.1: resolution: {integrity: sha512-J63PGu/9PpeCwLIcKYyzWP6yaVL5pxuBc0shlYCYM8BaAkmlwiQboXO1iNbOgSDbVklEyYFfNEcHD8oOAWacUA==} engines: {node: '>=20.19.0 <22.0.0 || >=22.12.0'} @@ -3684,6 +3752,10 @@ packages: resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==} engines: {node: '>=16 || 14 >=14.17'} + minizlib@3.1.0: + resolution: {integrity: sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==} + engines: {node: '>= 18'} + mitt@3.0.1: resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} @@ -3891,6 +3963,33 @@ packages: zod: optional: true + openai@7.60.0: + resolution: {integrity: sha512-vipS79MnBZX6zpWjMGdRQazRcbYc3CxGUNZYLpd8YANeq1ZlTAZeHctkeUJvqDVcET7+kHI2osGWyhk3Co9odg==} + engines: {node: '>=22.0.0'} + peerDependencies: + '@aws-sdk/credential-provider-node': '>=3.972.0 <4' + '@smithy/hash-node': '>=4.3.0 <5' + '@smithy/signature-v4': '>=5.4.0 <6' + google-auth-library: '>=9.15.1 <12' + undici: '>=5 <9' + ws: ^8.21.0 + zod: ^3.25 || ^4.0 + peerDependenciesMeta: + '@aws-sdk/credential-provider-node': + optional: true + '@smithy/hash-node': + optional: true + '@smithy/signature-v4': + optional: true + google-auth-library: + optional: true + undici: + optional: true + ws: + optional: true + zod: + optional: true + option@0.2.4: resolution: {integrity: sha512-pkEqbDyl8ou5cpq+VsnQbe/WlEy5qS7xPzMS1U55OCG9KPvwFD46zDbxQIj3egJSFc3D+XhYOPUzz49zQAVy7A==} @@ -4340,6 +4439,10 @@ packages: resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==} engines: {node: '>=6'} + tar@7.5.22: + resolution: {integrity: sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==} + engines: {node: '>=18'} + text-hex@1.0.0: resolution: {integrity: sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==} @@ -4635,6 +4738,18 @@ packages: utf-8-validate: optional: true + ws@8.23.0: + resolution: {integrity: sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + xml-name-validator@5.0.0: resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} engines: {node: '>=18'} @@ -4658,6 +4773,10 @@ packages: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} + yallist@5.0.0: + resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} + engines: {node: '>=18'} + yaml@2.9.0: resolution: {integrity: sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==} engines: {node: '>= 14.6'} @@ -5103,9 +5222,9 @@ snapshots: enabled: 2.0.0 kuler: 2.0.0 - '@earendil-works/pi-agent-core@0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.21.3)(zod@4.4.3)': + '@earendil-works/pi-agent-core@0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.23.0)(zod@4.4.3)': dependencies: - '@earendil-works/pi-ai': 0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.21.3)(zod@4.4.3) + '@earendil-works/pi-ai': 0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.23.0)(zod@4.4.3) diff: 8.0.4 ignore: 7.0.5 typebox: 1.1.38 @@ -5118,7 +5237,7 @@ snapshots: - ws - zod - '@earendil-works/pi-ai@0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.21.3)(zod@4.4.3)': + '@earendil-works/pi-ai@0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.23.0)(zod@4.4.3)': dependencies: '@anthropic-ai/sdk': 0.91.1(zod@4.4.3) '@aws-sdk/client-bedrock-runtime': 3.1048.0 @@ -5128,7 +5247,7 @@ snapshots: '@smithy/node-http-handler': 4.7.3 http-proxy-agent: 7.0.2 https-proxy-agent: 7.0.6 - openai: 6.26.0(ws@8.21.3)(zod@4.4.3) + openai: 6.26.0(ws@8.23.0)(zod@4.4.3) partial-json: 0.1.7 typebox: 1.1.38 transitivePeerDependencies: @@ -5139,10 +5258,10 @@ snapshots: - ws - zod - '@earendil-works/pi-coding-agent@0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.21.3)(zod@4.4.3)': + '@earendil-works/pi-coding-agent@0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.23.0)(zod@4.4.3)': dependencies: - '@earendil-works/pi-agent-core': 0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.21.3)(zod@4.4.3) - '@earendil-works/pi-ai': 0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.21.3)(zod@4.4.3) + '@earendil-works/pi-agent-core': 0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.23.0)(zod@4.4.3) + '@earendil-works/pi-ai': 0.82.1(@modelcontextprotocol/sdk@1.29.0(@cfworker/json-schema@4.1.6)(zod@4.4.3))(ws@8.23.0)(zod@4.4.3) '@earendil-works/pi-tui': 0.82.1 '@silvia-odwyer/photon-node': 0.3.4 chalk: 5.6.2 @@ -5418,6 +5537,10 @@ snapshots: '@img/sharp-win32-x64@0.34.5': optional: true + '@isaacs/fs-minipass@4.0.1': + dependencies: + minipass: 7.1.3 + '@jridgewell/gen-mapping@0.3.13': dependencies: '@jridgewell/sourcemap-codec': 1.5.5 @@ -5439,12 +5562,12 @@ snapshots: '@kurkle/color@0.3.4': {} - '@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3)': + '@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0)': dependencies: '@cfworker/json-schema': 4.1.6 '@standard-schema/spec': 1.1.0 js-tiktoken: 1.0.21 - langsmith: 0.11.8(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3) + langsmith: 0.11.8(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0) mustache: 4.2.0 p-queue: 6.6.2 zod: 4.4.3 @@ -5455,13 +5578,13 @@ snapshots: - openai - ws - '@langchain/langgraph-checkpoint@1.2.2(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3))': + '@langchain/langgraph-checkpoint@1.2.2(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0))': dependencies: - '@langchain/core': 1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3) + '@langchain/core': 1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0) - '@langchain/langgraph-sdk@1.13.0(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3))(react-dom@19.2.7(react@19.2.7))(react@19.2.7)': + '@langchain/langgraph-sdk@1.13.0(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0))(react-dom@19.2.7(react@19.2.7))(react@19.2.7)': dependencies: - '@langchain/core': 1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3) + '@langchain/core': 1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0) '@langchain/protocol': 0.0.20 '@types/json-schema': 7.0.15 p-queue: 9.3.5 @@ -5470,11 +5593,11 @@ snapshots: react: 19.2.7 react-dom: 19.2.7(react@19.2.7) - '@langchain/langgraph@1.7.0(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3))(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(zod@4.4.3)': + '@langchain/langgraph@1.7.0(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0))(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(zod@4.4.3)': dependencies: - '@langchain/core': 1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3) - '@langchain/langgraph-checkpoint': 1.2.2(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3)) - '@langchain/langgraph-sdk': 1.13.0(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3))(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + '@langchain/core': 1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0) + '@langchain/langgraph-checkpoint': 1.2.2(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0)) + '@langchain/langgraph-sdk': 1.13.0(@langchain/core@1.3.4(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0))(react-dom@19.2.7(react@19.2.7))(react@19.2.7) '@langchain/protocol': 0.0.20 '@standard-schema/spec': 1.1.0 zod: 4.4.3 @@ -5791,6 +5914,73 @@ snapshots: '@oh-my-pi/pi-utils': 17.1.8 '@oh-my-pi/pi-wire': 17.1.8 + '@openai/agents-core@0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3)': + dependencies: + '@standard-schema/spec': 1.1.0 + debug: 4.4.3 + openai: 7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + tar: 7.5.22 + optionalDependencies: + '@modelcontextprotocol/client': 2.4.0 + zod: 4.4.3 + transitivePeerDependencies: + - '@aws-sdk/credential-provider-node' + - '@smithy/hash-node' + - '@smithy/signature-v4' + - google-auth-library + - supports-color + - undici + - ws + + '@openai/agents-openai@0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3)': + dependencies: + '@openai/agents-core': 0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + openai: 7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + zod: 4.4.3 + transitivePeerDependencies: + - '@aws-sdk/credential-provider-node' + - '@smithy/hash-node' + - '@smithy/signature-v4' + - google-auth-library + - supports-color + - undici + - ws + + '@openai/agents-realtime@0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(zod@4.4.3)': + dependencies: + '@openai/agents-core': 0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + '@types/ws': 8.18.2 + openai: 7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + ws: 8.23.0 + zod: 4.4.3 + transitivePeerDependencies: + - '@aws-sdk/credential-provider-node' + - '@smithy/hash-node' + - '@smithy/signature-v4' + - bufferutil + - google-auth-library + - supports-color + - undici + - utf-8-validate + + '@openai/agents@0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3)': + dependencies: + '@openai/agents-core': 0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + '@openai/agents-openai': 0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + '@openai/agents-realtime': 0.22.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(zod@4.4.3) + openai: 7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + zod: 4.4.3 + transitivePeerDependencies: + - '@aws-sdk/credential-provider-node' + - '@smithy/hash-node' + - '@smithy/signature-v4' + - bufferutil + - google-auth-library + - supports-color + - undici + - utf-8-validate + - ws + '@opencode-ai/plugin@1.18.9': dependencies: '@ai-sdk/provider': 3.0.8 @@ -6355,6 +6545,10 @@ snapshots: '@types/turndown@5.0.6': {} + '@types/ws@8.18.2': + dependencies: + '@types/node': 25.6.0 + '@typescript/native-preview-darwin-arm64@7.0.0-dev.20260328.1': optional: true @@ -6737,6 +6931,8 @@ snapshots: readdirp: 5.0.0 optional: true + chownr@3.0.0: {} + chromium-bidi@16.0.1(devtools-protocol@0.0.1638949): dependencies: devtools-protocol: 0.0.1638949 @@ -7523,15 +7719,15 @@ snapshots: kysely@0.28.17: optional: true - langsmith@0.11.8(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3))(ws@8.21.3): + langsmith@0.11.8(@opentelemetry/api@1.9.1)(@opentelemetry/exporter-trace-otlp-proto@0.220.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.12.0(@opentelemetry/api@1.9.1))(openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3))(ws@8.23.0): dependencies: p-queue: 6.6.2 optionalDependencies: '@opentelemetry/api': 1.9.1 '@opentelemetry/exporter-trace-otlp-proto': 0.220.0(@opentelemetry/api@1.9.1) '@opentelemetry/sdk-trace-base': 2.12.0(@opentelemetry/api@1.9.1) - openai: 7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3) - ws: 8.21.3 + openai: 7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3) + ws: 8.23.0 lie@3.3.0: dependencies: @@ -7675,6 +7871,10 @@ snapshots: minipass@7.1.3: {} + minizlib@3.1.0: + dependencies: + minipass: 7.1.3 + mitt@3.0.1: {} modern-tar@0.7.7: {} @@ -7844,24 +8044,33 @@ snapshots: protobufjs: 7.6.5 optional: true - openai@6.26.0(ws@8.21.3)(zod@4.4.3): + openai@6.26.0(ws@8.23.0)(zod@4.4.3): optionalDependencies: - ws: 8.21.3 + ws: 8.23.0 zod: 4.4.3 - openai@6.45.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(ws@8.21.3)(zod@4.4.3): + openai@6.45.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(ws@8.23.0)(zod@4.4.3): optionalDependencies: '@aws-sdk/credential-provider-node': 3.972.83 '@smithy/signature-v4': 5.7.3 - ws: 8.21.3 + ws: 8.23.0 zod: 4.4.3 - openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.21.3)(zod@4.4.3): + openai@7.18.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3): optionalDependencies: '@aws-sdk/credential-provider-node': 3.972.83 '@smithy/signature-v4': 5.7.3 undici: 8.9.0 - ws: 8.21.3 + ws: 8.23.0 + zod: 4.4.3 + + openai@7.60.0(@aws-sdk/credential-provider-node@3.972.83)(@smithy/signature-v4@5.7.3)(google-auth-library@10.9.0)(undici@8.9.0)(ws@8.23.0)(zod@4.4.3): + optionalDependencies: + '@aws-sdk/credential-provider-node': 3.972.83 + '@smithy/signature-v4': 5.7.3 + google-auth-library: 10.9.0 + undici: 8.9.0 + ws: 8.23.0 zod: 4.4.3 option@0.2.4: {} @@ -8440,6 +8649,14 @@ snapshots: tapable@2.3.3: {} + tar@7.5.22: + dependencies: + '@isaacs/fs-minipass': 4.0.1 + chownr: 3.0.0 + minipass: 7.1.3 + minizlib: 3.1.0 + yallist: 5.0.0 + text-hex@1.0.0: {} tinybench@2.9.0: {} @@ -8774,6 +8991,8 @@ snapshots: ws@8.21.3: {} + ws@8.23.0: {} + xml-name-validator@5.0.0: optional: true @@ -8789,6 +9008,8 @@ snapshots: y18n@5.0.8: {} + yallist@5.0.0: {} + yaml@2.9.0: {} yargs-parser@22.0.0: {} diff --git a/release-please-config.json b/release-please-config.json index 5d4ca5b..9ad78ea 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -67,6 +67,11 @@ "component": "openai", "release-type": "node" }, + "packages/openai-agents": { + "component": "openai-agents", + "release-type": "node", + "initial-version": "0.1.0" + }, "packages/opencode": { "component": "opencode", "release-type": "node"