flowscale 2.1.0-beta.0 → 2.1.0-beta.3
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/dist/index.d.ts +3 -0
- package/dist/index.js +7 -1
- package/dist/local-pods.d.ts +67 -0
- package/dist/local-pods.js +319 -0
- package/dist/local-types.d.ts +149 -0
- package/dist/local-types.js +5 -0
- package/dist/node-index.d.ts +2 -0
- package/dist/node-index.js +7 -0
- package/dist/node-transport.d.ts +80 -0
- package/dist/node-transport.js +400 -0
- package/dist/operator-server.d.ts +26 -0
- package/dist/operator-server.js +178 -0
- package/dist/remote-transport.d.ts +43 -0
- package/dist/remote-transport.js +175 -0
- package/package.json +20 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.RemotePodsTransport = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* RemotePodsTransport — reads pods from a FlowScale Operator HTTP API
|
|
53
|
+
* served by PodsOperatorServer running on another machine.
|
|
54
|
+
*
|
|
55
|
+
* Only `list()` and `get()` are functional. All other methods throw since
|
|
56
|
+
* process lifecycle management must be done on the machine running the operator.
|
|
57
|
+
*
|
|
58
|
+
* Instance `baseUrl` fields are automatically set to `http://operatorHost:port`
|
|
59
|
+
* so that callers can reach the ComfyUI instances across the network.
|
|
60
|
+
*
|
|
61
|
+
* Usage:
|
|
62
|
+
* import { RemotePodsTransport, LocalPodsAPI } from 'flowscale'
|
|
63
|
+
* const podsApi = new LocalPodsAPI(new RemotePodsTransport('http://192.168.1.100:3001'))
|
|
64
|
+
*/
|
|
65
|
+
var RemotePodsTransport = /** @class */ (function () {
|
|
66
|
+
function RemotePodsTransport(operatorUrl) {
|
|
67
|
+
this.operatorUrl = operatorUrl.replace(/\/$/, '');
|
|
68
|
+
try {
|
|
69
|
+
this.operatorHost = new URL(this.operatorUrl).hostname;
|
|
70
|
+
}
|
|
71
|
+
catch (_a) {
|
|
72
|
+
this.operatorHost = 'localhost';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
RemotePodsTransport.prototype._injectBaseUrls = function (pod) {
|
|
76
|
+
var _this = this;
|
|
77
|
+
return __assign(__assign({}, pod), { instances: pod.instances.map(function (inst) { return (__assign(__assign({}, inst), { baseUrl: "http://".concat(_this.operatorHost, ":").concat(inst.port) })); }) });
|
|
78
|
+
};
|
|
79
|
+
RemotePodsTransport.prototype.list = function () {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
var res, pods;
|
|
82
|
+
var _this = this;
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
switch (_a.label) {
|
|
85
|
+
case 0: return [4 /*yield*/, fetch("".concat(this.operatorUrl, "/api/pods"), {
|
|
86
|
+
signal: AbortSignal.timeout(5000),
|
|
87
|
+
})];
|
|
88
|
+
case 1:
|
|
89
|
+
res = _a.sent();
|
|
90
|
+
if (!res.ok)
|
|
91
|
+
throw new Error("Operator /api/pods failed (".concat(res.status, ")"));
|
|
92
|
+
return [4 /*yield*/, res.json()];
|
|
93
|
+
case 2:
|
|
94
|
+
pods = (_a.sent());
|
|
95
|
+
return [2 /*return*/, pods.map(function (p) { return _this._injectBaseUrls(p); })];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
RemotePodsTransport.prototype.get = function (id) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
var res, pod;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, fetch("".concat(this.operatorUrl, "/api/pods/").concat(encodeURIComponent(id)), { signal: AbortSignal.timeout(5000) })];
|
|
106
|
+
case 1:
|
|
107
|
+
res = _a.sent();
|
|
108
|
+
if (res.status === 404)
|
|
109
|
+
return [2 /*return*/, null];
|
|
110
|
+
if (!res.ok)
|
|
111
|
+
throw new Error("Operator /api/pods/".concat(id, " failed (").concat(res.status, ")"));
|
|
112
|
+
return [4 /*yield*/, res.json()];
|
|
113
|
+
case 2:
|
|
114
|
+
pod = (_a.sent());
|
|
115
|
+
return [2 /*return*/, this._injectBaseUrls(pod)];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
// ── Not available via remote operator ──────────────────────────────────────
|
|
121
|
+
RemotePodsTransport.prototype._notSupported = function (method) {
|
|
122
|
+
throw new Error("RemotePodsTransport: \"".concat(method, "\" is not available via remote operator \u2014 ") +
|
|
123
|
+
'connect to the operator machine directly to manage pods.');
|
|
124
|
+
};
|
|
125
|
+
RemotePodsTransport.prototype.create = function (_data) {
|
|
126
|
+
return this._notSupported('create');
|
|
127
|
+
};
|
|
128
|
+
RemotePodsTransport.prototype.update = function (_id, _data) {
|
|
129
|
+
return this._notSupported('update');
|
|
130
|
+
};
|
|
131
|
+
RemotePodsTransport.prototype.delete = function (_id) {
|
|
132
|
+
return this._notSupported('delete');
|
|
133
|
+
};
|
|
134
|
+
RemotePodsTransport.prototype.scanPaths = function () {
|
|
135
|
+
return this._notSupported('scanPaths');
|
|
136
|
+
};
|
|
137
|
+
RemotePodsTransport.prototype.scanPorts = function (_podId) {
|
|
138
|
+
return this._notSupported('scanPorts');
|
|
139
|
+
};
|
|
140
|
+
RemotePodsTransport.prototype.refreshInstance = function (_instanceId) {
|
|
141
|
+
return this._notSupported('refreshInstance');
|
|
142
|
+
};
|
|
143
|
+
RemotePodsTransport.prototype.startInstance = function (_req) {
|
|
144
|
+
return this._notSupported('startInstance');
|
|
145
|
+
};
|
|
146
|
+
RemotePodsTransport.prototype.stopInstance = function (_instanceId) {
|
|
147
|
+
return this._notSupported('stopInstance');
|
|
148
|
+
};
|
|
149
|
+
RemotePodsTransport.prototype.restartInstance = function (_instanceId) {
|
|
150
|
+
return this._notSupported('restartInstance');
|
|
151
|
+
};
|
|
152
|
+
RemotePodsTransport.prototype.deleteInstance = function (_instanceId) {
|
|
153
|
+
return this._notSupported('deleteInstance');
|
|
154
|
+
};
|
|
155
|
+
RemotePodsTransport.prototype.getSystemInfo = function () {
|
|
156
|
+
return this._notSupported('getSystemInfo');
|
|
157
|
+
};
|
|
158
|
+
RemotePodsTransport.prototype.getLogs = function (_instanceId) {
|
|
159
|
+
return this._notSupported('getLogs');
|
|
160
|
+
};
|
|
161
|
+
RemotePodsTransport.prototype.installRocmPyTorch = function (_podId) {
|
|
162
|
+
this._notSupported('installRocmPyTorch');
|
|
163
|
+
};
|
|
164
|
+
RemotePodsTransport.prototype.onInstanceStatusChanged = function (_cb) {
|
|
165
|
+
return function () { };
|
|
166
|
+
};
|
|
167
|
+
RemotePodsTransport.prototype.onLog = function (_cb) {
|
|
168
|
+
return function () { };
|
|
169
|
+
};
|
|
170
|
+
RemotePodsTransport.prototype.onRocmSetupDone = function (_cb) {
|
|
171
|
+
return function () { };
|
|
172
|
+
};
|
|
173
|
+
return RemotePodsTransport;
|
|
174
|
+
}());
|
|
175
|
+
exports.RemotePodsTransport = RemotePodsTransport;
|
package/package.json
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowscale",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.3",
|
|
4
4
|
"description": "An NPM library for communicating with the Flowscale APIs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./node": {
|
|
13
|
+
"require": "./dist/node-index.js",
|
|
14
|
+
"types": "./dist/node-index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
7
17
|
"keywords": [
|
|
8
18
|
"flowscale",
|
|
9
19
|
"api",
|
|
@@ -33,7 +43,16 @@
|
|
|
33
43
|
"axios": "^1.7.7",
|
|
34
44
|
"form-data": "^4.0.1"
|
|
35
45
|
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"better-sqlite3": ">=9.0.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"better-sqlite3": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
36
54
|
"devDependencies": {
|
|
55
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
37
56
|
"@types/form-data": "^2.5.2",
|
|
38
57
|
"@types/node": "^22.9.1",
|
|
39
58
|
"typescript": "^5.6.3"
|