Skip to content

Commit 3838cb5

Browse files
committed
handle inputs
1 parent 9b543e2 commit 3838cb5

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class AIChatManager {
214214
this.systemMessage.content = this.NAVIGATION_SYSTEM_PROMPT + this.systemMessage.content
215215
const context = this.contextManager.getSelectedContext()
216216
const lang = this.scriptEditorOptions?.lang ?? 'bun'
217-
this.tools = [this.changeModeTool, ...prepareScriptTools(currentModel, lang, context)]
217+
this.tools = [...prepareScriptTools(currentModel, lang, context)]
218218
this.helpers = {
219219
getScriptOptions: () => {
220220
return {
@@ -238,7 +238,7 @@ class AIChatManager {
238238
const customPrompt = getCombinedCustomPrompt(mode)
239239
this.systemMessage = prepareFlowSystemMessage(customPrompt)
240240
this.systemMessage.content = this.NAVIGATION_SYSTEM_PROMPT + this.systemMessage.content
241-
this.tools = [this.changeModeTool, ...flowTools]
241+
this.tools = [...flowTools]
242242
this.helpers = this.flowAiChatHelpers
243243
} else if (mode === AIMode.NAVIGATOR) {
244244
const customPrompt = getCombinedCustomPrompt(mode)

frontend/src/lib/components/copilot/chat/flow/FlowAIChat.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,11 @@
620620
flowStore.val.value.failure_module = parsed.failure_module || undefined
621621
}
622622
623+
// Update schema if provided
624+
if (parsed.schema !== undefined) {
625+
flowStore.val.schema = parsed.schema
626+
}
627+
623628
// Mark all modules as modified
624629
const newModuleIds = dfsApply(flowStore.val.value.modules, (m) => m.id)
625630
for (const id of newModuleIds) {
@@ -642,6 +647,9 @@
642647
if (parsed.failure_module !== undefined) {
643648
setModuleStatus('failure', 'modified')
644649
}
650+
if (parsed.schema !== undefined) {
651+
setModuleStatus('Input', 'modified')
652+
}
645653
646654
// Refresh the state store to update UI
647655
refreshStateStore(flowStore)

frontend/src/lib/components/copilot/chat/flow/core.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ const setFlowYamlSchema = z.object({
6262
yaml: z
6363
.string()
6464
.describe(
65-
'Complete flow YAML including modules array, and optionally preprocessor_module and failure_module'
65+
'Complete flow YAML including modules array, and optionally schema (for flow inputs), preprocessor_module and failure_module'
6666
)
6767
})
6868

6969
const setFlowYamlToolDef = createToolDef(
7070
setFlowYamlSchema,
7171
'set_flow_yaml',
72-
'Set the entire flow structure using YAML. Use this for changes to the flow structure. The YAML should include the complete modules array, and optionally preprocessor_module and failure_module. All existing modules will be replaced.'
72+
'Set the entire flow structure using YAML. Use this for changes to the flow structure and/or input schema. The YAML should include the complete modules array, and optionally schema (for flow inputs), preprocessor_module and failure_module. All existing modules will be replaced.'
7373
)
7474

7575
class WorkspaceScriptsSearch {
@@ -377,6 +377,18 @@ When the user requests modifications to the flow structure (adding steps, removi
377377
### YAML Structure
378378
The YAML must include the complete flow definition:
379379
\`\`\`yaml
380+
schema: # optional - flow input schema
381+
$schema: "https://json-schema.org/draft/2020-12/schema"
382+
type: object
383+
properties:
384+
user_id:
385+
type: string
386+
description: "The user to process"
387+
count:
388+
type: number
389+
default: 10
390+
required: ["user_id"]
391+
order: ["user_id", "count"]
380392
modules:
381393
- id: step_a
382394
summary: "First step"
@@ -475,10 +487,12 @@ When creating new steps:
475487
4. Set appropriate \`input_transforms\` to pass data between steps
476488
477489
### Flow Input Schema
478-
The flow's input schema is defined separately in the flow object (not in YAML). When using \`flow_input\` properties, ensure they exist in the schema. For resource inputs, use:
490+
The flow's input schema can be included in the YAML at the top level using the \`schema\` key. It follows JSON Schema format. When using \`flow_input\` properties in modules, ensure they exist in the schema. For resource inputs, use:
479491
- Type: "object"
480492
- Format: "resource-<type>" (e.g., "resource-stripe")
481493
494+
If you need to add, modify, or remove flow input parameters, include the complete \`schema\` object at the top level of the YAML.
495+
482496
### Static Resource References
483497
To reference a specific resource in input_transforms, use: \`"$res:path/to/resource"\`
484498

0 commit comments

Comments
 (0)