mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
efbdc213a0
* [core] Make `hook.metadata` a lazy Promise getter Hydrating a hook's metadata is a decrypting READ: it needs the owning run's payload keys, and resolving those costs a run fetch plus a `run-key` API round trip (~350ms). `getHookByToken()` did that work eagerly on every lookup that found a metadata-bearing hook, so callers that only wanted `runId`/`token` — and hook resumption, which never reads metadata at all — paid for it anyway. `metadata` is now a getter returning a memoized Promise, the same shape as `run.returnValue`. The lookup is one read again; hydration and the key resolution behind it happen on first access, or never. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Pranay Prakash <1797812+pranaygp@users.noreply.github.com> * docs: surface the lazy hook.metadata change in What's new, the migration skill, and the resumeHook reference Adds the breaking-change row to the v5 What's new page and puts that page in the sidebar as the first visible entry (the /v5/docs redirect to getting-started is unchanged). Teaches the migrating-workflow-v4-to-v5 skill the `await hook.metadata` rewrite and bumps its version. Points the resumeHook reference at HookWithLazyMetadata, and notes on the World storage page that world.hooks.getByToken() returns raw serialized metadata. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [core] Export the lazy-metadata hook type as `Hook` from `workflow/api` `getHookByToken()` and `resumeHook()` return `Hook`, not a separate `HookWithLazyMetadata`: one public hook type whose `metadata` is a lazy Promise, mirroring `Run` for runs. The World-level record from `@workflow/world` is unchanged and is referenced as `WorldHook` inside the runtime. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [core] Define the lazy `metadata` getter in place; tighten changeset and docs wording Review feedback: the hook record a World returns is a fresh object per lookup and the eager path mutated it anyway, so define the getter on it directly instead of copying it with Object.create(). The changeset is one sentence, and the docs describe hydration as extra network round trips rather than decryption, since not every World encrypts. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> Co-authored-by: Pranay Prakash <1797812+pranaygp@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>