windmill-components 1.522.0 → 1.531.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/components/AIAgentLogViewer.svelte +123 -0
- package/package/components/AIAgentLogViewer.svelte.d.ts +13 -0
- package/package/components/AppConnectInner.svelte +10 -10
- package/package/components/AutoscalingConfigEditor.svelte +76 -2
- package/package/components/Dev.svelte +12 -28
- package/package/components/DiffEditor.svelte +6 -3
- package/package/components/DiffEditor.svelte.d.ts +1 -0
- package/package/components/DisplayResult.svelte +16 -10
- package/package/components/DisplayResult.svelte.d.ts +1 -0
- package/package/components/EditableSchemaForm.svelte +5 -2
- package/package/components/Editor.svelte +26 -8
- package/package/components/Editor.svelte.d.ts +1 -1
- package/package/components/EditorBar.svelte +25 -5
- package/package/components/EditorSettings.svelte +6 -0
- package/package/components/FirstStepInputs.svelte +2 -2
- package/package/components/FlowBuilder.svelte +18 -36
- package/package/components/FlowGraphViewerStep.svelte +7 -0
- package/package/components/FlowJobResult.svelte +15 -63
- package/package/components/FlowJobResult.svelte.d.ts +10 -4
- package/package/components/FlowLogViewer.svelte +660 -0
- package/package/components/FlowLogViewer.svelte.d.ts +34 -0
- package/package/components/FlowLogViewerWrapper.svelte +52 -0
- package/package/components/FlowLogViewerWrapper.svelte.d.ts +21 -0
- package/package/components/FlowLoopIterationPreview.svelte +3 -3
- package/package/components/FlowPreviewContent.svelte +4 -5
- package/package/components/FlowPreviewContent.svelte.d.ts +7 -7
- package/package/components/FlowPreviewResult.svelte +4 -5
- package/package/components/FlowPreviewResult.svelte.d.ts +3 -5
- package/package/components/FlowStatusViewer.svelte +28 -16
- package/package/components/FlowStatusViewer.svelte.d.ts +19 -27
- package/package/components/FlowStatusViewerInner.svelte +483 -296
- package/package/components/FlowStatusViewerInner.svelte.d.ts +27 -33
- package/package/components/FlowTimeline.svelte +11 -13
- package/package/components/FlowTimeline.svelte.d.ts +6 -5
- package/package/components/FlowWrapper.svelte +3 -2
- package/package/components/HighlightCode.svelte +4 -1
- package/package/components/IconedResourceType.svelte +9 -5
- package/package/components/JobLoader.svelte +61 -8
- package/package/components/JobLoader.svelte.d.ts +9 -1
- package/package/components/LogViewer.svelte +8 -2
- package/package/components/LogViewer.svelte.d.ts +1 -0
- package/package/components/LogViewerHeader.svelte +32 -0
- package/package/components/LogViewerHeader.svelte.d.ts +8 -0
- package/package/components/ModulePreviewForm.svelte +10 -6
- package/package/components/ModulePreviewResultViewer.svelte +16 -0
- package/package/components/ModulePreviewResultViewer.svelte.d.ts +1 -1
- package/package/components/ModuleTest.svelte +59 -16
- package/package/components/RelativeLineNumbers.svelte +16 -0
- package/package/components/RelativeLineNumbers.svelte.d.ts +18 -0
- package/package/components/ResourceEditor.svelte +9 -4
- package/package/components/ScriptBuilder.svelte +13 -11
- package/package/components/ScriptEditor.svelte +2 -2
- package/package/components/SimpleEditor.svelte +10 -4
- package/package/components/SimpleEditor.svelte.d.ts +1 -0
- package/package/components/TemplateEditor.svelte +1 -1
- package/package/components/UserSettings.svelte +4 -4
- package/package/components/apps/components/display/AppAccordionList.svelte +1 -1
- package/package/components/apps/components/display/AppCarouselList.svelte +10 -8
- package/package/components/apps/components/display/AppJobIdFlowStatus.svelte +3 -3
- package/package/components/apps/components/display/table/AppAggridTable.svelte +2 -2
- package/package/components/apps/components/helpers/HiddenComponent.svelte +0 -1
- package/package/components/apps/components/helpers/InputValue.svelte +6 -1
- package/package/components/apps/components/helpers/NonRunnableComponent.svelte +8 -4
- package/package/components/apps/components/helpers/NonRunnableComponent.svelte.d.ts +1 -1
- package/package/components/apps/components/helpers/RunnableComponent.svelte +7 -8
- package/package/components/apps/components/helpers/RunnableComponent.svelte.d.ts +1 -1
- package/package/components/apps/components/helpers/RunnableWrapper.svelte +12 -3
- package/package/components/apps/components/helpers/RunnableWrapper.svelte.d.ts +1 -1
- package/package/components/apps/components/inputs/AppCodeInputComponent.svelte +0 -5
- package/package/components/apps/components/layout/AppConditionalWrapper.svelte +1 -1
- package/package/components/apps/components/layout/AppContainer.svelte +1 -1
- package/package/components/apps/components/layout/AppDecisionTree.svelte +31 -20
- package/package/components/apps/components/layout/AppDrawer.svelte +1 -1
- package/package/components/apps/components/layout/AppList.svelte +9 -8
- package/package/components/apps/components/layout/AppModal.svelte +1 -1
- package/package/components/apps/components/layout/AppSplitpanes.svelte +5 -2
- package/package/components/apps/components/layout/AppStepper.svelte +9 -5
- package/package/components/apps/components/layout/AppTabs.svelte +2 -2
- package/package/components/apps/editor/AppJobsDrawer.svelte +2 -2
- package/package/components/apps/editor/GridEditor.svelte +24 -19
- package/package/components/apps/editor/GridEditor.svelte.d.ts +4 -1
- package/package/components/apps/editor/GridViewer.svelte +1 -1
- package/package/components/apps/editor/SubGridEditor.svelte +7 -11
- package/package/components/apps/editor/SubGridEditor.svelte.d.ts +3 -19
- package/package/components/apps/editor/appUtils.js +17 -68
- package/package/components/apps/editor/component/ComponentInner.svelte +845 -694
- package/package/components/apps/editor/component/componentCallbacks.svelte.js +8 -1
- package/package/components/apps/editor/contextPanel/components/OutputHeader.svelte +9 -46
- package/package/components/apps/editor/settingsPanel/DecisionTreeGraphEditor.svelte +29 -43
- package/package/components/apps/editor/settingsPanel/InputsSpecEditor.svelte +2 -1
- package/package/components/apps/editor/settingsPanel/InputsSpecEditor.svelte.d.ts +1 -0
- package/package/components/apps/editor/settingsPanel/inputEditor/EvalV2InputEditor.svelte +2 -2
- package/package/components/apps/editor/settingsPanel/inputEditor/EvalV2InputEditor.svelte.d.ts +1 -0
- package/package/components/apps/svelte-grid/Grid.svelte +23 -25
- package/package/components/apps/svelte-grid/Grid.svelte.d.ts +21 -9
- package/package/components/apps/svelte-grid/MoveResize.svelte +13 -15
- package/package/components/apps/svelte-grid/MoveResize.svelte.d.ts +17 -24
- package/package/components/apps/utils.d.ts +2 -0
- package/package/components/apps/utils.js +22 -0
- package/package/components/auditLogs/AuditLogsFilters.svelte.d.ts +1 -1
- package/package/components/common/fileDownload/FileDownload.svelte +1 -3
- package/package/components/common/fileDownload/FileDownload.svelte.d.ts +4 -18
- package/package/components/common/languageIcons/LanguageIcon.svelte +5 -2
- package/package/components/copilot/FlowInlineScriptAIButton.svelte +58 -0
- package/package/components/copilot/FlowInlineScriptAIButton.svelte.d.ts +3 -0
- package/package/components/copilot/MetadataGen.svelte +19 -1
- package/package/components/copilot/MetadataGen.svelte.d.ts +1 -1
- package/package/components/copilot/ScriptGen.svelte +23 -31
- package/package/components/copilot/ScriptGen.svelte.d.ts +0 -1
- package/package/components/copilot/autocomplete/Autocompletor.js +2 -0
- package/package/components/copilot/chat/AIChatDisplay.svelte +4 -4
- package/package/components/copilot/chat/AIChatInput.svelte +29 -6
- package/package/components/copilot/chat/AIChatManager.svelte.js +110 -26
- package/package/components/copilot/chat/AIChatMessage.svelte +3 -0
- package/package/components/copilot/chat/ToolContentDisplay.svelte +84 -0
- package/package/components/copilot/chat/ToolContentDisplay.svelte.d.ts +11 -0
- package/package/components/copilot/chat/ToolExecutionDisplay.svelte +105 -0
- package/package/components/copilot/chat/ToolExecutionDisplay.svelte.d.ts +7 -0
- package/package/components/copilot/chat/api/apiTools.d.ts +7 -0
- package/package/components/copilot/chat/api/apiTools.js +192 -0
- package/package/components/copilot/chat/api/core.d.ts +7 -0
- package/package/components/copilot/chat/api/core.js +61 -0
- package/package/components/copilot/chat/flow/FlowAIChat.svelte +4 -6
- package/package/components/copilot/chat/flow/core.js +213 -42
- package/package/components/copilot/chat/flow/utils.js +3 -0
- package/package/components/copilot/chat/monaco-adapter.d.ts +1 -1
- package/package/components/copilot/chat/monaco-adapter.js +10 -4
- package/package/components/copilot/chat/navigator/core.d.ts +1 -1
- package/package/components/copilot/chat/navigator/core.js +20 -22
- package/package/components/copilot/chat/script/core.d.ts +11 -3
- package/package/components/copilot/chat/script/core.js +92 -15
- package/package/components/copilot/chat/shared.d.ts +30 -3
- package/package/components/copilot/chat/shared.js +228 -9
- package/package/components/copilot/lib.d.ts +1 -1
- package/package/components/copilot/lib.js +15 -6
- package/package/components/custom_ui.d.ts +2 -0
- package/package/components/details/DetailPageLayout.svelte +34 -33
- package/package/components/flow_builder.d.ts +1 -2
- package/package/components/flows/FlowEditor.svelte +3 -3
- package/package/components/flows/FlowEditor.svelte.d.ts +7 -6
- package/package/components/flows/common/FlowCard.svelte +2 -2
- package/package/components/flows/common/FlowCard.svelte.d.ts +1 -0
- package/package/components/flows/common/FlowCardHeader.svelte +13 -4
- package/package/components/flows/common/FlowCardHeader.svelte.d.ts +1 -0
- package/package/components/flows/content/BranchPredicateEditor.svelte +4 -7
- package/package/components/flows/content/BranchPredicateEditor.svelte.d.ts +12 -11
- package/package/components/flows/content/FlowConstants.svelte +3 -3
- package/package/components/flows/content/FlowEditorPanel.svelte +3 -3
- package/package/components/flows/content/FlowEditorPanel.svelte.d.ts +2 -4
- package/package/components/flows/content/FlowInputsQuick.svelte +2 -1
- package/package/components/flows/content/FlowLoop.svelte +2 -2
- package/package/components/flows/content/FlowModuleComponent.svelte +130 -108
- package/package/components/flows/content/FlowModuleComponent.svelte.d.ts +1 -0
- package/package/components/flows/content/FlowModuleEarlyStop.svelte +2 -2
- package/package/components/flows/content/FlowModuleSkip.svelte +1 -1
- package/package/components/flows/content/FlowModuleSleep.svelte +1 -1
- package/package/components/flows/content/FlowModuleSuspend.svelte +1 -1
- package/package/components/flows/content/FlowModuleWrapper.svelte +15 -5
- package/package/components/flows/content/FlowModuleWrapper.svelte.d.ts +1 -0
- package/package/components/flows/content/FlowResult.svelte +2 -3
- package/package/components/flows/content/FlowResult.svelte.d.ts +2 -4
- package/package/components/flows/content/FlowWhileLoop.svelte +1 -1
- package/package/components/flows/dfs.d.ts +3 -1
- package/package/components/flows/dfs.js +5 -1
- package/package/components/flows/flowInfers.js +78 -0
- package/package/components/flows/flowState.d.ts +2 -3
- package/package/components/flows/flowState.js +2 -2
- package/package/components/flows/flowStateUtils.svelte.d.ts +4 -4
- package/package/components/flows/flowStateUtils.svelte.js +14 -13
- package/package/components/flows/flowStore.d.ts +3 -4
- package/package/components/flows/header/FlowPreviewButtons.svelte +2 -1
- package/package/components/flows/header/FlowYamlEditor.svelte +10 -1
- package/package/components/flows/map/FlowGraphPreviewButton.svelte +1 -1
- package/package/components/flows/map/FlowJobsMenu.svelte +7 -3
- package/package/components/flows/map/FlowJobsMenu.svelte.d.ts +1 -0
- package/package/components/flows/map/FlowModuleSchemaItem.svelte +12 -12
- package/package/components/flows/map/FlowModuleSchemaMap.svelte +26 -19
- package/package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +6 -4
- package/package/components/flows/map/InsertModuleInner.svelte +9 -1
- package/package/components/flows/map/InsertModuleInner.svelte.d.ts +1 -0
- package/package/components/flows/map/MapItem.svelte +4 -2
- package/package/components/flows/pickers/TopLevelNode.svelte +4 -1
- package/package/components/flows/propPicker/InputPickerInner.svelte +5 -4
- package/package/components/flows/propPicker/OutputBadge.svelte +11 -9
- package/package/components/flows/propPicker/OutputPickerInner.svelte +10 -1
- package/package/components/flows/propPicker/OutputPickerInner.svelte.d.ts +1 -1
- package/package/components/flows/testSteps.svelte.d.ts +3 -2
- package/package/components/flows/testSteps.svelte.js +26 -23
- package/package/components/flows/types.d.ts +1 -1
- package/package/components/flows/utils.d.ts +3 -5
- package/package/components/flows/utils.js +3 -4
- package/package/components/git_sync/GitSyncContext.svelte.js +2 -1
- package/package/components/graph/FlowGraphV2.svelte +44 -24
- package/package/components/graph/FlowGraphV2.svelte.d.ts +5 -2
- package/package/components/graph/graphBuilder.svelte.d.ts +49 -17
- package/package/components/graph/graphBuilder.svelte.js +30 -14
- package/package/components/graph/model.d.ts +9 -6
- package/package/components/graph/renderers/edges/BaseEdge.svelte +3 -3
- package/package/components/graph/renderers/edges/BaseEdge.svelte.d.ts +2 -3
- package/package/components/graph/renderers/nodes/AIToolNode.svelte +234 -0
- package/package/components/graph/renderers/nodes/AIToolNode.svelte.d.ts +24 -0
- package/package/components/graph/renderers/nodes/AssetNode.svelte +15 -10
- package/package/components/graph/renderers/nodes/AssetNode.svelte.d.ts +18 -1
- package/package/components/graph/renderers/nodes/BranchAllEndNode.svelte +1 -1
- package/package/components/graph/renderers/nodes/BranchAllStart.svelte +1 -1
- package/package/components/graph/renderers/nodes/BranchOneStart.svelte +1 -1
- package/package/components/graph/renderers/nodes/ForLoopEndNode.svelte +2 -2
- package/package/components/graph/renderers/nodes/ForLoopStartNode.svelte +1 -1
- package/package/components/graph/renderers/nodes/ModuleNode.svelte +21 -21
- package/package/components/graph/renderers/nodes/NewAIToolNode.svelte +64 -0
- package/package/components/graph/renderers/nodes/NewAIToolNode.svelte.d.ts +7 -0
- package/package/components/graph/renderers/nodes/branchOneEndNode.svelte +1 -1
- package/package/components/icons/RubyIcon.svelte +656 -0
- package/package/components/icons/RubyIcon.svelte.d.ts +7 -0
- package/package/components/instanceSettings.js +9 -0
- package/package/components/modulesTest.svelte.d.ts +6 -3
- package/package/components/modulesTest.svelte.js +32 -0
- package/package/components/preview/FlowPreviewStatus.svelte +3 -1
- package/package/components/raw_apps/RawAppEditor.svelte +27 -26
- package/package/components/raw_apps/RawAppEditor.svelte.d.ts +17 -17
- package/package/components/runs/{JobPreview.svelte → JobRunsPreview.svelte} +1 -4
- package/package/components/runs/{JobPreview.svelte.d.ts → JobRunsPreview.svelte.d.ts} +3 -3
- package/package/components/runs/RunRow.svelte +5 -1
- package/package/components/schema/AddProperty.svelte +41 -36
- package/package/components/schema/AddProperty.svelte.d.ts +2 -2
- package/package/components/schema/AddPropertyV2.svelte +41 -37
- package/package/components/schema/AddPropertyV2.svelte.d.ts +1 -1
- package/package/components/schema/FlowPropertyEditor.svelte +8 -6
- package/package/components/search/RunsSearch.svelte +1 -1
- package/package/components/settings/CreateToken.svelte +132 -12
- package/package/components/settings/CreateToken.svelte.d.ts +3 -20
- package/package/components/settings/TokenDisplay.svelte +18 -42
- package/package/components/settings/TokenDisplay.svelte.d.ts +0 -1
- package/package/components/settings/TokensTable.svelte +2 -4
- package/package/components/settings/TokensTable.svelte.d.ts +3 -19
- package/package/components/settings/WorkspaceUserSettings.svelte +428 -69
- package/package/components/sidebar/MenuButton.svelte +12 -10
- package/package/components/stepHistoryLoader.svelte.d.ts +2 -2
- package/package/components/stepHistoryLoader.svelte.js +7 -12
- package/package/components/triggers/http/OpenAPISpecGenerator.svelte +2 -2
- package/package/components/tutorials/FlowBuilderTutorialBranchOne.svelte +1 -1
- package/package/components/tutorials/FlowBuilderTutorialForLoop.svelte +4 -4
- package/package/components/tutorials/utils.js +3 -0
- package/package/components/worker_group.d.ts +4 -1
- package/package/components/worker_group.js +3 -2
- package/package/editorLangUtils.d.ts +1 -1
- package/package/editorLangUtils.js +2 -0
- package/package/editorUtils.d.ts +2 -1
- package/package/editorUtils.js +2 -1
- package/package/gen/core/OpenAPI.js +1 -1
- package/package/gen/schemas.gen.d.ts +296 -8
- package/package/gen/schemas.gen.js +364 -70
- package/package/gen/services.gen.d.ts +118 -16
- package/package/gen/services.gen.js +226 -19
- package/package/gen/types.gen.d.ts +660 -16
- package/package/hubPaths.json +7 -4
- package/package/infer.js +10 -1
- package/package/monaco_workers/graphql.worker.bundle.js +144 -110
- package/package/script_helpers.d.ts +3 -0
- package/package/script_helpers.js +58 -3
- package/package/scripts.d.ts +1 -1
- package/package/scripts.js +3 -2
- package/package/stores.d.ts +2 -0
- package/package/stores.js +2 -0
- package/package/svelte5Utils.svelte.d.ts +16 -0
- package/package/svelte5Utils.svelte.js +26 -0
- package/package/utils.d.ts +1 -1
- package/package.json +20 -19
- package/package/components/AllFlowLogs.svelte +0 -31
- package/package/components/AllFlowLogs.svelte.d.ts +0 -8
- package/package/components/copilot/chat/navigator/apiTools.d.ts +0 -68
- package/package/components/copilot/chat/navigator/apiTools.js +0 -258
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ScriptService } from '../../../../gen';
|
|
1
|
+
import { ScriptService, JobService } from '../../../../gen';
|
|
2
2
|
import YAML from 'yaml';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import uFuzzy from '@leeoniya/ufuzzy';
|
|
5
5
|
import { emptySchema, emptyString } from '../../../../utils';
|
|
6
6
|
import { getFormattedResourceTypes, getLangContext, SUPPORTED_CHAT_SCRIPT_LANGUAGES } from '../script/core';
|
|
7
|
-
import { createSearchHubScriptsTool, createToolDef } from '../shared';
|
|
7
|
+
import { createSearchHubScriptsTool, createToolDef, executeTestRun, buildSchemaForTool, buildTestRunArgs } from '../shared';
|
|
8
8
|
const searchScriptsSchema = z.object({
|
|
9
9
|
query: z
|
|
10
10
|
.string()
|
|
@@ -186,20 +186,39 @@ const getInstructionsForCodeGenerationToolSchema = z.object({
|
|
|
186
186
|
language: langSchema.describe('The programming language the code will be written in')
|
|
187
187
|
});
|
|
188
188
|
const getInstructionsForCodeGenerationToolDef = createToolDef(getInstructionsForCodeGenerationToolSchema, 'get_instructions_for_code_generation', 'Get instructions for code generation for a raw script step');
|
|
189
|
+
// Will be overridden by setSchema
|
|
190
|
+
const testRunFlowSchema = z.object({
|
|
191
|
+
args: z.object({}).nullable().optional()
|
|
192
|
+
.describe('Arguments to pass to the flow (optional, uses default flow inputs if not provided)')
|
|
193
|
+
});
|
|
194
|
+
const testRunFlowToolDef = createToolDef(testRunFlowSchema, 'test_run_flow', 'Execute a test run of the current flow');
|
|
195
|
+
const testRunStepSchema = z.object({
|
|
196
|
+
stepId: z.string().describe('The id of the step to test'),
|
|
197
|
+
args: z
|
|
198
|
+
.object({})
|
|
199
|
+
.nullable()
|
|
200
|
+
.optional()
|
|
201
|
+
.describe('Arguments to pass to the step (optional, uses default step inputs if not provided)')
|
|
202
|
+
});
|
|
203
|
+
const testRunStepToolDef = createToolDef(testRunStepSchema, 'test_run_step', 'Execute a test run of a specific step in the flow');
|
|
189
204
|
const workspaceScriptsSearch = new WorkspaceScriptsSearch();
|
|
190
205
|
export const flowTools = [
|
|
191
206
|
createSearchHubScriptsTool(false),
|
|
192
207
|
{
|
|
193
208
|
def: searchScriptsToolDef,
|
|
194
209
|
fn: async ({ args, workspace, toolId, toolCallbacks }) => {
|
|
195
|
-
toolCallbacks.setToolStatus(toolId,
|
|
210
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
211
|
+
content: 'Searching for workspace scripts related to "' + args.query + '"...'
|
|
212
|
+
});
|
|
196
213
|
const parsedArgs = searchScriptsSchema.parse(args);
|
|
197
214
|
const scriptResults = await workspaceScriptsSearch.search(parsedArgs.query, workspace);
|
|
198
|
-
toolCallbacks.setToolStatus(toolId,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
215
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
216
|
+
content: 'Found ' +
|
|
217
|
+
scriptResults.length +
|
|
218
|
+
' scripts in the workspace related to "' +
|
|
219
|
+
args.query +
|
|
220
|
+
'"'
|
|
221
|
+
});
|
|
203
222
|
return JSON.stringify(scriptResults);
|
|
204
223
|
}
|
|
205
224
|
},
|
|
@@ -207,74 +226,76 @@ export const flowTools = [
|
|
|
207
226
|
def: addStepToolDef,
|
|
208
227
|
fn: async ({ args, helpers, toolId, toolCallbacks }) => {
|
|
209
228
|
const parsedArgs = addStepSchema.parse(args);
|
|
210
|
-
toolCallbacks.setToolStatus(toolId,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
229
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
230
|
+
content: parsedArgs.location.type === 'after'
|
|
231
|
+
? `Adding a step after step '${parsedArgs.location.afterId}'`
|
|
232
|
+
: parsedArgs.location.type === 'start'
|
|
233
|
+
? 'Adding a step at the start'
|
|
234
|
+
: parsedArgs.location.type === 'start_inside_forloop'
|
|
235
|
+
? `Adding a step at the start of the forloop step '${parsedArgs.location.inside}'`
|
|
236
|
+
: parsedArgs.location.type === 'start_inside_branch'
|
|
237
|
+
? `Adding a step at the start of the branch ${parsedArgs.location.branchIndex + 1} of step '${parsedArgs.location.inside}'`
|
|
238
|
+
: parsedArgs.location.type === 'preprocessor'
|
|
239
|
+
? 'Adding a preprocessor step'
|
|
240
|
+
: parsedArgs.location.type === 'failure'
|
|
241
|
+
? 'Adding a failure step'
|
|
242
|
+
: 'Adding a step'
|
|
243
|
+
});
|
|
223
244
|
const id = await helpers.insertStep(parsedArgs.location, parsedArgs.step);
|
|
224
245
|
helpers.selectStep(id);
|
|
225
|
-
toolCallbacks.setToolStatus(toolId, `Added step '${id}'`);
|
|
246
|
+
toolCallbacks.setToolStatus(toolId, { content: `Added step '${id}'` });
|
|
226
247
|
return `Step ${id} added. Here is the updated flow, make sure to take it into account when adding another step:\n${YAML.stringify(helpers.getModules())}`;
|
|
227
248
|
}
|
|
228
249
|
},
|
|
229
250
|
{
|
|
230
251
|
def: removeStepToolDef,
|
|
231
252
|
fn: async ({ args, helpers, toolId, toolCallbacks }) => {
|
|
232
|
-
toolCallbacks.setToolStatus(toolId, `Removing step ${args.id}...`);
|
|
253
|
+
toolCallbacks.setToolStatus(toolId, { content: `Removing step ${args.id}...` });
|
|
233
254
|
const parsedArgs = removeStepSchema.parse(args);
|
|
234
255
|
helpers.removeStep(parsedArgs.id);
|
|
235
|
-
toolCallbacks.setToolStatus(toolId, `Removed step '${parsedArgs.id}'`);
|
|
256
|
+
toolCallbacks.setToolStatus(toolId, { content: `Removed step '${parsedArgs.id}'` });
|
|
236
257
|
return `Step '${parsedArgs.id}' removed. Here is the updated flow:\n${YAML.stringify(helpers.getModules())}`;
|
|
237
258
|
}
|
|
238
259
|
},
|
|
239
260
|
{
|
|
240
261
|
def: getStepInputsToolDef,
|
|
241
262
|
fn: async ({ args, helpers, toolId, toolCallbacks }) => {
|
|
242
|
-
toolCallbacks.setToolStatus(toolId, `Getting step ${args.id} inputs...`);
|
|
263
|
+
toolCallbacks.setToolStatus(toolId, { content: `Getting step ${args.id} inputs...` });
|
|
243
264
|
const parsedArgs = getStepInputsSchema.parse(args);
|
|
244
265
|
const inputs = await helpers.getStepInputs(parsedArgs.id);
|
|
245
|
-
toolCallbacks.setToolStatus(toolId, `Retrieved step '${parsedArgs.id}' inputs`);
|
|
266
|
+
toolCallbacks.setToolStatus(toolId, { content: `Retrieved step '${parsedArgs.id}' inputs` });
|
|
246
267
|
return YAML.stringify(inputs);
|
|
247
268
|
}
|
|
248
269
|
},
|
|
249
270
|
{
|
|
250
271
|
def: setStepInputsToolDef,
|
|
251
272
|
fn: async ({ args, helpers, toolId, toolCallbacks }) => {
|
|
252
|
-
toolCallbacks.setToolStatus(toolId, `Setting step ${args.id} inputs...`);
|
|
273
|
+
toolCallbacks.setToolStatus(toolId, { content: `Setting step ${args.id} inputs...` });
|
|
253
274
|
const parsedArgs = setStepInputsSchema.parse(args);
|
|
254
275
|
await helpers.setStepInputs(parsedArgs.id, parsedArgs.inputs);
|
|
255
276
|
helpers.selectStep(parsedArgs.id);
|
|
256
277
|
const inputs = await helpers.getStepInputs(parsedArgs.id);
|
|
257
|
-
toolCallbacks.setToolStatus(toolId, `Set step '${parsedArgs.id}' inputs`);
|
|
278
|
+
toolCallbacks.setToolStatus(toolId, { content: `Set step '${parsedArgs.id}' inputs` });
|
|
258
279
|
return `Step '${parsedArgs.id}' inputs set. New inputs:\n${YAML.stringify(inputs)}`;
|
|
259
280
|
},
|
|
260
281
|
preAction: ({ toolCallbacks, toolId }) => {
|
|
261
|
-
toolCallbacks.setToolStatus(toolId, 'Setting step inputs...');
|
|
282
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Setting step inputs...' });
|
|
262
283
|
}
|
|
263
284
|
},
|
|
264
285
|
{
|
|
265
286
|
def: setFlowInputsSchemaToolDef,
|
|
266
287
|
fn: async ({ args, helpers, toolId, toolCallbacks }) => {
|
|
267
|
-
toolCallbacks.setToolStatus(toolId, 'Setting flow inputs schema...');
|
|
288
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Setting flow inputs schema...' });
|
|
268
289
|
const parsedArgs = setFlowInputsSchemaSchema.parse(args);
|
|
269
290
|
const schema = JSON.parse(parsedArgs.schema);
|
|
270
291
|
await helpers.setFlowInputsSchema(schema);
|
|
271
292
|
helpers.selectStep('Input');
|
|
272
293
|
const updatedSchema = await helpers.getFlowInputsSchema();
|
|
273
|
-
toolCallbacks.setToolStatus(toolId, 'Set flow inputs schema');
|
|
294
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Set flow inputs schema' });
|
|
274
295
|
return `Flow inputs schema set. New schema:\n${JSON.stringify(updatedSchema)}`;
|
|
275
296
|
},
|
|
276
297
|
preAction: ({ toolCallbacks, toolId }) => {
|
|
277
|
-
toolCallbacks.setToolStatus(toolId, 'Setting flow inputs schema...');
|
|
298
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Setting flow inputs schema...' });
|
|
278
299
|
}
|
|
279
300
|
},
|
|
280
301
|
{
|
|
@@ -285,7 +306,9 @@ export const flowTools = [
|
|
|
285
306
|
allowResourcesFetch: true,
|
|
286
307
|
isPreprocessor: parsedArgs.id === 'preprocessor'
|
|
287
308
|
});
|
|
288
|
-
toolCallbacks.setToolStatus(toolId,
|
|
309
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
310
|
+
content: 'Retrieved instructions for code generation in ' + parsedArgs.language
|
|
311
|
+
});
|
|
289
312
|
return langContext;
|
|
290
313
|
}
|
|
291
314
|
},
|
|
@@ -293,14 +316,16 @@ export const flowTools = [
|
|
|
293
316
|
def: setCodeToolDef,
|
|
294
317
|
fn: async ({ args, helpers, toolId, toolCallbacks }) => {
|
|
295
318
|
const parsedArgs = setCodeSchema.parse(args);
|
|
296
|
-
toolCallbacks.setToolStatus(toolId,
|
|
319
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
320
|
+
content: `Setting code for step '${parsedArgs.id}'...`
|
|
321
|
+
});
|
|
297
322
|
await helpers.setCode(parsedArgs.id, parsedArgs.code);
|
|
298
323
|
helpers.selectStep(parsedArgs.id);
|
|
299
|
-
toolCallbacks.setToolStatus(toolId, `Set code for step '${parsedArgs.id}'`);
|
|
324
|
+
toolCallbacks.setToolStatus(toolId, { content: `Set code for step '${parsedArgs.id}'` });
|
|
300
325
|
return `Step code set`;
|
|
301
326
|
},
|
|
302
327
|
preAction: ({ toolCallbacks, toolId }) => {
|
|
303
|
-
toolCallbacks.setToolStatus(toolId, 'Setting code for step...');
|
|
328
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Setting code for step...' });
|
|
304
329
|
}
|
|
305
330
|
},
|
|
306
331
|
{
|
|
@@ -309,7 +334,9 @@ export const flowTools = [
|
|
|
309
334
|
const parsedArgs = setBranchPredicateSchema.parse(args);
|
|
310
335
|
await helpers.setBranchPredicate(parsedArgs.id, parsedArgs.branchIndex, parsedArgs.expression);
|
|
311
336
|
helpers.selectStep(parsedArgs.id);
|
|
312
|
-
toolCallbacks.setToolStatus(toolId,
|
|
337
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
338
|
+
content: `Set predicate of branch ${parsedArgs.branchIndex + 1} of '${parsedArgs.id}'`
|
|
339
|
+
});
|
|
313
340
|
return `Branch ${parsedArgs.branchIndex} of '${parsedArgs.id}' predicate set`;
|
|
314
341
|
}
|
|
315
342
|
},
|
|
@@ -319,7 +346,7 @@ export const flowTools = [
|
|
|
319
346
|
const parsedArgs = addBranchSchema.parse(args);
|
|
320
347
|
await helpers.addBranch(parsedArgs.id);
|
|
321
348
|
helpers.selectStep(parsedArgs.id);
|
|
322
|
-
toolCallbacks.setToolStatus(toolId, `Added branch to '${parsedArgs.id}'`);
|
|
349
|
+
toolCallbacks.setToolStatus(toolId, { content: `Added branch to '${parsedArgs.id}'` });
|
|
323
350
|
return `Branch added to '${parsedArgs.id}'`;
|
|
324
351
|
}
|
|
325
352
|
},
|
|
@@ -329,7 +356,9 @@ export const flowTools = [
|
|
|
329
356
|
const parsedArgs = removeBranchSchema.parse(args);
|
|
330
357
|
await helpers.removeBranch(parsedArgs.id, parsedArgs.branchIndex);
|
|
331
358
|
helpers.selectStep(parsedArgs.id);
|
|
332
|
-
toolCallbacks.setToolStatus(toolId,
|
|
359
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
360
|
+
content: `Removed branch ${parsedArgs.branchIndex + 1} of '${parsedArgs.id}'`
|
|
361
|
+
});
|
|
333
362
|
return `Branch ${parsedArgs.branchIndex} of '${parsedArgs.id}' removed`;
|
|
334
363
|
}
|
|
335
364
|
},
|
|
@@ -339,7 +368,9 @@ export const flowTools = [
|
|
|
339
368
|
const parsedArgs = setForLoopIteratorExpressionSchema.parse(args);
|
|
340
369
|
await helpers.setForLoopIteratorExpression(parsedArgs.id, parsedArgs.expression);
|
|
341
370
|
helpers.selectStep(parsedArgs.id);
|
|
342
|
-
toolCallbacks.setToolStatus(toolId,
|
|
371
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
372
|
+
content: `Set forloop '${parsedArgs.id}' iterator expression`
|
|
373
|
+
});
|
|
343
374
|
return `Forloop '${parsedArgs.id}' iterator expression set`;
|
|
344
375
|
}
|
|
345
376
|
},
|
|
@@ -347,11 +378,150 @@ export const flowTools = [
|
|
|
347
378
|
def: resourceTypeToolDef,
|
|
348
379
|
fn: async ({ args, toolId, workspace, toolCallbacks }) => {
|
|
349
380
|
const parsedArgs = resourceTypeToolSchema.parse(args);
|
|
350
|
-
toolCallbacks.setToolStatus(toolId,
|
|
381
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
382
|
+
content: 'Searching resource types for "' + parsedArgs.query + '"...'
|
|
383
|
+
});
|
|
351
384
|
const formattedResourceTypes = await getFormattedResourceTypes(parsedArgs.language, parsedArgs.query, workspace);
|
|
352
|
-
toolCallbacks.setToolStatus(toolId,
|
|
385
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
386
|
+
content: 'Retrieved resource types for "' + parsedArgs.query + '"'
|
|
387
|
+
});
|
|
353
388
|
return formattedResourceTypes;
|
|
354
389
|
}
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
def: testRunFlowToolDef,
|
|
393
|
+
fn: async function ({ args, workspace, helpers, toolCallbacks, toolId }) {
|
|
394
|
+
const { flow } = helpers.getFlowAndSelectedId();
|
|
395
|
+
if (!flow || !flow.value) {
|
|
396
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
397
|
+
content: 'No flow available to test',
|
|
398
|
+
error: 'No flow found in current context'
|
|
399
|
+
});
|
|
400
|
+
throw new Error('No flow available to test. Please ensure you have a flow open in the editor.');
|
|
401
|
+
}
|
|
402
|
+
const parsedArgs = await buildTestRunArgs(args, this.def);
|
|
403
|
+
return executeTestRun({
|
|
404
|
+
jobStarter: () => JobService.runFlowPreview({
|
|
405
|
+
workspace: workspace,
|
|
406
|
+
requestBody: {
|
|
407
|
+
args: parsedArgs,
|
|
408
|
+
value: flow.value,
|
|
409
|
+
}
|
|
410
|
+
}),
|
|
411
|
+
workspace,
|
|
412
|
+
toolCallbacks,
|
|
413
|
+
toolId,
|
|
414
|
+
startMessage: 'Starting flow test run...',
|
|
415
|
+
contextName: 'flow'
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
setSchema: async function (helpers) {
|
|
419
|
+
await buildSchemaForTool(this.def, async () => {
|
|
420
|
+
const flowInputsSchema = await helpers.getFlowInputsSchema();
|
|
421
|
+
return flowInputsSchema;
|
|
422
|
+
});
|
|
423
|
+
},
|
|
424
|
+
requiresConfirmation: true,
|
|
425
|
+
confirmationMessage: 'Run flow test',
|
|
426
|
+
showDetails: true
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
// set strict to false to avoid issues with open ai models
|
|
430
|
+
def: { ...testRunStepToolDef, function: { ...testRunStepToolDef.function, strict: false } },
|
|
431
|
+
fn: async ({ args, workspace, helpers, toolCallbacks, toolId }) => {
|
|
432
|
+
const { flow } = helpers.getFlowAndSelectedId();
|
|
433
|
+
if (!flow || !flow.value) {
|
|
434
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
435
|
+
content: 'No flow available to test step from',
|
|
436
|
+
error: 'No flow found in current context'
|
|
437
|
+
});
|
|
438
|
+
throw new Error('No flow available to test step from. Please ensure you have a flow open in the editor.');
|
|
439
|
+
}
|
|
440
|
+
const stepId = args.stepId;
|
|
441
|
+
const stepArgs = args.args || {};
|
|
442
|
+
// Find the step in the flow
|
|
443
|
+
const modules = helpers.getModules();
|
|
444
|
+
let targetModule = modules.find((m) => m.id === stepId);
|
|
445
|
+
if (!targetModule) {
|
|
446
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
447
|
+
content: `Step '${stepId}' not found in flow`,
|
|
448
|
+
error: `Step with id '${stepId}' does not exist in the current flow`
|
|
449
|
+
});
|
|
450
|
+
throw new Error(`Step with id '${stepId}' not found in flow. Available steps: ${modules.map((m) => m.id).join(', ')}`);
|
|
451
|
+
}
|
|
452
|
+
const module = targetModule;
|
|
453
|
+
const moduleValue = module.value;
|
|
454
|
+
if (moduleValue.type === 'rawscript') {
|
|
455
|
+
// Test raw script step
|
|
456
|
+
return executeTestRun({
|
|
457
|
+
jobStarter: () => JobService.runScriptPreview({
|
|
458
|
+
workspace: workspace,
|
|
459
|
+
requestBody: {
|
|
460
|
+
content: moduleValue.content ?? '',
|
|
461
|
+
language: moduleValue.language,
|
|
462
|
+
args: module.id === 'preprocessor' ? { _ENTRYPOINT_OVERRIDE: 'preprocessor', ...stepArgs } : stepArgs
|
|
463
|
+
}
|
|
464
|
+
}),
|
|
465
|
+
workspace,
|
|
466
|
+
toolCallbacks,
|
|
467
|
+
toolId,
|
|
468
|
+
startMessage: `Starting test run of step '${stepId}'...`,
|
|
469
|
+
contextName: 'script'
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
else if (moduleValue.type === 'script') {
|
|
473
|
+
// Test script step - need to get the script content
|
|
474
|
+
const script = moduleValue.hash
|
|
475
|
+
? await ScriptService.getScriptByHash({
|
|
476
|
+
workspace: workspace,
|
|
477
|
+
hash: moduleValue.hash
|
|
478
|
+
})
|
|
479
|
+
: await ScriptService.getScriptByPath({
|
|
480
|
+
workspace: workspace,
|
|
481
|
+
path: moduleValue.path
|
|
482
|
+
});
|
|
483
|
+
return executeTestRun({
|
|
484
|
+
jobStarter: () => JobService.runScriptPreview({
|
|
485
|
+
workspace: workspace,
|
|
486
|
+
requestBody: {
|
|
487
|
+
content: script.content,
|
|
488
|
+
language: script.language,
|
|
489
|
+
args: module.id === 'preprocessor' ? { _ENTRYPOINT_OVERRIDE: 'preprocessor', ...stepArgs } : stepArgs,
|
|
490
|
+
}
|
|
491
|
+
}),
|
|
492
|
+
workspace,
|
|
493
|
+
toolCallbacks,
|
|
494
|
+
toolId,
|
|
495
|
+
startMessage: `Starting test run of script step '${stepId}'...`,
|
|
496
|
+
contextName: 'script'
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
else if (moduleValue.type === 'flow') {
|
|
500
|
+
// Test flow step
|
|
501
|
+
return executeTestRun({
|
|
502
|
+
jobStarter: () => JobService.runFlowByPath({
|
|
503
|
+
workspace: workspace,
|
|
504
|
+
path: moduleValue.path,
|
|
505
|
+
requestBody: stepArgs
|
|
506
|
+
}),
|
|
507
|
+
workspace,
|
|
508
|
+
toolCallbacks,
|
|
509
|
+
toolId,
|
|
510
|
+
startMessage: `Starting test run of flow step '${stepId}'...`,
|
|
511
|
+
contextName: 'flow'
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
516
|
+
content: `Step type '${moduleValue.type}' not supported for testing`,
|
|
517
|
+
error: `Cannot test step of type '${moduleValue.type}'`
|
|
518
|
+
});
|
|
519
|
+
throw new Error(`Cannot test step of type '${moduleValue.type}'. Supported types: rawscript, script, flow`);
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
requiresConfirmation: true,
|
|
523
|
+
confirmationMessage: 'Run flow step test',
|
|
524
|
+
showDetails: true
|
|
355
525
|
}
|
|
356
526
|
];
|
|
357
527
|
export function prepareFlowSystemMessage() {
|
|
@@ -359,6 +529,7 @@ export function prepareFlowSystemMessage() {
|
|
|
359
529
|
Follow the user instructions carefully.
|
|
360
530
|
Go step by step, and explain what you're doing as you're doing it.
|
|
361
531
|
DO NOT wait for user confirmation before performing an action. Only do it if the user explicitly asks you to wait in their initial instructions.
|
|
532
|
+
ALWAYS test your modifications. You have access to the \`test_run_flow\` and \`test_run_step\` tools to test the flow and steps. If you only modified a single step, use the \`test_run_step\` tool to test it. If you modified the flow, use the \`test_run_flow\` tool to test it. If the user cancels the test run, do not try again and wait for the next user instruction.
|
|
362
533
|
|
|
363
534
|
## Understanding User Requests
|
|
364
535
|
|
|
@@ -147,7 +147,7 @@ export class AIChatEditorHandler {
|
|
|
147
147
|
}
|
|
148
148
|
return changedLines;
|
|
149
149
|
}
|
|
150
|
-
async reviewAndApply(newCode) {
|
|
150
|
+
async reviewAndApply(newCode, applyAll = false) {
|
|
151
151
|
if (aiChatManager.pendingNewCode === newCode) {
|
|
152
152
|
this.acceptAll();
|
|
153
153
|
return;
|
|
@@ -204,9 +204,15 @@ export class AIChatEditorHandler {
|
|
|
204
204
|
return c;
|
|
205
205
|
}
|
|
206
206
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
if (!applyAll) {
|
|
208
|
+
;
|
|
209
|
+
({ collection, ids } = await displayVisualChanges('editor-windmill-chat-style', this.editor, changes));
|
|
210
|
+
this.decorationsCollections.push(collection);
|
|
211
|
+
this.viewZoneIds.push(...ids);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (applyAll) {
|
|
215
|
+
this.acceptAll();
|
|
210
216
|
}
|
|
211
217
|
}
|
|
212
218
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam } from 'openai/resources/index.mjs';
|
|
2
2
|
import type { Tool } from '../shared';
|
|
3
|
-
export declare const CHAT_SYSTEM_PROMPT:
|
|
3
|
+
export declare const CHAT_SYSTEM_PROMPT = "\nYou are Windmill's intelligent assistant, designed to help users navigate the application and answer questions about its functionality. It is your only purpose to help the user in the context of the windmill application.\nWindmill is an open-source developer platform for building internal tools, API integrations, background jobs, workflows, and user interfaces. It offers a unified system where scripts are automatically turned into sharable UIs and can be composed into flows or embedded in custom applications.\n\nYou have access to these tools:\n1. View current buttons and inputs on the page (get_triggerable_components)\n2. Execute buttons and inputs (trigger_component) \n3. Get documentation for user requests (get_documentation)\n4. Change the AI mode to the one specified (change_mode)\n\nINSTRUCTIONS:\n- When users ask about application features or concepts, first use get_documentation internally to retrieve accurate information about how to fulfill the user's request.\n- Then immediately use the available tools to guide the user through the application. Do not wait for the user's confirmation before taking action.\n- If you detect a confirmation modal that needs user confirmation, stop the navigation and let the user know that the action is pending confirmation.\n- Use get_triggerable_components to understand available options, and then trigger the components using trigger_component. Then wait a moment before rescanning the current page, and then continue with the next step. Do this 5 times max.\n- Make sure you navigated as far as possible before responding to the user. Always use get_triggerable_components one last time to make sure you didn't miss anything.\n- If you are not able to fulfill the user's request after 5 attempts, redirect the user to the documentation.\n- If you are asked to fill a form or act on an input, input the existing json object and change the fields the user asked you to change. Take into account the prompt_for_ai field of the schema to know what and how to do changes. Then tell the user that you have updated the form, and ask him to review the changes before running the script or flow.\n- For form inputs where format starts with \"resource-\" and is not \"resource-obj\", fetch the available resources using get_available_resources, and then use the resource_path prefixed with \"$res:\" to fill the input.\n- If you are not sure about an input, set the ones you are sure about, and then ask the user for the value of the input you are not sure about.\n- If the user asks you to make an API call, switch to API mode with the change_mode tool before using the new tools you'll have access to to make the API call.\n\nGENERAL PRINCIPLES:\n- Be concise but thorough\n- Focus on taking action and completing the user's goals\n- Maintain a friendly, professional tone\n- If you encounter an error or can't complete a request, explain why and suggest alternatives\n- When asked about a specific script, flow or app, first check components directly related to the mentioned entity, before checking the other components.\n- When you do not find what you are looking for on the current page, go to the home page by looking for the \"Home\" component, then scan the components again.\n\nIMPORTANT CONSIDERATIONS:\n- The user might have changed the page in the middle of the conversation, so make sure you rescan the page on each user request instead of just responding that you cannot find what the user is asking for.\n- If you navigate to a script creation page, consider this:\n - The page opens with the settings drawer open. After doing the changes mentioned by the user, close the settings drawer.\n - Then if the user has described what he wanted the script to do, switch to script mode with the change_mode tool, and use the new tools you'll have access to to edit the script.\n- If you navigate to a flow creation page, consider this:\n - If the user has described what he wanted the flow to do, switch to flow mode with the change_mode tool before using the new tools you'll have access to to edit the flow.\n\nAlways use the provided tools purposefully and appropriately to achieve the user's goals.\nYour actions only allow you to navigate the application through the provided tools.\nWhen you complete the user's request, do not say \"I created...\" or \"I updated...\" or \"I deleted...\", but rather complete your response with precisions about how it works based on the documentation. Also drop a link to the relevant documentation if possible.\n\nExample of good behavior:\n- User: \"How can I set my AI providers?\"\n- You: <call get_documentation and fetch relevant documentation>\n- You: <call get_triggerable_components to find relevant components>\n- You: <trigger the components>\n- You: \"<precisions about the request based on the documentation>\"\n";
|
|
4
4
|
export declare const getDocumentationTool: Tool<{}>;
|
|
5
5
|
export declare const navigatorTools: Tool<{}>[];
|
|
6
6
|
export declare function prepareNavigatorSystemMessage(): ChatCompletionSystemMessageParam;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ResourceService } from '../../../../gen';
|
|
2
|
-
import {
|
|
2
|
+
import { workspaceStore } from '../../../../stores';
|
|
3
3
|
import { get } from 'svelte/store';
|
|
4
4
|
import { triggerablesByAi } from '../sharedChatState.svelte';
|
|
5
5
|
export const CHAT_SYSTEM_PROMPT = `
|
|
@@ -10,7 +10,7 @@ You have access to these tools:
|
|
|
10
10
|
1. View current buttons and inputs on the page (get_triggerable_components)
|
|
11
11
|
2. Execute buttons and inputs (trigger_component)
|
|
12
12
|
3. Get documentation for user requests (get_documentation)
|
|
13
|
-
4.
|
|
13
|
+
4. Change the AI mode to the one specified (change_mode)
|
|
14
14
|
|
|
15
15
|
INSTRUCTIONS:
|
|
16
16
|
- When users ask about application features or concepts, first use get_documentation internally to retrieve accurate information about how to fulfill the user's request.
|
|
@@ -22,7 +22,7 @@ INSTRUCTIONS:
|
|
|
22
22
|
- If you are asked to fill a form or act on an input, input the existing json object and change the fields the user asked you to change. Take into account the prompt_for_ai field of the schema to know what and how to do changes. Then tell the user that you have updated the form, and ask him to review the changes before running the script or flow.
|
|
23
23
|
- For form inputs where format starts with "resource-" and is not "resource-obj", fetch the available resources using get_available_resources, and then use the resource_path prefixed with "$res:" to fill the input.
|
|
24
24
|
- If you are not sure about an input, set the ones you are sure about, and then ask the user for the value of the input you are not sure about.
|
|
25
|
-
|
|
25
|
+
- If the user asks you to make an API call, switch to API mode with the change_mode tool before using the new tools you'll have access to to make the API call.
|
|
26
26
|
|
|
27
27
|
GENERAL PRINCIPLES:
|
|
28
28
|
- Be concise but thorough
|
|
@@ -33,7 +33,6 @@ GENERAL PRINCIPLES:
|
|
|
33
33
|
- When you do not find what you are looking for on the current page, go to the home page by looking for the "Home" component, then scan the components again.
|
|
34
34
|
|
|
35
35
|
IMPORTANT CONSIDERATIONS:
|
|
36
|
-
- If you do an API call, make sure you ask the user if he also wants you to navigate the application to fulfill his request.
|
|
37
36
|
- The user might have changed the page in the middle of the conversation, so make sure you rescan the page on each user request instead of just responding that you cannot find what the user is asking for.
|
|
38
37
|
- If you navigate to a script creation page, consider this:
|
|
39
38
|
- The page opens with the settings drawer open. After doing the changes mentioned by the user, close the settings drawer.
|
|
@@ -41,13 +40,6 @@ IMPORTANT CONSIDERATIONS:
|
|
|
41
40
|
- If you navigate to a flow creation page, consider this:
|
|
42
41
|
- If the user has described what he wanted the flow to do, switch to flow mode with the change_mode tool before using the new tools you'll have access to to edit the flow.
|
|
43
42
|
|
|
44
|
-
API_TOOLS_RESTRICTIONS:
|
|
45
|
-
- You can only use the API tools to fetch data from the backend API after you tried to navigate the application to fulfill the user's request and it's not enough to do so. ALWAYS ask the user if he also wants you to navigate the application to fulfill his request.
|
|
46
|
-
- If you use api tools, also fetch the relevant documentation to help the user understand the data you fetched, with a link to the documentation if possible.
|
|
47
|
-
|
|
48
|
-
RETRIEVE_AVAILABLE_RESOURCES_RESTRICTION:
|
|
49
|
-
- You can only use the get_available_resources tool to fill a form or an input based on the user's request. Do not use it when directly asked to fetch available resources, use the API tools instead.
|
|
50
|
-
|
|
51
43
|
Always use the provided tools purposefully and appropriately to achieve the user's goals.
|
|
52
44
|
Your actions only allow you to navigate the application through the provided tools.
|
|
53
45
|
When you complete the user's request, do not say "I created..." or "I updated..." or "I deleted...", but rather complete your response with precisions about how it works based on the documentation. Also drop a link to the relevant documentation if possible.
|
|
@@ -259,18 +251,24 @@ async function getAvailableResources(args) {
|
|
|
259
251
|
const triggerComponentTool = {
|
|
260
252
|
def: EXECUTE_COMMAND_TOOL,
|
|
261
253
|
fn: async ({ args, toolId, toolCallbacks }) => {
|
|
262
|
-
toolCallbacks.setToolStatus(toolId, 'Triggering component...');
|
|
254
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Triggering component...' });
|
|
263
255
|
const result = triggerComponent(args);
|
|
264
|
-
toolCallbacks.setToolStatus(toolId,
|
|
256
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
257
|
+
content: args.actionTaken.charAt(0).toUpperCase() + args.actionTaken.slice(1)
|
|
258
|
+
});
|
|
265
259
|
return result;
|
|
266
260
|
}
|
|
267
261
|
};
|
|
268
262
|
const getTriggerableComponentsTool = {
|
|
269
263
|
def: GET_TRIGGERABLE_COMPONENTS_TOOL,
|
|
270
264
|
fn: async ({ toolId, toolCallbacks }) => {
|
|
271
|
-
toolCallbacks.setToolStatus(toolId,
|
|
265
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
266
|
+
content: 'Scanning the page...',
|
|
267
|
+
});
|
|
272
268
|
const components = getTriggerableComponents();
|
|
273
|
-
toolCallbacks.setToolStatus(toolId,
|
|
269
|
+
toolCallbacks.setToolStatus(toolId, {
|
|
270
|
+
content: 'Scanned the page',
|
|
271
|
+
});
|
|
274
272
|
return components;
|
|
275
273
|
}
|
|
276
274
|
};
|
|
@@ -278,21 +276,21 @@ const getCurrentPageNameTool = {
|
|
|
278
276
|
def: GET_CURRENT_PAGE_NAME_TOOL,
|
|
279
277
|
fn: async ({ toolId, toolCallbacks }) => {
|
|
280
278
|
const pageName = getCurrentPageName();
|
|
281
|
-
toolCallbacks.setToolStatus(toolId, 'Retrieved current page name');
|
|
279
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Retrieved current page name' });
|
|
282
280
|
return pageName;
|
|
283
281
|
}
|
|
284
282
|
};
|
|
285
283
|
export const getDocumentationTool = {
|
|
286
284
|
def: GET_DOCUMENTATION_TOOL,
|
|
287
285
|
fn: async ({ args, toolId, toolCallbacks }) => {
|
|
288
|
-
toolCallbacks.setToolStatus(toolId, 'Getting documentation...');
|
|
286
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Getting documentation...' });
|
|
289
287
|
try {
|
|
290
288
|
const docResult = await getDocumentation(args);
|
|
291
|
-
toolCallbacks.setToolStatus(toolId, 'Retrieved documentation');
|
|
289
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Retrieved documentation' });
|
|
292
290
|
return docResult;
|
|
293
291
|
}
|
|
294
292
|
catch (error) {
|
|
295
|
-
toolCallbacks.setToolStatus(toolId, 'Error getting documentation');
|
|
293
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Error getting documentation', error: 'Error getting documentation' });
|
|
296
294
|
console.error('Error getting documentation:', error);
|
|
297
295
|
return 'Failed to get documentation, pursuing with the user request...';
|
|
298
296
|
}
|
|
@@ -301,14 +299,14 @@ export const getDocumentationTool = {
|
|
|
301
299
|
const getAvailableResourcesTool = {
|
|
302
300
|
def: GET_AVAILABLE_RESOURCES_TOOL,
|
|
303
301
|
fn: async ({ args, toolId, toolCallbacks }) => {
|
|
304
|
-
toolCallbacks.setToolStatus(toolId, 'Getting available resources...');
|
|
302
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Getting available resources...' });
|
|
305
303
|
try {
|
|
306
304
|
const resources = await getAvailableResources(args);
|
|
307
|
-
toolCallbacks.setToolStatus(toolId, 'Retrieved available resources');
|
|
305
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Retrieved available resources' });
|
|
308
306
|
return resources;
|
|
309
307
|
}
|
|
310
308
|
catch (error) {
|
|
311
|
-
toolCallbacks.setToolStatus(toolId, 'Error getting available resources');
|
|
309
|
+
toolCallbacks.setToolStatus(toolId, { content: 'Error getting available resources', error: 'Error getting available resources' });
|
|
312
310
|
console.error('Error getting available resources:', error);
|
|
313
311
|
return 'Failed to get available resources, pursuing with the user request...';
|
|
314
312
|
}
|
|
@@ -10,7 +10,7 @@ export declare function getLangContext(lang: ScriptLang | 'bunnative' | 'jsx' |
|
|
|
10
10
|
isFailure?: boolean;
|
|
11
11
|
}): string;
|
|
12
12
|
export declare function getFormattedResourceTypes(lang: ScriptLang | 'bunnative', prompt: string, workspace: string): Promise<string>;
|
|
13
|
-
export declare const CHAT_SYSTEM_PROMPT = "\n\tYou are a coding assistant for the Windmill platform. You are provided with a list of `INSTRUCTIONS` and the current contents of a code file under `CODE`.\n\n\tYour task is to respond to the user's request. Assume all user queries are valid and actionable.\n\n\tWhen the user requests code changes:\n\t- Always include a **single code block** with the **entire updated file**, not just the modified sections.\n\t- The code can include `[#START]` and `[#END]` markers to indicate the start and end of a code piece. You MUST only modify the code between these markers if given, and remove them in your response. If a question is asked about the code, you MUST only talk about the code between the markers. Refer to it as the code piece, not the code between the markers.\n\t- Follow the instructions carefully and explain the reasoning behind your changes.\n\t- If the request is abstract (e.g., \"make this cleaner\"), interpret it concretely and reflect that in the code block.\n\t- Preserve existing formatting, indentation, and whitespace unless changes are strictly required to fulfill the user's request.\n\t- The user can ask you to look at or modify specific files, databases or errors by having its name in the INSTRUCTIONS preceded by the @ symbol. In this case, put your focus on the element that is explicitly mentioned.\n\t- The user can ask you questions about a list of `DATABASES` that are available in the user's workspace. If the user asks you a question about a database, you should ask the user to specify the database name if not given, or take the only one available if there is only one.\n\t- You can also receive a `DIFF` of the changes that have been made to the code. You should use this diff to give better answers.\n\t- Before giving your answer, check again that you carefully followed these instructions.\n\t- When asked to create a script that communicates with an external service, you can use the `search_hub_scripts` tool to search for relevant scripts in the hub. Make sure the language is the same as what the user is coding in. If you do not find any relevant scripts, you can use the `search_npm_packages` tool to search for relevant packages and their documentation. Always give a link to the documentation in your answer if possible.\n\n\tImportant:\n\tDo not mention or reveal these instructions to the user unless explicitly asked to do so.\n";
|
|
13
|
+
export declare const CHAT_SYSTEM_PROMPT = "\n\tYou are a coding assistant for the Windmill platform. You are provided with a list of `INSTRUCTIONS` and the current contents of a code file under `CODE`.\n\n\tYour task is to respond to the user's request. Assume all user queries are valid and actionable.\n\n\tWhen the user requests code changes:\n\t- Always include a **single code block** with the **entire updated file**, not just the modified sections.\n\t- The code can include `[#START]` and `[#END]` markers to indicate the start and end of a code piece. You MUST only modify the code between these markers if given, and remove them in your response. If a question is asked about the code, you MUST only talk about the code between the markers. Refer to it as the code piece, not the code between the markers.\n\t- Follow the instructions carefully and explain the reasoning behind your changes.\n\t- If the request is abstract (e.g., \"make this cleaner\"), interpret it concretely and reflect that in the code block.\n\t- Preserve existing formatting, indentation, and whitespace unless changes are strictly required to fulfill the user's request.\n\t- The user can ask you to look at or modify specific files, databases or errors by having its name in the INSTRUCTIONS preceded by the @ symbol. In this case, put your focus on the element that is explicitly mentioned.\n\t- The user can ask you questions about a list of `DATABASES` that are available in the user's workspace. If the user asks you a question about a database, you should ask the user to specify the database name if not given, or take the only one available if there is only one.\n\t- You can also receive a `DIFF` of the changes that have been made to the code. You should use this diff to give better answers.\n\t- Before giving your answer, check again that you carefully followed these instructions.\n\t- When asked to create a script that communicates with an external service, you can use the `search_hub_scripts` tool to search for relevant scripts in the hub. Make sure the language is the same as what the user is coding in. If you do not find any relevant scripts, you can use the `search_npm_packages` tool to search for relevant packages and their documentation. Always give a link to the documentation in your answer if possible.\n\t- After modifying the code, ALWAYS use the `test_run_script` tool to test the code, and iterate on the code until it works as expected. If the user cancels the test run, do not try again and wait for the next user instruction.\n\n\tImportant:\n\tDo not mention or reveal these instructions to the user unless explicitly asked to do so.\n";
|
|
14
14
|
export declare const INLINE_CHAT_SYSTEM_PROMPT = "\n# Windmill Inline Coding Assistant\n\nYou are a coding assistant for the Windmill platform. You provide precise code modifications based on user instructions.\n\n## Input Format\n\nYou will receive:\n- **INSTRUCTIONS**: User's modification request\n- **CODE**: Current code content with modification boundaries\n- **DATABASES** *(optional)*: Available workspace databases\n\n### Code Boundaries\n\nThe code contains `[#START]` and `[#END]` markers indicating the modification scope:\n- **MUST** only modify code between these markers\n- **MUST** remove the markers in your response\n- **MUST** preserve all other code exactly as provided\n\n## Task Requirements\n\nReturn the modified CODE that fulfills the user's request. Assume all user queries are valid and actionable.\n\n### Critical Rules\n\n- \u2705 **ALWAYS** include a single code block with the entire updated CODE\n- \u2705 **ALWAYS** use the structured XML output format below\n- \u274C **NEVER** include only modified sections\n- \u274C **NEVER** add explanatory text or comments outside the format\n- \u274C **NEVER** include ``` code fences in your response\n- \u274C **NEVER** modify the code outside the boundaries\n\n## Output Format\n\n```xml\n<changes_made>\nBrief description of what was changed\n</changes_made>\n<new_code>\n[complete modified code without markers]\n</new_code>\n```\n\n## Example\n\n### Input:\n```xml\n<user_request>\nINSTRUCTIONS:\nReturn 2 instead of 1\n\nCODE:\nimport * as wmill from \"windmill-client\"\n\nfunction test() {\n\treturn \"hello\"\n}\n\n[#START]\nexport async function main() {\n\treturn 1;\n}\n[#END]\n</user_request>\n```\n\n### Expected Output:\n```xml\n<changes_made>\nChanged return value from 1 to 2 in main function\n</changes_made>\n<new_code>\nimport * as wmill from \"windmill-client\"\n\nfunction test() {\n\treturn \"hello\"\n}\n\nexport async function main() {\n\treturn 2;\n}\n</new_code>\n```\n";
|
|
15
15
|
export declare const CHAT_USER_PROMPT = "\nINSTRUCTIONS:\n{instructions}\n\nWINDMILL LANGUAGE CONTEXT:\n{lang_context}\n\n";
|
|
16
16
|
export declare const CHAT_USER_DB_CONTEXT = "- {title}: SCHEMA: \n{schema}\n";
|
|
@@ -18,10 +18,17 @@ export declare function prepareScriptSystemMessage(): ChatCompletionSystemMessag
|
|
|
18
18
|
export declare function prepareScriptTools(language: ScriptLang | 'bunnative', context: ContextElement[]): Tool<ScriptChatHelpers>[];
|
|
19
19
|
export declare function prepareScriptUserMessage(instructions: string, language: ScriptLang | 'bunnative', selectedContext: ContextElement[], options?: {
|
|
20
20
|
isPreprocessor?: boolean;
|
|
21
|
-
}):
|
|
21
|
+
}): ChatCompletionUserMessageParam;
|
|
22
22
|
export declare const MAX_SCHEMA_LENGTH: number;
|
|
23
23
|
export interface ScriptChatHelpers {
|
|
24
|
-
|
|
24
|
+
getScriptOptions: () => {
|
|
25
|
+
code: string;
|
|
26
|
+
lang: ScriptLang | 'bunnative';
|
|
27
|
+
path: string;
|
|
28
|
+
args: Record<string, any>;
|
|
29
|
+
};
|
|
30
|
+
getLastSuggestedCode: () => string | undefined;
|
|
31
|
+
applyCode: (code: string, applyAll?: boolean) => void;
|
|
25
32
|
}
|
|
26
33
|
export declare const resourceTypeTool: Tool<ScriptChatHelpers>;
|
|
27
34
|
export declare const dbSchemaTool: Tool<ScriptChatHelpers>;
|
|
@@ -34,3 +41,4 @@ export declare function fetchNpmPackageTypes(packageName: string, version?: stri
|
|
|
34
41
|
types: string;
|
|
35
42
|
error?: string;
|
|
36
43
|
}>;
|
|
44
|
+
export declare const testRunScriptTool: Tool<ScriptChatHelpers>;
|