Skip to content

Generator Configuration

The generator accepts structured runtime options through PluginConfig and deployment overrides through environment variables.

PluginConfig

ts
export interface PluginConfig {
  port?: number;
  plugins?: string[];
  pluginsDir?: string;
  maxImportImageBytes?: number;
  maxImportImagePixels?: number;
  allowedImportImageFormats?: string[];
  allowLocalImagePaths?: boolean;
  sessionResumeTtlMs?: number;
  [key: string]: unknown;
}

port controls the HTTP/WebSocket service port. plugins contains absolute plugin package directories loaded in array order. pluginsDir points to a collection directory whose direct child folders are plugin packages.

Plugin sources load in this priority order:

  1. absolute paths from PS_BRIDGE_PLUGINS, in list order
  2. absolute paths from PluginConfig.plugins, in array order
  3. direct children of pluginsDir, sorted by folder name

Real paths are deduplicated across sources. The first candidate that fully activates claims its plugin id; an initialization or registration failure leaves that id available for a later candidate.

Layer image import validates inputs before handing them to Photoshop. maxImportImageBytes caps decoded/imported image bytes, maxImportImagePixels caps image dimensions by total pixels, allowedImportImageFormats limits accepted formats, and allowLocalImagePaths controls whether public layer:importImage requests may use local paths or file:// URIs.

sessionResumeTtlMs controls how long an unexpectedly disconnected WebSocket session can be resumed. The default is 30 minutes. Explicit SDK close() calls dispose sessions immediately.

Defaults

SettingDefault
Host127.0.0.1
Port7700
Root WebSocket/ws
Plugin WebSocket/ws/{pluginId}
Plugin directorypackage-local plugins/
Import max bytes104857600
Import max pixels100000000
Import formatspng, jpeg, webp, gif, tiff
Local image pathsenabled
Session resume TTL1800000 ms

Environment Overrides

Environment variables are deployment knobs:

When generator-core requires the package through main.js, the generator loads the package-local .env file before the bundled host code starts. Values already present in the process environment take precedence over .env values.

VariablePurpose
PS_BRIDGE_PORTOverrides the configured port when valid.
PS_BRIDGE_PLUGINSPrepends a platform-delimited list of absolute plugin package paths.
PS_BRIDGE_PLUGINS_DIROverrides the default plugin directory when pluginsDir is not provided.
PS_BRIDGE_LOG_DIROverrides the generator runtime log directory before the bundle loads.
PS_BRIDGE_SESSION_RESUME_TTL_MSOverrides the session resume TTL with a non-negative integer.
PS_BRIDGE_COS_SECRET_IDRequired for COS upload support.
PS_BRIDGE_COS_SECRET_KEYRequired for COS upload support.
PS_BRIDGE_COS_BUCKETRequired for COS upload support.
PS_BRIDGE_COS_REGIONRequired for COS upload support.
PS_BRIDGE_COS_KEY_PREFIXOptional object key prefix, default ps-bridge/exports.
PS_BRIDGE_COS_URL_EXPIRESOptional signed URL lifetime in seconds, default 315360000.

COS upload support is enabled only when all four required COS fields are present and non-empty.

PS_BRIDGE_PLUGINS uses the platform path delimiter: ; on Windows and : on POSIX systems. Empty entries are ignored.