From 872e034312fc544699b59d0bc1560fc885866291 Mon Sep 17 00:00:00 2001 From: Waleed Date: Tue, 7 Oct 2025 15:10:37 -0700 Subject: [PATCH] feat(chat-streaming): added a `stream` option to workflow execute route, updated SDKs, updated docs (#1565) * feat(chat-stream): updated workflow id execute route to support streaming via API * enable streaming via api * added only text stream option * cleanup deployed preview componnet * updated selectedOutputIds to selectedOutput * updated TS and Python SDKs with async, rate limits, usage, and streaming API routes * stream non-streaming blocks when streaming is specified * fix(chat-panel): add onBlockComplete handler to chat panel to stream back blocks as they complete * update docs * cleanup * ack PR comments * updated next config * removed getAssetUrl in favor of local assets * resolve merge conflicts * remove extra logic to create sensitive result * simplify internal auth * remove vercel blob from CSP + next config --- apps/docs/components/ui/lightbox.tsx | 4 +- apps/docs/components/ui/video.tsx | 4 +- apps/docs/content/docs/de/sdks/python.mdx | 18 +- apps/docs/content/docs/de/sdks/typescript.mdx | 24 +- apps/docs/content/docs/en/sdks/python.mdx | 402 +++++++++++- apps/docs/content/docs/en/sdks/typescript.mdx | 456 +++++++++++++- apps/docs/content/docs/en/triggers/api.mdx | 78 +++ apps/docs/content/docs/es/sdks/python.mdx | 18 +- apps/docs/content/docs/es/sdks/typescript.mdx | 24 +- apps/docs/content/docs/fr/sdks/python.mdx | 18 +- apps/docs/content/docs/fr/sdks/typescript.mdx | 24 +- apps/docs/content/docs/ja/sdks/python.mdx | 18 +- apps/docs/content/docs/ja/sdks/typescript.mdx | 24 +- apps/docs/content/docs/zh/sdks/python.mdx | 18 +- apps/docs/content/docs/zh/sdks/typescript.mdx | 24 +- apps/docs/lib/utils.ts | 11 +- .../components/testimonials/testimonials.tsx | 26 +- .../app/api/chat/[identifier]/route.test.ts | 61 +- apps/sim/app/api/chat/[identifier]/route.ts | 43 +- apps/sim/app/api/chat/utils.test.ts | 2 +- apps/sim/app/api/chat/utils.ts | 587 +----------------- .../app/api/workflows/[id]/execute/route.ts | 251 ++++++-- apps/sim/app/api/workflows/middleware.ts | 7 +- apps/sim/app/chat/hooks/use-chat-streaming.ts | 35 +- .../frozen-canvas/frozen-canvas-modal.tsx | 8 +- .../frozen-canvas/frozen-canvas.tsx | 2 + .../example-command/example-command.tsx | 142 +++-- .../deployment-info/deployment-info.tsx | 9 +- .../components/deploy-modal/deploy-modal.tsx | 401 ++++++------ .../components/deployed-workflow-card.tsx | 7 +- .../components/deployed-workflow-modal.tsx | 25 +- .../components/panel/components/chat/chat.tsx | 115 ++-- .../output-select/output-select.tsx | 176 ++++-- .../w/[workflowId]/hooks/use-wand.ts | 8 +- .../hooks/use-workflow-execution.ts | 104 +++- .../lib/workflow-execution-utils.ts | 8 +- .../workflow-preview/workflow-preview.tsx | 12 +- .../emails/enterprise-subscription-email.tsx | 4 +- apps/sim/components/emails/footer.tsx | 11 +- .../emails/help-confirmation-email.tsx | 4 +- .../components/emails/invitation-email.tsx | 4 +- .../emails/otp-verification-email.tsx | 4 +- .../components/emails/plan-welcome-email.tsx | 4 +- .../emails/reset-password-email.tsx | 4 +- .../emails/usage-threshold-email.tsx | 4 +- .../emails/workspace-invitation.tsx | 4 +- .../handlers/agent/agent-handler.test.ts | 6 +- .../executor/handlers/agent/agent-handler.ts | 6 +- apps/sim/executor/index.test.ts | 12 +- apps/sim/executor/index.ts | 148 +++-- apps/sim/executor/types.ts | 5 +- apps/sim/executor/utils.ts | 6 +- apps/sim/lib/auth/internal.ts | 5 +- apps/sim/lib/branding/metadata.ts | 5 +- apps/sim/lib/env.ts | 4 - apps/sim/lib/redis.ts | 2 - apps/sim/lib/response-format.ts | 60 +- apps/sim/lib/security/csp.ts | 3 +- apps/sim/lib/tokenization/calculators.ts | 10 - apps/sim/lib/tokenization/estimators.ts | 20 +- apps/sim/lib/tokenization/streaming.ts | 22 - apps/sim/lib/utils.ts | 32 +- apps/sim/lib/workflows/streaming.ts | 181 ++++++ apps/sim/next.config.ts | 21 +- packages/README.md | 12 +- packages/python-sdk/README.md | 14 +- packages/python-sdk/examples/basic_usage.py | 67 +- packages/python-sdk/simstudio/__init__.py | 321 +++++++++- packages/python-sdk/tests/test_client.py | 369 ++++++++++- packages/ts-sdk/README.md | 8 +- packages/ts-sdk/examples/basic-usage.ts | 41 +- packages/ts-sdk/src/index.test.ts | 408 ++++++++++++ packages/ts-sdk/src/index.ts | 255 +++++++- 73 files changed, 3662 insertions(+), 1618 deletions(-) create mode 100644 apps/sim/lib/workflows/streaming.ts diff --git a/apps/docs/components/ui/lightbox.tsx b/apps/docs/components/ui/lightbox.tsx index 0dacda7e24..c73df2aa07 100644 --- a/apps/docs/components/ui/lightbox.tsx +++ b/apps/docs/components/ui/lightbox.tsx @@ -1,7 +1,7 @@ 'use client' import { useEffect, useRef } from 'react' -import { getVideoUrl } from '@/lib/utils' +import { getAssetUrl } from '@/lib/utils' interface LightboxProps { isOpen: boolean @@ -60,7 +60,7 @@ export function Lightbox({ isOpen, onClose, src, alt, type }: LightboxProps) { /> ) : (