Skip to content

Commit fb8de90

Browse files
brianstrauchclaude
andauthored
Add workflow-streams sample (#470)
* Add workflow-streams sample 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> * Use published Temporal SDK 1.18.0 for workflow-streams sample Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Add AI SDK team as code owners for AI samples Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Pin nanoid to ^3.3.8 and add workflow-streams to pnpm lockfile 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> * Register workflow-streams in shared-files sync; fix pre-push without TTY - 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> * Revert pre-push hook change Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Apply suggestion from @brianstrauch * Apply suggestion from @brianstrauch * Re-resolve next to 16.2.9 to fix lint-format-build 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> * Don't number the scenarios in the workflow-streams README Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Add tests for the workflow-streams sample 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> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0abaf50 commit fb8de90

30 files changed

Lines changed: 3874 additions & 2356 deletions

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
# @temporalio/sdk will be requested for review when
44
# someone opens a pull request.
55
* @temporalio/sdk
6+
/ai-sdk/ @temporalio/sdk @temporalio/ai-sdk
7+
/workflow-streams/ @temporalio/sdk @temporalio/ai-sdk

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
sleep-for-days
6767
standalone-activity
6868
timer-examples
69+
workflow-streams
6970
message-passing/introduction
7071
message-passing/safe-message-handlers
7172
polling/infrequent

.scripts/copy-shared-files.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const ESLINTRC_EXCLUDE = [
4949
'protobufs',
5050
'food-delivery',
5151
'nestjs-exchange-rates',
52+
'workflow-streams',
5253
];
5354
const ESLINTIGNORE_EXCLUDE = [
5455
'production',
@@ -80,6 +81,7 @@ const POST_CREATE_EXCLUDE = [
8081
'worker-versioning',
8182
'empty',
8283
'scratchpad',
84+
'workflow-streams',
8385
];
8486

8587
const PRETTIERRC_EXCLUDE = ['food-delivery'];

.scripts/list-of-samples.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"vscode-debugger",
5252
"worker-specific-task-queues",
5353
"worker-versioning",
54+
"workflow-streams",
5455
"message-passing/execute-update",
5556
"message-passing/introduction",
5657
"message-passing/safe-message-handlers",

pnpm-lock.yaml

Lines changed: 2480 additions & 2356 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workflow-streams/.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
lib
3+
.eslintrc.js

workflow-streams/.eslintrc.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const { builtinModules } = require('module');
2+
3+
const ALLOWED_NODE_BUILTINS = new Set(['assert']);
4+
5+
module.exports = {
6+
root: true,
7+
parser: '@typescript-eslint/parser',
8+
parserOptions: {
9+
project: './tsconfig.json',
10+
tsconfigRootDir: __dirname,
11+
},
12+
plugins: ['@typescript-eslint', 'deprecation'],
13+
extends: [
14+
'eslint:recommended',
15+
'plugin:@typescript-eslint/eslint-recommended',
16+
'plugin:@typescript-eslint/recommended',
17+
'prettier',
18+
],
19+
rules: {
20+
// recommended for safety
21+
'@typescript-eslint/no-floating-promises': 'error', // forgetting to await Activities and Workflow APIs is bad
22+
'deprecation/deprecation': 'warn',
23+
24+
// code style preference
25+
'object-shorthand': ['error', 'always'],
26+
27+
// relaxed rules, for convenience
28+
'@typescript-eslint/no-unused-vars': [
29+
'warn',
30+
{
31+
argsIgnorePattern: '^_',
32+
varsIgnorePattern: '^_',
33+
},
34+
],
35+
'@typescript-eslint/no-explicit-any': 'off',
36+
},
37+
overrides: [
38+
{
39+
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts', 'src/llm-workflows.ts'],
40+
rules: {
41+
'no-restricted-imports': [
42+
'error',
43+
...builtinModules.filter((m) => !ALLOWED_NODE_BUILTINS.has(m)).flatMap((m) => [m, `node:${m}`]),
44+
],
45+
},
46+
},
47+
],
48+
};

workflow-streams/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib
2+
node_modules

workflow-streams/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

workflow-streams/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

0 commit comments

Comments
 (0)