windmill-components 1.511.1 → 1.522.0
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/AppConnectInner.svelte.d.ts +1 -1
- package/package/components/ArgInput.svelte +42 -14
- package/package/components/ArgInput.svelte.d.ts +2 -10
- package/package/components/AssignableTagsInner.svelte +5 -0
- package/package/components/AuthSettings.svelte +4 -2
- package/package/components/AuthSettings.svelte.d.ts +1 -0
- package/package/components/DBManagerDrawer.svelte +154 -151
- package/package/components/DBManagerDrawer.svelte.d.ts +2 -2
- package/package/components/DBTable.svelte +3 -3
- package/package/components/DBTable.svelte.d.ts +1 -0
- package/package/components/DBTableEditor.svelte +7 -7
- package/package/components/DBTableEditor.svelte.d.ts +1 -1
- package/package/components/DeployWorkspace.svelte +1 -1
- package/package/components/DisplayResult.svelte +34 -8
- package/package/components/DisplayResult.svelte.d.ts +4 -1
- package/package/components/DynSelect.svelte +58 -34
- package/package/components/DynSelect.svelte.d.ts +3 -11
- package/package/components/EditableSchemaForm.svelte +126 -6
- package/package/components/EditableSchemaForm.svelte.d.ts +5 -1
- package/package/components/Editor.svelte +1 -1
- package/package/components/EditorBar.svelte +82 -4
- package/package/components/ErrorOrRecoveryHandler.svelte +76 -8
- package/package/components/ErrorOrRecoveryHandler.svelte.d.ts +2 -1
- package/package/components/ExploreAssetButton.svelte +14 -4
- package/package/components/ExploreAssetButton.svelte.d.ts +1 -0
- package/package/components/FlowJobResult.svelte +3 -3
- package/package/components/FlowJobResult.svelte.d.ts +1 -0
- package/package/components/FlowPreviewContent.svelte +9 -1
- package/package/components/FlowPreviewResult.svelte +4 -1
- package/package/components/FlowPreviewResult.svelte.d.ts +1 -0
- package/package/components/FlowStatusViewerInner.svelte +21 -3
- package/package/components/FlowStatusViewerInner.svelte.d.ts +7 -1
- package/package/components/FolderEditor.svelte +1 -1
- package/package/components/GitDiffPreview.svelte +14 -18
- package/package/components/GitDiffPreview.svelte.d.ts +2 -8
- package/package/components/GitHubAppIntegration.svelte +3 -1
- package/package/components/IdEditorInput.svelte +25 -22
- package/package/components/IdEditorInput.svelte.d.ts +11 -23
- package/package/components/InstanceSetting.svelte +7 -2
- package/package/components/InstanceSettings.svelte +1 -0
- package/package/components/JobLoader.svelte +48 -5
- package/package/components/JobLoader.svelte.d.ts +7 -2
- package/package/components/Login.svelte +8 -2
- package/package/components/MemoryFootprintViewer.svelte +1 -1
- package/package/components/ModulePreviewResultViewer.svelte +2 -2
- package/package/components/MoveDrawer.svelte.d.ts +2 -2
- package/package/components/NextcloudSetting.svelte +84 -0
- package/package/components/NextcloudSetting.svelte.d.ts +7 -0
- package/package/components/ObjectResourceInput.svelte +3 -2
- package/package/components/ObjectResourceInput.svelte.d.ts +1 -0
- package/package/components/ParqetCsvTableRenderer.svelte +1 -1
- package/package/components/ResourceEditor.svelte +1 -1
- package/package/components/ResourcePicker.svelte +8 -1
- package/package/components/ResourcePicker.svelte.d.ts +1 -0
- package/package/components/ResultStreamDisplay.svelte +5 -0
- package/package/components/ResultStreamDisplay.svelte.d.ts +5 -0
- package/package/components/RunForm.svelte +9 -1
- package/package/components/SchemaForm.svelte +2 -2
- package/package/components/SchemaForm.svelte.d.ts +2 -10
- package/package/components/ScriptBuilder.svelte +13 -8
- package/package/components/ScriptBuilder.svelte.d.ts +1 -1
- package/package/components/ScriptEditor.svelte.d.ts +1 -1
- package/package/components/ScriptWrapper.svelte +1 -1
- package/package/components/ShareModal.svelte.d.ts +1 -1
- package/package/components/SimpleAgTable.svelte +2 -0
- package/package/components/SimpleAgTable.svelte.d.ts +2 -0
- package/package/components/SqlRepl.svelte +21 -7
- package/package/components/SqlRepl.svelte.d.ts +2 -2
- package/package/components/StringTypeNarrowing.svelte.d.ts +1 -1
- package/package/components/WorkerTagSelect.svelte +70 -1
- package/package/components/apps/components/display/AppDisplayComponent.svelte +13 -1
- package/package/components/apps/components/display/AppText.svelte +2 -2
- package/package/components/apps/components/display/dbtable/AppDbExplorer.svelte +8 -1
- package/package/components/apps/components/display/dbtable/InsertRow.svelte +5 -4
- package/package/components/apps/components/display/dbtable/queries/count.js +11 -1
- package/package/components/apps/components/display/dbtable/queries/createTable.d.ts +1 -1
- package/package/components/apps/components/display/dbtable/queries/createTable.js +3 -3
- package/package/components/apps/components/display/dbtable/queries/delete.js +7 -0
- package/package/components/apps/components/display/dbtable/queries/insert.js +2 -0
- package/package/components/apps/components/display/dbtable/queries/select.js +14 -0
- package/package/components/apps/components/display/dbtable/queries/update.js +7 -0
- package/package/components/apps/components/display/dbtable/utils.d.ts +6 -5
- package/package/components/apps/components/display/dbtable/utils.js +52 -28
- package/package/components/apps/components/display/table/AppAggridExplorerTable.svelte +1 -1
- package/package/components/apps/components/display/table/AppAggridInfiniteTable.svelte +1 -0
- package/package/components/apps/components/display/table/AppAggridInfiniteTable.svelte.d.ts +1 -0
- package/package/components/apps/components/display/table/AppAggridTable.svelte +5 -4
- package/package/components/apps/components/display/table/AppAggridTable.svelte.d.ts +1 -0
- package/package/components/apps/components/display/table/utils.js +7 -4
- package/package/components/apps/components/helpers/HiddenComponent.svelte +2 -2
- package/package/components/apps/components/helpers/RunnableComponent.svelte +4 -1
- package/package/components/apps/components/helpers/RunnableComponent.svelte.d.ts +2 -1
- package/package/components/apps/components/inputs/AppS3FileInput.svelte +2 -2
- package/package/components/apps/components/layout/AppDecisionTree.svelte +1 -1
- package/package/components/apps/components/layout/AppStepper.svelte +1 -1
- package/package/components/apps/components/layout/AppTabs.svelte +1 -1
- package/package/components/apps/editor/AppEditorHeader.svelte +13 -2
- package/package/components/apps/editor/GridViewer.svelte +1 -0
- package/package/components/apps/editor/RunnableJobPanelInner.svelte +2 -1
- package/package/components/apps/editor/contextPanel/components/IdEditor.svelte +7 -7
- package/package/components/apps/editor/contextPanel/components/IdEditor.svelte.d.ts +7 -19
- package/package/components/apps/editor/contextPanel/components/OutputHeader.svelte +8 -12
- package/package/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte.d.ts +1 -1
- package/package/components/apps/editor/inlineScriptsPanel/InlineScriptEditorDrawer.svelte.d.ts +1 -1
- package/package/components/apps/editor/inlineScriptsPanel/InlineScriptRunnableByPath.svelte.d.ts +1 -1
- package/package/components/apps/editor/settingsPanel/DecisionTreeGraphEditor.svelte +3 -3
- package/package/components/apps/editor/settingsPanel/decisionTree/DecisionTreePreview.svelte +1 -3
- package/package/components/assets/AssetsDropdownButton.svelte +1 -1
- package/package/components/assets/JobAssetsViewer.svelte +2 -2
- package/package/components/assets/lib.js +4 -0
- package/package/components/auditLogs/AuditLogsFilters.svelte +7 -9
- package/package/components/common/button/Button.svelte +4 -3
- package/package/components/common/button/Button.svelte.d.ts +1 -0
- package/package/components/common/confirmationModal/ConfirmationModal.svelte +6 -5
- package/package/components/common/confirmationModal/ConfirmationModal.svelte.d.ts +6 -11
- package/package/components/common/confirmationModal/asyncConfirmationModal.svelte.d.ts +26 -0
- package/package/components/common/confirmationModal/asyncConfirmationModal.svelte.js +50 -0
- package/package/components/common/modal/Modal.svelte +2 -5
- package/package/components/common/tabs/TabsV2.svelte +2 -1
- package/package/components/common/tabs/TabsV2.svelte.d.ts +1 -0
- package/package/components/copilot/chat/AIChatManager.svelte.js +61 -7
- package/package/components/copilot/chat/ContextTextarea.svelte +1 -1
- package/package/components/copilot/chat/script/core.js +28 -29
- package/package/components/copilot/chat/shared.d.ts +1 -1
- package/package/components/copilot/chat/shared.js +8 -2
- package/package/components/custom_ui.d.ts +2 -0
- package/package/components/dbOps.d.ts +20 -8
- package/package/components/dbOps.js +85 -40
- package/package/components/details/DetailPageHeader.svelte +0 -2
- package/package/components/flows/content/FlowInput.svelte +5 -0
- package/package/components/flows/content/FlowModuleScript.svelte +0 -1
- package/package/components/flows/idUtils.js +2 -1
- package/package/components/flows/map/FlowModuleSchemaItem.svelte +3 -3
- package/package/components/flows/map/FlowModuleSchemaMap.svelte +5 -0
- package/package/components/flows/map/InsertModuleButton.svelte +4 -1
- package/package/components/flows/propPicker/OutputBadge.svelte +5 -1
- package/package/components/flows/propPicker/OutputPickerInner.svelte +9 -5
- package/package/components/flows/propPicker/OutputPickerInner.svelte.d.ts +6 -2
- package/package/components/flows/propPicker/StepHistory.svelte +4 -1
- package/package/components/git_sync/DetectionFlow.svelte +202 -0
- package/package/components/git_sync/DetectionFlow.svelte.d.ts +6 -0
- package/package/components/git_sync/GitSyncContext.svelte.d.ts +82 -0
- package/package/components/git_sync/GitSyncContext.svelte.js +461 -0
- package/package/components/git_sync/GitSyncModalManager.svelte +99 -0
- package/package/components/git_sync/GitSyncModalManager.svelte.d.ts +18 -0
- package/package/components/git_sync/GitSyncRepositoryCard.svelte +339 -0
- package/package/components/git_sync/GitSyncRepositoryCard.svelte.d.ts +6 -0
- package/package/components/git_sync/GitSyncRepositoryList.svelte +17 -0
- package/package/components/git_sync/GitSyncRepositoryList.svelte.d.ts +18 -0
- package/package/components/git_sync/GitSyncSection.svelte +89 -0
- package/package/components/git_sync/GitSyncSection.svelte.d.ts +3 -0
- package/package/components/git_sync/GitSyncSuccessModal.svelte +58 -0
- package/package/components/git_sync/GitSyncSuccessModal.svelte.d.ts +7 -0
- package/package/components/git_sync/PullWorkspaceModal.svelte +575 -0
- package/package/components/git_sync/PullWorkspaceModal.svelte.d.ts +15 -0
- package/package/components/git_sync/PushWorkspaceModal.svelte +320 -0
- package/package/components/git_sync/PushWorkspaceModal.svelte.d.ts +12 -0
- package/package/components/graph/FlowGraphV2.svelte +5 -1
- package/package/components/graph/graphBuilder.svelte.js +1 -1
- package/package/components/graph/renderers/nodes/AssetNode.svelte +4 -4
- package/package/components/icons/AssetDucklakeIcon.svelte +28 -0
- package/package/components/icons/AssetDucklakeIcon.svelte.d.ts +9 -0
- package/package/components/icons/AssetGenericIcon.svelte +3 -0
- package/package/components/icons/DucklakeIcon.svelte +18 -0
- package/package/components/icons/DucklakeIcon.svelte.d.ts +6 -0
- package/package/components/instanceSettings.js +11 -3
- package/package/components/runs/JobPreview.svelte +2 -2
- package/package/components/runs/NoWorkerWithTagWarning.svelte +3 -3
- package/package/components/runs/RunsFilter.svelte.d.ts +1 -1
- package/package/components/schema/FlowPropertyEditor.svelte +3 -2
- package/package/components/schema/FlowPropertyEditor.svelte.d.ts +1 -1
- package/package/components/schema/PropertyEditor.svelte +0 -2
- package/package/components/schema/PropertyEditor.svelte.d.ts +1 -1
- package/package/components/schema/SchemaFormDND.svelte +2 -1
- package/package/components/schema/SchemaFormDND.svelte.d.ts +2 -0
- package/package/components/scriptEditor/LogPanel.svelte +5 -3
- package/package/components/scriptEditor/LogPanel.svelte.d.ts +5 -1
- package/package/components/select/Select.svelte +7 -4
- package/package/components/select/Select.svelte.d.ts +5 -0
- package/package/components/select/SelectDropdown.svelte +2 -1
- package/package/components/select/SelectDropdown.svelte.d.ts +3 -0
- package/package/components/sidebar/changelogs.js +5 -0
- package/package/components/table/AutoDataTable.svelte +6 -4
- package/package/components/table/AutoDataTable.svelte.d.ts +1 -0
- package/package/components/table/DataTable.svelte +12 -10
- package/package/components/table/DataTable.svelte.d.ts +1 -0
- package/package/components/triggers/TriggerRetriesAndErrorHandler.svelte.d.ts +2 -2
- package/package/components/triggers/gcp/GcpTriggerEditorConfigSection.svelte +1 -1
- package/package/components/triggers/gcp/GcpTriggerEditorConfigSection.svelte.d.ts +2 -1
- package/package/components/triggers/gcp/GcpTriggerEditorInner.svelte +50 -11
- package/package/components/triggers/gcp/utils.js +1 -0
- package/package/components/triggers/http/utils.js +1 -1
- package/package/components/triggers/kafka/utils.js +1 -1
- package/package/components/triggers/mqtt/utils.js +1 -1
- package/package/components/triggers/nats/utils.js +1 -1
- package/package/components/triggers/postgres/utils.js +1 -1
- package/package/components/triggers/sqs/utils.js +1 -1
- package/package/components/triggers/utils.js +2 -1
- package/package/components/triggers/webhook/WebhooksConfigSection.svelte +24 -26
- package/package/components/triggers/webhook/WebhooksPanel.svelte +1 -15
- package/package/components/triggers/websocket/utils.js +1 -1
- package/package/components/workspaceSettings/AISettings.svelte +52 -36
- package/package/components/workspaceSettings/DucklakeSettings.svelte +321 -0
- package/package/components/workspaceSettings/DucklakeSettings.svelte.d.ts +23 -0
- package/package/components/workspaceSettings/GitSyncFilterSettings.svelte +122 -499
- package/package/components/workspaceSettings/GitSyncFilterSettings.svelte.d.ts +8 -10
- package/package/consts.js +2 -1
- package/package/gen/core/OpenAPI.js +1 -1
- package/package/gen/schemas.gen.d.ts +7 -6
- package/package/gen/schemas.gen.js +7 -6
- package/package/gen/services.gen.d.ts +19 -1
- package/package/gen/services.gen.js +38 -0
- package/package/gen/types.gen.d.ts +78 -3
- package/package/git-sync.d.ts +36 -0
- package/package/git-sync.js +1 -0
- package/package/hub.d.ts +1 -0
- package/package/hubPaths.json +5 -2
- package/package/infer.js +3 -2
- package/package/script_helpers.d.ts +2 -2
- package/package/script_helpers.js +29 -11
- package/package/services/JobManager.d.ts +28 -0
- package/package/services/JobManager.js +114 -0
- package/package/stores.d.ts +1 -1
- package/package/utils.d.ts +18 -1
- package/package/utils.js +55 -2
- package/package.json +5 -4
- package/package/components/InitGitRepoPopover.svelte +0 -410
- package/package/components/InitGitRepoPopover.svelte.d.ts +0 -13
- package/package/components/PullGitRepoPopover.svelte +0 -355
- package/package/components/PullGitRepoPopover.svelte.d.ts +0 -18
- package/package/inferArgSig.d.ts +0 -42
- package/package/inferArgSig.js +0 -198
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { inferAssets } from '../../infer';
|
|
3
3
|
import { workspaceStore } from '../../stores';
|
|
4
4
|
import { usePromise } from '../../svelte5Utils.svelte';
|
|
5
|
-
import {
|
|
5
|
+
import { pruneNullishArray, uniqueBy } from '../../utils';
|
|
6
6
|
import DbManagerDrawer from '../DBManagerDrawer.svelte';
|
|
7
7
|
import ResourceEditorDrawer from '../ResourceEditorDrawer.svelte';
|
|
8
8
|
import S3FilePicker from '../S3FilePicker.svelte';
|
|
@@ -14,7 +14,7 @@ async function extractAssets(job) {
|
|
|
14
14
|
const additionalAssetsMap = {
|
|
15
15
|
// TODO : Transitive assets
|
|
16
16
|
};
|
|
17
|
-
return uniqueBy(
|
|
17
|
+
return uniqueBy(pruneNullishArray([
|
|
18
18
|
...(job.raw_flow?.modules.flatMap((m) => getFlowModuleAssets(m, additionalAssetsMap)) ??
|
|
19
19
|
[]),
|
|
20
20
|
...parseInputArgsAssets(job.args ?? {})
|
|
@@ -5,6 +5,8 @@ export function formatAsset(asset) {
|
|
|
5
5
|
return `res://${asset.path}`;
|
|
6
6
|
case 's3object':
|
|
7
7
|
return `s3://${asset.path}`;
|
|
8
|
+
case 'ducklake':
|
|
9
|
+
return `ducklake://${asset.path}`;
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
12
|
export function getAssetUsagePageUri(usage) {
|
|
@@ -54,6 +56,8 @@ export function formatAssetKind(asset) {
|
|
|
54
56
|
}
|
|
55
57
|
case 's3object':
|
|
56
58
|
return 'S3 Object';
|
|
59
|
+
case 'ducklake':
|
|
60
|
+
return 'Ducklake';
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
export function formatAssetAccessType(accessType) {
|
|
@@ -45,7 +45,6 @@ $effect.pre(() => {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
async function loadLogs(username, page, perPage, before, after, operation, resource, actionKind, scope) {
|
|
48
|
-
console.log("loading logs");
|
|
49
48
|
loading = true;
|
|
50
49
|
if (username == 'all') {
|
|
51
50
|
username = undefined;
|
|
@@ -74,7 +73,6 @@ async function loadLogs(username, page, perPage, before, after, operation, resou
|
|
|
74
73
|
});
|
|
75
74
|
hasMore = logs.length > 0 && logs.length === perPage;
|
|
76
75
|
loading = false;
|
|
77
|
-
console.log("loadede logs");
|
|
78
76
|
}
|
|
79
77
|
async function loadUsers() {
|
|
80
78
|
usernames =
|
|
@@ -111,7 +109,7 @@ function updateLogs() {
|
|
|
111
109
|
addQueryParam('workspace', 'admins');
|
|
112
110
|
}
|
|
113
111
|
const query = '?' + queryParams.join('&');
|
|
114
|
-
goto(query);
|
|
112
|
+
goto(query, { replaceState: true, keepFocus: true });
|
|
115
113
|
loadLogs(username, page, perPage, before, after, operation, resource, actionKind, scope);
|
|
116
114
|
}
|
|
117
115
|
function updateQueryParams() {
|
|
@@ -282,13 +280,13 @@ $effect(() => {
|
|
|
282
280
|
</div>
|
|
283
281
|
{/if}
|
|
284
282
|
<div class="flex gap-1 relative w-full">
|
|
285
|
-
<span class="text-xs absolute -top-4">
|
|
286
|
-
<input type="text" value={after ?? '
|
|
283
|
+
<span class="text-xs absolute -top-4">From</span>
|
|
284
|
+
<input type="text" value={after ?? 'From'} disabled />
|
|
287
285
|
<CalendarPicker
|
|
288
286
|
clearable
|
|
289
287
|
date={after}
|
|
290
288
|
placement="bottom-end"
|
|
291
|
-
label="
|
|
289
|
+
label="From"
|
|
292
290
|
on:change={({ detail }) => {
|
|
293
291
|
after = new Date(detail).toISOString()
|
|
294
292
|
}}
|
|
@@ -298,12 +296,12 @@ $effect(() => {
|
|
|
298
296
|
/>
|
|
299
297
|
</div>
|
|
300
298
|
<div class="flex gap-1 relative w-full">
|
|
301
|
-
<span class="text-xs absolute -top-4">
|
|
302
|
-
<input type="text" value={before ?? '
|
|
299
|
+
<span class="text-xs absolute -top-4">To</span>
|
|
300
|
+
<input type="text" value={before ?? 'To'} disabled />
|
|
303
301
|
<CalendarPicker
|
|
304
302
|
clearable
|
|
305
303
|
bind:date={before}
|
|
306
|
-
label="
|
|
304
|
+
label="To"
|
|
307
305
|
placement="bottom-end"
|
|
308
306
|
on:change={({ detail }) => {
|
|
309
307
|
before = new Date(detail).toISOString()
|
|
@@ -10,7 +10,7 @@ import { createTooltip } from '@melt-ui/svelte';
|
|
|
10
10
|
import { conditionalMelt } from '../../../utils';
|
|
11
11
|
import { createDispatcherIfMounted } from '../../../createDispatcherIfMounted';
|
|
12
12
|
import { triggerableByAI } from '../../../actions/triggerableByAI.svelte';
|
|
13
|
-
let { id = '', aiId = undefined, aiDescription = undefined, size = 'md', spacingSize = size, color = 'blue', variant = 'contained', btnClasses = '', wrapperClasses = '', wrapperStyle = '', disabled = false, href = undefined, target = undefined, iconOnly = false, loadUntilNav = false, clickableWhileLoading = false, element = $bindable(undefined), nonCaptureEvent = false, propagateEvent = false, loading = $bindable(false), title = undefined, style = '', download = undefined, startIcon = undefined, endIcon = undefined, shortCut = undefined, tooltipPopover = undefined, dropdownBtnClasses = '', dropdownItems = undefined, hideDropdown = false, children, tooltip, dropdownOpen = $bindable(false), ...rest } = $props();
|
|
13
|
+
let { id = '', aiId = undefined, aiDescription = undefined, size = 'md', spacingSize = size, color = 'blue', variant = 'contained', btnClasses = '', wrapperClasses = '', wrapperStyle = '', disabled = false, href = undefined, target = undefined, iconOnly = false, loadUntilNav = false, clickableWhileLoading = false, element = $bindable(undefined), nonCaptureEvent = false, propagateEvent = false, loading = $bindable(false), title = undefined, style = '', download = undefined, startIcon = undefined, endIcon = undefined, shortCut = undefined, tooltipPopover = undefined, dropdownBtnClasses = '', dropdownItems = undefined, hideDropdown = false, children, tooltip, onClick, dropdownOpen = $bindable(false), ...rest } = $props();
|
|
14
14
|
function computeDropdowns(menuItems) {
|
|
15
15
|
const items = typeof menuItems === 'function' ? menuItems() : menuItems;
|
|
16
16
|
return items.map((item) => ({
|
|
@@ -30,13 +30,14 @@ export function click() {
|
|
|
30
30
|
const dispatch = createEventDispatcher();
|
|
31
31
|
const dispatchIfMounted = createDispatcherIfMounted(dispatch);
|
|
32
32
|
// Order of classes: border, border modifier, bg, bg modifier, text, text modifier, everything else
|
|
33
|
-
async function
|
|
33
|
+
async function onclick(event) {
|
|
34
34
|
if (!nonCaptureEvent) {
|
|
35
35
|
event.preventDefault();
|
|
36
36
|
if (!propagateEvent) {
|
|
37
37
|
// by default events are not propagated, added this prop so that we can
|
|
38
38
|
event.stopPropagation();
|
|
39
39
|
}
|
|
40
|
+
onClick?.(event);
|
|
40
41
|
dispatch('click', event);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -165,7 +166,7 @@ $effect(() => {
|
|
|
165
166
|
<button
|
|
166
167
|
bind:this={element}
|
|
167
168
|
onpointerdown={bubble('pointerdown')}
|
|
168
|
-
onclick
|
|
169
|
+
{onclick}
|
|
169
170
|
onfocus={bubble('focus')}
|
|
170
171
|
onblur={bubble('blur')}
|
|
171
172
|
onmouseenter={bubble('mouseenter')}
|
|
@@ -48,6 +48,7 @@ interface Props {
|
|
|
48
48
|
dropdownBtnClasses?: string;
|
|
49
49
|
dropdownItems?: MenuItem[] | (() => MenuItem[]) | undefined;
|
|
50
50
|
hideDropdown?: boolean;
|
|
51
|
+
onClick?: (e?: Event) => void;
|
|
51
52
|
children?: import('svelte').Snippet;
|
|
52
53
|
tooltip?: import('svelte').Snippet;
|
|
53
54
|
[key: string]: any;
|
|
@@ -4,7 +4,7 @@ import { fade } from 'svelte/transition';
|
|
|
4
4
|
import Button from '../button/Button.svelte';
|
|
5
5
|
import { AlertTriangle, CornerDownLeft, Loader2, RefreshCcw } from 'lucide-svelte';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
|
-
const { title, confirmationText, keyListen = true, loading = false, open = false, type: _type, showIcon = true } = $props();
|
|
7
|
+
const { title, confirmationText, keyListen = true, loading = false, open = false, type: _type, showIcon = true, children, onConfirmed, onCanceled } = $props();
|
|
8
8
|
const type = $derived(_type ?? 'danger');
|
|
9
9
|
const dispatch = createEventDispatcher();
|
|
10
10
|
function onKeyDown(event) {
|
|
@@ -14,9 +14,11 @@ function onKeyDown(event) {
|
|
|
14
14
|
switch (event.key) {
|
|
15
15
|
case 'Enter':
|
|
16
16
|
dispatch('confirmed');
|
|
17
|
+
onConfirmed?.();
|
|
17
18
|
break;
|
|
18
19
|
case 'Escape':
|
|
19
20
|
dispatch('canceled');
|
|
21
|
+
onCanceled?.();
|
|
20
22
|
break;
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -83,15 +85,14 @@ const Icon = $derived(theme[type].Icon ?? AlertTriangle);
|
|
|
83
85
|
{title}
|
|
84
86
|
</h3>
|
|
85
87
|
<div class="mt-2 text-sm text-secondary">
|
|
86
|
-
|
|
87
|
-
<slot />
|
|
88
|
+
{@render children?.()}
|
|
88
89
|
</div>
|
|
89
90
|
</div>
|
|
90
91
|
</div>
|
|
91
92
|
<div class="flex items-center space-x-2 flex-row-reverse space-x-reverse mt-4">
|
|
92
93
|
<Button
|
|
93
94
|
disabled={loading}
|
|
94
|
-
on:click={() => dispatch('confirmed')}
|
|
95
|
+
on:click={() => (dispatch('confirmed'), onConfirmed?.())}
|
|
95
96
|
color={theme[type].color}
|
|
96
97
|
size="sm"
|
|
97
98
|
shortCut={{ Icon: CornerDownLeft, hide: !keyListen, withoutModifier: true }}
|
|
@@ -103,7 +104,7 @@ const Icon = $derived(theme[type].Icon ?? AlertTriangle);
|
|
|
103
104
|
</Button>
|
|
104
105
|
<Button
|
|
105
106
|
disabled={loading}
|
|
106
|
-
on:click={() => dispatch('canceled')}
|
|
107
|
+
on:click={() => (dispatch('canceled'), onCanceled?.())}
|
|
107
108
|
color="light"
|
|
108
109
|
size="sm"
|
|
109
110
|
shortCut={{ key: 'Esc', hide: !keyListen, withoutModifier: true }}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
1
2
|
type Props = {
|
|
2
3
|
title: string;
|
|
3
4
|
confirmationText: string;
|
|
@@ -6,6 +7,9 @@ type Props = {
|
|
|
6
7
|
open?: boolean;
|
|
7
8
|
type?: 'danger' | 'reload';
|
|
8
9
|
showIcon?: boolean;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
onConfirmed?: () => void | Promise<void>;
|
|
12
|
+
onCanceled?: () => void;
|
|
9
13
|
};
|
|
10
14
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
11
15
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
@@ -20,20 +24,11 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
20
24
|
};
|
|
21
25
|
z_$$bindings?: Bindings;
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
default: any;
|
|
25
|
-
} ? Props extends Record<string, never> ? any : {
|
|
26
|
-
children?: any;
|
|
27
|
-
} : {});
|
|
28
|
-
declare const ConfirmationModal: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<Props, {
|
|
29
|
-
default: {};
|
|
30
|
-
}>, {
|
|
27
|
+
declare const ConfirmationModal: $$__sveltets_2_IsomorphicComponent<Props, {
|
|
31
28
|
confirmed: CustomEvent<any>;
|
|
32
29
|
canceled: CustomEvent<any>;
|
|
33
30
|
} & {
|
|
34
31
|
[evt: string]: CustomEvent<any>;
|
|
35
|
-
}, {
|
|
36
|
-
default: {};
|
|
37
|
-
}, {}, "">;
|
|
32
|
+
}, {}, {}, "">;
|
|
38
33
|
type ConfirmationModal = InstanceType<typeof ConfirmationModal>;
|
|
39
34
|
export default ConfirmationModal;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ComponentProps } from 'svelte';
|
|
2
|
+
import type ConfirmationModal from './ConfirmationModal.svelte';
|
|
3
|
+
/**
|
|
4
|
+
* This allows asking for confirmation while maintaining a linear imperative flow,
|
|
5
|
+
* and avoiding unnecessary states and callback hopping
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* let confirmationModal = createAsyncConfirmationModal()
|
|
9
|
+
* // ...
|
|
10
|
+
* let confirmed = await confirmationModal.ask({
|
|
11
|
+
* title: "The following objects do not exist",
|
|
12
|
+
* confirmationText: `Yes`,
|
|
13
|
+
* children: `Do you want to create the objects ?`
|
|
14
|
+
* })
|
|
15
|
+
* if (!confirmed) return
|
|
16
|
+
* // ...
|
|
17
|
+
* <ConfirmationModal {...confirmationModal.props} />
|
|
18
|
+
*/
|
|
19
|
+
export declare function createAsyncConfirmationModal(): {
|
|
20
|
+
props: ComponentProps<ConfirmationModal>;
|
|
21
|
+
ask: (props: Params) => Promise<boolean>;
|
|
22
|
+
};
|
|
23
|
+
type Params = Omit<ComponentProps<ConfirmationModal>, 'children'> & {
|
|
24
|
+
children: string;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createRawSnippet } from 'svelte';
|
|
2
|
+
import { sendUserToast } from '../../../toast';
|
|
3
|
+
/**
|
|
4
|
+
* This allows asking for confirmation while maintaining a linear imperative flow,
|
|
5
|
+
* and avoiding unnecessary states and callback hopping
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* let confirmationModal = createAsyncConfirmationModal()
|
|
9
|
+
* // ...
|
|
10
|
+
* let confirmed = await confirmationModal.ask({
|
|
11
|
+
* title: "The following objects do not exist",
|
|
12
|
+
* confirmationText: `Yes`,
|
|
13
|
+
* children: `Do you want to create the objects ?`
|
|
14
|
+
* })
|
|
15
|
+
* if (!confirmed) return
|
|
16
|
+
* // ...
|
|
17
|
+
* <ConfirmationModal {...confirmationModal.props} />
|
|
18
|
+
*/
|
|
19
|
+
export function createAsyncConfirmationModal() {
|
|
20
|
+
// Create a new instance of ConfirmationModal with the provided props
|
|
21
|
+
const o = $state({
|
|
22
|
+
props: {
|
|
23
|
+
confirmationText: '',
|
|
24
|
+
title: ''
|
|
25
|
+
},
|
|
26
|
+
ask: (params) => new Promise((resolve) => {
|
|
27
|
+
o.props = {
|
|
28
|
+
...params,
|
|
29
|
+
children: createRawSnippet(() => ({ render: () => params.children })),
|
|
30
|
+
open: true,
|
|
31
|
+
loading: false,
|
|
32
|
+
onCanceled: () => (resolve(false), (o.props.open = false)),
|
|
33
|
+
onConfirmed: async () => {
|
|
34
|
+
o.props.loading = true;
|
|
35
|
+
try {
|
|
36
|
+
await params.onConfirmed?.();
|
|
37
|
+
o.props.loading = false;
|
|
38
|
+
resolve(true);
|
|
39
|
+
o.props.open = false;
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
sendUserToast('Error : ' + JSON.stringify(e), true);
|
|
43
|
+
o.props.loading = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
return o;
|
|
50
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">import { createEventDispatcher } from 'svelte';
|
|
2
2
|
import { fade } from 'svelte/transition';
|
|
3
3
|
import Button from '../button/Button.svelte';
|
|
4
|
-
import Badge from '../badge/Badge.svelte';
|
|
5
4
|
import { twMerge } from 'tailwind-merge';
|
|
6
5
|
import CloseButton from '../CloseButton.svelte';
|
|
7
6
|
export let title;
|
|
@@ -34,7 +33,7 @@ function fadeFast(node) {
|
|
|
34
33
|
}
|
|
35
34
|
</script>
|
|
36
35
|
|
|
37
|
-
<svelte:window on:keydown={onKeyDown} />
|
|
36
|
+
<svelte:window on:keydown|capture={onKeyDown} />
|
|
38
37
|
|
|
39
38
|
{#if open}
|
|
40
39
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
@@ -94,9 +93,7 @@ function fadeFast(node) {
|
|
|
94
93
|
color="light"
|
|
95
94
|
size="sm"
|
|
96
95
|
>
|
|
97
|
-
|
|
98
|
-
>{cancelText ?? 'Cancel'}<Badge color="dark-gray">Escape</Badge></span
|
|
99
|
-
>
|
|
96
|
+
{cancelText ?? 'Cancel'}
|
|
100
97
|
</Button>
|
|
101
98
|
</div>
|
|
102
99
|
{/if}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script lang="ts">import { setContext, untrack } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
|
-
let { selected = $bindable(), hideTabs = false, class: c = '', wrapperClass = '', style = '', hashNavigation = false, values = undefined, children, content, onSelectedChange } = $props();
|
|
4
|
+
let { selected = $bindable(), hideTabs = false, class: c = '', wrapperClass = '', style = '', hashNavigation = false, values = undefined, children, content, onSelectedChange, onTabClick } = $props();
|
|
5
5
|
const selectedStore = writable(selected);
|
|
6
6
|
setContext('Tabs', {
|
|
7
7
|
selected: selectedStore,
|
|
8
8
|
update: (value) => {
|
|
9
9
|
selectedStore.set(value);
|
|
10
10
|
selected = value;
|
|
11
|
+
onTabClick?.(value);
|
|
11
12
|
},
|
|
12
13
|
hashNavigation
|
|
13
14
|
});
|
|
@@ -9,6 +9,7 @@ interface Props {
|
|
|
9
9
|
children?: import('svelte').Snippet<[any]>;
|
|
10
10
|
content?: import('svelte').Snippet;
|
|
11
11
|
onSelectedChange?: (value: string) => void;
|
|
12
|
+
onTabClick?: (value: string) => void;
|
|
12
13
|
}
|
|
13
14
|
declare const TabsV2: import("svelte").Component<Props, {}, "selected">;
|
|
14
15
|
type TabsV2 = ReturnType<typeof TabsV2>;
|
|
@@ -8,12 +8,17 @@ import { loadApiTools } from './navigator/apiTools';
|
|
|
8
8
|
import { prepareScriptUserMessage } from './script/core';
|
|
9
9
|
import { prepareNavigatorUserMessage } from './navigator/core';
|
|
10
10
|
import { sendUserToast } from '../../../toast';
|
|
11
|
-
import { getCompletion } from '../lib';
|
|
11
|
+
import { getCompletion, getModelContextWindow } from '../lib';
|
|
12
12
|
import { dfs } from '../../flows/previousResults';
|
|
13
13
|
import { getStringError } from './utils';
|
|
14
14
|
import { untrack } from 'svelte';
|
|
15
|
+
import { copilotSessionModel } from '../../../stores';
|
|
15
16
|
import { askTools, prepareAskSystemMessage } from './ask/core';
|
|
16
17
|
import { chatState, DEFAULT_SIZE, triggerablesByAi } from './sharedChatState.svelte';
|
|
18
|
+
import { get } from 'svelte/store';
|
|
19
|
+
// If the estimated token usage is greater than the model context window - the threshold, we delete the oldest message
|
|
20
|
+
const MAX_TOKENS_THRESHOLD_PERCENTAGE = 0.05;
|
|
21
|
+
const MAX_TOKENS_HARD_LIMIT = 5000;
|
|
17
22
|
export var AIMode;
|
|
18
23
|
(function (AIMode) {
|
|
19
24
|
AIMode["SCRIPT"] = "script";
|
|
@@ -59,6 +64,42 @@ class AIChatManager {
|
|
|
59
64
|
ask: true
|
|
60
65
|
});
|
|
61
66
|
open = $derived(chatState.size > 0);
|
|
67
|
+
checkTokenUsageOverLimit = (messages) => {
|
|
68
|
+
const estimatedTokens = messages.reduce((acc, message) => {
|
|
69
|
+
// one token is ~ 4 characters
|
|
70
|
+
const tokenPerCharacter = 4;
|
|
71
|
+
// handle content
|
|
72
|
+
if (message.content) {
|
|
73
|
+
acc += message.content.length / tokenPerCharacter;
|
|
74
|
+
}
|
|
75
|
+
// Handle tool calls
|
|
76
|
+
if (message.role === 'assistant' && message.tool_calls) {
|
|
77
|
+
acc += JSON.stringify(message.tool_calls).length / tokenPerCharacter;
|
|
78
|
+
}
|
|
79
|
+
return acc;
|
|
80
|
+
}, 0);
|
|
81
|
+
const modelContextWindow = getModelContextWindow(get(copilotSessionModel)?.model ?? '');
|
|
82
|
+
return (estimatedTokens >
|
|
83
|
+
modelContextWindow -
|
|
84
|
+
Math.max(modelContextWindow * MAX_TOKENS_THRESHOLD_PERCENTAGE, MAX_TOKENS_HARD_LIMIT));
|
|
85
|
+
};
|
|
86
|
+
deleteOldestMessage = (messages, maxDepth = 10) => {
|
|
87
|
+
if (maxDepth <= 0 || messages.length <= 1) {
|
|
88
|
+
return messages;
|
|
89
|
+
}
|
|
90
|
+
const removed = messages.shift();
|
|
91
|
+
// if the removed message is an assistant with tool calls, we need to delete correspding tool response.
|
|
92
|
+
if (removed?.role === 'assistant' && removed.tool_calls) {
|
|
93
|
+
if (messages.length > 0 && messages[0]?.role === 'tool') {
|
|
94
|
+
messages.shift();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// keep deleting messages until we are under the limit
|
|
98
|
+
if (this.checkTokenUsageOverLimit(messages)) {
|
|
99
|
+
return this.deleteOldestMessage(messages, maxDepth - 1);
|
|
100
|
+
}
|
|
101
|
+
return messages;
|
|
102
|
+
};
|
|
62
103
|
loadApiTools = async () => {
|
|
63
104
|
try {
|
|
64
105
|
this.apiTools = await loadApiTools();
|
|
@@ -213,6 +254,7 @@ class AIChatManager {
|
|
|
213
254
|
}
|
|
214
255
|
};
|
|
215
256
|
chatRequest = async ({ messages, abortController, callbacks, systemMessage: systemMessageOverride }) => {
|
|
257
|
+
let addedMessages = [];
|
|
216
258
|
try {
|
|
217
259
|
let completion = null;
|
|
218
260
|
while (true) {
|
|
@@ -283,12 +325,14 @@ class AIChatManager {
|
|
|
283
325
|
}
|
|
284
326
|
}
|
|
285
327
|
if (answer) {
|
|
286
|
-
|
|
328
|
+
const toAdd = { role: 'assistant', content: answer };
|
|
329
|
+
addedMessages.push(toAdd);
|
|
330
|
+
messages.push(toAdd);
|
|
287
331
|
}
|
|
288
332
|
callbacks.onMessageEnd();
|
|
289
333
|
const toolCalls = Object.values(finalToolCalls).filter((toolCall) => toolCall.id !== undefined && toolCall.function?.arguments !== undefined);
|
|
290
334
|
if (toolCalls.length > 0) {
|
|
291
|
-
|
|
335
|
+
const toAdd = {
|
|
292
336
|
role: 'assistant',
|
|
293
337
|
tool_calls: toolCalls.map((t) => ({
|
|
294
338
|
...t,
|
|
@@ -297,15 +341,19 @@ class AIChatManager {
|
|
|
297
341
|
arguments: t.function.arguments || '{}'
|
|
298
342
|
}
|
|
299
343
|
}))
|
|
300
|
-
}
|
|
344
|
+
};
|
|
345
|
+
messages.push(toAdd);
|
|
346
|
+
addedMessages.push(toAdd);
|
|
301
347
|
for (const toolCall of toolCalls) {
|
|
302
|
-
await processToolCall({
|
|
348
|
+
const messageToAdd = await processToolCall({
|
|
303
349
|
tools,
|
|
304
350
|
toolCall,
|
|
305
351
|
messages,
|
|
306
352
|
helpers,
|
|
307
353
|
toolCallbacks: callbacks
|
|
308
354
|
});
|
|
355
|
+
messages.push(messageToAdd);
|
|
356
|
+
addedMessages.push(messageToAdd);
|
|
309
357
|
}
|
|
310
358
|
}
|
|
311
359
|
else {
|
|
@@ -313,6 +361,7 @@ class AIChatManager {
|
|
|
313
361
|
}
|
|
314
362
|
}
|
|
315
363
|
}
|
|
364
|
+
return addedMessages;
|
|
316
365
|
}
|
|
317
366
|
catch (err) {
|
|
318
367
|
callbacks.onMessageEnd();
|
|
@@ -453,8 +502,12 @@ class AIChatManager {
|
|
|
453
502
|
this.messages.push(userMessage);
|
|
454
503
|
await this.historyManager.saveChat(this.displayMessages, this.messages);
|
|
455
504
|
this.currentReply = '';
|
|
505
|
+
let trimmedMessages = [...this.messages];
|
|
506
|
+
if (this.checkTokenUsageOverLimit(trimmedMessages)) {
|
|
507
|
+
trimmedMessages = this.deleteOldestMessage(trimmedMessages);
|
|
508
|
+
}
|
|
456
509
|
const params = {
|
|
457
|
-
messages:
|
|
510
|
+
messages: trimmedMessages,
|
|
458
511
|
abortController: this.abortController,
|
|
459
512
|
callbacks: {
|
|
460
513
|
onNewToken: (token) => (this.currentReply += token),
|
|
@@ -487,9 +540,10 @@ class AIChatManager {
|
|
|
487
540
|
if (this.mode === AIMode.NAVIGATOR && this.apiTools.length === 0) {
|
|
488
541
|
await this.loadApiTools();
|
|
489
542
|
}
|
|
490
|
-
await this.chatRequest({
|
|
543
|
+
const addedMessages = await this.chatRequest({
|
|
491
544
|
...params
|
|
492
545
|
});
|
|
546
|
+
this.messages = [...this.messages, ...(addedMessages ?? [])];
|
|
493
547
|
await this.historyManager.saveChat(this.displayMessages, this.messages);
|
|
494
548
|
}
|
|
495
549
|
catch (err) {
|
|
@@ -296,7 +296,7 @@ export function focus() {
|
|
|
296
296
|
}}
|
|
297
297
|
{placeholder}
|
|
298
298
|
class={twMerge(
|
|
299
|
-
'textarea-input resize-none bg-transparent caret-black dark:caret-white',
|
|
299
|
+
'textarea-input resize-none bg-transparent caret-black dark:caret-white overflow-clip',
|
|
300
300
|
className
|
|
301
301
|
)}
|
|
302
302
|
style={value.length > 0 ? 'color: transparent; -webkit-text-fill-color: transparent;' : ''}
|
|
@@ -203,37 +203,36 @@ export function getLangContext(lang, { allowResourcesFetch = false, isPreprocess
|
|
|
203
203
|
PHP_RESOURCE_TYPE_SYSTEM +
|
|
204
204
|
`${allowResourcesFetch ? `\nTo query the available resource types, you can use the \`search_resource_types\` tool.` : ''}` +
|
|
205
205
|
`\nIf you need to import libraries, you need to specify them as comments in the following manner before the main function:
|
|
206
|
-
\`\`\`
|
|
207
|
-
// require:
|
|
208
|
-
// mylibrary/mylibrary
|
|
209
|
-
// myotherlibrary/myotherlibrary@optionalversion
|
|
210
|
-
\`\`\`
|
|
211
|
-
Make sure to have one per line.
|
|
212
|
-
No need to require autoload, it is already done.`);
|
|
206
|
+
\`\`\`
|
|
207
|
+
// require:
|
|
208
|
+
// mylibrary/mylibrary
|
|
209
|
+
// myotherlibrary/myotherlibrary@optionalversion
|
|
210
|
+
\`\`\`
|
|
211
|
+
Make sure to have one per line.
|
|
212
|
+
No need to require autoload, it is already done.`);
|
|
213
213
|
case 'rust':
|
|
214
214
|
return `The user is coding in Rust. On Windmill, it is expected the script contains at least one function called \`main\` (without calling it) defined like this:
|
|
215
|
-
\`\`\`rust
|
|
216
|
-
use anyhow::anyhow;
|
|
217
|
-
use serde::Serialize;
|
|
218
|
-
|
|
219
|
-
#[derive(Serialize, Debug)]
|
|
220
|
-
struct ReturnType {
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
fn main(...) -> anyhow::Result<ReturnType>
|
|
225
|
-
\`\`\`
|
|
226
|
-
Arguments should be owned. Make sure the return type is serializable.
|
|
227
|
-
|
|
228
|
-
Packages must be made available with a partial cargo.toml by adding the following comment at the beginning of the script:
|
|
229
|
-
//! \`\`\`cargo
|
|
230
|
-
//! [dependencies]
|
|
231
|
-
//! anyhow = "1.0.86"
|
|
232
|
-
//! \`\`\'
|
|
233
|
-
Serde is already included, no need to add it again.
|
|
234
|
-
|
|
235
|
-
If you want to handle async functions (e.g., using tokio), you need to keep the main function sync and create the runtime inside
|
|
236
|
-
`;
|
|
215
|
+
\`\`\`rust
|
|
216
|
+
use anyhow::anyhow;
|
|
217
|
+
use serde::Serialize;
|
|
218
|
+
|
|
219
|
+
#[derive(Serialize, Debug)]
|
|
220
|
+
struct ReturnType {
|
|
221
|
+
// ...
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
fn main(...) -> anyhow::Result<ReturnType>
|
|
225
|
+
\`\`\`
|
|
226
|
+
Arguments should be owned. Make sure the return type is serializable.
|
|
227
|
+
|
|
228
|
+
Packages must be made available with a partial cargo.toml by adding the following comment at the beginning of the script:
|
|
229
|
+
//! \`\`\`cargo
|
|
230
|
+
//! [dependencies]
|
|
231
|
+
//! anyhow = "1.0.86"
|
|
232
|
+
//! \`\`\'
|
|
233
|
+
Serde is already included, no need to add it again.
|
|
234
|
+
|
|
235
|
+
If you want to handle async functions (e.g., using tokio), you need to keep the main function sync and create the runtime inside.`;
|
|
237
236
|
case 'go':
|
|
238
237
|
return `The user is coding in Go. On Windmill, it is expected the script exports a single function called \`main\`. Its return type has to be (\`{return_type}\`, error). The file package has to be "inner".`;
|
|
239
238
|
case 'bash':
|
|
@@ -27,7 +27,7 @@ export declare function processToolCall<T>({ tools, toolCall, messages, helpers,
|
|
|
27
27
|
messages: ChatCompletionMessageParam[];
|
|
28
28
|
helpers: T;
|
|
29
29
|
toolCallbacks: ToolCallbacks;
|
|
30
|
-
}): Promise<
|
|
30
|
+
}): Promise<ChatCompletionMessageParam>;
|
|
31
31
|
export interface Tool<T> {
|
|
32
32
|
def: ChatCompletionTool;
|
|
33
33
|
fn: (p: {
|
|
@@ -30,14 +30,20 @@ export async function processToolCall({ tools, toolCall, messages, helpers, tool
|
|
|
30
30
|
result =
|
|
31
31
|
'Error while calling tool, MUST tell the user to check the browser console for more details, and then respond as much as possible to the original request';
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
const toAdd = {
|
|
34
34
|
role: 'tool',
|
|
35
35
|
tool_call_id: toolCall.id,
|
|
36
36
|
content: result
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
|
+
return toAdd;
|
|
38
39
|
}
|
|
39
40
|
catch (err) {
|
|
40
41
|
console.error(err);
|
|
42
|
+
return {
|
|
43
|
+
role: 'tool',
|
|
44
|
+
tool_call_id: toolCall.id,
|
|
45
|
+
content: 'Error while calling tool, MUST tell the user to check the browser console for more details, and then respond as much as possible to the original request'
|
|
46
|
+
};
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
export function createToolDef(zodSchema, name, description) {
|