Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/agent/src/lib/model-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,14 @@ function isRecord(value: unknown): value is Record<string, unknown> {

/**
* Type guard for stream event with toReadableStream method
* Checks constructor name, prototype, and method availability
* Checks ReadableStream inheritance and method availability
*/
function isEventStream(value: unknown): value is EventStream<models.StreamEvents> {
if (value === null || typeof value !== 'object') {
return false;
}

// Check constructor name for EventStream
const constructorName = Object.getPrototypeOf(value)?.constructor?.name;
if (constructorName === 'EventStream') {
if (typeof ReadableStream !== 'undefined' && value instanceof ReadableStream) {
return true;
}

Expand Down