(client, request3, options)
| 42452 | var components = __importStar(require_components()); |
| 42453 | var errors = __importStar(require_errors2()); |
| 42454 | async function agentsStream(client, request3, options) { |
| 42455 | const parsed = (0, schemas_js_1.safeParse)(request3, (value) => components.AgentsCompletionStreamRequest$outboundSchema.parse(value), "Input validation failed"); |
| 42456 | if (!parsed.ok) { |
| 42457 | return parsed; |
| 42458 | } |
| 42459 | const payload = parsed.value; |
| 42460 | const body = (0, encodings_js_1.encodeJSON)("body", payload, { explode: true }); |
| 42461 | const path5 = (0, url_js_1.pathToFunc)("/v1/agents/completions#stream")(); |
| 42462 | const headers = new Headers({ |
| 42463 | "Content-Type": "application/json", |
| 42464 | Accept: "text/event-stream" |
| 42465 | }); |
| 42466 | const secConfig = await (0, security_js_1.extractSecurity)(client._options.apiKey); |
| 42467 | const securityInput = secConfig == null ? {} : { apiKey: secConfig }; |
| 42468 | const requestSecurity = (0, security_js_1.resolveGlobalSecurity)(securityInput); |
| 42469 | const context = { |
| 42470 | operationID: "stream_agents", |
| 42471 | oAuth2Scopes: [], |
| 42472 | resolvedSecurity: requestSecurity, |
| 42473 | securitySource: client._options.apiKey, |
| 42474 | retryConfig: (options === null || options === void 0 ? void 0 : options.retries) || client._options.retryConfig || { strategy: "none" }, |
| 42475 | retryCodes: (options === null || options === void 0 ? void 0 : options.retryCodes) || ["429", "500", "502", "503", "504"] |
| 42476 | }; |
| 42477 | const requestRes = client._createRequest(context, { |
| 42478 | security: requestSecurity, |
| 42479 | method: "POST", |
| 42480 | path: path5, |
| 42481 | headers, |
| 42482 | body, |
| 42483 | timeoutMs: (options === null || options === void 0 ? void 0 : options.timeoutMs) || client._options.timeoutMs || -1 |
| 42484 | }, options); |
| 42485 | if (!requestRes.ok) { |
| 42486 | return requestRes; |
| 42487 | } |
| 42488 | const req = requestRes.value; |
| 42489 | const doResult = await client._do(req, { |
| 42490 | context, |
| 42491 | errorCodes: ["422", "4XX", "5XX"], |
| 42492 | retryConfig: context.retryConfig, |
| 42493 | retryCodes: context.retryCodes |
| 42494 | }); |
| 42495 | if (!doResult.ok) { |
| 42496 | return doResult; |
| 42497 | } |
| 42498 | const response = doResult.value; |
| 42499 | const responseFields = { |
| 42500 | HttpMeta: { Response: response, Request: req } |
| 42501 | }; |
| 42502 | const [result] = await M5.match(M5.sse(200, z6.instanceof(ReadableStream).transform((stream4) => { |
| 42503 | return new event_streams_js_1.EventStream({ |
| 42504 | stream: stream4, |
| 42505 | decoder(rawEvent) { |
| 42506 | const schema = components.CompletionEvent$inboundSchema; |
| 42507 | return schema.parse(rawEvent); |
| 42508 | } |
| 42509 | }); |
| 42510 | }), { sseSentinel: "[DONE]" }), M5.jsonErr(422, errors.HTTPValidationError$inboundSchema), M5.fail(["4XX", "5XX"]))(response, { extraFields: responseFields }); |
| 42511 | if (!result.ok) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…