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

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
博客园_首页
爱范儿
爱范儿
博客园 - 叶小钗
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 【当耐特】
Y
Y Combinator Blog
量子位
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Blog of Author Tim Ferriss
月光博客
月光博客
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans

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.