@nodetool-ai/integration-nodes 0.8.1

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 ADDED
@@ -0,0 +1,68 @@
1
+ # @nodetool-ai/integration-nodes
2
+
3
+ External-API integration nodes for [NodeTool](https://nodetool.ai).
4
+
5
+ Connect visual AI workflows to the outside world: email, Discord and Telegram
6
+ triggers, and ComfyUI workflows.
7
+
8
+ Services that are one authenticated HTTP call — S3, Supabase, Notion, Twilio,
9
+ Discord and Telegram sends — no longer ship as nodes. They are written as
10
+ scripts in a `nodetool.code.Code` node, with `fetch`,
11
+ `nodetool.secrets.get(name)`, and the auth-helper sandbox packs
12
+ (`@nodetool-ai/sandbox-aws`, `-notion`, `-supabase`, `-twilio`). See
13
+ [packages/sandbox-packs](../sandbox-packs/README.md).
14
+
15
+ Apify and SerpApi are capability modules instead
16
+ (`@nodetool-ai/sandbox-nodetool/apify` and `.../serpapi`), so the credential
17
+ stays on the host rather than being read by the script.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install @nodetool-ai/integration-nodes
23
+ ```
24
+
25
+ ## Nodes
26
+
27
+ **Messaging** (`messaging.*`) — Discord and Telegram bot triggers:
28
+ `discord.DiscordBotTrigger`, `telegram.TelegramBotTrigger`. A trigger holds a
29
+ long-lived connection, which is what a script cannot do; sending a message is a
30
+ `fetch` call and is one.
31
+
32
+ **ComfyUI** (`lib.comfy.*`) — `RunWorkflow` runs an API-format ComfyUI workflow
33
+ against any reachable ComfyUI server, streaming each output file as its save node
34
+ finishes. `RunWorkflowOnWorker` runs the same workflow on a NodeTool worker that
35
+ fronts a loopback-only ComfyUI, proxied over the worker bridge's `comfy.*`
36
+ messages. `RunWorkflowOnCloud` runs it on Comfy Cloud through the official
37
+ `@comfyorg/sdk` (Comfy API v2, `COMFY_API_KEY`), streaming outputs the same way
38
+ the direct node does. All three derive typed inputs from `Load*` nodes and typed
39
+ outputs from `Save*` nodes, keyed `<comfyNodeId>:<field>`. See
40
+ [docs/comfyui.md](https://docs.nodetool.ai/comfyui).
41
+
42
+ **Other** — `kie.dynamic_schema.KieAI`.
43
+
44
+ Mail is not a node package any more. `lib.mail.GmailSearch`, `AddLabel` and
45
+ `MoveToArchive` were removed: the same three operations ship as the
46
+ `search_email` / `add_label_to_email` / `archive_email` capabilities, and Gmail
47
+ reaches a Code node through `@nodetool-ai/sandbox-nodetool/google` with the
48
+ OAuth token held host-side. `lib.secret.GetSecret` went too — `getSecret(name)`
49
+ in the sandbox does the same read, bound by the run's declared secret scope.
50
+
51
+ ## Configuration
52
+
53
+ Set the keys for the services you use in NodeTool's secret store (Settings → API
54
+ Keys) or as environment variables:
55
+
56
+ - Mail: `GOOGLE_APP_PASSWORD`
57
+ - KIE: `KIE_API_KEY`
58
+ - Discord: `DISCORD_BOT_TOKEN`
59
+ - Telegram: `TELEGRAM_BOT_TOKEN`
60
+
61
+ Google Workspace is not a node package any more. Drive, Gmail, Docs, Sheets and
62
+ Calendar are the `google` capability module in `@nodetool-ai/agents` — agent
63
+ tools and sandbox imports at once (`@nodetool-ai/sandbox-nodetool/google`).
64
+
65
+ ## Links
66
+
67
+ - [NodeTool](https://nodetool.ai)
68
+ - [GitHub](https://github.com/nodetool-ai/nodetool)
@@ -0,0 +1 @@
1
+ 2026-09-28T09:19:16.069Z
@@ -0,0 +1,6 @@
1
+ export * from "./nodes/messaging.js";
2
+ export * from "./nodes/kie-dynamic.js";
3
+ export * from "./nodes/comfy-sdk.js";
4
+ export * from "./nodes/comfy-cloud.js";
5
+ export * from "./nodes/comfy.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./nodes/messaging.js";
2
+ export * from "./nodes/kie-dynamic.js";
3
+ export * from "./nodes/comfy-sdk.js";
4
+ export * from "./nodes/comfy-cloud.js";
5
+ export * from "./nodes/comfy.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { BaseNode } from "@nodetool-ai/node-sdk";
2
+ import type { ProcessingContext } from "@nodetool-ai/runtime";
3
+ import { type ComfyPrompt, type ComfyTransport } from "./comfy-sdk.js";
4
+ /**
5
+ * Run a ComfyUI workflow on Comfy Cloud through the Comfy API v2.
6
+ *
7
+ * The workflow is supplied in ComfyUI's API ("prompt") format — a map of node
8
+ * id to `{ class_type, inputs }`. Dynamic input handles are keyed
9
+ * `"<comfyNodeId>:<field>"`; connected values are injected into the prompt
10
+ * before submission, and connected media is uploaded to Comfy Cloud as an
11
+ * asset first.
12
+ *
13
+ * Outputs stream: each file is emitted on a per-node slot keyed
14
+ * `"<comfyNodeId>:image|audio|video|text|file"` the moment that node's output
15
+ * lands, so a batch naturally produces several outputs. A final `output` slot
16
+ * carries the finished job's id, status and output manifest.
17
+ *
18
+ * Comfy Cloud bills per GPU second by plan and reports no per-job cost, so
19
+ * this node records the job id and no charge amount.
20
+ */
21
+ export declare class ComfyCloudWorkflowNode extends BaseNode {
22
+ static readonly nodeType = "lib.comfy.RunWorkflowOnCloud";
23
+ static readonly title = "Run ComfyUI Workflow (Comfy Cloud)";
24
+ static readonly description = "Run a ComfyUI workflow on Comfy Cloud via the Comfy API v2.\n comfy, comfyui, cloud, workflow, image, diffusion\n\n Use cases:\n - Run a ComfyUI workflow without hosting a GPU\n - Generate images or video from an exported API-format workflow\n - Embed Comfy Cloud generation inside a NodeTool workflow";
25
+ static readonly supportsDynamicInputs = true;
26
+ static readonly supportsDynamicOutputs = true;
27
+ static readonly autoSaveAsset = true;
28
+ static readonly requiredSettings: string[];
29
+ static readonly metadataOutputTypes: {
30
+ output: string;
31
+ };
32
+ workflow: string | ComfyPrompt;
33
+ timeout: number;
34
+ previews: boolean;
35
+ /**
36
+ * Build the transport. Split out so tests can inject a fake without a real
37
+ * Comfy Cloud account, the way {@link ComfyWorkerWorkflowNode} splits out
38
+ * `connectBridge`.
39
+ */
40
+ protected createTransport(apiKey: string): ComfyTransport;
41
+ /**
42
+ * Parse the `workflow` prop into a ComfyUI prompt object. The prop holds a
43
+ * JSON string (API prompt format); a raw object is also accepted for
44
+ * backward compatibility with previously-saved graphs.
45
+ */
46
+ private parseWorkflow;
47
+ /**
48
+ * Buffered fallback for non-streaming consumers: drain the streaming output
49
+ * and merge frames into a single record (slots with multiple files collapse
50
+ * to an array).
51
+ */
52
+ process(context?: ProcessingContext): Promise<Record<string, unknown>>;
53
+ genProcess(context?: ProcessingContext): AsyncGenerator<Record<string, unknown>>;
54
+ }
55
+ //# sourceMappingURL=comfy-cloud.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comfy-cloud.d.ts","sourceRoot":"","sources":["../../src/nodes/comfy-cloud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,sBAAuB,SAAQ,QAAQ;IAClD,MAAM,CAAC,QAAQ,CAAC,QAAQ,kCAAkC;IAC1D,MAAM,CAAC,QAAQ,CAAC,KAAK,wCAAwC;IAC7D,MAAM,CAAC,QAAQ,CAAC,WAAW,kUACsS;IACjU,MAAM,CAAC,QAAQ,CAAC,qBAAqB,QAAQ;IAC7C,MAAM,CAAC,QAAQ,CAAC,sBAAsB,QAAQ;IAC9C,MAAM,CAAC,QAAQ,CAAC,aAAa,QAAQ;IACrC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,WAAqB;IACrD,MAAM,CAAC,QAAQ,CAAC,mBAAmB;QACjC,MAAM;MACN;IAUM,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC;IAS/B,OAAO,EAAE,MAAM,CAAC;IAQhB,QAAQ,EAAE,OAAO,CAAC;IAE1B;;;;OAIG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAExD;IAED;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAqBrB;;;;OAIG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAa3E;IAEM,UAAU,CACf,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA4CzC;CACF"}
@@ -0,0 +1,147 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseNode, prop } from "@nodetool-ai/node-sdk";
8
+ import { cloudTransport, runComfyWorkflow } from "./comfy-sdk.js";
9
+ /**
10
+ * Run a ComfyUI workflow on Comfy Cloud through the Comfy API v2.
11
+ *
12
+ * The workflow is supplied in ComfyUI's API ("prompt") format — a map of node
13
+ * id to `{ class_type, inputs }`. Dynamic input handles are keyed
14
+ * `"<comfyNodeId>:<field>"`; connected values are injected into the prompt
15
+ * before submission, and connected media is uploaded to Comfy Cloud as an
16
+ * asset first.
17
+ *
18
+ * Outputs stream: each file is emitted on a per-node slot keyed
19
+ * `"<comfyNodeId>:image|audio|video|text|file"` the moment that node's output
20
+ * lands, so a batch naturally produces several outputs. A final `output` slot
21
+ * carries the finished job's id, status and output manifest.
22
+ *
23
+ * Comfy Cloud bills per GPU second by plan and reports no per-job cost, so
24
+ * this node records the job id and no charge amount.
25
+ */
26
+ export class ComfyCloudWorkflowNode extends BaseNode {
27
+ static nodeType = "lib.comfy.RunWorkflowOnCloud";
28
+ static title = "Run ComfyUI Workflow (Comfy Cloud)";
29
+ static description = "Run a ComfyUI workflow on Comfy Cloud via the Comfy API v2.\n comfy, comfyui, cloud, workflow, image, diffusion\n\n Use cases:\n - Run a ComfyUI workflow without hosting a GPU\n - Generate images or video from an exported API-format workflow\n - Embed Comfy Cloud generation inside a NodeTool workflow";
30
+ static supportsDynamicInputs = true;
31
+ static supportsDynamicOutputs = true;
32
+ static autoSaveAsset = true;
33
+ static requiredSettings = ["COMFY_API_KEY"];
34
+ static metadataOutputTypes = {
35
+ output: "dict[str, any]"
36
+ };
37
+ /**
38
+ * Build the transport. Split out so tests can inject a fake without a real
39
+ * Comfy Cloud account, the way {@link ComfyWorkerWorkflowNode} splits out
40
+ * `connectBridge`.
41
+ */
42
+ createTransport(apiKey) {
43
+ return cloudTransport(apiKey);
44
+ }
45
+ /**
46
+ * Parse the `workflow` prop into a ComfyUI prompt object. The prop holds a
47
+ * JSON string (API prompt format); a raw object is also accepted for
48
+ * backward compatibility with previously-saved graphs.
49
+ */
50
+ parseWorkflow(value) {
51
+ let parsed = value;
52
+ if (typeof value === "string") {
53
+ const trimmed = value.trim();
54
+ if (!trimmed)
55
+ return {};
56
+ try {
57
+ parsed = JSON.parse(trimmed);
58
+ }
59
+ catch (err) {
60
+ throw new Error(`ComfyUI workflow is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
61
+ }
62
+ }
63
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
64
+ return {};
65
+ }
66
+ return parsed;
67
+ }
68
+ /**
69
+ * Buffered fallback for non-streaming consumers: drain the streaming output
70
+ * and merge frames into a single record (slots with multiple files collapse
71
+ * to an array).
72
+ */
73
+ async process(context) {
74
+ const merged = {};
75
+ for await (const frame of this.genProcess(context)) {
76
+ for (const [key, value] of Object.entries(frame)) {
77
+ if (key in merged) {
78
+ const prev = merged[key];
79
+ merged[key] = Array.isArray(prev) ? [...prev, value] : [prev, value];
80
+ }
81
+ else {
82
+ merged[key] = value;
83
+ }
84
+ }
85
+ }
86
+ return merged;
87
+ }
88
+ async *genProcess(context) {
89
+ const apiKey = this._secrets.COMFY_API_KEY?.trim();
90
+ if (!apiKey) {
91
+ throw new Error("COMFY_API_KEY is required to run a workflow on Comfy Cloud. " +
92
+ "Add it in Settings; get a key at https://platform.comfy.org.");
93
+ }
94
+ const source = this.parseWorkflow(this.workflow);
95
+ if (Object.keys(source).length === 0) {
96
+ throw new Error("ComfyUI workflow is required (API prompt format: { nodeId: { class_type, inputs } })");
97
+ }
98
+ const timeoutSeconds = Math.max(1, this.timeout);
99
+ const timeoutSignal = AbortSignal.timeout(timeoutSeconds * 1000);
100
+ const signal = context?.signal
101
+ ? AbortSignal.any([context.signal, timeoutSignal])
102
+ : timeoutSignal;
103
+ try {
104
+ yield* runComfyWorkflow(this.createTransport(apiKey), source, this.dynamicProps, {
105
+ signal,
106
+ context,
107
+ apiKey,
108
+ nodeId: this.__node_id,
109
+ nodeName: this.__node_name ?? "Run ComfyUI Workflow (Comfy Cloud)",
110
+ previews: this.previews
111
+ });
112
+ }
113
+ catch (err) {
114
+ if (timeoutSignal.aborted) {
115
+ throw new Error(`Comfy Cloud job did not finish within ${timeoutSeconds}s`);
116
+ }
117
+ throw err;
118
+ }
119
+ }
120
+ }
121
+ __decorate([
122
+ prop({
123
+ type: "str",
124
+ default: "",
125
+ title: "Workflow",
126
+ description: "ComfyUI workflow in API (prompt) format, as a JSON string: a map of node id to { class_type, inputs }.",
127
+ required: true
128
+ })
129
+ ], ComfyCloudWorkflowNode.prototype, "workflow", void 0);
130
+ __decorate([
131
+ prop({
132
+ type: "int",
133
+ default: 600,
134
+ title: "Timeout",
135
+ description: "Maximum seconds to wait for the job to finish.",
136
+ min: 1
137
+ })
138
+ ], ComfyCloudWorkflowNode.prototype, "timeout", void 0);
139
+ __decorate([
140
+ prop({
141
+ type: "bool",
142
+ default: false,
143
+ title: "Previews",
144
+ description: "Log ComfyUI preview frames while the job runs."
145
+ })
146
+ ], ComfyCloudWorkflowNode.prototype, "previews", void 0);
147
+ //# sourceMappingURL=comfy-cloud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comfy-cloud.js","sourceRoot":"","sources":["../../src/nodes/comfy-cloud.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,cAAc,EACd,gBAAgB,EAGjB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,sBAAuB,SAAQ,QAAQ;IAClD,MAAM,CAAU,QAAQ,GAAG,8BAA8B,CAAC;IAC1D,MAAM,CAAU,KAAK,GAAG,oCAAoC,CAAC;IAC7D,MAAM,CAAU,WAAW,GACzB,8TAA8T,CAAC;IACjU,MAAM,CAAU,qBAAqB,GAAG,IAAI,CAAC;IAC7C,MAAM,CAAU,sBAAsB,GAAG,IAAI,CAAC;IAC9C,MAAM,CAAU,aAAa,GAAG,IAAI,CAAC;IACrC,MAAM,CAAU,gBAAgB,GAAG,CAAC,eAAe,CAAC,CAAC;IACrD,MAAM,CAAU,mBAAmB,GAAG;QACpC,MAAM,EAA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BACN,OAAO;gBACP,MAAM;gBACN,MAAM,EAAE,IAAI,CAAC,SAAS;gBACtB,QAAQ,EAAE,IAAI,CAAC,WAAW,IAAI,oCAAoC;gBAClE,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CACb,yCAAyC,cAAc,GAAG,CAC3D,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAzHS;IARP,IAAI,CAAC;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,UAAU;QACjB,WAAW,EACT,wGAAwG;QAC1G,QAAQ,EAAE,IAAI;KACf,CAAC;wDACqC;AAS/B;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,gDAAgD;QAC7D,GAAG,EAAE,CAAC;KACP,CAAC;uDACsB;AAQhB;IANP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,gDAAgD;KAC9D,CAAC;wDACwB"}
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Comfy API v2 transport and the workflow runner shared by the SDK-backed
3
+ * ComfyUI nodes.
4
+ *
5
+ * A {@link ComfyTransport} is the only thing that differs between Comfy
6
+ * surfaces: Comfy Cloud gets {@link cloudTransport}, and any other v2 surface
7
+ * at a known base URL gets {@link v2Transport}. {@link runComfyWorkflow} takes one, plus
8
+ * an API-format prompt and the node's dynamic inputs, and yields the same
9
+ * frames every ComfyUI node in this package yields — one per output file on
10
+ * `"<comfyNodeId>:<kind>"`, then a final `output` frame.
11
+ *
12
+ * The structural `ComfyJob` / `ComfyOutput` / `ComfyRunEvent` types mirror the
13
+ * `@comfyorg/sdk` surface this module uses. The compile-time assignability
14
+ * checks at the bottom of the type block pin that surface, so a breaking bump
15
+ * of the (0.1.x) SDK fails `tsc` here instead of at run time.
16
+ */
17
+ import { type MediaRefValue, type ProcessingContext } from "@nodetool-ai/runtime";
18
+ /** A ComfyUI workflow in API ("prompt") format. */
19
+ export type ComfyPrompt = Record<string, {
20
+ class_type: string;
21
+ inputs: Record<string, unknown>;
22
+ }>;
23
+ /** Media kind → default filename extension / mime for uploads. */
24
+ export declare const UPLOAD_DEFAULTS: Record<string, {
25
+ ext: string;
26
+ mime: string;
27
+ }>;
28
+ /** A connected media ref looks like an object carrying uri/data/asset_id. */
29
+ export declare function isMediaRef(value: unknown): value is MediaRefValue;
30
+ export declare function extFromUri(uri: string | undefined): string | undefined;
31
+ /** Filename + content type to upload a connected media ref under. */
32
+ export declare function uploadNaming(nodeId: string, field: string, value: MediaRefValue): {
33
+ filename: string;
34
+ contentType: string;
35
+ };
36
+ /**
37
+ * A lazy asset handle. The transport mints one; the runner writes it into the
38
+ * prompt and the transport substitutes the real `core/ASSET` object at submit.
39
+ * Opaque here on purpose — the runner never reads it.
40
+ */
41
+ export type ComfyAssetHandle = object;
42
+ /** One file produced by one node of a finished job. */
43
+ export interface ComfyOutput {
44
+ readonly nodeId: string;
45
+ readonly name: string;
46
+ readonly id: string;
47
+ readonly type: "image" | "video" | "audio" | "text" | "file" | "latent";
48
+ readonly contentType: string;
49
+ readonly sizeBytes: number;
50
+ toBytes(options?: {
51
+ signal?: AbortSignal;
52
+ }): Promise<Uint8Array>;
53
+ }
54
+ /** Execution failure detail carried on a terminal `failed` job. */
55
+ export interface ComfyJobError {
56
+ code: string;
57
+ message: string;
58
+ node_id?: string | null;
59
+ class_type?: string | null;
60
+ traceback?: string | null;
61
+ }
62
+ /** Typed live events, discriminated on `kind`. */
63
+ export type ComfyRunEvent = {
64
+ kind: "progress";
65
+ value: number;
66
+ message: string | null;
67
+ nodesDone: number | null;
68
+ nodesTotal: number | null;
69
+ currentNode: string | null;
70
+ step: number | null;
71
+ steps: number | null;
72
+ } | {
73
+ kind: "preview";
74
+ nodeId: string;
75
+ contentType: string;
76
+ data: Uint8Array;
77
+ } | {
78
+ kind: "outputReady";
79
+ output: ComfyOutput;
80
+ } | {
81
+ kind: "statusChange";
82
+ status: string;
83
+ queuePosition: number | null;
84
+ } | {
85
+ kind: "log";
86
+ level: string;
87
+ message: string;
88
+ };
89
+ /** A handle to one submitted job. */
90
+ export interface ComfyJob {
91
+ readonly id: string;
92
+ readonly status: string;
93
+ readonly outputs: ComfyOutput[];
94
+ readonly error: ComfyJobError | null;
95
+ events(signal?: AbortSignal): AsyncGenerator<ComfyRunEvent, void, void>;
96
+ /** Re-reads the job from the server; resolves to the same handle. */
97
+ refresh(signal?: AbortSignal): Promise<this>;
98
+ /** Requests cancellation; resolves to the same handle. */
99
+ cancel(signal?: AbortSignal): Promise<this>;
100
+ }
101
+ /** The one thing that differs between Comfy API v2 surfaces. */
102
+ export interface ComfyTransport {
103
+ submit(graph: ComfyPrompt, options: {
104
+ signal: AbortSignal;
105
+ apiKey?: string;
106
+ }): Promise<ComfyJob>;
107
+ assetFromBytes(bytes: Uint8Array, filename: string, contentType: string): ComfyAssetHandle;
108
+ }
109
+ /** Comfy Cloud, authenticated with a `COMFY_API_KEY`. */
110
+ export declare function cloudTransport(apiKey: string): ComfyTransport;
111
+ /** Drop every trailing `/` without a regex that backtracks on long runs. */
112
+ export declare function stripTrailingSlashes(value: string): string;
113
+ /**
114
+ * Any Comfy API v2 surface at a caller-supplied base URL — a
115
+ * `comfy-api-proxy` in front of a local ComfyUI, a NodeTool worker, or a
116
+ * ComfyUI that serves v2 itself.
117
+ *
118
+ * The high-level `Comfy` client cannot target one: it reads `COMFY_BASE_URL`
119
+ * from the environment per construction, which is process-global and races
120
+ * across concurrent node runs. So this builds `ComfyLow` directly and
121
+ * reimplements the one thing `Comfy` keeps private — the submit loop: guard
122
+ * UI-format JSON, materialize asset handles, mint an idempotency key, and
123
+ * retry a 429 against a 60 second budget with the same key. Collapses to
124
+ * `new Comfy({ apiKey, baseUrl })` once upstream accepts a `baseUrl` option
125
+ * (spec D3), and the loop below is deleted with it.
126
+ *
127
+ * `options.fetch` is handed to `ComfyLow` verbatim; tests script the wire with
128
+ * it, and production passes nothing.
129
+ */
130
+ export declare function v2Transport(baseUrl: string, apiKey?: string, options?: {
131
+ fetch?: typeof fetch;
132
+ }): ComfyTransport;
133
+ export interface ComfyRunOptions {
134
+ /** Cancels the submit, the event stream, and the output downloads. */
135
+ signal: AbortSignal;
136
+ /** Node id used to address `log_update` / `node_progress` messages. */
137
+ nodeId: string;
138
+ /** Node name shown on `log_update` messages. */
139
+ nodeName: string;
140
+ context?: ProcessingContext;
141
+ /** Also sent as `extra_data.api_key_comfy_org` for partner (API) nodes. */
142
+ apiKey?: string;
143
+ /** Log preview frames as they arrive. */
144
+ previews?: boolean;
145
+ }
146
+ /** Turn an SDK error into a message a workflow author can act on. */
147
+ export declare function describeComfyError(err: unknown): Error;
148
+ /**
149
+ * Submit `prompt` through `transport` and stream what it produces.
150
+ *
151
+ * Yields one frame per output file, keyed `"<comfyNodeId>:<kind>"`, as each
152
+ * arrives, then a final `{ output }` frame describing the finished job.
153
+ * Throws on a `failed` job (with the node-level detail), on cancellation, and
154
+ * on the SDK errors an author can act on (queue full, insufficient credits,
155
+ * UI-format workflow).
156
+ */
157
+ export declare function runComfyWorkflow(transport: ComfyTransport, prompt: ComfyPrompt, dynamicProps: Iterable<[string, unknown]>, options: ComfyRunOptions): AsyncGenerator<Record<string, unknown>>;
158
+ //# sourceMappingURL=comfy-sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comfy-sdk.d.ts","sourceRoot":"","sources":["../../src/nodes/comfy-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAgBH,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAA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