Skip to content

Commit 78b5ae7

Browse files
icecrasher321waleedlatif1adiologydevemir-karabegVikhyath Mondreti
authored
v0.2.7: fix + feat (#615)
* feat(logging): add additional logs for proxy routes * fix(blocks): workflow handler not working outside gui (#609) * fix: key to call api internally for workflow block * feat: use jwt for internal auth to avoid a static key * chore: formatter * fix(sidebar): added loop & parallel subblcoks to sidebar search * merged improvement/connection into staging (#604) * merged improvement/connection into staging * fix: merge conflicts and improved block path calculation * fix: removed migration * fix: removed duplicate call * fix: resolver and merge conflicts * fix: knowledge base folder * fix: settings modal * fix: typeform block * fix: parallel handler * fix: stores index * fix: tests * fix: tag-dropdown * improvement: start block input and tag dropdown * fix block id resolution + missing bracket * fix lint * fix test * works * fix * fix lint * Revert "fix lint" This reverts commit 433e2f9. --------- Co-authored-by: Vikhyath Mondreti <[email protected]> Co-authored-by: Vikhyath Mondreti <[email protected]> * fix(autopan): migration missing (#614) * add autopan migration * fix lint * fix linter * fix tests --------- Co-authored-by: Vikhyath Mondreti <[email protected]> --------- Co-authored-by: Waleed Latif <[email protected]> Co-authored-by: Aditya Tripathi <[email protected]> Co-authored-by: Emir Karabeg <[email protected]> Co-authored-by: Vikhyath Mondreti <[email protected]> Co-authored-by: Vikhyath Mondreti <[email protected]>
1 parent 016cd67 commit 78b5ae7

File tree

157 files changed

+7709
-2877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+7709
-2877
lines changed

apps/docs/content/docs/blocks/workflow.mdx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@ Define the data to pass to the child workflow:
6666

6767
- **Single Variable Input**: Select a variable or block output to pass to the child workflow
6868
- **Variable References**: Use `<variable.name>` to reference workflow variables
69-
- **Block References**: Use `<blockName.response.field>` to reference outputs from previous blocks
70-
- **Automatic Mapping**: The selected data is automatically available as `start.response.input` in the child workflow
69+
- **Block References**: Use `<blockName.field>` to reference outputs from previous blocks
70+
- **Automatic Mapping**: The selected data is automatically available as `start.input` in the child workflow
7171
- **Optional**: The input field is optional - child workflows can run without input data
7272
- **Type Preservation**: Variable types (strings, numbers, objects, etc.) are preserved when passed to the child workflow
7373

7474
### Examples of Input References
7575

7676
- `<variable.customerData>` - Pass a workflow variable
77-
- `<dataProcessor.response.result>` - Pass the result from a previous block
78-
- `<start.response.input>` - Pass the original workflow input
79-
- `<apiCall.response.data.user>` - Pass a specific field from an API response
77+
- `<dataProcessor.result>` - Pass the result from a previous block
78+
- `<start.input>` - Pass the original workflow input
79+
- `<apiCall.data.user>` - Pass a specific field from an API response
8080

8181
### Execution Context
8282

@@ -109,7 +109,7 @@ To prevent infinite recursion and ensure system stability, the Workflow block in
109109
<strong>Workflow ID</strong>: The identifier of the workflow to execute
110110
</li>
111111
<li>
112-
<strong>Input Variable</strong>: Variable or block reference to pass to the child workflow (e.g., `<variable.name>` or `<block.response.field>`)
112+
<strong>Input Variable</strong>: Variable or block reference to pass to the child workflow (e.g., `<variable.name>` or `<block.field>`)
113113
</li>
114114
</ul>
115115
</Tab>
@@ -150,31 +150,31 @@ blocks:
150150
- type: workflow
151151
name: "Setup Customer Account"
152152
workflowId: "account-setup-workflow"
153-
input: "<Validate Customer Data.response.result>"
153+
input: "<Validate Customer Data.result>"
154154

155155
- type: workflow
156156
name: "Send Welcome Email"
157157
workflowId: "welcome-email-workflow"
158-
input: "<Setup Customer Account.response.result.accountDetails>"
158+
input: "<Setup Customer Account.result.accountDetails>"
159159
```
160160
161161
### Child Workflow: Customer Validation
162162
```yaml
163163
# Reusable customer validation workflow
164-
# Access the input data using: start.response.input
164+
# Access the input data using: start.input
165165
blocks:
166166
- type: function
167167
name: "Validate Email"
168168
code: |
169-
const customerData = start.response.input;
169+
const customerData = start.input;
170170
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
171171
return emailRegex.test(customerData.email);
172172
173173
- type: api
174174
name: "Check Credit Score"
175175
url: "https://api.creditcheck.com/score"
176176
method: "POST"
177-
body: "<start.response.input>"
177+
body: "<start.input>"
178178
```
179179
180180
### Variable Reference Examples
@@ -184,13 +184,13 @@ blocks:
184184
input: "<variable.customerInfo>"
185185

186186
# Using block outputs
187-
input: "<dataProcessor.response.cleanedData>"
187+
input: "<dataProcessor.cleanedData>"
188188

189189
# Using nested object properties
190-
input: "<apiCall.response.data.user.profile>"
190+
input: "<apiCall.data.user.profile>"
191191

192192
# Using array elements (if supported by the resolver)
193-
input: "<listProcessor.response.items[0]>"
193+
input: "<listProcessor.items[0]>"
194194
```
195195
196196
## Access Control and Permissions

apps/sim/app/api/__test-utils__/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const sampleWorkflowState = {
9393
webhookPath: { id: 'webhookPath', type: 'short-input', value: '' },
9494
},
9595
outputs: {
96-
response: { type: { input: 'any' } },
96+
input: 'any',
9797
},
9898
enabled: true,
9999
horizontalHandles: true,
@@ -111,7 +111,7 @@ export const sampleWorkflowState = {
111111
type: 'long-input',
112112
value: 'You are a helpful assistant',
113113
},
114-
context: { id: 'context', type: 'short-input', value: '<start.response.input>' },
114+
context: { id: 'context', type: 'short-input', value: '<start.input>' },
115115
model: { id: 'model', type: 'dropdown', value: 'gpt-4o' },
116116
apiKey: { id: 'apiKey', type: 'short-input', value: '{{OPENAI_API_KEY}}' },
117117
},
@@ -138,6 +138,7 @@ export const sampleWorkflowState = {
138138
},
139139
],
140140
loops: {},
141+
parallels: {},
141142
lastSaved: Date.now(),
142143
isDeployed: false,
143144
}

apps/sim/app/api/chat/[subdomain]/route.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ describe('Chat Subdomain API Route', () => {
241241
})
242242

243243
describe('POST endpoint', () => {
244-
it('should handle authentication requests without messages', async () => {
244+
it('should handle authentication requests without input', async () => {
245245
const req = createMockRequest('POST', { password: 'test-password' })
246246
const params = Promise.resolve({ subdomain: 'password-protected-chat' })
247247

@@ -257,7 +257,7 @@ describe('Chat Subdomain API Route', () => {
257257
expect(mockSetChatAuthCookie).toHaveBeenCalled()
258258
})
259259

260-
it('should return 400 for requests without message', async () => {
260+
it('should return 400 for requests without input', async () => {
261261
const req = createMockRequest('POST', {})
262262
const params = Promise.resolve({ subdomain: 'test-chat' })
263263

@@ -269,7 +269,7 @@ describe('Chat Subdomain API Route', () => {
269269

270270
const data = await response.json()
271271
expect(data).toHaveProperty('error')
272-
expect(data).toHaveProperty('message', 'No message provided')
272+
expect(data).toHaveProperty('message', 'No input provided')
273273
})
274274

275275
it('should return 401 for unauthorized access', async () => {
@@ -279,7 +279,7 @@ describe('Chat Subdomain API Route', () => {
279279
error: 'Authentication required',
280280
}))
281281

282-
const req = createMockRequest('POST', { message: 'Hello' })
282+
const req = createMockRequest('POST', { input: 'Hello' })
283283
const params = Promise.resolve({ subdomain: 'protected-chat' })
284284

285285
const { POST } = await import('./route')
@@ -342,7 +342,7 @@ describe('Chat Subdomain API Route', () => {
342342
}
343343
})
344344

345-
const req = createMockRequest('POST', { message: 'Hello' })
345+
const req = createMockRequest('POST', { input: 'Hello' })
346346
const params = Promise.resolve({ subdomain: 'test-chat' })
347347

348348
const { POST } = await import('./route')
@@ -357,7 +357,7 @@ describe('Chat Subdomain API Route', () => {
357357
})
358358

359359
it('should return streaming response for valid chat messages', async () => {
360-
const req = createMockRequest('POST', { message: 'Hello world', conversationId: 'conv-123' })
360+
const req = createMockRequest('POST', { input: 'Hello world', conversationId: 'conv-123' })
361361
const params = Promise.resolve({ subdomain: 'test-chat' })
362362

363363
const { POST } = await import('./route')
@@ -374,7 +374,7 @@ describe('Chat Subdomain API Route', () => {
374374
})
375375

376376
it('should handle streaming response body correctly', async () => {
377-
const req = createMockRequest('POST', { message: 'Hello world' })
377+
const req = createMockRequest('POST', { input: 'Hello world' })
378378
const params = Promise.resolve({ subdomain: 'test-chat' })
379379

380380
const { POST } = await import('./route')
@@ -404,7 +404,7 @@ describe('Chat Subdomain API Route', () => {
404404
throw new Error('Execution failed')
405405
})
406406

407-
const req = createMockRequest('POST', { message: 'Trigger error' })
407+
const req = createMockRequest('POST', { input: 'Trigger error' })
408408
const params = Promise.resolve({ subdomain: 'test-chat' })
409409

410410
const { POST } = await import('./route')
@@ -444,7 +444,7 @@ describe('Chat Subdomain API Route', () => {
444444

445445
it('should pass conversationId to executeWorkflowForChat when provided', async () => {
446446
const req = createMockRequest('POST', {
447-
message: 'Hello world',
447+
input: 'Hello world',
448448
conversationId: 'test-conversation-123',
449449
})
450450
const params = Promise.resolve({ subdomain: 'test-chat' })
@@ -461,7 +461,7 @@ describe('Chat Subdomain API Route', () => {
461461
})
462462

463463
it('should handle missing conversationId gracefully', async () => {
464-
const req = createMockRequest('POST', { message: 'Hello world' })
464+
const req = createMockRequest('POST', { input: 'Hello world' })
465465
const params = Promise.resolve({ subdomain: 'test-chat' })
466466

467467
const { POST } = await import('./route')

apps/sim/app/api/chat/[subdomain]/route.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ export async function POST(
7272
}
7373

7474
// Use the already parsed body
75-
const { message, password, email, conversationId } = parsedBody
75+
const { input, password, email, conversationId } = parsedBody
7676

77-
// If this is an authentication request (has password or email but no message),
77+
// If this is an authentication request (has password or email but no input),
7878
// set auth cookie and return success
79-
if ((password || email) && !message) {
79+
if ((password || email) && !input) {
8080
const response = addCorsHeaders(createSuccessResponse({ authenticated: true }), request)
8181

8282
// Set authentication cookie
@@ -86,8 +86,8 @@ export async function POST(
8686
}
8787

8888
// For chat messages, create regular response
89-
if (!message) {
90-
return addCorsHeaders(createErrorResponse('No message provided', 400), request)
89+
if (!input) {
90+
return addCorsHeaders(createErrorResponse('No input provided', 400), request)
9191
}
9292

9393
// Get the workflow for this chat
@@ -105,8 +105,8 @@ export async function POST(
105105
}
106106

107107
try {
108-
// Execute workflow with structured input (message + conversationId for context)
109-
const result = await executeWorkflowForChat(deployment.id, message, conversationId)
108+
// Execute workflow with structured input (input + conversationId for context)
109+
const result = await executeWorkflowForChat(deployment.id, input, conversationId)
110110

111111
// The result is always a ReadableStream that we can pipe to the client
112112
const streamResponse = new NextResponse(result, {

apps/sim/app/api/chat/utils.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ export async function validateChatAuth(
128128
return { authorized: false, error: 'Password is required' }
129129
}
130130

131-
const { password, message } = parsedBody
131+
const { password, input } = parsedBody
132132

133133
// If this is a chat message, not an auth attempt
134-
if (message && !password) {
134+
if (input && !password) {
135135
return { authorized: false, error: 'auth_required_password' }
136136
}
137137

@@ -170,10 +170,10 @@ export async function validateChatAuth(
170170
return { authorized: false, error: 'Email is required' }
171171
}
172172

173-
const { email, message } = parsedBody
173+
const { email, input } = parsedBody
174174

175175
// If this is a chat message, not an auth attempt
176-
if (message && !email) {
176+
if (input && !email) {
177177
return { authorized: false, error: 'auth_required_email' }
178178
}
179179

@@ -211,17 +211,17 @@ export async function validateChatAuth(
211211
/**
212212
* Executes a workflow for a chat request and returns the formatted output.
213213
*
214-
* When workflows reference <start.response.input>, they receive a structured JSON
215-
* containing both the message and conversationId for maintaining chat context.
214+
* When workflows reference <start.input>, they receive the input directly.
215+
* The conversationId is available at <start.conversationId> for maintaining chat context.
216216
*
217217
* @param chatId - Chat deployment identifier
218-
* @param message - User's chat message
218+
* @param input - User's chat input
219219
* @param conversationId - Optional ID for maintaining conversation context
220220
* @returns Workflow execution result formatted for the chat interface
221221
*/
222222
export async function executeWorkflowForChat(
223223
chatId: string,
224-
message: string,
224+
input: string,
225225
conversationId?: string
226226
): Promise<any> {
227227
const requestId = crypto.randomUUID().slice(0, 8)
@@ -445,7 +445,7 @@ export async function executeWorkflowForChat(
445445
workflow: serializedWorkflow,
446446
currentBlockStates: processedBlockStates,
447447
envVarValues: decryptedEnvVars,
448-
workflowInput: { input: message, conversationId },
448+
workflowInput: { input: input, conversationId },
449449
workflowVariables,
450450
contextExtensions: {
451451
stream: true,
@@ -463,8 +463,8 @@ export async function executeWorkflowForChat(
463463
if (result && 'success' in result) {
464464
result.logs?.forEach((log: BlockLog) => {
465465
if (streamedContent.has(log.blockId)) {
466-
if (log.output?.response) {
467-
log.output.response.content = streamedContent.get(log.blockId)
466+
if (log.output) {
467+
log.output.content = streamedContent.get(log.blockId)
468468
}
469469
}
470470
})

apps/sim/app/api/codegen/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Example Scenario:
239239
User Prompt: "Fetch user data from an API. Use the User ID passed in as 'userId' and an API Key stored as the 'SERVICE_API_KEY' environment variable."
240240
241241
Generated Code:
242-
const userId = <block.response.content>; // Correct: Accessing input parameter without quotes
242+
const userId = <block.content>; // Correct: Accessing input parameter without quotes
243243
const apiKey = {{SERVICE_API_KEY}}; // Correct: Accessing environment variable without quotes
244244
const url = \`https://api.example.com/users/\${userId}\`;
245245
@@ -273,7 +273,7 @@ Do not include import/require statements unless absolutely necessary and they ar
273273
Do not include markdown formatting or explanations.
274274
Output only the raw TypeScript code. Use modern TypeScript features where appropriate. Do not use semicolons.
275275
Example:
276-
const userId = <block.response.content> as string
276+
const userId = <block.content> as string
277277
const apiKey = {{SERVICE_API_KEY}}
278278
const response = await fetch(\`https://api.example.com/users/\${userId}\`, { headers: { Authorization: \`Bearer \${apiKey}\` } })
279279
if (!response.ok) {

apps/sim/app/api/providers/route.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,22 @@ export async function POST(request: NextRequest) {
137137
const safeExecutionData = {
138138
success: executionData.success,
139139
output: {
140-
response: {
141-
// Sanitize content to remove non-ASCII characters that would cause ByteString errors
142-
content: executionData.output?.response?.content
143-
? String(executionData.output.response.content).replace(/[\u0080-\uFFFF]/g, '')
144-
: '',
145-
model: executionData.output?.response?.model,
146-
tokens: executionData.output?.response?.tokens || {
147-
prompt: 0,
148-
completion: 0,
149-
total: 0,
150-
},
151-
// Sanitize any potential Unicode characters in tool calls
152-
toolCalls: executionData.output?.response?.toolCalls
153-
? sanitizeToolCalls(executionData.output.response.toolCalls)
154-
: undefined,
155-
providerTiming: executionData.output?.response?.providerTiming,
156-
cost: executionData.output?.response?.cost,
140+
// Sanitize content to remove non-ASCII characters that would cause ByteString errors
141+
content: executionData.output?.content
142+
? String(executionData.output.content).replace(/[\u0080-\uFFFF]/g, '')
143+
: '',
144+
model: executionData.output?.model,
145+
tokens: executionData.output?.tokens || {
146+
prompt: 0,
147+
completion: 0,
148+
total: 0,
157149
},
150+
// Sanitize any potential Unicode characters in tool calls
151+
toolCalls: executionData.output?.toolCalls
152+
? sanitizeToolCalls(executionData.output.toolCalls)
153+
: undefined,
154+
providerTiming: executionData.output?.providerTiming,
155+
cost: executionData.output?.cost,
158156
},
159157
error: executionData.error,
160158
logs: [], // Strip logs from header to avoid encoding issues

0 commit comments

Comments
 (0)