Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import { normalizeNodePackCatalog, type NodePackCatalog } from '@features/nodes/core/catalog';
import { browserNodesDataPort } from './transport';
const CUSTOM_NODES_BASE = '/api/v2/custom_nodes';
const { requestJson } = browserNodesDataPort;
export interface InstallNodePackResponse {
name: string;
success: boolean;
message: string;
workflows_imported: number;
requires_dependencies: boolean;
dependency_file: string | null;
}
export interface UninstallNodePackResponse {
name: string;
success: boolean;
message: string;
}
export const listCustomNodePacks = async (signal?: AbortSignal): Promise<NodePackCatalog> =>
normalizeNodePackCatalog(await requestJson<unknown>(`${CUSTOM_NODES_BASE}/`, { signal }));
export const installCustomNodePack = (source: string, signal?: AbortSignal): Promise<InstallNodePackResponse> =>
requestJson<InstallNodePackResponse>(`${CUSTOM_NODES_BASE}/install`, {
body: JSON.stringify({ source }),
method: 'POST',
signal,
});
export const uninstallCustomNodePack = (packName: string, signal?: AbortSignal): Promise<UninstallNodePackResponse> =>
requestJson<UninstallNodePackResponse>(`${CUSTOM_NODES_BASE}/${encodeURIComponent(packName)}`, {
method: 'DELETE',
signal,
});
/** The body's status is prose (e.g. "No custom nodes directory found.") — callers must not assume success. */
export const reloadCustomNodes = (signal?: AbortSignal): Promise<{ status: string }> =>
requestJson<{ status: string }>(`${CUSTOM_NODES_BASE}/reload`, { method: 'POST', signal });
/** Imported workflows by pack tag, an estimate for the confirmation: uninstall uses manifest IDs, so retags differ. */
export const getPackWorkflowCount = async (packName: string, signal?: AbortSignal): Promise<number> => {
const tag = `node-pack:${packName}`;
const counts = await requestJson<Record<string, number>>(
`/api/v1/workflows/counts_by_tag?tags=${encodeURIComponent(tag)}`,
{ signal }
);
return counts[tag] ?? 0;
};