comfy-ts 0.3.0 → 0.4.0
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 +3 -3
- package/dist/cli.js +1 -1
- package/dist/index.cjs +45 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +45 -2
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-Io8Xea0L.js → run-tui-SDSJo1Qf.js} +638 -82
- package/dist/run-tui-SDSJo1Qf.js.map +1 -0
- package/package.json +2 -3
- package/src/cli/tui/components/Header.tsx +5 -0
- package/src/cli/tui/components/LogsPanel.tsx +23 -0
- package/src/cli/tui/components/PreviewPanel.tsx +52 -7
- package/src/cli/tui/components/StatusBar.tsx +10 -4
- package/src/cli/tui/components/TuiApp.tsx +26 -3
- package/src/cli/tui/protocolImagePainter.ts +54 -18
- package/src/cli/tui/run-tui.tsx +4 -1
- package/src/cli/tui/state/ExecSt.ts +4 -1
- package/src/cli/tui/state/HostSt.ts +124 -1
- package/src/cli/tui/state/LogsSt.ts +107 -0
- package/src/cli/tui/state/PreviewSt.ts +173 -23
- package/src/cli/tui/state/SettingsSt.ts +48 -21
- package/src/cli/tui/state/TuiSt.ts +6 -0
- package/src/cli/tui/state/WorkflowsSt.ts +1 -0
- package/src/host/ComfyHost.ts +44 -0
- package/src/runner/ComfyWsApi.ts +12 -1
- package/src/ssh-host-manager/ssh-manager.ts +0 -15
- package/src/utils/ansi.ts +7 -0
- package/src/utils/mojibake.ts +60 -0
- package/dist/run-tui-Io8Xea0L.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -5262,6 +5262,10 @@ declare const types$1: import("arktype").Module<{
|
|
|
5262
5262
|
sid?: string | undefined;
|
|
5263
5263
|
};
|
|
5264
5264
|
};
|
|
5265
|
+
LogEntry: {
|
|
5266
|
+
t: string;
|
|
5267
|
+
m: string;
|
|
5268
|
+
};
|
|
5265
5269
|
NodeProgress: {
|
|
5266
5270
|
value: number;
|
|
5267
5271
|
max: number;
|
|
@@ -5422,6 +5426,15 @@ declare const types$1: import("arktype").Module<{
|
|
|
5422
5426
|
sid?: string | undefined;
|
|
5423
5427
|
};
|
|
5424
5428
|
};
|
|
5429
|
+
} | {
|
|
5430
|
+
type: "logs";
|
|
5431
|
+
data: {
|
|
5432
|
+
entries: {
|
|
5433
|
+
t: string;
|
|
5434
|
+
m: string;
|
|
5435
|
+
}[];
|
|
5436
|
+
size?: unknown;
|
|
5437
|
+
};
|
|
5425
5438
|
};
|
|
5426
5439
|
WsMsgExecuted: {
|
|
5427
5440
|
type: "executed";
|
|
@@ -5485,6 +5498,16 @@ declare const types$1: import("arktype").Module<{
|
|
|
5485
5498
|
prompt_id: PromptID;
|
|
5486
5499
|
timestamp: number;
|
|
5487
5500
|
};
|
|
5501
|
+
WsMsgLogs: {
|
|
5502
|
+
type: "logs";
|
|
5503
|
+
data: {
|
|
5504
|
+
entries: {
|
|
5505
|
+
t: string;
|
|
5506
|
+
m: string;
|
|
5507
|
+
}[];
|
|
5508
|
+
size?: unknown;
|
|
5509
|
+
};
|
|
5510
|
+
};
|
|
5488
5511
|
WsMsgProgress: {
|
|
5489
5512
|
type: "progress";
|
|
5490
5513
|
data: {
|
|
@@ -5547,6 +5570,13 @@ declare const types$1: import("arktype").Module<{
|
|
|
5547
5570
|
_WsMsgExecutionStartData: {
|
|
5548
5571
|
prompt_id: PromptID;
|
|
5549
5572
|
};
|
|
5573
|
+
_WsMsgLogsData: {
|
|
5574
|
+
entries: {
|
|
5575
|
+
t: string;
|
|
5576
|
+
m: string;
|
|
5577
|
+
}[];
|
|
5578
|
+
size?: unknown;
|
|
5579
|
+
};
|
|
5550
5580
|
_WsMsgProgressStateData: {
|
|
5551
5581
|
prompt_id: PromptID;
|
|
5552
5582
|
nodes: Record<string, unknown>;
|
|
@@ -5560,6 +5590,7 @@ type WsMsgExecutionCached = typeof types$1.WsMsgExecutionCached.infer;
|
|
|
5560
5590
|
type WsMsgExecuting = typeof types$1.WsMsgExecuting.infer;
|
|
5561
5591
|
type WsMsgProgress = typeof types$1.WsMsgProgress.infer;
|
|
5562
5592
|
type WsMsgExecutionError = typeof types$1.WsMsgExecutionError.infer;
|
|
5593
|
+
type LogEntry = typeof types$1.LogEntry.infer;
|
|
5563
5594
|
type ComfyImageInfo = typeof types$1.ComfyImageInfo.infer;
|
|
5564
5595
|
//#endregion
|
|
5565
5596
|
//#region src/sdk-generator/comfy-api-json.d.ts
|
|
@@ -9316,6 +9347,16 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9316
9347
|
clearQueue: () => Promise<void>;
|
|
9317
9348
|
/** interrupt the CURRENTLY RUNNING prompt */
|
|
9318
9349
|
interrupt: () => Promise<void>;
|
|
9350
|
+
/** the server's recent console buffer (entries are write CHUNKS, not lines) */
|
|
9351
|
+
fetchRawLogs: () => Promise<{
|
|
9352
|
+
entries: LogEntry[];
|
|
9353
|
+
}>;
|
|
9354
|
+
/** (un)subscribe THIS session to ws 'logs' messages — per-sid server state,
|
|
9355
|
+
* must be re-sent after every reconnect (see onSession) */
|
|
9356
|
+
subscribeLogs: (p: {
|
|
9357
|
+
enabled: boolean;
|
|
9358
|
+
clientId: string;
|
|
9359
|
+
}) => Promise<void>;
|
|
9319
9360
|
/** GET a JSON route, preferring the /api prefix, falling back to the bare route */
|
|
9320
9361
|
private fetchJSON_;
|
|
9321
9362
|
/** retrieve the comfy spec from the schema*/
|
|
@@ -9409,6 +9450,13 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9409
9450
|
onStatus: Maybe<(p: {
|
|
9410
9451
|
queueRemaining: number;
|
|
9411
9452
|
}) => void>;
|
|
9453
|
+
/** fires when the server assigns a NEW session id (first connect AND every
|
|
9454
|
+
* reconnect — per-sid server state like log subscriptions must be redone) */
|
|
9455
|
+
onSession: Maybe<(sid: string) => void>;
|
|
9456
|
+
/** fires on ws 'logs' messages (server console stream, see subscribeLogs) */
|
|
9457
|
+
onLogs: Maybe<(p: {
|
|
9458
|
+
entries: LogEntry[];
|
|
9459
|
+
}) => void>;
|
|
9412
9460
|
/** the session assigned to us by the server */
|
|
9413
9461
|
comfySessionId: string; /** send by ComfyUI server */
|
|
9414
9462
|
/** handy to keep around */
|
package/dist/index.d.ts
CHANGED
|
@@ -5262,6 +5262,10 @@ declare const types$1: import("arktype").Module<{
|
|
|
5262
5262
|
sid?: string | undefined;
|
|
5263
5263
|
};
|
|
5264
5264
|
};
|
|
5265
|
+
LogEntry: {
|
|
5266
|
+
t: string;
|
|
5267
|
+
m: string;
|
|
5268
|
+
};
|
|
5265
5269
|
NodeProgress: {
|
|
5266
5270
|
value: number;
|
|
5267
5271
|
max: number;
|
|
@@ -5422,6 +5426,15 @@ declare const types$1: import("arktype").Module<{
|
|
|
5422
5426
|
sid?: string | undefined;
|
|
5423
5427
|
};
|
|
5424
5428
|
};
|
|
5429
|
+
} | {
|
|
5430
|
+
type: "logs";
|
|
5431
|
+
data: {
|
|
5432
|
+
entries: {
|
|
5433
|
+
t: string;
|
|
5434
|
+
m: string;
|
|
5435
|
+
}[];
|
|
5436
|
+
size?: unknown;
|
|
5437
|
+
};
|
|
5425
5438
|
};
|
|
5426
5439
|
WsMsgExecuted: {
|
|
5427
5440
|
type: "executed";
|
|
@@ -5485,6 +5498,16 @@ declare const types$1: import("arktype").Module<{
|
|
|
5485
5498
|
prompt_id: PromptID;
|
|
5486
5499
|
timestamp: number;
|
|
5487
5500
|
};
|
|
5501
|
+
WsMsgLogs: {
|
|
5502
|
+
type: "logs";
|
|
5503
|
+
data: {
|
|
5504
|
+
entries: {
|
|
5505
|
+
t: string;
|
|
5506
|
+
m: string;
|
|
5507
|
+
}[];
|
|
5508
|
+
size?: unknown;
|
|
5509
|
+
};
|
|
5510
|
+
};
|
|
5488
5511
|
WsMsgProgress: {
|
|
5489
5512
|
type: "progress";
|
|
5490
5513
|
data: {
|
|
@@ -5547,6 +5570,13 @@ declare const types$1: import("arktype").Module<{
|
|
|
5547
5570
|
_WsMsgExecutionStartData: {
|
|
5548
5571
|
prompt_id: PromptID;
|
|
5549
5572
|
};
|
|
5573
|
+
_WsMsgLogsData: {
|
|
5574
|
+
entries: {
|
|
5575
|
+
t: string;
|
|
5576
|
+
m: string;
|
|
5577
|
+
}[];
|
|
5578
|
+
size?: unknown;
|
|
5579
|
+
};
|
|
5550
5580
|
_WsMsgProgressStateData: {
|
|
5551
5581
|
prompt_id: PromptID;
|
|
5552
5582
|
nodes: Record<string, unknown>;
|
|
@@ -5560,6 +5590,7 @@ type WsMsgExecutionCached = typeof types$1.WsMsgExecutionCached.infer;
|
|
|
5560
5590
|
type WsMsgExecuting = typeof types$1.WsMsgExecuting.infer;
|
|
5561
5591
|
type WsMsgProgress = typeof types$1.WsMsgProgress.infer;
|
|
5562
5592
|
type WsMsgExecutionError = typeof types$1.WsMsgExecutionError.infer;
|
|
5593
|
+
type LogEntry = typeof types$1.LogEntry.infer;
|
|
5563
5594
|
type ComfyImageInfo = typeof types$1.ComfyImageInfo.infer;
|
|
5564
5595
|
//#endregion
|
|
5565
5596
|
//#region src/sdk-generator/comfy-api-json.d.ts
|
|
@@ -9316,6 +9347,16 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9316
9347
|
clearQueue: () => Promise<void>;
|
|
9317
9348
|
/** interrupt the CURRENTLY RUNNING prompt */
|
|
9318
9349
|
interrupt: () => Promise<void>;
|
|
9350
|
+
/** the server's recent console buffer (entries are write CHUNKS, not lines) */
|
|
9351
|
+
fetchRawLogs: () => Promise<{
|
|
9352
|
+
entries: LogEntry[];
|
|
9353
|
+
}>;
|
|
9354
|
+
/** (un)subscribe THIS session to ws 'logs' messages — per-sid server state,
|
|
9355
|
+
* must be re-sent after every reconnect (see onSession) */
|
|
9356
|
+
subscribeLogs: (p: {
|
|
9357
|
+
enabled: boolean;
|
|
9358
|
+
clientId: string;
|
|
9359
|
+
}) => Promise<void>;
|
|
9319
9360
|
/** GET a JSON route, preferring the /api prefix, falling back to the bare route */
|
|
9320
9361
|
private fetchJSON_;
|
|
9321
9362
|
/** retrieve the comfy spec from the schema*/
|
|
@@ -9409,6 +9450,13 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9409
9450
|
onStatus: Maybe<(p: {
|
|
9410
9451
|
queueRemaining: number;
|
|
9411
9452
|
}) => void>;
|
|
9453
|
+
/** fires when the server assigns a NEW session id (first connect AND every
|
|
9454
|
+
* reconnect — per-sid server state like log subscriptions must be redone) */
|
|
9455
|
+
onSession: Maybe<(sid: string) => void>;
|
|
9456
|
+
/** fires on ws 'logs' messages (server console stream, see subscribeLogs) */
|
|
9457
|
+
onLogs: Maybe<(p: {
|
|
9458
|
+
entries: LogEntry[];
|
|
9459
|
+
}) => void>;
|
|
9412
9460
|
/** the session assigned to us by the server */
|
|
9413
9461
|
comfySessionId: string; /** send by ComfyUI server */
|
|
9414
9462
|
/** handy to keep around */
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import https from "node:https";
|
|
|
11
11
|
import { stdout } from "node:process";
|
|
12
12
|
import { readFileSync as readFileSync$1, writeFileSync as writeFileSync$1 } from "fs";
|
|
13
13
|
//#region package.json
|
|
14
|
-
var version = "0.
|
|
14
|
+
var version = "0.4.0";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/sdk-generator/Primitives.ts
|
|
17
17
|
const ComfyPrimitiveMapping = {
|
|
@@ -772,6 +772,18 @@ const types$1 = scope({
|
|
|
772
772
|
type: "'manager-terminal-feedback'",
|
|
773
773
|
data: "WSMsgManagerFeedbackData"
|
|
774
774
|
},
|
|
775
|
+
LogEntry: {
|
|
776
|
+
t: "string",
|
|
777
|
+
m: "string"
|
|
778
|
+
},
|
|
779
|
+
_WsMsgLogsData: {
|
|
780
|
+
entries: "LogEntry[]",
|
|
781
|
+
"size?": "unknown"
|
|
782
|
+
},
|
|
783
|
+
WsMsgLogs: {
|
|
784
|
+
type: "'logs'",
|
|
785
|
+
data: "_WsMsgLogsData"
|
|
786
|
+
},
|
|
775
787
|
WsMsgProgress: {
|
|
776
788
|
type: "'progress'",
|
|
777
789
|
data: "NodeProgress"
|
|
@@ -785,11 +797,12 @@ const types$1 = scope({
|
|
|
785
797
|
data: "_WsMsgProgressStateData"
|
|
786
798
|
},
|
|
787
799
|
PromptRelated_WsMsg: "WsMsgExecutionStart | WsMsgExecutionCached | WsMsgExecuting | WsMsgProgress | WsMsgProgressState | WsMsgExecuted | WsMsgExecutionError | WsMsgExecutionSuccess",
|
|
788
|
-
WsMsg: "WsMsgStatus | WSMsgManagerFeedback | PromptRelated_WsMsg"
|
|
800
|
+
WsMsg: "WsMsgStatus | WSMsgManagerFeedback | WsMsgLogs | PromptRelated_WsMsg"
|
|
789
801
|
}).export();
|
|
790
802
|
const PromptInfo_ark = type({ prompt_id: types$1.PromptID }).as();
|
|
791
803
|
const WsMsg_ark = types$1.WsMsg;
|
|
792
804
|
const ComfyImageInfo_ark = types$1.ComfyImageInfo;
|
|
805
|
+
const WsMsgLogsData_ark = types$1._WsMsgLogsData;
|
|
793
806
|
type({
|
|
794
807
|
comfyHostHttpURL: "string",
|
|
795
808
|
comfyImageInfo: ComfyImageInfo_ark
|
|
@@ -3170,6 +3183,28 @@ var ComfyHost = class {
|
|
|
3170
3183
|
this.interrupt = () => {
|
|
3171
3184
|
return this.postJSON_("/interrupt", {});
|
|
3172
3185
|
};
|
|
3186
|
+
this.fetchRawLogs = async () => {
|
|
3187
|
+
const res = await fetch(`${this.getServerHostHTTP()}/internal/logs/raw`);
|
|
3188
|
+
if (!res.ok) throw new Error(`GET /internal/logs/raw failed: ${res.status}`);
|
|
3189
|
+
const json = await res.json();
|
|
3190
|
+
const checked = WsMsgLogsData_ark(json);
|
|
3191
|
+
if (checked instanceof type.errors) {
|
|
3192
|
+
console.log(`[🔴] /!\\ /internal/logs/raw payload does not match schema.`);
|
|
3193
|
+
printArkResultInConsole(checked);
|
|
3194
|
+
}
|
|
3195
|
+
return json;
|
|
3196
|
+
};
|
|
3197
|
+
this.subscribeLogs = async (p) => {
|
|
3198
|
+
const res = await fetch(`${this.getServerHostHTTP()}/internal/logs/subscribe`, {
|
|
3199
|
+
method: "PATCH",
|
|
3200
|
+
headers: { "Content-Type": "application/json" },
|
|
3201
|
+
body: JSON.stringify({
|
|
3202
|
+
enabled: p.enabled,
|
|
3203
|
+
clientId: p.clientId
|
|
3204
|
+
})
|
|
3205
|
+
});
|
|
3206
|
+
if (!res.ok) throw new Error(`PATCH /internal/logs/subscribe failed: ${res.status}`);
|
|
3207
|
+
};
|
|
3173
3208
|
this.fetchJSON_ = async (route) => {
|
|
3174
3209
|
const base = this.getServerHostHTTP();
|
|
3175
3210
|
for (const url of [`${base}/api${route}`, `${base}${route}`]) {
|
|
@@ -3218,6 +3253,8 @@ var ComfyHost = class {
|
|
|
3218
3253
|
this.latentPreview = null;
|
|
3219
3254
|
this.onLatentPreview = null;
|
|
3220
3255
|
this.onStatus = null;
|
|
3256
|
+
this.onSession = null;
|
|
3257
|
+
this.onLogs = null;
|
|
3221
3258
|
this.comfySessionId = "temp";
|
|
3222
3259
|
this.status = null;
|
|
3223
3260
|
/** folder where file related to the host config will be cached */
|
|
@@ -3401,9 +3438,11 @@ var ComfyHost = class {
|
|
|
3401
3438
|
const msg = msg_;
|
|
3402
3439
|
if (msg.type === "status") {
|
|
3403
3440
|
if (msg.data.sid) {
|
|
3441
|
+
const sidChanged = msg.data.sid !== this.comfySessionId;
|
|
3404
3442
|
this.comfySessionId = msg.data.sid;
|
|
3405
3443
|
this._sessionResolve?.();
|
|
3406
3444
|
this._sessionResolve = null;
|
|
3445
|
+
if (sidChanged) this.onSession?.(msg.data.sid);
|
|
3407
3446
|
}
|
|
3408
3447
|
this.status = msg.data.status;
|
|
3409
3448
|
this.onStatus?.({ queueRemaining: msg.data.status?.exec_info?.queue_remaining ?? 0 });
|
|
@@ -3426,6 +3465,10 @@ var ComfyHost = class {
|
|
|
3426
3465
|
this.addLog(msg.data.data);
|
|
3427
3466
|
return;
|
|
3428
3467
|
}
|
|
3468
|
+
if (msg.type === "logs") {
|
|
3469
|
+
this.onLogs?.(msg.data);
|
|
3470
|
+
return;
|
|
3471
|
+
}
|
|
3429
3472
|
console.log("❌", "Unknown message:", msg);
|
|
3430
3473
|
logError("Unknown message type: " + JSON.stringify(msg.type));
|
|
3431
3474
|
}
|