Skip to content

Commit cc33ab9

Browse files
committed
Get block options and config for subflows
1 parent fd5695e commit cc33ab9

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,64 @@ export const getBlockConfigServerTool: BaseServerTool<
356356
const logger = createLogger('GetBlockConfigServerTool')
357357
logger.debug('Executing get_block_config', { blockType, operation, trigger })
358358

359+
if (blockType === 'loop') {
360+
const result = {
361+
blockType,
362+
blockName: 'Loop',
363+
operation,
364+
trigger,
365+
inputs: {
366+
loopType: {
367+
type: 'string',
368+
description: 'Loop type',
369+
options: ['for', 'forEach', 'while', 'doWhile'],
370+
default: 'for',
371+
},
372+
iterations: {
373+
type: 'number',
374+
description: 'Number of iterations (for loop type "for")',
375+
},
376+
collection: {
377+
type: 'string',
378+
description: 'Collection to iterate (for loop type "forEach")',
379+
},
380+
condition: {
381+
type: 'string',
382+
description: 'Loop condition (for loop types "while" and "doWhile")',
383+
},
384+
},
385+
outputs: {},
386+
}
387+
return GetBlockConfigResult.parse(result)
388+
}
389+
390+
if (blockType === 'parallel') {
391+
const result = {
392+
blockType,
393+
blockName: 'Parallel',
394+
operation,
395+
trigger,
396+
inputs: {
397+
parallelType: {
398+
type: 'string',
399+
description: 'Parallel type',
400+
options: ['count', 'collection'],
401+
default: 'count',
402+
},
403+
count: {
404+
type: 'number',
405+
description: 'Number of parallel branches (for parallel type "count")',
406+
},
407+
collection: {
408+
type: 'string',
409+
description: 'Collection to branch over (for parallel type "collection")',
410+
},
411+
},
412+
outputs: {},
413+
}
414+
return GetBlockConfigResult.parse(result)
415+
}
416+
359417
const permissionConfig = context?.userId ? await getUserPermissionConfig(context.userId) : null
360418
const allowedIntegrations = permissionConfig?.allowedIntegrations
361419

apps/sim/lib/copilot/tools/server/blocks/get-block-options.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,32 @@ export const getBlockOptionsServerTool: BaseServerTool<
2121
const logger = createLogger('GetBlockOptionsServerTool')
2222
logger.debug('Executing get_block_options', { blockId })
2323

24+
if (blockId === 'loop') {
25+
const result = {
26+
blockId,
27+
blockName: 'Loop',
28+
operations: [
29+
{ id: 'for', name: 'For', description: 'Run a fixed number of iterations.' },
30+
{ id: 'forEach', name: 'For each', description: 'Iterate over a collection.' },
31+
{ id: 'while', name: 'While', description: 'Repeat while a condition is true.' },
32+
{ id: 'doWhile', name: 'Do while', description: 'Run once, then repeat while a condition is true.' },
33+
],
34+
}
35+
return GetBlockOptionsResult.parse(result)
36+
}
37+
38+
if (blockId === 'parallel') {
39+
const result = {
40+
blockId,
41+
blockName: 'Parallel',
42+
operations: [
43+
{ id: 'count', name: 'Count', description: 'Run a fixed number of parallel branches.' },
44+
{ id: 'collection', name: 'Collection', description: 'Run one branch per collection item.' },
45+
],
46+
}
47+
return GetBlockOptionsResult.parse(result)
48+
}
49+
2450
const permissionConfig = context?.userId ? await getUserPermissionConfig(context.userId) : null
2551
const allowedIntegrations = permissionConfig?.allowedIntegrations
2652

0 commit comments

Comments
 (0)