惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
U
Unit 42
D
Docker
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Recent Announcements
Recent Announcements
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
V
Visual Studio Blog
I
InfoQ
Google DeepMind News
Google DeepMind News
小众软件
小众软件
L
LangChain Blog
C
Check Point Blog
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
J
Java Code Geeks
罗磊的独立博客

Workflow SDK Documentation

Patterns for Defining Tools Human-in-the-Loop Building Durable AI Agents Queueing User Messages Resumable Streams Sleep, Suspense, and Scheduling Streaming Updates from Tools API Reference Workflow Globals Changelog Resilient run start Cookbook Building a World Deploying Astro Express Fastify Hono Getting Started NestJS Next.js Nitro Nuxt Python SvelteKit Vite corrupted-event-log fetch-in-workflow hook-conflict Errors
WORKFLOW_SERIALIZE
2026-05-31 · via Workflow SDK Documentation

A symbol used to define custom serialization for user-defined class instances. The static method should accept an instance and return serializable data.

import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from "@workflow/serde";

class Point {
  constructor(public x: number, public y: number) {}

  static [WORKFLOW_SERIALIZE](instance: Point) {
    return { x: instance.x, y: instance.y };
  }

  static [WORKFLOW_DESERIALIZE](data: { x: number; y: number }) {
    return new Point(data.x, data.y);
  }
}
static [WORKFLOW_SERIALIZE](instance: T): SerializableData

Parameters

NameTypeDescription
instanceTThe class instance to serialize.

Returns

The method should return serializable data. This can be:

  • Primitives (string, number, boolean, null, undefined, bigint)
  • Plain objects with serializable values
  • Arrays of serializable values
  • Built-in serializable types (Date, Map, Set, RegExp, URL, etc.)
  • Other custom classes that implement serialization

The method must be implemented as a static method on the class. Instance methods are not supported.

  • Both WORKFLOW_SERIALIZE and WORKFLOW_DESERIALIZE must be implemented together
  • The returned data must itself be serializable
  • The SWC compiler plugin automatically detects and registers classes that implement these symbols

This method runs inside the workflow context and is subject to the same constraints as "use workflow" functions:

  • No Node.js-specific APIs (like fs, path, crypto, etc.)
  • No non-deterministic operations (like Math.random() or Date.now())
  • No external network calls

Keep this method simple and focused on extracting data from the instance.