@openrouter/sdk 1.5.94 → 1.5.96

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/README.md CHANGED
@@ -203,7 +203,7 @@ import { OpenRouter } from "@openrouter/sdk";
203
203
  const sdk = new OpenRouter({ debugLogger: console });
204
204
  ```
205
205
 
206
- You can also enable a default debug logger by setting an environment variable `OPENROUTER_DEBUG` to true.
206
+ You can also enable a default debug logger by setting an environment variable `OPENROUTER_DEBUG` to `true`, `1`, `yes` or `on` (case-insensitive). Any other value leaves it off.
207
207
  <!-- End Debugging [debug] -->
208
208
 
209
209
  <!-- Placeholder for Future Speakeasy SDK Sections -->
@@ -50,8 +50,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
50
50
  export declare const SDK_METADATA: {
51
51
  readonly language: "typescript";
52
52
  readonly openapiDocVersion: "1.0.0";
53
- readonly sdkVersion: "1.5.94";
54
- readonly genVersion: "2.950.13";
55
- readonly userAgent: "speakeasy-sdk/typescript 1.5.94 2.950.13 1.0.0 @openrouter/sdk";
53
+ readonly sdkVersion: "1.5.96";
54
+ readonly genVersion: "2.960.8";
55
+ readonly userAgent: "speakeasy-sdk/typescript 1.5.96 2.960.8 1.0.0 @openrouter/sdk";
56
56
  };
57
57
  //# sourceMappingURL=config.d.ts.map
package/esm/lib/config.js CHANGED
@@ -29,8 +29,8 @@ export function serverURLFromOptions(options) {
29
29
  export const SDK_METADATA = {
30
30
  language: "typescript",
31
31
  openapiDocVersion: "1.0.0",
32
- sdkVersion: "1.5.94",
33
- genVersion: "2.950.13",
34
- userAgent: "speakeasy-sdk/typescript 1.5.94 2.950.13 1.0.0 @openrouter/sdk",
32
+ sdkVersion: "1.5.96",
33
+ genVersion: "2.960.8",
34
+ userAgent: "speakeasy-sdk/typescript 1.5.96 2.960.8 1.0.0 @openrouter/sdk",
35
35
  };
36
36
  //# sourceMappingURL=config.js.map
package/esm/lib/env.js CHANGED
@@ -8,9 +8,12 @@ export const envSchema = z.object({
8
8
  OPENROUTER_HTTP_REFERER: z.string().optional(),
9
9
  OPENROUTER_APP_TITLE: z.string().optional(),
10
10
  OPENROUTER_APP_CATEGORIES: z.string().optional(),
11
- OPENROUTER_DEBUG: z.coerce.boolean().optional(),
11
+ OPENROUTER_DEBUG: z.unknown().transform(parseEnvFlag).optional(),
12
12
  OPENROUTER_BASE_URL: z.string().url().optional(),
13
13
  });
14
+ function parseEnvFlag(value) {
15
+ return ["true", "1", "yes", "on"].includes(String(value).trim().toLowerCase());
16
+ }
14
17
  /**
15
18
  * Checks for the existence of the Deno global object to determine the environment.
16
19
  * @returns {boolean} True if the runtime is Deno, false otherwise.
@@ -8,6 +8,12 @@ declare global {
8
8
  };
9
9
  }
10
10
  }
11
+ type StreamIterator<T> = (ReadableStream<T>[typeof Symbol.asyncIterator] & (() => unknown)) extends {
12
+ (options?: any): infer A;
13
+ (options?: any): infer B;
14
+ (options?: any): infer C;
15
+ (options?: any): infer D;
16
+ } ? A & B & C & D : never;
11
17
  export type SseMessage<T> = {
12
18
  data?: T | undefined;
13
19
  event?: string | null | undefined;
@@ -18,6 +24,7 @@ export declare class EventStream<T> extends ReadableStream<T> {
18
24
  constructor(responseBody: ReadableStream<Uint8Array>, parse: (x: SseMessage<string>) => IteratorResult<T, undefined>, opts?: {
19
25
  dataRequired?: boolean;
20
26
  });
21
- [Symbol.asyncIterator](): ReturnType<ReadableStream<T>[typeof Symbol.asyncIterator]>;
27
+ [Symbol.asyncIterator](): StreamIterator<T>;
22
28
  }
29
+ export {};
23
30
  //# sourceMappingURL=event-streams.d.ts.map
@@ -67,29 +67,58 @@ export class EventStream extends ReadableStream {
67
67
  if (typeof fn === "function")
68
68
  return fn.call(this);
69
69
  const reader = this.getReader();
70
- return {
70
+ let released = false;
71
+ const release = () => {
72
+ released = true;
73
+ reader.releaseLock();
74
+ };
75
+ const iterator = {
71
76
  next: async () => {
72
- const r = await reader.read();
77
+ if (released)
78
+ return { done: true, value: undefined };
79
+ const r = await reader.read().catch((e) => {
80
+ release();
81
+ throw e;
82
+ });
73
83
  if (r.done) {
74
- reader.releaseLock();
84
+ release();
75
85
  return { done: true, value: undefined };
76
86
  }
77
87
  return { done: false, value: r.value };
78
88
  },
79
89
  throw: async (e) => {
80
- await reader.cancel(e);
81
- reader.releaseLock();
90
+ if (released)
91
+ return { done: true, value: undefined };
92
+ try {
93
+ await reader.cancel(e);
94
+ }
95
+ finally {
96
+ release();
97
+ }
82
98
  return { done: true, value: undefined };
83
99
  },
84
100
  return: async () => {
85
- await reader.cancel("done");
86
- reader.releaseLock();
101
+ if (released)
102
+ return { done: true, value: undefined };
103
+ try {
104
+ await reader.cancel("done");
105
+ }
106
+ finally {
107
+ release();
108
+ }
87
109
  return { done: true, value: undefined };
88
110
  },
89
111
  [Symbol.asyncIterator]() {
90
112
  return this;
91
113
  },
92
114
  };
115
+ const asyncDispose = Symbol.asyncDispose;
116
+ if (asyncDispose) {
117
+ iterator[asyncDispose] = async () => {
118
+ await iterator.return();
119
+ };
120
+ }
121
+ return iterator;
93
122
  }
94
123
  }
95
124
  const CR = 13;
@@ -7,6 +7,8 @@ export declare const ResponseIncludesEnum: {
7
7
  readonly ReasoningEncryptedContent: "reasoning.encrypted_content";
8
8
  readonly OutputEncryptedContent: "output.encrypted_content";
9
9
  readonly CodeInterpreterCallOutputs: "code_interpreter_call.outputs";
10
+ readonly WebSearchCallResults: "web_search_call.results";
11
+ readonly WebSearchCallActionSources: "web_search_call.action.sources";
10
12
  };
11
13
  export type ResponseIncludesEnum = OpenEnum<typeof ResponseIncludesEnum>;
12
14
  /** @internal */
@@ -10,6 +10,8 @@ export const ResponseIncludesEnum = {
10
10
  ReasoningEncryptedContent: "reasoning.encrypted_content",
11
11
  OutputEncryptedContent: "output.encrypted_content",
12
12
  CodeInterpreterCallOutputs: "code_interpreter_call.outputs",
13
+ WebSearchCallResults: "web_search_call.results",
14
+ WebSearchCallActionSources: "web_search_call.action.sources",
13
15
  };
14
16
  /** @internal */
15
17
  export const ResponseIncludesEnum$outboundSchema = openEnums.outboundSchema(ResponseIncludesEnum);
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "1.5.94",
5
+ "version": "1.5.96",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrouter/sdk",
3
- "version": "1.5.94",
3
+ "version": "1.5.96",
4
4
  "author": "OpenRouter",
5
5
  "description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.",
6
6
  "keywords": [
@@ -21,8 +21,8 @@
21
21
  "license": "Apache-2.0",
22
22
  "packageManager": "pnpm@10.22.0",
23
23
  "publishConfig": {
24
- "provenance": true,
25
- "access": "public"
24
+ "access": "public",
25
+ "provenance": true
26
26
  },
27
27
  "type": "module",
28
28
  "main": "./esm/index.js",
@@ -73,15 +73,15 @@
73
73
  "lint": "eslint --cache --max-warnings=0 src",
74
74
  "build": "tsc && node scripts/unbarrel-imports.js",
75
75
  "prepublishOnly": "npm run build",
76
- "prepare": "npm run build",
77
76
  "test": "vitest --run --project unit",
77
+ "compile": "tsc && node scripts/unbarrel-imports.js",
78
78
  "test:e2e": "vitest --run --project e2e",
79
79
  "test:transit": "exit 0",
80
80
  "test:watch": "vitest --watch --project unit",
81
- "compile": "tsc && node scripts/unbarrel-imports.js",
82
- "postinstall": "node scripts/check-types.js || true",
83
81
  "typecheck": "tsc --noEmit",
84
- "typecheck:transit": "exit 0"
82
+ "typecheck:transit": "exit 0",
83
+ "postinstall": "node scripts/check-types.js || true",
84
+ "prepare": "npm run build"
85
85
  },
86
86
  "peerDependencies": {
87
87