From de14ada4247b18561f0fce3bed941d3a637aa12c Mon Sep 17 00:00:00 2001 From: BusyWritingLessCode Date: Fri, 27 Mar 2026 14:05:28 +0100 Subject: [PATCH 1/4] feat: add sdk version to params --- .claude/worktrees/magical-ardinghelli | 1 + .claude/worktrees/romantic-heisenberg | 1 + Runware/Runware-client.ts | 4 +++- Runware/Runware-server.ts | 8 +++++++- Runware/index.ts | 1 + Runware/utils.ts | 8 ++++++++ tsconfig.json | 1 + 7 files changed, 22 insertions(+), 2 deletions(-) create mode 160000 .claude/worktrees/magical-ardinghelli create mode 160000 .claude/worktrees/romantic-heisenberg diff --git a/.claude/worktrees/magical-ardinghelli b/.claude/worktrees/magical-ardinghelli new file mode 160000 index 0000000..8f035f4 --- /dev/null +++ b/.claude/worktrees/magical-ardinghelli @@ -0,0 +1 @@ +Subproject commit 8f035f48581e5f2ab00a95bf961ab0123756e40c diff --git a/.claude/worktrees/romantic-heisenberg b/.claude/worktrees/romantic-heisenberg new file mode 160000 index 0000000..8f035f4 --- /dev/null +++ b/.claude/worktrees/romantic-heisenberg @@ -0,0 +1 @@ +Subproject commit 8f035f48581e5f2ab00a95bf961ab0123756e40c diff --git a/Runware/Runware-client.ts b/Runware/Runware-client.ts index c7f9b09..aaa80fe 100644 --- a/Runware/Runware-client.ts +++ b/Runware/Runware-client.ts @@ -1,14 +1,16 @@ import { RunwareBase } from "./Runware-base"; import ReconnectingWebsocket from "./reconnect"; import { ReconnectingWebsocketProps, RunwareBaseType } from "./types"; +import { buildSdkUrl } from "./utils"; export class RunwareClient extends RunwareBase { constructor(props: RunwareBaseType) { const { shouldReconnect, ...rest } = props; super(rest); + const url = buildSdkUrl(this._url || ""); this._ws = new (ReconnectingWebsocket as any)( - this._url + url ) as ReconnectingWebsocketProps; this.connect(); } diff --git a/Runware/Runware-server.ts b/Runware/Runware-server.ts index 5626b07..c3f2c46 100644 --- a/Runware/Runware-server.ts +++ b/Runware/Runware-server.ts @@ -4,6 +4,7 @@ import WebSocket from "ws"; import { RunwareBase } from "./Runware-base"; import { ETaskType, RunwareBaseType, SdkType } from "./types"; +import { buildSdkUrl, SDK_VERSION } from "./utils"; // let allImages: IImage[] = []; @@ -53,8 +54,13 @@ export class RunwareServer extends RunwareBase { this.resetConnection(); - this._ws = new WebSocket(this._url, { + const url = buildSdkUrl(this._url); + this._ws = new WebSocket(url, { perMessageDeflate: false, + headers: { + "X-SDK-Name": "js-runware-sdk", + "X-SDK-Version": SDK_VERSION, + }, }); // delay(1); diff --git a/Runware/index.ts b/Runware/index.ts index 74b1de6..aff1bee 100644 --- a/Runware/index.ts +++ b/Runware/index.ts @@ -3,3 +3,4 @@ export * from "./types"; export * from "./Runware-server"; export * from "./Runware"; +export { SDK_VERSION } from "./utils"; diff --git a/Runware/utils.ts b/Runware/utils.ts index 7c6a621..d8508b3 100644 --- a/Runware/utils.ts +++ b/Runware/utils.ts @@ -7,6 +7,14 @@ import { IRequestImage, } from "./types"; import { v4 as uuidv4, validate as validateUUID } from "uuid"; +import pkg from "../package.json"; + +export const SDK_VERSION = pkg.version; + +export function buildSdkUrl(baseUrl: string): string { + const separator = baseUrl.includes("?") ? "&" : "?"; + return `${baseUrl}${separator}sdk=js&version=${SDK_VERSION}`; +} export const TIMEOUT_DURATION = 60000; // 120S; export const MINIMUM_TIMEOUT_DURATION = 1000; // 120S; diff --git a/tsconfig.json b/tsconfig.json index 8daf163..bf6dbd7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "strict": true, "esModuleInterop": true, "allowJs": true, + "resolveJsonModule": true, "skipLibCheck": true }, "exclude": ["node_modules", "dist"], From 84bb65baf3bd6c98cfb2a2fa350ea20a796f4c05 Mon Sep 17 00:00:00 2001 From: BusyWritingLessCode Date: Fri, 27 Mar 2026 14:08:00 +0100 Subject: [PATCH 2/4] feat: add sdk version to params --- .claude/worktrees/magical-ardinghelli | 1 - .claude/worktrees/romantic-heisenberg | 1 - .gitignore | 3 ++- 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 160000 .claude/worktrees/magical-ardinghelli delete mode 160000 .claude/worktrees/romantic-heisenberg diff --git a/.claude/worktrees/magical-ardinghelli b/.claude/worktrees/magical-ardinghelli deleted file mode 160000 index 8f035f4..0000000 --- a/.claude/worktrees/magical-ardinghelli +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8f035f48581e5f2ab00a95bf961ab0123756e40c diff --git a/.claude/worktrees/romantic-heisenberg b/.claude/worktrees/romantic-heisenberg deleted file mode 160000 index 8f035f4..0000000 --- a/.claude/worktrees/romantic-heisenberg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8f035f48581e5f2ab00a95bf961ab0123756e40c diff --git a/.gitignore b/.gitignore index f67effc..c7153af 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist/ *.env /tests/script.ts /tests/script-error.ts -.npmrc \ No newline at end of file +.npmrc +.claude \ No newline at end of file From 3a2a0af15d1cdac6d9b76fa8524ed4b0fd717617 Mon Sep 17 00:00:00 2001 From: BusyWritingLessCode Date: Fri, 27 Mar 2026 14:55:01 +0100 Subject: [PATCH 3/4] feat: fix naming --- Runware/Runware-server.ts | 2 +- Runware/async-retry.ts | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Runware/Runware-server.ts b/Runware/Runware-server.ts index c3f2c46..1255545 100644 --- a/Runware/Runware-server.ts +++ b/Runware/Runware-server.ts @@ -58,7 +58,7 @@ export class RunwareServer extends RunwareBase { this._ws = new WebSocket(url, { perMessageDeflate: false, headers: { - "X-SDK-Name": "js-runware-sdk", + "X-SDK-Name": "js", "X-SDK-Version": SDK_VERSION, }, }); diff --git a/Runware/async-retry.ts b/Runware/async-retry.ts index 621c177..17a979a 100644 --- a/Runware/async-retry.ts +++ b/Runware/async-retry.ts @@ -22,7 +22,7 @@ export const asyncRetry = async ( maxRetries--; if (maxRetries > 0) { await delay(delayInSeconds); // Delay before the next retry - await asyncRetry(apiCall, { ...options, maxRetries }); + return await asyncRetry(apiCall, { ...options, maxRetries }); } else { throw error; // Throw the error if max retries are reached } diff --git a/package.json b/package.json index 661e72d..0b84c8a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@runware/sdk-js", - "version": "1.2.5", + "version": "1.2.6", "description": "The SDK is used to run image inference with the Runware API, powered by the RunWare inference platform. It can be used to generate imaged with text-to-image and image-to-image. It also allows the use of an existing gallery of models or selecting any model or LoRA from the CivitAI gallery. The API also supports upscaling, background removal, inpainting and outpainting, and a series of other ControlNet models.", "main": "dist/index.js", "module": "dist/index.js", From a4f05f292dcfcada011eda2dc203e05c583df4e4 Mon Sep 17 00:00:00 2001 From: BusyWritingLessCode Date: Fri, 27 Mar 2026 15:01:56 +0100 Subject: [PATCH 4/4] feat: update readme --- readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme.md b/readme.md index f20688d..0bbbcef 100644 --- a/readme.md +++ b/readme.md @@ -739,6 +739,11 @@ export type TImageMaskingResponse = { ## Changelog +### - v1.2.6 + +- Fix in-memory recursive while loop call without returning for async-retry +- Add sdk versioning to connection + ### - v1.2.5 - Fix JS SDK error race condition