Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

Automated translation updates triggered by changes to documentation.

This PR was automatically created after content changes were made, updating translations for all supported languages using Lingo.dev AI translation engine.

Original trigger: feat(billing): bill by threshold to prevent cancellation edge case (#1583)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

This PR includes automated translations for modified English documentation content:

  • 🇪🇸 Spanish (es) translations
  • 🇫🇷 French (fr) translations
  • 🇨🇳 Chinese (zh) translations
  • 🇯🇵 Japanese (ja) translations
  • 🇩🇪 German (de) translations

What reviewers should focus on:

  • Verify translated content accuracy and context
  • Check that all links and references work correctly in translated versions
  • Ensure formatting, code blocks, and structure are preserved
  • Validate that technical terms are appropriately translated

Checklist

  • Code follows project style guidelines (automated translation)
  • Self-reviewed my changes (automated process)
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

waleedlatif1 and others added 4 commits October 8, 2025 08:36
…splayText to various subblocks that didn't have it (#1582)
…1583)

* feat(billing): bill by threshold to prevent cancellation edge case

* fix org billing

* fix idempotency key issue

* small optimization for team checks

* remove console log

* remove unused type

* fix error handling
@vercel
Copy link

vercel bot commented Oct 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs Error Error Oct 10, 2025 5:10am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
sim Skipped Skipped Oct 10, 2025 5:10am

Copy link
Collaborator Author

waleedlatif1 commented Oct 10, 2025

1 Job Failed:

CI / Test and Build / Test and Build failed on "Build application"
[...]
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

   ▲ Next.js 15.4.1 (Turbopack)
   - Experiments (use with caution):
     ✓ optimizeCss
     ⨯ turbopackSourceMaps

   Creating an optimized production build ...
error: script "build" exited with code 130

 Tasks:    2 successful, 4 total
Cached:    0 cached, 4 total
  Time:    39.877s 
Failed:    docs#build

 ERROR  run failed: command  exited (1)
error: script "build" exited with code 1
Error: Process completed with exit code 1.

Summary: 1 failed workflow
  • CI (1 job failed)

Last updated: 2025-10-10 05:11:05 UTC

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This automated translation PR updates documentation translations across 5 languages (German, Spanish, French, Japanese, Chinese) following changes from PR #1583.

Critical Issues Found:

  • All 5 translated TypeScript SDK files (*/sdks/typescript.mdx) contain ~290 lines of duplicated content after the License section
  • Duplicate content includes entire code blocks, documentation sections, and multiple License headers
  • Files are 30% larger than they should be (1291-1292 lines vs 995 in English source)

Minor Changes:

  • Python SDK files have whitespace cleanup (trailing spaces removed)
  • Costs documentation files received new billing model content and minor wording updates
  • i18n.lock file updated with new content hashes

Root Cause:
The Lingo.dev AI translation engine appears to have malfunctioned when processing the TypeScript SDK documentation, causing it to duplicate large sections of content after the License header instead of properly terminating the file.

Confidence Score: 0/5

  • This PR is NOT safe to merge and will break documentation
  • Score reflects critical duplication bug affecting all TypeScript SDK translations. 290 duplicate lines per file will display incorrect/duplicate documentation to users in 5 languages. This is a translation system failure that must be fixed before merge.
  • All TypeScript SDK translation files require immediate attention: apps/docs/content/docs/{de,es,fr,ja,zh}/sdks/typescript.mdx - each contains ~290 lines of duplicate content that must be removed (lines 1002 onwards)

Important Files Changed

File Analysis

Filename Score Overview
apps/docs/content/docs/de/sdks/typescript.mdx 0/5 Critical duplication: File contains 296 duplicate lines including entire code sections after the License header
apps/docs/content/docs/es/sdks/typescript.mdx 0/5 Critical duplication: File contains 296 duplicate lines including entire code sections, License section appears 3 times
apps/docs/content/docs/fr/sdks/typescript.mdx 0/5 Critical duplication: File contains 296 duplicate lines including entire code sections, License section appears 3 times
apps/docs/content/docs/ja/sdks/typescript.mdx 0/5 Critical duplication: File contains 296 duplicate lines including entire code sections after the License header
apps/docs/content/docs/zh/sdks/typescript.mdx 0/5 Critical duplication: File contains 296 duplicate lines including entire code sections, License section appears 3 times

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant GH as GitHub Actions
    participant Lingo as Lingo.dev AI
    participant Repo as Repository

    Dev->>Repo: Merge PR #1583 (billing changes)
    Repo->>GH: Trigger translation workflow
    GH->>Lingo: Send changed English docs
    Note over Lingo: Translate to 5 languages<br/>(de, es, fr, ja, zh)
    Lingo-->>GH: Return translations
    Note over GH,Lingo: ⚠️ Translation error occurs<br/>Content duplicated in TypeScript SDK files
    GH->>Repo: Create automated PR #1591
    GH->>Repo: Update i18n.lock file
    Repo->>Dev: PR ready for review
Loading

Additional Comments (1)

  1. apps/docs/content/docs/zh/sdks/typescript.mdx, line 1002-1292 (link)

    logic: 290 lines of duplicate code following the License section. All content after line 1000 is duplicated and should be removed.

15 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +1002 to +1291
const reader = response.body?.getReader();
const decoder = new TextDecoder();

while (reader) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');

for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}

try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Execution complete:', parsed.metadata);
}
} catch (e) {
// Skip invalid JSON
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Generiere...' : 'Streaming starten'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
```

## Getting Your API Key

<Steps>
<Step title="Log in to Sim">
Navigate to [Sim](https://sim.ai) and log in to your account.
</Step>
<Step title="Open your workflow">
Navigate to the workflow you want to execute programmatically.
</Step>
<Step title="Deploy your workflow">
Click on "Deploy" to deploy your workflow if it hasn't been deployed yet.
</Step>
<Step title="Create or select an API key">
During the deployment process, select or create an API key.
</Step>
<Step title="Copy the API key">
Copy the API key to use in your TypeScript/JavaScript application.
</Step>
</Steps>

<Callout type="warning">
Keep your API key secure and never commit it to version control. Use environment variables or secure configuration management.
</Callout>

## Requirements

- Node.js 16+
- TypeScript 5.0+ (for TypeScript projects)

## TypeScript Support

The SDK is written in TypeScript and provides full type safety:

```typescript
import {
SimStudioClient,
WorkflowExecutionResult,
WorkflowStatus,
SimStudioError
} from 'simstudio-ts-sdk';

// Typsichere Client-Initialisierung
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// Typsichere Workflow-Ausführung
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hallo, TypeScript!'
}
});

// Typsichere Statusprüfung
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## License

Apache-2.0 + limits.usage.limit.toFixed(2));
console.log('Plan:', limits.usage.plan);

const percentUsed = (limits.usage.currentPeriodCost / limits.usage.limit) * 100;
console.log('Usage: ' + percentUsed.toFixed(1) + '%');

if (percentUsed > 80) {
console.warn('⚠️ Warning: You are approaching your usage limit!');
}
} catch (error) {
console.error('Error checking usage:', error);
}
}

checkUsage();
```

### Streaming-Workflow-Ausführung

Führen Sie Workflows mit Echtzeit-Streaming-Antworten aus:

```typescript
import { SimStudioClient } from 'simstudio-ts-sdk';

const client = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

async function executeWithStreaming() {
try {
// Enable streaming for specific block outputs
const result = await client.executeWorkflow('workflow-id', {
input: { message: 'Count to five' },
stream: true,
selectedOutputs: ['agent1.content'] // Use blockName.attribute format
});

console.log('Workflow result:', result);
} catch (error) {
console.error('Error:', error);
}
}
```

Die Streaming-Antwort folgt dem Server-Sent Events (SSE) Format:

```
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}

data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}

data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}

data: [DONE]
```

**React Streaming-Beispiel:**

```typescript
import { useState, useEffect } from 'react';

function StreamingWorkflow() {
const [output, setOutput] = useState('');
const [loading, setLoading] = useState(false);

const executeStreaming = async () => {
setLoading(true);
setOutput('');

// IMPORTANT: Make this API call from your backend server, not the browser
// Never expose your API key in client-side code
const response = await fetch('https://sim.ai/api/workflows/WORKFLOW_ID/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.SIM_API_KEY! // Server-side environment variable only
},
body: JSON.stringify({
message: 'Generate a story',
stream: true,
selectedOutputs: ['agent1.content']
})
});

const reader = response.body?.getReader();
const decoder = new TextDecoder();

while (reader) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');

for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}

try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Execution complete:', parsed.metadata);
}
} catch (e) {
// Skip invalid JSON
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Generating...' : 'Start Streaming'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
```

## Ihren API-Schlüssel erhalten

<Steps>
<Step title="Bei Sim anmelden">
Navigieren Sie zu [Sim](https://sim.ai) und melden Sie sich bei Ihrem Konto an.
</Step>
<Step title="Öffnen Sie Ihren Workflow">
Navigieren Sie zu dem Workflow, den Sie programmatisch ausführen möchten.
</Step>
<Step title="Deployen Sie Ihren Workflow">
Klicken Sie auf "Deploy", um Ihren Workflow zu deployen, falls dies noch nicht geschehen ist.
</Step>
<Step title="Erstellen oder wählen Sie einen API-Schlüssel">
Wählen Sie während des Deployment-Prozesses einen API-Schlüssel aus oder erstellen Sie einen neuen.
</Step>
<Step title="Kopieren Sie den API-Schlüssel">
Kopieren Sie den API-Schlüssel zur Verwendung in Ihrer TypeScript/JavaScript-Anwendung.
</Step>
</Steps>

<Callout type="warning">
Halte deinen API-Schlüssel sicher und committe ihn niemals in die Versionskontrolle. Verwende Umgebungsvariablen oder sicheres Konfigurationsmanagement.
</Callout>

## Anforderungen

- Node.js 16+
- TypeScript 5.0+ (für TypeScript-Projekte)

## TypeScript-Unterstützung

Das SDK ist in TypeScript geschrieben und bietet vollständige Typsicherheit:

```typescript
import {
SimStudioClient,
WorkflowExecutionResult,
WorkflowStatus,
SimStudioError
} from 'simstudio-ts-sdk';

// Type-safe client initialization
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// Type-safe workflow execution
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hello, TypeScript!'
}
});

// Type-safe status checking
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## Lizenz

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: 290 lines of duplicate code following the License section. Content from lines 1002-1291 duplicates earlier sections of the file and should be removed entirely.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/de/sdks/typescript.mdx
Line: 1002:1291

Comment:
**logic:** 290 lines of duplicate code following the License section. Content from lines 1002-1291 duplicates earlier sections of the file and should be removed entirely.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +1002 to 1292
const reader = response.body?.getReader();
const decoder = new TextDecoder();

while (reader) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');

for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}

try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Ejecución completada:', parsed.metadata);
}
} catch (e) {
// Omitir JSON inválido
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Generando...' : 'Iniciar streaming'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
```

## Getting Your API Key

<Steps>
<Step title="Log in to Sim">
Navigate to [Sim](https://sim.ai) and log in to your account.
</Step>
<Step title="Open your workflow">
Navigate to the workflow you want to execute programmatically.
</Step>
<Step title="Deploy your workflow">
Click on "Deploy" to deploy your workflow if it hasn't been deployed yet.
</Step>
<Step title="Create or select an API key">
During the deployment process, select or create an API key.
</Step>
<Step title="Copy the API key">
Copy the API key to use in your TypeScript/JavaScript application.
</Step>
</Steps>

<Callout type="warning">
Keep your API key secure and never commit it to version control. Use environment variables or secure configuration management.
</Callout>

## Requirements

- Node.js 16+
- TypeScript 5.0+ (for TypeScript projects)

## TypeScript Support

The SDK is written in TypeScript and provides full type safety:

```typescript
import {
SimStudioClient,
WorkflowExecutionResult,
WorkflowStatus,
SimStudioError
} from 'simstudio-ts-sdk';

// Inicialización del cliente con seguridad de tipos
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// Ejecución de flujo de trabajo con seguridad de tipos
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hola, TypeScript!'
}
});

// Verificación de estado con seguridad de tipos
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## License

Apache-2.0 + limits.usage.limit.toFixed(2));
console.log('Plan:', limits.usage.plan);

const percentUsed = (limits.usage.currentPeriodCost / limits.usage.limit) * 100;
console.log('Usage: ' + percentUsed.toFixed(1) + '%');

if (percentUsed > 80) {
console.warn('⚠️ Warning: You are approaching your usage limit!');
}
} catch (error) {
console.error('Error checking usage:', error);
}
}

checkUsage();
```

### Ejecución de flujo de trabajo en streaming

Ejecuta flujos de trabajo con respuestas en tiempo real:

```typescript
import { SimStudioClient } from 'simstudio-ts-sdk';

const client = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

async function executeWithStreaming() {
try {
// Enable streaming for specific block outputs
const result = await client.executeWorkflow('workflow-id', {
input: { message: 'Count to five' },
stream: true,
selectedOutputs: ['agent1.content'] // Use blockName.attribute format
});

console.log('Workflow result:', result);
} catch (error) {
console.error('Error:', error);
}
}
```

La respuesta en streaming sigue el formato de eventos enviados por el servidor (SSE):

```
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}

data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}

data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}

data: [DONE]
```

**Ejemplo de streaming en React:**

```typescript
import { useState, useEffect } from 'react';

function StreamingWorkflow() {
const [output, setOutput] = useState('');
const [loading, setLoading] = useState(false);

const executeStreaming = async () => {
setLoading(true);
setOutput('');

// IMPORTANT: Make this API call from your backend server, not the browser
// Never expose your API key in client-side code
const response = await fetch('https://sim.ai/api/workflows/WORKFLOW_ID/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.SIM_API_KEY! // Server-side environment variable only
},
body: JSON.stringify({
message: 'Generate a story',
stream: true,
selectedOutputs: ['agent1.content']
})
});

const reader = response.body?.getReader();
const decoder = new TextDecoder();

while (reader) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');

for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}

try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Execution complete:', parsed.metadata);
}
} catch (e) {
// Skip invalid JSON
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Generating...' : 'Start Streaming'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
```

## Obtener tu clave API

<Steps>
<Step title="Inicia sesión en Sim">
Navega a [Sim](https://sim.ai) e inicia sesión en tu cuenta.
</Step>
<Step title="Abre tu flujo de trabajo">
Navega al flujo de trabajo que quieres ejecutar programáticamente.
</Step>
<Step title="Despliega tu flujo de trabajo">
Haz clic en "Desplegar" para desplegar tu flujo de trabajo si aún no ha sido desplegado.
</Step>
<Step title="Crea o selecciona una clave API">
Durante el proceso de despliegue, selecciona o crea una clave API.
</Step>
<Step title="Copia la clave API">
Copia la clave API para usarla en tu aplicación TypeScript/JavaScript.
</Step>
</Steps>

<Callout type="warning">
Mantén tu clave API segura y nunca la incluyas en el control de versiones. Utiliza variables de entorno o gestión de configuración segura.
</Callout>

## Requisitos

- Node.js 16+
- TypeScript 5.0+ (para proyectos TypeScript)

## Soporte para TypeScript

El SDK está escrito en TypeScript y proporciona seguridad de tipos completa:

```typescript
import {
SimStudioClient,
WorkflowExecutionResult,
WorkflowStatus,
SimStudioError
} from 'simstudio-ts-sdk';

// Type-safe client initialization
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// Type-safe workflow execution
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hello, TypeScript!'
}
});

// Type-safe status checking
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## Licencia

Apache-2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: 290 lines of duplicate code following the License section. All content after line 1000 is duplicated and should be removed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/es/sdks/typescript.mdx
Line: 1002:1292

Comment:
**logic:** 290 lines of duplicate code following the License section. All content after line 1000 is duplicated and should be removed.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +1002 to 1292
const reader = response.body?.getReader();
const decoder = new TextDecoder();

while (reader) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');

for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}

try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Exécution terminée :', parsed.metadata);
}
} catch (e) {
// Ignorer le JSON invalide
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Génération en cours...' : 'Démarrer le streaming'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
```

## Getting Your API Key

<Steps>
<Step title="Log in to Sim">
Navigate to [Sim](https://sim.ai) and log in to your account.
</Step>
<Step title="Open your workflow">
Navigate to the workflow you want to execute programmatically.
</Step>
<Step title="Deploy your workflow">
Click on "Deploy" to deploy your workflow if it hasn't been deployed yet.
</Step>
<Step title="Create or select an API key">
During the deployment process, select or create an API key.
</Step>
<Step title="Copy the API key">
Copy the API key to use in your TypeScript/JavaScript application.
</Step>
</Steps>

<Callout type="warning">
Keep your API key secure and never commit it to version control. Use environment variables or secure configuration management.
</Callout>

## Requirements

- Node.js 16+
- TypeScript 5.0+ (for TypeScript projects)

## TypeScript Support

The SDK is written in TypeScript and provides full type safety:

```typescript
import {
SimStudioClient,
WorkflowExecutionResult,
WorkflowStatus,
SimStudioError
} from 'simstudio-ts-sdk';

// Initialisation du client avec typage sécurisé
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// Exécution de workflow avec typage sécurisé
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hello, TypeScript!'
}
});

// Vérification de statut avec typage sécurisé
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## License

Apache-2.0 + limits.usage.limit.toFixed(2));
console.log('Plan:', limits.usage.plan);

const percentUsed = (limits.usage.currentPeriodCost / limits.usage.limit) * 100;
console.log('Usage: ' + percentUsed.toFixed(1) + '%');

if (percentUsed > 80) {
console.warn('⚠️ Warning: You are approaching your usage limit!');
}
} catch (error) {
console.error('Error checking usage:', error);
}
}

checkUsage();
```

### Exécution de workflow en streaming

Exécutez des workflows avec des réponses en streaming en temps réel :

```typescript
import { SimStudioClient } from 'simstudio-ts-sdk';

const client = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

async function executeWithStreaming() {
try {
// Enable streaming for specific block outputs
const result = await client.executeWorkflow('workflow-id', {
input: { message: 'Count to five' },
stream: true,
selectedOutputs: ['agent1.content'] // Use blockName.attribute format
});

console.log('Workflow result:', result);
} catch (error) {
console.error('Error:', error);
}
}
```

La réponse en streaming suit le format Server-Sent Events (SSE) :

```
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}

data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}

data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}

data: [DONE]
```

**Exemple de streaming avec React :**

```typescript
import { useState, useEffect } from 'react';

function StreamingWorkflow() {
const [output, setOutput] = useState('');
const [loading, setLoading] = useState(false);

const executeStreaming = async () => {
setLoading(true);
setOutput('');

// IMPORTANT: Make this API call from your backend server, not the browser
// Never expose your API key in client-side code
const response = await fetch('https://sim.ai/api/workflows/WORKFLOW_ID/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.SIM_API_KEY! // Server-side environment variable only
},
body: JSON.stringify({
message: 'Generate a story',
stream: true,
selectedOutputs: ['agent1.content']
})
});

const reader = response.body?.getReader();
const decoder = new TextDecoder();

while (reader) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');

for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}

try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Execution complete:', parsed.metadata);
}
} catch (e) {
// Skip invalid JSON
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Generating...' : 'Start Streaming'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
```

## Obtenir votre clé API

<Steps>
<Step title="Connectez-vous à Sim">
Accédez à [Sim](https://sim.ai) et connectez-vous à votre compte.
</Step>
<Step title="Ouvrez votre workflow">
Accédez au workflow que vous souhaitez exécuter par programmation.
</Step>
<Step title="Déployez votre workflow">
Cliquez sur « Déployer » pour déployer votre workflow s'il n'a pas encore été déployé.
</Step>
<Step title="Créez ou sélectionnez une clé API">
Pendant le processus de déploiement, sélectionnez ou créez une clé API.
</Step>
<Step title="Copiez la clé API">
Copiez la clé API pour l'utiliser dans votre application TypeScript/JavaScript.
</Step>
</Steps>

<Callout type="warning">
Gardez votre clé API sécurisée et ne la soumettez jamais au contrôle de version. Utilisez des variables d'environnement ou une gestion de configuration sécurisée.
</Callout>

## Prérequis

- Node.js 16+
- TypeScript 5.0+ (pour les projets TypeScript)

## Support TypeScript

Le SDK est écrit en TypeScript et offre une sécurité de typage complète :

```typescript
import {
SimStudioClient,
WorkflowExecutionResult,
WorkflowStatus,
SimStudioError
} from 'simstudio-ts-sdk';

// Type-safe client initialization
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// Type-safe workflow execution
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hello, TypeScript!'
}
});

// Type-safe status checking
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## Licence

Apache-2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: 290 lines of duplicate code following the License section. All content after line 1000 is duplicated and should be removed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/fr/sdks/typescript.mdx
Line: 1002:1292

Comment:
**logic:** 290 lines of duplicate code following the License section. All content after line 1000 is duplicated and should be removed.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +1002 to 1291
const reader = response.body?.getReader();
const decoder = new TextDecoder();

while (reader) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');

for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}

try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Execution complete:', parsed.metadata);
}
} catch (e) {
// Skip invalid JSON
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? '生成中...' : 'ストリーミング開始'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
```

## Getting Your API Key

<Steps>
<Step title="Log in to Sim">
Navigate to [Sim](https://sim.ai) and log in to your account.
</Step>
<Step title="Open your workflow">
Navigate to the workflow you want to execute programmatically.
</Step>
<Step title="Deploy your workflow">
Click on "Deploy" to deploy your workflow if it hasn't been deployed yet.
</Step>
<Step title="Create or select an API key">
During the deployment process, select or create an API key.
</Step>
<Step title="Copy the API key">
Copy the API key to use in your TypeScript/JavaScript application.
</Step>
</Steps>

<Callout type="warning">
Keep your API key secure and never commit it to version control. Use environment variables or secure configuration management.
</Callout>

## Requirements

- Node.js 16+
- TypeScript 5.0+ (for TypeScript projects)

## TypeScript Support

The SDK is written in TypeScript and provides full type safety:

```typescript
import {
SimStudioClient,
WorkflowExecutionResult,
WorkflowStatus,
SimStudioError
} from 'simstudio-ts-sdk';

// 型安全なクライアント初期化
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// 型安全なワークフロー実行
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hello, TypeScript!'
}
});

// 型安全なステータス確認
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## License

Apache-2.0 + limits.usage.limit.toFixed(2));
console.log('Plan:', limits.usage.plan);

const percentUsed = (limits.usage.currentPeriodCost / limits.usage.limit) * 100;
console.log('Usage: ' + percentUsed.toFixed(1) + '%');

if (percentUsed > 80) {
console.warn('⚠️ Warning: You are approaching your usage limit!');
}
} catch (error) {
console.error('Error checking usage:', error);
}
}

checkUsage();
```

### ストリーミングワークフロー実行

リアルタイムストリーミングレスポンスでワークフローを実行します:

```typescript
import { SimStudioClient } from 'simstudio-ts-sdk';

const client = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

async function executeWithStreaming() {
try {
// Enable streaming for specific block outputs
const result = await client.executeWorkflow('workflow-id', {
input: { message: 'Count to five' },
stream: true,
selectedOutputs: ['agent1.content'] // Use blockName.attribute format
});

console.log('Workflow result:', result);
} catch (error) {
console.error('Error:', error);
}
}
```

ストリーミングレスポンスはServer-Sent Events(SSE)形式に従います:

```
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}

data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}

data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}

data: [DONE]
```

**Reactストリーミング例:**

```typescript
import { useState, useEffect } from 'react';

function StreamingWorkflow() {
const [output, setOutput] = useState('');
const [loading, setLoading] = useState(false);

const executeStreaming = async () => {
setLoading(true);
setOutput('');

// IMPORTANT: Make this API call from your backend server, not the browser
// Never expose your API key in client-side code
const response = await fetch('https://sim.ai/api/workflows/WORKFLOW_ID/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.SIM_API_KEY! // Server-side environment variable only
},
body: JSON.stringify({
message: 'Generate a story',
stream: true,
selectedOutputs: ['agent1.content']
})
});

const reader = response.body?.getReader();
const decoder = new TextDecoder();

while (reader) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');

for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}

try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Execution complete:', parsed.metadata);
}
} catch (e) {
// Skip invalid JSON
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Generating...' : 'Start Streaming'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
```

## APIキーの取得方法

<Steps>
<Step title="Simにログイン">
[Sim](https://sim.ai)に移動してアカウントにログインします。
</Step>
<Step title="ワークフローを開く">
プログラムで実行したいワークフローに移動します。
</Step>
<Step title="ワークフローをデプロイする">
まだデプロイされていない場合は、「デプロイ」をクリックしてワークフローをデプロイします。
</Step>
<Step title="APIキーを作成または選択する">
デプロイプロセス中に、APIキーを選択または作成します。
</Step>
<Step title="APIキーをコピーする">
TypeScript/JavaScriptアプリケーションで使用するAPIキーをコピーします。
</Step>
</Steps>

<Callout type="warning">
APIキーは安全に保管し、バージョン管理システムにコミットしないでください。環境変数や安全な設定管理を使用してください。
</Callout>

## 要件

- Node.js 16以上
- TypeScript 5.0以上(TypeScriptプロジェクトの場合)

## TypeScriptサポート

このSDKはTypeScriptで書かれており、完全な型安全性を提供します:

```typescript
import {
SimStudioClient,
WorkflowExecutionResult,
WorkflowStatus,
SimStudioError
} from 'simstudio-ts-sdk';

// Type-safe client initialization
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// Type-safe workflow execution
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hello, TypeScript!'
}
});

// Type-safe status checking
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## ライセンス

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: 290 lines of duplicate code following the License section. Content from lines 1002-1291 duplicates earlier sections and should be removed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/ja/sdks/typescript.mdx
Line: 1002:1291

Comment:
**logic:** 290 lines of duplicate code following the License section. Content from lines 1002-1291 duplicates earlier sections and should be removed.

How can I resolve this? If you propose a fix, please make it concise.

@waleedlatif1 waleedlatif1 deleted the auto-translate/staging-merge-18396244736 branch October 13, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants