openai 7.25.0 → 7.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/client.d.mts +5 -6
- package/client.d.mts.map +1 -1
- package/client.d.ts +5 -6
- package/client.d.ts.map +1 -1
- package/client.js +38 -10
- package/client.js.map +1 -1
- package/client.mjs +39 -11
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts +4 -0
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts +4 -0
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +6 -0
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +6 -0
- package/core/streaming.mjs.map +1 -1
- package/helpers/beta/agents/filesystem.d.mts +17 -0
- package/helpers/beta/agents/filesystem.d.mts.map +1 -0
- package/helpers/beta/agents/filesystem.d.ts +17 -0
- package/helpers/beta/agents/filesystem.d.ts.map +1 -0
- package/helpers/beta/agents/filesystem.js +168 -0
- package/helpers/beta/agents/filesystem.js.map +1 -0
- package/helpers/beta/agents/filesystem.mjs +162 -0
- package/helpers/beta/agents/filesystem.mjs.map +1 -0
- package/helpers/beta/agents/standard-schema.d.mts +7 -0
- package/helpers/beta/agents/standard-schema.d.mts.map +1 -0
- package/helpers/beta/agents/standard-schema.d.ts +7 -0
- package/helpers/beta/agents/standard-schema.d.ts.map +1 -0
- package/helpers/beta/agents/standard-schema.js +12 -0
- package/helpers/beta/agents/standard-schema.js.map +1 -0
- package/helpers/beta/agents/standard-schema.mjs +9 -0
- package/helpers/beta/agents/standard-schema.mjs.map +1 -0
- package/helpers/beta/agents/zod.d.mts +10 -0
- package/helpers/beta/agents/zod.d.mts.map +1 -0
- package/helpers/beta/agents/zod.d.ts +10 -0
- package/helpers/beta/agents/zod.d.ts.map +1 -0
- package/helpers/beta/agents/zod.js +12 -0
- package/helpers/beta/agents/zod.js.map +1 -0
- package/helpers/beta/agents/zod.mjs +9 -0
- package/helpers/beta/agents/zod.mjs.map +1 -0
- package/internal/realtime-credentials.d.mts +22 -1
- package/internal/realtime-credentials.d.mts.map +1 -1
- package/internal/realtime-credentials.d.ts +22 -1
- package/internal/realtime-credentials.d.ts.map +1 -1
- package/internal/realtime-credentials.js +48 -4
- package/internal/realtime-credentials.js.map +1 -1
- package/internal/realtime-credentials.mjs +45 -4
- package/internal/realtime-credentials.mjs.map +1 -1
- package/internal/responses-ws-credentials.d.mts +23 -0
- package/internal/responses-ws-credentials.d.mts.map +1 -0
- package/internal/responses-ws-credentials.d.ts +23 -0
- package/internal/responses-ws-credentials.d.ts.map +1 -0
- package/internal/responses-ws-credentials.js +108 -0
- package/internal/responses-ws-credentials.js.map +1 -0
- package/internal/responses-ws-credentials.mjs +104 -0
- package/internal/responses-ws-credentials.mjs.map +1 -0
- package/internal/shim-types.d.mts +9 -0
- package/internal/shim-types.d.mts.map +1 -1
- package/internal/shim-types.d.ts +9 -0
- package/internal/shim-types.d.ts.map +1 -1
- package/internal/tslib.js +4 -0
- package/internal/ws-adapter-node.d.mts +4 -0
- package/internal/ws-adapter-node.d.mts.map +1 -1
- package/internal/ws-adapter-node.d.ts +4 -0
- package/internal/ws-adapter-node.d.ts.map +1 -1
- package/internal/ws-adapter-node.js +56 -0
- package/internal/ws-adapter-node.js.map +1 -1
- package/internal/ws-adapter-node.mjs +55 -0
- package/internal/ws-adapter-node.mjs.map +1 -1
- package/internal/ws.d.mts +27 -4
- package/internal/ws.d.mts.map +1 -1
- package/internal/ws.d.ts +27 -4
- package/internal/ws.d.ts.map +1 -1
- package/internal/ws.js +105 -5
- package/internal/ws.js.map +1 -1
- package/internal/ws.mjs +102 -4
- package/internal/ws.mjs.map +1 -1
- package/lib/agents/agent-session-stream.d.mts +13 -4
- package/lib/agents/agent-session-stream.d.mts.map +1 -1
- package/lib/agents/agent-session-stream.d.ts +13 -4
- package/lib/agents/agent-session-stream.d.ts.map +1 -1
- package/lib/agents/agent-session-stream.js +24 -21
- package/lib/agents/agent-session-stream.js.map +1 -1
- package/lib/agents/agent-session-stream.mjs +24 -21
- package/lib/agents/agent-session-stream.mjs.map +1 -1
- package/lib/beta/agents/agent-session-create-stream.d.mts +15 -0
- package/lib/beta/agents/agent-session-create-stream.d.mts.map +1 -0
- package/lib/beta/agents/agent-session-create-stream.d.ts +15 -0
- package/lib/beta/agents/agent-session-create-stream.d.ts.map +1 -0
- package/lib/beta/agents/agent-session-create-stream.js +25 -0
- package/lib/beta/agents/agent-session-create-stream.js.map +1 -0
- package/lib/beta/agents/agent-session-create-stream.mjs +22 -0
- package/lib/beta/agents/agent-session-create-stream.mjs.map +1 -0
- package/lib/beta/agents/agent-turn-result-collector.d.mts +17 -0
- package/lib/beta/agents/agent-turn-result-collector.d.mts.map +1 -0
- package/lib/beta/agents/agent-turn-result-collector.d.ts +17 -0
- package/lib/beta/agents/agent-turn-result-collector.d.ts.map +1 -0
- package/lib/beta/agents/agent-turn-result-collector.js +99 -0
- package/lib/beta/agents/agent-turn-result-collector.js.map +1 -0
- package/lib/beta/agents/agent-turn-result-collector.mjs +95 -0
- package/lib/beta/agents/agent-turn-result-collector.mjs.map +1 -0
- package/lib/beta/agents/agent-turn-result-error.d.mts +16 -0
- package/lib/beta/agents/agent-turn-result-error.d.mts.map +1 -0
- package/lib/beta/agents/agent-turn-result-error.d.ts +16 -0
- package/lib/beta/agents/agent-turn-result-error.d.ts.map +1 -0
- package/lib/beta/agents/agent-turn-result-error.js +22 -0
- package/lib/beta/agents/agent-turn-result-error.js.map +1 -0
- package/lib/beta/agents/agent-turn-result-error.mjs +18 -0
- package/lib/beta/agents/agent-turn-result-error.mjs.map +1 -0
- package/lib/beta/agents/agent-turn-result.d.mts +12 -0
- package/lib/beta/agents/agent-turn-result.d.mts.map +1 -0
- package/lib/beta/agents/agent-turn-result.d.ts +12 -0
- package/lib/beta/agents/agent-turn-result.d.ts.map +1 -0
- package/lib/beta/agents/agent-turn-result.js +22 -0
- package/lib/beta/agents/agent-turn-result.js.map +1 -0
- package/lib/beta/agents/agent-turn-result.mjs +18 -0
- package/lib/beta/agents/agent-turn-result.mjs.map +1 -0
- package/lib/beta/agents/files.d.mts +33 -0
- package/lib/beta/agents/files.d.mts.map +1 -0
- package/lib/beta/agents/files.d.ts +33 -0
- package/lib/beta/agents/files.d.ts.map +1 -0
- package/lib/beta/agents/files.js +93 -0
- package/lib/beta/agents/files.js.map +1 -0
- package/lib/beta/agents/files.mjs +86 -0
- package/lib/beta/agents/files.mjs.map +1 -0
- package/lib/beta/agents/function-tool.d.mts +27 -0
- package/lib/beta/agents/function-tool.d.mts.map +1 -0
- package/lib/beta/agents/function-tool.d.ts +27 -0
- package/lib/beta/agents/function-tool.d.ts.map +1 -0
- package/lib/beta/agents/function-tool.js +48 -0
- package/lib/beta/agents/function-tool.js.map +1 -0
- package/lib/beta/agents/function-tool.mjs +45 -0
- package/lib/beta/agents/function-tool.mjs.map +1 -0
- package/lib/beta/agents/output-format-types.d.mts +11 -0
- package/lib/beta/agents/output-format-types.d.mts.map +1 -0
- package/lib/beta/agents/output-format-types.d.ts +11 -0
- package/lib/beta/agents/output-format-types.d.ts.map +1 -0
- package/lib/beta/agents/output-format-types.js +3 -0
- package/lib/beta/agents/output-format-types.js.map +1 -0
- package/lib/beta/agents/output-format-types.mjs +2 -0
- package/lib/beta/agents/output-format-types.mjs.map +1 -0
- package/lib/beta/agents/output-format.d.mts +8 -0
- package/lib/beta/agents/output-format.d.mts.map +1 -0
- package/lib/beta/agents/output-format.d.ts +8 -0
- package/lib/beta/agents/output-format.d.ts.map +1 -0
- package/lib/beta/agents/output-format.js +20 -0
- package/lib/beta/agents/output-format.js.map +1 -0
- package/lib/beta/agents/output-format.mjs +14 -0
- package/lib/beta/agents/output-format.mjs.map +1 -0
- package/lib/beta/agents/output-parse-error.d.mts +11 -0
- package/lib/beta/agents/output-parse-error.d.mts.map +1 -0
- package/lib/beta/agents/output-parse-error.d.ts +11 -0
- package/lib/beta/agents/output-parse-error.d.ts.map +1 -0
- package/lib/beta/agents/output-parse-error.js +22 -0
- package/lib/beta/agents/output-parse-error.js.map +1 -0
- package/lib/beta/agents/output-parse-error.mjs +18 -0
- package/lib/beta/agents/output-parse-error.mjs.map +1 -0
- package/lib/beta/agents/pages.d.mts +9 -0
- package/lib/beta/agents/pages.d.mts.map +1 -0
- package/lib/beta/agents/pages.d.ts +9 -0
- package/lib/beta/agents/pages.d.ts.map +1 -0
- package/lib/beta/agents/pages.js +32 -0
- package/lib/beta/agents/pages.js.map +1 -0
- package/lib/beta/agents/pages.mjs +29 -0
- package/lib/beta/agents/pages.mjs.map +1 -0
- package/lib/beta/agents/parse-result.d.mts +95 -0
- package/lib/beta/agents/parse-result.d.mts.map +1 -0
- package/lib/beta/agents/parse-result.d.ts +95 -0
- package/lib/beta/agents/parse-result.d.ts.map +1 -0
- package/lib/beta/agents/parse-result.js +116 -0
- package/lib/beta/agents/parse-result.js.map +1 -0
- package/lib/beta/agents/parse-result.mjs +110 -0
- package/lib/beta/agents/parse-result.mjs.map +1 -0
- package/lib/beta/agents/parsed-agent-turn-result.d.mts +8 -0
- package/lib/beta/agents/parsed-agent-turn-result.d.mts.map +1 -0
- package/lib/beta/agents/parsed-agent-turn-result.d.ts +8 -0
- package/lib/beta/agents/parsed-agent-turn-result.d.ts.map +1 -0
- package/lib/beta/agents/parsed-agent-turn-result.js +14 -0
- package/lib/beta/agents/parsed-agent-turn-result.js.map +1 -0
- package/lib/beta/agents/parsed-agent-turn-result.mjs +10 -0
- package/lib/beta/agents/parsed-agent-turn-result.mjs.map +1 -0
- package/lib/beta/agents/result-artifacts.d.mts +19 -0
- package/lib/beta/agents/result-artifacts.d.mts.map +1 -0
- package/lib/beta/agents/result-artifacts.d.ts +19 -0
- package/lib/beta/agents/result-artifacts.d.ts.map +1 -0
- package/lib/beta/agents/result-artifacts.js +67 -0
- package/lib/beta/agents/result-artifacts.js.map +1 -0
- package/lib/beta/agents/result-artifacts.mjs +63 -0
- package/lib/beta/agents/result-artifacts.mjs.map +1 -0
- package/lib/beta/agents/result-collection.d.mts +15 -0
- package/lib/beta/agents/result-collection.d.mts.map +1 -0
- package/lib/beta/agents/result-collection.d.ts +15 -0
- package/lib/beta/agents/result-collection.d.ts.map +1 -0
- package/lib/beta/agents/result-collection.js +110 -0
- package/lib/beta/agents/result-collection.js.map +1 -0
- package/lib/beta/agents/result-collection.mjs +106 -0
- package/lib/beta/agents/result-collection.mjs.map +1 -0
- package/lib/beta/agents/tool-output.d.mts +7 -0
- package/lib/beta/agents/tool-output.d.mts.map +1 -0
- package/lib/beta/agents/tool-output.d.ts +7 -0
- package/lib/beta/agents/tool-output.d.ts.map +1 -0
- package/lib/beta/agents/tool-output.js +26 -0
- package/lib/beta/agents/tool-output.js.map +1 -0
- package/lib/beta/agents/tool-output.mjs +23 -0
- package/lib/beta/agents/tool-output.mjs.map +1 -0
- package/lib/responses/responses-websocket-session.d.mts +1 -1
- package/lib/responses/responses-websocket-session.d.mts.map +1 -1
- package/lib/responses/responses-websocket-session.d.ts +1 -1
- package/lib/responses/responses-websocket-session.d.ts.map +1 -1
- package/lib/responses/responses-websocket-session.js +12 -2
- package/lib/responses/responses-websocket-session.js.map +1 -1
- package/lib/responses/responses-websocket-session.mjs +12 -2
- package/lib/responses/responses-websocket-session.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/agents/agents.d.mts +9 -0
- package/resources/beta/agents/agents.d.mts.map +1 -1
- package/resources/beta/agents/agents.d.ts +9 -0
- package/resources/beta/agents/agents.d.ts.map +1 -1
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/agents/environments/files.d.mts +12 -0
- package/resources/beta/agents/environments/files.d.mts.map +1 -1
- package/resources/beta/agents/environments/files.d.ts +12 -0
- package/resources/beta/agents/environments/files.d.ts.map +1 -1
- package/resources/beta/agents/environments/files.js +9 -0
- package/resources/beta/agents/environments/files.js.map +1 -1
- package/resources/beta/agents/environments/files.mjs +9 -0
- package/resources/beta/agents/environments/files.mjs.map +1 -1
- package/resources/beta/agents/sessions/artifacts.d.mts +4 -0
- package/resources/beta/agents/sessions/artifacts.d.mts.map +1 -1
- package/resources/beta/agents/sessions/artifacts.d.ts +4 -0
- package/resources/beta/agents/sessions/artifacts.d.ts.map +1 -1
- package/resources/beta/agents/sessions/artifacts.js +5 -0
- package/resources/beta/agents/sessions/artifacts.js.map +1 -1
- package/resources/beta/agents/sessions/artifacts.mjs +5 -0
- package/resources/beta/agents/sessions/artifacts.mjs.map +1 -1
- package/resources/beta/agents/sessions/events.d.mts +6 -5
- package/resources/beta/agents/sessions/events.d.mts.map +1 -1
- package/resources/beta/agents/sessions/events.d.ts +6 -5
- package/resources/beta/agents/sessions/events.d.ts.map +1 -1
- package/resources/beta/agents/sessions/events.js +6 -5
- package/resources/beta/agents/sessions/events.js.map +1 -1
- package/resources/beta/agents/sessions/events.mjs +6 -5
- package/resources/beta/agents/sessions/events.mjs.map +1 -1
- package/resources/beta/agents/sessions/index.d.mts +1 -0
- package/resources/beta/agents/sessions/index.d.mts.map +1 -1
- package/resources/beta/agents/sessions/index.d.ts +1 -0
- package/resources/beta/agents/sessions/index.d.ts.map +1 -1
- package/resources/beta/agents/sessions/index.js +3 -1
- package/resources/beta/agents/sessions/index.js.map +1 -1
- package/resources/beta/agents/sessions/index.mjs +1 -0
- package/resources/beta/agents/sessions/index.mjs.map +1 -1
- package/resources/beta/agents/sessions/sessions.d.mts +16 -4
- package/resources/beta/agents/sessions/sessions.d.mts.map +1 -1
- package/resources/beta/agents/sessions/sessions.d.ts +16 -4
- package/resources/beta/agents/sessions/sessions.d.ts.map +1 -1
- package/resources/beta/agents/sessions/sessions.js +17 -4
- package/resources/beta/agents/sessions/sessions.js.map +1 -1
- package/resources/beta/agents/sessions/sessions.mjs +17 -4
- package/resources/beta/agents/sessions/sessions.mjs.map +1 -1
- package/resources/beta/agents/sessions/traces.d.mts +68 -0
- package/resources/beta/agents/sessions/traces.d.mts.map +1 -0
- package/resources/beta/agents/sessions/traces.d.ts +68 -0
- package/resources/beta/agents/sessions/traces.d.ts.map +1 -0
- package/resources/beta/agents/sessions/traces.js +81 -0
- package/resources/beta/agents/sessions/traces.js.map +1 -0
- package/resources/beta/agents/sessions/traces.mjs +77 -0
- package/resources/beta/agents/sessions/traces.mjs.map +1 -0
- package/resources/beta/responses/ws-base.d.mts +3 -1
- package/resources/beta/responses/ws-base.d.mts.map +1 -1
- package/resources/beta/responses/ws-base.d.ts +3 -1
- package/resources/beta/responses/ws-base.d.ts.map +1 -1
- package/resources/beta/responses/ws-base.js +35 -6
- package/resources/beta/responses/ws-base.js.map +1 -1
- package/resources/beta/responses/ws-base.mjs +35 -6
- package/resources/beta/responses/ws-base.mjs.map +1 -1
- package/resources/beta/responses/ws.d.mts +10 -0
- package/resources/beta/responses/ws.d.mts.map +1 -1
- package/resources/beta/responses/ws.d.ts +10 -0
- package/resources/beta/responses/ws.d.ts.map +1 -1
- package/resources/beta/responses/ws.js +23 -22
- package/resources/beta/responses/ws.js.map +1 -1
- package/resources/beta/responses/ws.mjs +24 -23
- package/resources/beta/responses/ws.mjs.map +1 -1
- package/resources/chat/completions/completions.d.mts +1 -1
- package/resources/chat/completions/completions.d.mts.map +1 -1
- package/resources/chat/completions/completions.d.ts +1 -1
- package/resources/chat/completions/completions.d.ts.map +1 -1
- package/resources/evals/runs/runs.js +1 -1
- package/resources/evals/runs/runs.js.map +1 -1
- package/resources/evals/runs/runs.mjs +1 -1
- package/resources/evals/runs/runs.mjs.map +1 -1
- package/resources/live/forks/forks.d.mts +5 -1
- package/resources/live/forks/forks.d.mts.map +1 -1
- package/resources/live/forks/forks.d.ts +5 -1
- package/resources/live/forks/forks.d.ts.map +1 -1
- package/resources/live/live.d.mts +5 -1
- package/resources/live/live.d.mts.map +1 -1
- package/resources/live/live.d.ts +5 -1
- package/resources/live/live.d.ts.map +1 -1
- package/resources/live/live.js.map +1 -1
- package/resources/live/live.mjs.map +1 -1
- package/resources/responses/ws-base.d.mts +3 -1
- package/resources/responses/ws-base.d.mts.map +1 -1
- package/resources/responses/ws-base.d.ts +3 -1
- package/resources/responses/ws-base.d.ts.map +1 -1
- package/resources/responses/ws-base.js +35 -6
- package/resources/responses/ws-base.js.map +1 -1
- package/resources/responses/ws-base.mjs +35 -6
- package/resources/responses/ws-base.mjs.map +1 -1
- package/resources/responses/ws.d.mts +10 -0
- package/resources/responses/ws.d.mts.map +1 -1
- package/resources/responses/ws.d.ts +10 -0
- package/resources/responses/ws.d.ts.map +1 -1
- package/resources/responses/ws.js +23 -22
- package/resources/responses/ws.js.map +1 -1
- package/resources/responses/ws.mjs +24 -23
- package/resources/responses/ws.mjs.map +1 -1
- package/src/client.ts +55 -19
- package/src/core/streaming.ts +9 -0
- package/src/helpers/beta/agents/filesystem.ts +187 -0
- package/src/helpers/beta/agents/standard-schema.ts +13 -0
- package/src/helpers/beta/agents/zod.ts +10 -0
- package/src/internal/realtime-credentials.ts +70 -4
- package/src/internal/responses-ws-credentials.ts +160 -0
- package/src/internal/shim-types.ts +17 -0
- package/src/internal/ws-adapter-node.ts +66 -0
- package/src/internal/ws.ts +139 -11
- package/src/lib/agents/agent-session-stream.ts +36 -24
- package/src/lib/beta/agents/agent-session-create-stream.ts +36 -0
- package/src/lib/beta/agents/agent-turn-result-collector.ts +122 -0
- package/src/lib/beta/agents/agent-turn-result-error.ts +33 -0
- package/src/lib/beta/agents/agent-turn-result.ts +22 -0
- package/src/lib/beta/agents/files.ts +119 -0
- package/src/lib/beta/agents/function-tool.ts +60 -0
- package/src/lib/beta/agents/output-format-types.ts +12 -0
- package/src/lib/beta/agents/output-format.ts +20 -0
- package/src/lib/beta/agents/output-parse-error.ts +16 -0
- package/src/lib/beta/agents/pages.ts +32 -0
- package/src/lib/beta/agents/parse-result.ts +133 -0
- package/src/lib/beta/agents/parsed-agent-turn-result.ts +12 -0
- package/src/lib/beta/agents/result-artifacts.ts +76 -0
- package/src/lib/beta/agents/result-collection.ts +115 -0
- package/src/lib/beta/agents/tool-output.ts +22 -0
- package/src/lib/responses/responses-websocket-session.ts +14 -3
- package/src/resources/beta/agents/agents.ts +11 -0
- package/src/resources/beta/agents/environments/files.ts +16 -0
- package/src/resources/beta/agents/sessions/artifacts.ts +7 -0
- package/src/resources/beta/agents/sessions/events.ts +6 -5
- package/src/resources/beta/agents/sessions/index.ts +1 -0
- package/src/resources/beta/agents/sessions/sessions.ts +48 -18
- package/src/resources/beta/agents/sessions/traces.ts +298 -0
- package/src/resources/beta/responses/ws-base.ts +40 -6
- package/src/resources/beta/responses/ws.ts +37 -27
- package/src/resources/chat/completions/completions.ts +1 -1
- package/src/resources/evals/runs/runs.ts +1 -1
- package/src/resources/live/forks/forks.ts +6 -1
- package/src/resources/live/live.ts +6 -1
- package/src/resources/responses/ws-base.ts +40 -6
- package/src/resources/responses/ws.ts +37 -27
- package/src/tsconfig.dist-src-node.d.ts +7 -0
- package/src/tsconfig.dist-src.d.ts +3 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { OpenAIError } from '../../../core/error';
|
|
2
|
+
import type { AgentSessionEvent } from '../../../resources/beta/agents/agents';
|
|
3
|
+
import type { AgentTurnResult } from './agent-turn-result';
|
|
4
|
+
import { AgentTurnResultCollector } from './agent-turn-result-collector';
|
|
5
|
+
import { AgentTurnResultError } from './agent-turn-result-error';
|
|
6
|
+
|
|
7
|
+
/** Shares collection between a raw creation stream and the follow-up helper.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export class ResultCollection {
|
|
11
|
+
#iterator: AsyncGenerator<AgentSessionEvent, void> | undefined;
|
|
12
|
+
#ended = false;
|
|
13
|
+
#enabled = false;
|
|
14
|
+
#uncollectedEvents = false;
|
|
15
|
+
#error: unknown;
|
|
16
|
+
#result: Promise<AgentTurnResult> | undefined;
|
|
17
|
+
readonly collector: AgentTurnResultCollector;
|
|
18
|
+
|
|
19
|
+
readonly #source: () => AsyncIterator<AgentSessionEvent>;
|
|
20
|
+
readonly #signal: AbortSignal | undefined;
|
|
21
|
+
readonly #canHandle: (name: string) => boolean;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
source: () => AsyncIterator<AgentSessionEvent>,
|
|
25
|
+
canHandle: (name: string) => boolean = () => false,
|
|
26
|
+
sessionID?: string,
|
|
27
|
+
signal?: AbortSignal,
|
|
28
|
+
) {
|
|
29
|
+
this.#source = source;
|
|
30
|
+
this.#signal = signal;
|
|
31
|
+
this.#canHandle = canHandle;
|
|
32
|
+
this.collector = new AgentTurnResultCollector(sessionID);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
enable(): void {
|
|
36
|
+
if (!this.#enabled && this.#uncollectedEvents) {
|
|
37
|
+
throw new OpenAIError(
|
|
38
|
+
'Call withResultCollection() before consuming events, or call finalResult() on a fresh stream.',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
this.#enabled = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
iterate(): AsyncIterator<AgentSessionEvent> {
|
|
45
|
+
if (this.#iterator) {
|
|
46
|
+
throw new OpenAIError('An agent result stream can only be consumed once');
|
|
47
|
+
}
|
|
48
|
+
return (this.#iterator = this.#observe());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async *#observe(): AsyncGenerator<AgentSessionEvent, void> {
|
|
52
|
+
const iterator = this.#source();
|
|
53
|
+
let done = false;
|
|
54
|
+
try {
|
|
55
|
+
while (true) {
|
|
56
|
+
// oxlint-disable-next-line no-await-in-loop -- Pull the single-use stream sequentially.
|
|
57
|
+
const next = await iterator.next();
|
|
58
|
+
if (next.done) {
|
|
59
|
+
done = true;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (this.#enabled) {
|
|
63
|
+
this.collector.accept(next.value);
|
|
64
|
+
} else {
|
|
65
|
+
this.#uncollectedEvents = true;
|
|
66
|
+
}
|
|
67
|
+
yield next.value;
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (this.#enabled) {
|
|
71
|
+
this.#error = error;
|
|
72
|
+
}
|
|
73
|
+
throw error;
|
|
74
|
+
} finally {
|
|
75
|
+
this.#ended = true;
|
|
76
|
+
if (!done) {
|
|
77
|
+
await iterator.return?.();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
finalResult(): Promise<AgentTurnResult> {
|
|
83
|
+
return (this.#result ??= this.#collect());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async #collect(): Promise<AgentTurnResult> {
|
|
87
|
+
this.enable();
|
|
88
|
+
try {
|
|
89
|
+
const iterator = this.#iterator ?? this.iterate();
|
|
90
|
+
while (!this.#ended && !this.collector.ready) {
|
|
91
|
+
this.collector.checkAction(this.#canHandle);
|
|
92
|
+
// oxlint-disable-next-line no-await-in-loop -- Each event can dispatch tools before the next pull.
|
|
93
|
+
const next = await iterator.next();
|
|
94
|
+
if (next.done) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (this.#error !== undefined && !this.collector.ready) {
|
|
99
|
+
throw this.#error;
|
|
100
|
+
}
|
|
101
|
+
if (!this.collector.ready && this.#signal?.aborted) {
|
|
102
|
+
throw this.collector.error('observation', this.#signal.reason);
|
|
103
|
+
}
|
|
104
|
+
return this.collector.finish();
|
|
105
|
+
} catch (error) {
|
|
106
|
+
throw error instanceof AgentTurnResultError ? error : this.collector.error('observation', error);
|
|
107
|
+
} finally {
|
|
108
|
+
try {
|
|
109
|
+
await this.#iterator?.return();
|
|
110
|
+
} finally {
|
|
111
|
+
this.collector.release();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { hasOwn, isObj } from '../../../internal/utils/values';
|
|
2
|
+
import type { InputContentParam } from '../../../resources/beta/agents/agents';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Recognizes supported content blocks without confusing JSON business data with content.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export function isInputContent(value: unknown): value is InputContentParam {
|
|
9
|
+
if (!isObj(value)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const content = value;
|
|
13
|
+
let field: string;
|
|
14
|
+
if (content['type'] === 'input_text') {
|
|
15
|
+
field = 'text';
|
|
16
|
+
} else if (content['type'] === 'input_image') {
|
|
17
|
+
field = 'image_url';
|
|
18
|
+
} else {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return hasOwn(content, 'type') && hasOwn(content, field) && typeof content[field] === 'string';
|
|
22
|
+
}
|
|
@@ -22,9 +22,13 @@ interface LaneState {
|
|
|
22
22
|
bytes: number;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// A disposed helper cannot distinguish a delayed terminal from a later request
|
|
26
|
+
// on the same socket. Retain only IDs (never lane buffers) until that socket is gone.
|
|
27
|
+
const reservedLanes = new WeakMap<WebSocketLike, Set<string | undefined>>();
|
|
28
|
+
|
|
25
29
|
/** Limits for this optional helper. They do not change the underlying socket's limits. */
|
|
26
30
|
export interface ResponsesWebSocketSessionOptions {
|
|
27
|
-
/** Maximum lane IDs registered until the next reconnect, including detached lanes. */
|
|
31
|
+
/** Maximum lane IDs registered on the socket until the next reconnect, including detached lanes. */
|
|
28
32
|
maxLanes: number;
|
|
29
33
|
/** Maximum queued events across all lanes. */
|
|
30
34
|
maxBufferedEvents: number;
|
|
@@ -129,10 +133,16 @@ export class ResponsesWebSocketSession {
|
|
|
129
133
|
) {
|
|
130
134
|
throw new OpenAIError('Invalid Responses WebSocket stream ID');
|
|
131
135
|
}
|
|
132
|
-
|
|
136
|
+
const { socket: physicalSocket } = this.#connection;
|
|
137
|
+
let reservations = reservedLanes.get(physicalSocket);
|
|
138
|
+
if (!reservations) {
|
|
139
|
+
reservations = new Set();
|
|
140
|
+
reservedLanes.set(physicalSocket, reservations);
|
|
141
|
+
}
|
|
142
|
+
if (reservations.has(streamID)) {
|
|
133
143
|
throw new OpenAIError('Responses WebSocket lane is already registered');
|
|
134
144
|
}
|
|
135
|
-
if (
|
|
145
|
+
if (reservations.size >= this.#maxLanes) {
|
|
136
146
|
throw new OpenAIError('Responses WebSocket lane limit exceeded');
|
|
137
147
|
}
|
|
138
148
|
const entry: LaneState = {
|
|
@@ -160,6 +170,7 @@ export class ResponsesWebSocketSession {
|
|
|
160
170
|
positiveInteger(limits.maxBufferedBytes ?? this.#maxBytes),
|
|
161
171
|
),
|
|
162
172
|
};
|
|
173
|
+
reservations.add(streamID);
|
|
163
174
|
this.#lanes.set(streamID, entry);
|
|
164
175
|
return entry.lane;
|
|
165
176
|
}
|
|
@@ -3667,6 +3667,12 @@ export namespace Environment {
|
|
|
3667
3667
|
*/
|
|
3668
3668
|
type: 'openai_hosted';
|
|
3669
3669
|
|
|
3670
|
+
/**
|
|
3671
|
+
* The effective CPU and memory tier, or null when unknown or outside the public
|
|
3672
|
+
* tiers.
|
|
3673
|
+
*/
|
|
3674
|
+
container_size?: 'small' | 'medium' | 'large' | null;
|
|
3675
|
+
|
|
3670
3676
|
/**
|
|
3671
3677
|
* The effective desktop configuration.
|
|
3672
3678
|
*/
|
|
@@ -3791,6 +3797,11 @@ export namespace EnvironmentParam {
|
|
|
3791
3797
|
*/
|
|
3792
3798
|
capability_directories?: Array<string> | null;
|
|
3793
3799
|
|
|
3800
|
+
/**
|
|
3801
|
+
* The hosted container size. Omission selects the medium tier.
|
|
3802
|
+
*/
|
|
3803
|
+
container_size?: 'small' | 'medium' | 'large';
|
|
3804
|
+
|
|
3794
3805
|
/**
|
|
3795
3806
|
* Desktop provisioning. Omission or null inherits the template setting, or
|
|
3796
3807
|
* defaults to disabled.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
prepareAgentFiles,
|
|
5
|
+
uploadAgentFile,
|
|
6
|
+
type PreparedAgentFiles,
|
|
7
|
+
} from '../../../../lib/beta/agents/files';
|
|
8
|
+
import type { Uploadable } from '../../../../internal/uploads';
|
|
3
9
|
import { APIResource } from '../../../../core/resource';
|
|
4
10
|
import { APIPromise } from '../../../../core/api-promise';
|
|
5
11
|
import { PagePromise, TokenPage, type TokenPageParams } from '../../../../core/pagination';
|
|
@@ -15,6 +21,16 @@ function resolveResourceRequestOptions(
|
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
export class Files extends APIResource {
|
|
24
|
+
/** Beta: prepare initial hosted file references; uploaded Files API objects remain caller-owned. */
|
|
25
|
+
prepare(files: Record<string, Uploadable>, options?: RequestOptions): Promise<PreparedAgentFiles> {
|
|
26
|
+
return prepareAgentFiles(this._client, files, options);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Beta: upload one local file and stage its reference in a live environment. */
|
|
30
|
+
upload(environmentID: string, params: { file: Uploadable; path: string }, options?: RequestOptions) {
|
|
31
|
+
return uploadAgentFile(this._client, this, environmentID, params, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
/**
|
|
19
35
|
* Copies inline bytes or a Files API file into a connected execution environment.
|
|
20
36
|
* See
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
import { AgentResultArtifacts } from '../../../../lib/beta/agents/result-artifacts';
|
|
4
|
+
import type { AgentTurnResult } from '../../../../lib/beta/agents/agent-turn-result';
|
|
3
5
|
import { APIResource } from '../../../../core/resource';
|
|
4
6
|
import { APIPromise } from '../../../../core/api-promise';
|
|
5
7
|
import { CursorPage, type CursorPageParams, PagePromise } from '../../../../core/pagination';
|
|
@@ -122,6 +124,11 @@ function normalizeRequestOptionsForQuery(
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
export class Artifacts extends APIResource {
|
|
127
|
+
/** Beta: bind artifact lookup and downloads to a completed result's exact session and turn. */
|
|
128
|
+
forResult(result: AgentTurnResult): AgentResultArtifacts {
|
|
129
|
+
return new AgentResultArtifacts(this, result);
|
|
130
|
+
}
|
|
131
|
+
|
|
125
132
|
/**
|
|
126
133
|
* Retrieves immutable metadata for one durable session artifact. See
|
|
127
134
|
* [session artifacts](https://developers.openai.com/api/docs/guides/agents-api/environments/files#openai-hosted-artifacts).
|
|
@@ -17,11 +17,12 @@ function resolveResourceRequestOptions(
|
|
|
17
17
|
|
|
18
18
|
export class Events extends APIResource {
|
|
19
19
|
/**
|
|
20
|
-
* Submits message, cancellation,
|
|
21
|
-
* Cancellation can recover a still-open turn
|
|
22
|
-
* marking it cancelled and abandoning
|
|
23
|
-
* published files, and existing terminal
|
|
24
|
-
* acceptance, not durable completion.
|
|
20
|
+
* Submits message, cancellation, tool-result, or computer-use approval-response
|
|
21
|
+
* events to a managed agent session. Cancellation can recover a still-open turn
|
|
22
|
+
* whose backend execution has ended by marking it cancelled and abandoning
|
|
23
|
+
* unpublished outputs. Saved results, published files, and existing terminal
|
|
24
|
+
* outcomes are preserved. HTTP 202 confirms acceptance, not durable completion.
|
|
25
|
+
* See
|
|
25
26
|
* [session events](https://developers.openai.com/api/docs/guides/agents-api/sessions/events).
|
|
26
27
|
*
|
|
27
28
|
* @example
|
|
@@ -21,4 +21,5 @@ export {
|
|
|
21
21
|
type SessionListParams,
|
|
22
22
|
} from './sessions';
|
|
23
23
|
export { Subagents, type SubagentRetrieveParams, type SubagentListParams } from './subagents/index';
|
|
24
|
+
export { Traces, type SessionTrace, type TraceListParams, type SessionTracesPage } from './traces';
|
|
24
25
|
export { Turns, type Turn, type TurnRetrieveParams, type TurnListParams, type TurnsPage } from './turns';
|
|
@@ -4,6 +4,12 @@ import {
|
|
|
4
4
|
AgentSessionStream,
|
|
5
5
|
type AgentSessionStreamParams,
|
|
6
6
|
} from '../../../../lib/agents/agent-session-stream';
|
|
7
|
+
import {
|
|
8
|
+
type AgentSessionCreateStream,
|
|
9
|
+
withAgentTurnResult,
|
|
10
|
+
} from '../../../../lib/beta/agents/agent-session-create-stream';
|
|
11
|
+
import type { AgentOutputFormat } from '../../../../lib/beta/agents/output-format-types';
|
|
12
|
+
import { captureAgentOutput } from '../../../../lib/beta/agents/parse-result';
|
|
7
13
|
import { APIResource } from '../../../../core/resource';
|
|
8
14
|
import * as SessionsAPI from './sessions';
|
|
9
15
|
import * as AgentsAPI from '../agents';
|
|
@@ -23,13 +29,15 @@ import * as EventsAPI from './events';
|
|
|
23
29
|
import { EventCreateParams, Events } from './events';
|
|
24
30
|
import * as ItemsAPI from './items';
|
|
25
31
|
import { ItemListParams, Items } from './items';
|
|
32
|
+
import * as TracesAPI from './traces';
|
|
33
|
+
import { SessionTrace, SessionTracesPage, TraceListParams, Traces } from './traces';
|
|
26
34
|
import * as TurnsAPI from './turns';
|
|
27
35
|
import { Turn, TurnListParams, TurnRetrieveParams, Turns, TurnsPage } from './turns';
|
|
28
36
|
import * as SubagentsAPI from './subagents/subagents';
|
|
29
37
|
import { SubagentListParams, SubagentRetrieveParams, Subagents } from './subagents/subagents';
|
|
30
38
|
import { APIPromise } from '../../../../core/api-promise';
|
|
31
39
|
import { CursorPage, type CursorPageParams, PagePromise } from '../../../../core/pagination';
|
|
32
|
-
import { Stream } from '../../../../core/streaming';
|
|
40
|
+
import type { Stream } from '../../../../core/streaming';
|
|
33
41
|
import { buildHeaders } from '../../../../internal/headers';
|
|
34
42
|
import { RequestOptions } from '../../../../internal/request-options';
|
|
35
43
|
import { path } from '../../../../internal/utils/path';
|
|
@@ -150,7 +158,11 @@ function normalizeRequestOptionsForQuery(
|
|
|
150
158
|
|
|
151
159
|
export class Sessions extends APIResource {
|
|
152
160
|
/** Stream one turn on an idle session with a single input writer. See AgentSessionStream for lifecycle and tool handling. */
|
|
153
|
-
stream
|
|
161
|
+
stream<T = never>(
|
|
162
|
+
sessionID: string,
|
|
163
|
+
params: AgentSessionStreamParams<T>,
|
|
164
|
+
options?: RequestOptions,
|
|
165
|
+
): AgentSessionStream<T> {
|
|
154
166
|
return new AgentSessionStream(this, sessionID, params, options);
|
|
155
167
|
}
|
|
156
168
|
|
|
@@ -158,6 +170,7 @@ export class Sessions extends APIResource {
|
|
|
158
170
|
artifacts: ArtifactsAPI.Artifacts = new ArtifactsAPI.Artifacts(this._client);
|
|
159
171
|
items: ItemsAPI.Items = new ItemsAPI.Items(this._client);
|
|
160
172
|
events: EventsAPI.Events = new EventsAPI.Events(this._client);
|
|
173
|
+
traces: TracesAPI.Traces = new TracesAPI.Traces(this._client);
|
|
161
174
|
turns: TurnsAPI.Turns = new TurnsAPI.Turns(this._client);
|
|
162
175
|
|
|
163
176
|
/**
|
|
@@ -173,29 +186,38 @@ export class Sessions extends APIResource {
|
|
|
173
186
|
* });
|
|
174
187
|
* ```
|
|
175
188
|
*/
|
|
176
|
-
create(
|
|
177
|
-
|
|
178
|
-
body: SessionCreateParamsStreaming,
|
|
189
|
+
create<T>(
|
|
190
|
+
body: SessionCreateParamsStreaming & { agent: { text: { format: AgentOutputFormat<T> } } },
|
|
179
191
|
options?: RequestOptions,
|
|
180
|
-
): APIPromise<
|
|
192
|
+
): APIPromise<AgentSessionCreateStream<T>>;
|
|
193
|
+
create(body: SessionCreateParamsNonStreaming, options?: RequestOptions): APIPromise<AgentsAPI.AgentSession>;
|
|
194
|
+
create(body: SessionCreateParamsStreaming, options?: RequestOptions): APIPromise<AgentSessionCreateStream>;
|
|
181
195
|
create(
|
|
182
196
|
body: SessionCreateParamsBase,
|
|
183
197
|
options?: RequestOptions,
|
|
184
|
-
): APIPromise<
|
|
198
|
+
): APIPromise<AgentSessionCreateStream | AgentsAPI.AgentSession>;
|
|
185
199
|
create(
|
|
186
200
|
body: SessionCreateParams,
|
|
187
201
|
options?: RequestOptions,
|
|
188
|
-
): APIPromise<AgentsAPI.AgentSession> | APIPromise<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
): APIPromise<AgentsAPI.AgentSession> | APIPromise<AgentSessionCreateStream> {
|
|
203
|
+
const output = captureAgentOutput(body, options);
|
|
204
|
+
return this._client
|
|
205
|
+
.post<AgentsAPI.AgentSession | Stream<AgentsAPI.AgentSessionEvent>>(
|
|
206
|
+
'/agents/sessions',
|
|
207
|
+
resolveResourceRequestOptions(output.options, (options) => ({
|
|
208
|
+
body: output.body,
|
|
209
|
+
...options,
|
|
210
|
+
headers: buildHeaders([{ 'OpenAI-Beta': 'agents=v1' }, options?.headers]),
|
|
211
|
+
stream: output.body.stream ?? false,
|
|
212
|
+
__security: { bearerAuth: true },
|
|
213
|
+
})),
|
|
214
|
+
)
|
|
215
|
+
._thenUnwrap((data, { options }) =>
|
|
216
|
+
// SAFETY: defaultParseResponse uses this same resolved flag to return the configured stream instance.
|
|
217
|
+
options.stream
|
|
218
|
+
? withAgentTurnResult(data as Stream<AgentsAPI.AgentSessionEvent>, output.format)
|
|
219
|
+
: data,
|
|
220
|
+
) as APIPromise<AgentsAPI.AgentSession> | APIPromise<AgentSessionCreateStream>;
|
|
199
221
|
}
|
|
200
222
|
|
|
201
223
|
/**
|
|
@@ -587,6 +609,7 @@ Sessions.Subagents = Subagents;
|
|
|
587
609
|
Sessions.Artifacts = Artifacts;
|
|
588
610
|
Sessions.Items = Items;
|
|
589
611
|
Sessions.Events = Events;
|
|
612
|
+
Sessions.Traces = Traces;
|
|
590
613
|
Sessions.Turns = Turns;
|
|
591
614
|
|
|
592
615
|
export declare namespace Sessions {
|
|
@@ -619,6 +642,13 @@ export declare namespace Sessions {
|
|
|
619
642
|
|
|
620
643
|
export { Events as Events, type EventCreateParams as EventCreateParams };
|
|
621
644
|
|
|
645
|
+
export {
|
|
646
|
+
Traces as Traces,
|
|
647
|
+
type SessionTrace as SessionTrace,
|
|
648
|
+
type SessionTracesPage as SessionTracesPage,
|
|
649
|
+
type TraceListParams as TraceListParams,
|
|
650
|
+
};
|
|
651
|
+
|
|
622
652
|
export {
|
|
623
653
|
Turns as Turns,
|
|
624
654
|
type Turn as Turn,
|