Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist/
*.env
/tests/script.ts
/tests/script-error.ts
.npmrc
.npmrc
.claude
4 changes: 3 additions & 1 deletion Runware/Runware-client.ts
Original file line number Diff line number Diff line change
@@ -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();
}
Expand Down
8 changes: 7 additions & 1 deletion Runware/Runware-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];

Expand Down Expand Up @@ -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",
"X-SDK-Version": SDK_VERSION,
},
});

// delay(1);
Expand Down
2 changes: 1 addition & 1 deletion Runware/async-retry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { delay } from "./utils";

export const asyncRetry = async (

Check failure on line 3 in Runware/async-retry.ts

View workflow job for this annotation

GitHub Actions / build

'asyncRetry' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
apiCall: Function,
options: {
maxRetries?: number;
Expand All @@ -22,7 +22,7 @@
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
}
Expand Down
1 change: 1 addition & 0 deletions Runware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from "./types";

export * from "./Runware-server";
export * from "./Runware";
export { SDK_VERSION } from "./utils";
8 changes: 8 additions & 0 deletions Runware/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@runware/sdk-js",
"version": "1.2.6",
"version": "1.2.7",
"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",
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,15 @@ export type TImageMaskingResponse = {

## Changelog

### - v1.2.7

- Fix in-memory recursive while loop call without returning for async-retry
- Add sdk versioning to connection

### - v1.2.6

- Update upscale() to accept open-ended payload


### - v1.2.5

- Fix JS SDK error race condition
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"strict": true,
"esModuleInterop": true,
"allowJs": true,
"resolveJsonModule": true,
"skipLibCheck": true
},
"exclude": ["node_modules", "dist"],
Expand Down
Loading