mirror of
https://github.com/run-llama/workflows-ts.git
synced 2026-07-20 21:59:32 -04:00
[PR #97] [MERGED] feat: add withSnapshot API
#104
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/run-llama/workflows-ts/pull/97
Author: @himself65
Created: 4/30/2025
Status: ✅ Merged
Merged: 5/20/2025
Merged by: @himself65
Base:
main← Head:snapshot-2📝 Commits (10+)
9eac0bafeat: init snapshot v26808e4cfeat: initsnapshotAPIf15df4dfeat: recoverContext APIec85b3achore: remove dep7a3084efix: test9c9021bfeat: resumec524f9dfeat: add onRequestEvent callback47b604bfix: naming93ced6ffix: snapshotbaae397feat: update change📊 Changes
14 files changed (+1217 additions, -56 deletions)
View changed files
➕
.changeset/pretty-moose-share.md(+12 -0)📝
demo/hono/app.ts(+48 -0)➕
demo/node/name-ask-readline.ts(+29 -0)📝
demo/package.json(+1 -0)➕
demo/workflows/human-in-the-loop.ts(+73 -0)📝
packages/core/package.json(+4 -0)📝
packages/core/src/core/context.ts(+46 -40)📝
packages/core/src/core/stream.ts(+3 -3)📝
packages/core/src/core/utils.ts(+16 -10)➕
packages/core/src/middleware/snapshot.ts(+361 -0)➕
packages/core/src/middleware/snapshot/stable-hash.ts(+60 -0)➕
packages/core/tests/middleware/with-snapshot.spec.ts(+279 -0)📝
packages/core/vitest.config.ts(+3 -3)📝
pnpm-lock.yaml(+282 -0)📄 Description
add snapshot API, for human in the loop feature. The API is designed for cross JavaScript platform, including node.js, browser, and serverless platform such as cloudflare worker and edge runtime
workflow.createContext(): Contextcontext.snapshot(): Promise<[requestEvent, snapshot]>This will stop all incoming handler, lock the context and wait until all existing handler get result.
workflow.resume(data, snapshot)Recover all pending events in the queue and send request event back
Test Code sample
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.