Skip to content

Add workflow-streams sample#470

Open
brianstrauch wants to merge 14 commits into
mainfrom
workflow-streams-sample
Open

Add workflow-streams sample#470
brianstrauch wants to merge 14 commits into
mainfrom
workflow-streams-sample

Conversation

@brianstrauch

Copy link
Copy Markdown
Member

Summary

  • Ports the five scenarios from samples-python/workflow_streams to TypeScript, using the experimental @temporalio/workflow-streams contrib package on the contrib/pubsub branch of sdk-typescript.
  • Scenarios: basic publish/subscribe with heterogeneous topics, reconnecting subscriber, external (non-Activity) publisher, bounded log via truncate(), and LLM token streaming with retry handling.
  • Workflow files import from @temporalio/workflow-streams/workflow; client/activity/runner files import from @temporalio/workflow-streams/client. The split keeps the workflow bundle free of crypto/@temporalio/activity/@temporalio/client.
  • Depends on the unpublished contrib package via a local `file:` link (`file:../../sdk-typescript/contrib/workflow-streams`). Should switch to a published `^1.17.x` range once the package ships to npm.

Test plan

  • `npm install`, `tsc --build`, `eslint .`, `prettier --check .` all clean
  • Workflow bundles compile (regression case for the contrib/pubsub split-entrypoints work)
  • Scenarios 1–4 run end-to-end against `temporal server start-dev` and produce output shaped like the Python sample
  • Scenario 5 verified end-to-end with `OPENAI_API_KEY` set; tokens stream, complete event terminates cleanly
  • Retry path for scenario 5 (kill LLM worker mid-stream, confirm ANSI rewind) — not exercised in CI; manual reproduction only

🤖 Generated with Claude Code

Ports the five scenarios from samples-python/workflow_streams to TypeScript,
using the @temporalio/workflow-streams contrib package (currently on the
contrib/pubsub branch of sdk-typescript). Covers basic publish/subscribe,
reconnecting subscriber, external (non-Activity) publisher, bounded log via
truncate(), and LLM token streaming with retry handling.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread workflow-streams/src/run-truncating-ticker.ts
Comment thread workflow-streams/src/run-reconnecting-subscriber.ts
Comment thread workflow-streams/src/run-publisher.ts
Comment thread workflow-streams/src/run-llm.ts
Comment thread workflow-streams/src/run-external-publisher.ts
Comment thread workflow-streams/src/run-truncating-ticker.ts
Comment thread workflow-streams/src/run-reconnecting-subscriber.ts
Comment thread workflow-streams/src/run-publisher.ts
Comment thread workflow-streams/src/run-llm.ts
Comment thread workflow-streams/src/run-external-publisher.ts
brianstrauch and others added 5 commits June 9, 2026 13:31
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Resolves semgrep supply-chain findings (CVE-2021-23566, CVE-2024-55565)
flagged on the workflow-streams sample, which was missing from the
workspace lockfile.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Add workflow-streams to list-of-samples.json so the pre-push hook's
  copy-shared-files script no longer prompts on every push.
- Exclude workflow-streams from .eslintrc.js sync (it adds
  src/llm-workflows.ts to the workflow lint rules) and from .post-create
  sync (its run command is `npm run workflow.publisher`).
- Skip the /dev/tty redirect in the pre-push hook when no terminal is
  attached, so pushes from IDE integrations and CI don't fail with
  "/dev/tty: Device not configured".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread .scripts/list-of-samples.json Outdated
Comment thread .github/CODEOWNERS Outdated
brianstrauch and others added 3 commits June 9, 2026 13:56
The lockfile had pinned next@16.3.0-preview.0 (briefly published as
"latest"), whose @next/swc-* binaries were never published, causing a
404 during next build in CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@xumaple xumaple left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, but can you add some tests?

Comment thread workflow-streams/README.md Outdated
brianstrauch and others added 3 commits June 12, 2026 13:57
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirrors the Go sample's coverage: time-skipping unit tests for the
order, pipeline, hub, ticker, and llmStreaming workflows, plus a
dev-server integration test that subscribes to the order workflow's
status and progress topics end to end. Runs in CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@brianstrauch brianstrauch enabled auto-merge (squash) June 12, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants