@flowgram.ai/form-materials 0.2.26 → 0.2.28

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.
Files changed (38) hide show
  1. package/bin/materials.ts +1 -1
  2. package/dist/esm/index.js +506 -224
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/index.d.mts +53 -15
  5. package/dist/index.d.ts +53 -15
  6. package/dist/index.js +514 -230
  7. package/dist/index.js.map +1 -1
  8. package/package.json +6 -5
  9. package/src/components/batch-outputs/config.json +2 -1
  10. package/src/components/batch-outputs/index.tsx +4 -12
  11. package/src/components/code-editor/config.json +2 -1
  12. package/src/components/code-editor/language-features.ts +3 -4
  13. package/src/components/constant-input/index.tsx +19 -2
  14. package/src/components/constant-input/types.ts +1 -0
  15. package/src/components/dynamic-value-input/index.tsx +58 -9
  16. package/src/components/dynamic-value-input/styles.tsx +28 -2
  17. package/src/components/index.ts +1 -0
  18. package/src/components/inputs-values/config.json +12 -0
  19. package/src/components/inputs-values/index.tsx +60 -0
  20. package/src/components/inputs-values/styles.tsx +19 -0
  21. package/src/components/inputs-values/types.ts +19 -0
  22. package/src/components/json-schema-editor/index.tsx +14 -1
  23. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
  24. package/src/components/type-selector/index.tsx +15 -8
  25. package/src/components/variable-selector/index.tsx +30 -11
  26. package/src/components/variable-selector/styles.tsx +18 -8
  27. package/src/effects/auto-rename-ref/index.ts +59 -8
  28. package/src/effects/index.ts +0 -1
  29. package/src/form-plugins/index.ts +2 -1
  30. package/src/form-plugins/infer-inputs-plugin/config.json +7 -0
  31. package/src/form-plugins/infer-inputs-plugin/index.ts +108 -0
  32. package/src/hooks/index.tsx +6 -0
  33. package/src/hooks/use-object-list/config.json +8 -0
  34. package/src/{components/batch-outputs/use-list.ts → hooks/use-object-list/index.tsx} +49 -12
  35. package/src/typings/flow-value/config.json +3 -1
  36. package/src/typings/flow-value/index.ts +3 -0
  37. package/src/effects/provide-batch-outputs/config.json +0 -5
  38. package/src/effects/provide-batch-outputs/index.ts +0 -38
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/components/variable-selector/index.tsx
2
2
  import React3, { useMemo } from "react";
3
+ import { Popover } from "@douyinfe/semi-ui";
3
4
  import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
4
5
 
5
6
  // src/components/variable-selector/use-variable-tree.tsx
@@ -579,7 +580,7 @@ function useVariableTree(params) {
579
580
  }
580
581
 
581
582
  // src/components/variable-selector/styles.tsx
582
- import styled from "styled-components";
583
+ import styled, { css } from "styled-components";
583
584
  import { Tag, TreeSelect } from "@douyinfe/semi-ui";
584
585
  var UIRootTitle = styled.div`
585
586
  margin-right: 4px;
@@ -593,7 +594,10 @@ var UIVarName = styled.div`
593
594
  overflow: hidden;
594
595
  text-overflow: ellipsis;
595
596
  white-space: nowrap;
596
- min-width: 50%;
597
+
598
+ ${({ $inSelector }) => $inSelector && css`
599
+ min-width: 50%;
600
+ `}
597
601
  `;
598
602
  var UITag = styled(Tag)`
599
603
  width: 100%;
@@ -607,17 +611,14 @@ var UITag = styled(Tag)`
607
611
 
608
612
  &.semi-tag {
609
613
  margin: 0;
614
+ height: 22px;
610
615
  }
611
616
  `;
612
617
  var UITreeSelect = styled(TreeSelect)`
613
618
  outline: ${({ $error }) => $error ? "1px solid red" : "none"};
614
619
 
615
- height: 22px;
616
- min-height: 22px;
617
- line-height: 22px;
618
-
619
620
  & .semi-tree-select-selection {
620
- padding: 0 2px;
621
+ padding: 0px;
621
622
  height: 22px;
622
623
  }
623
624
 
@@ -629,6 +630,13 @@ var UITreeSelect = styled(TreeSelect)`
629
630
  padding-left: 10px;
630
631
  }
631
632
  `;
633
+ var UIPopoverContent = styled.div`
634
+ padding: 10px;
635
+ display: inline-flex;
636
+ align-items: center;
637
+ justify-content: flex-start;
638
+ white-space: nowrap;
639
+ `;
632
640
 
633
641
  // src/components/variable-selector/index.tsx
634
642
  var VariableSelector = ({
@@ -687,16 +695,24 @@ var VariableSelector = ({
687
695
  config?.notFoundContent ?? "Undefined"
688
696
  );
689
697
  }
690
- return /* @__PURE__ */ React3.createElement(
691
- UITag,
698
+ const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
699
+ const rootTitle = /* @__PURE__ */ React3.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null);
700
+ return /* @__PURE__ */ React3.createElement("div", null, /* @__PURE__ */ React3.createElement(
701
+ Popover,
692
702
  {
693
- prefixIcon: renderIcon(_option.rootMeta?.icon || _option?.icon),
694
- closable: !readonly,
695
- onClose: () => onChange(void 0)
703
+ content: /* @__PURE__ */ React3.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React3.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
696
704
  },
697
- /* @__PURE__ */ React3.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
698
- /* @__PURE__ */ React3.createElement(UIVarName, null, _option.label)
699
- );
705
+ /* @__PURE__ */ React3.createElement(
706
+ UITag,
707
+ {
708
+ prefixIcon: rootIcon,
709
+ closable: !readonly,
710
+ onClose: () => onChange(void 0)
711
+ },
712
+ rootTitle,
713
+ /* @__PURE__ */ React3.createElement(UIVarName, { $inSelector: true }, _option.label)
714
+ )
715
+ ));
700
716
  },
701
717
  showClear: false,
702
718
  arrowIcon: /* @__PURE__ */ React3.createElement(IconChevronDownStroked, { size: "small" }),
@@ -708,7 +724,7 @@ var VariableSelector = ({
708
724
 
709
725
  // src/components/type-selector/index.tsx
710
726
  import React4, { useMemo as useMemo2 } from "react";
711
- import { Button, Cascader } from "@douyinfe/semi-ui";
727
+ import { Cascader, IconButton } from "@douyinfe/semi-ui";
712
728
  var getTypeSelectValue = (value) => {
713
729
  if (value?.type === "array" && value?.items) {
714
730
  return [value.type, ...getTypeSelectValue(value.items) || []];
@@ -723,19 +739,27 @@ var parseTypeSelectValue = (value) => {
723
739
  return { type };
724
740
  };
725
741
  function TypeSelector(props) {
726
- const { value, onChange, disabled, style } = props;
742
+ const { value, onChange, readonly, disabled, style } = props;
727
743
  const selectValue = useMemo2(() => getTypeSelectValue(value), [value]);
728
744
  return /* @__PURE__ */ React4.createElement(
729
745
  Cascader,
730
746
  {
731
- disabled,
747
+ disabled: readonly || disabled,
732
748
  size: "small",
733
- triggerRender: () => /* @__PURE__ */ React4.createElement(Button, { size: "small", style }, getSchemaIcon(value)),
749
+ triggerRender: () => /* @__PURE__ */ React4.createElement(
750
+ IconButton,
751
+ {
752
+ size: "small",
753
+ style,
754
+ disabled: readonly || disabled,
755
+ icon: getSchemaIcon(value)
756
+ }
757
+ ),
734
758
  treeData: options,
735
759
  value: selectValue,
736
760
  leafOnly: true,
737
761
  onChange: (value2) => {
738
- onChange(parseTypeSelectValue(value2));
762
+ onChange?.(parseTypeSelectValue(value2));
739
763
  }
740
764
  }
741
765
  );
@@ -743,7 +767,7 @@ function TypeSelector(props) {
743
767
 
744
768
  // src/components/json-schema-editor/index.tsx
745
769
  import React9, { useMemo as useMemo5, useState as useState4 } from "react";
746
- import { Button as Button2, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
770
+ import { Button, Checkbox, IconButton as IconButton3 } from "@douyinfe/semi-ui";
747
771
  import {
748
772
  IconExpand,
749
773
  IconShrink,
@@ -755,7 +779,7 @@ import {
755
779
 
756
780
  // src/components/json-schema-editor/styles.tsx
757
781
  import React5 from "react";
758
- import styled2, { css } from "styled-components";
782
+ import styled2, { css as css2 } from "styled-components";
759
783
  import Icon3 from "@douyinfe/semi-icons";
760
784
  var UIContainer = styled2.div`
761
785
  /* & .semi-input {
@@ -787,7 +811,7 @@ var UIProperties = styled2.div`
787
811
  display: grid;
788
812
  grid-template-columns: auto 1fr;
789
813
 
790
- ${({ $shrink }) => $shrink && css`
814
+ ${({ $shrink }) => $shrink && css2`
791
815
  padding-left: 10px;
792
816
  margin-top: 10px;
793
817
  `}
@@ -802,7 +826,7 @@ var UIPropertyLeft = styled2.div`
802
826
  if ($parentType && $isLast) {
803
827
  height = "24px";
804
828
  }
805
- return $showLine && css`
829
+ return $showLine && css2`
806
830
  &::before {
807
831
  /* 竖线 */
808
832
  content: '';
@@ -856,12 +880,12 @@ var UIPropertyMain = styled2.div`
856
880
  background: #d9d9d9;
857
881
  display: block;
858
882
  }`;
859
- return $expand && css`
883
+ return $expand && css2`
860
884
  background-color: #f5f5f5;
861
885
  padding: 10px;
862
886
  border-radius: 4px;
863
887
 
864
- ${$showCollapse && $collapse && (type === "array" || type === "object") && css`
888
+ ${$showCollapse && $collapse && (type === "array" || type === "object") && css2`
865
889
  ${beforeElement}
866
890
  `}
867
891
  `;
@@ -870,7 +894,7 @@ var UIPropertyMain = styled2.div`
870
894
  var UICollapsible = styled2.div`
871
895
  display: none;
872
896
 
873
- ${({ $collapse }) => $collapse && css`
897
+ ${({ $collapse }) => $collapse && css2`
874
898
  display: block;
875
899
  `}
876
900
  `;
@@ -1061,7 +1085,7 @@ function usePropertiesEdit(value, onChange) {
1061
1085
 
1062
1086
  // src/components/json-schema-editor/default-value.tsx
1063
1087
  import React7, { useRef as useRef2, useState as useState2, useCallback as useCallback2 } from "react";
1064
- import { IconButton, JsonViewer, Tooltip } from "@douyinfe/semi-ui";
1088
+ import { IconButton as IconButton2, JsonViewer, Tooltip } from "@douyinfe/semi-ui";
1065
1089
  import { IconBrackets } from "@douyinfe/semi-icons";
1066
1090
 
1067
1091
  // src/components/json-schema-editor/utils.ts
@@ -1141,9 +1165,18 @@ var defaultStrategies = [
1141
1165
  }
1142
1166
  ];
1143
1167
  function ConstantInput(props) {
1144
- const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
1168
+ const {
1169
+ value,
1170
+ onChange,
1171
+ schema,
1172
+ strategies: extraStrategies,
1173
+ fallbackRenderer,
1174
+ readonly,
1175
+ ...rest
1176
+ } = props;
1145
1177
  const strategies = useMemo4(
1146
- () => [...defaultStrategies, ...extraStrategies || []],
1178
+ // user's extraStrategies first
1179
+ () => [...extraStrategies || [], ...defaultStrategies],
1147
1180
  [extraStrategies]
1148
1181
  );
1149
1182
  const Renderer2 = useMemo4(() => {
@@ -1151,6 +1184,14 @@ function ConstantInput(props) {
1151
1184
  return strategy?.Renderer;
1152
1185
  }, [strategies, schema]);
1153
1186
  if (!Renderer2) {
1187
+ if (fallbackRenderer) {
1188
+ return React6.createElement(fallbackRenderer, {
1189
+ value,
1190
+ onChange,
1191
+ readonly,
1192
+ ...rest
1193
+ });
1194
+ }
1154
1195
  return /* @__PURE__ */ React6.createElement(Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
1155
1196
  }
1156
1197
  return /* @__PURE__ */ React6.createElement(Renderer2, { value, onChange, readonly, ...rest });
@@ -1188,7 +1229,7 @@ function DefaultValue(props) {
1188
1229
  }
1189
1230
  }, [internalJsonValue, onChange]);
1190
1231
  return type === "object" ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(JSONHeader, null, /* @__PURE__ */ React7.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React7.createElement(JSONHeaderRight, null, /* @__PURE__ */ React7.createElement(Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ React7.createElement(
1191
- IconButton,
1232
+ IconButton2,
1192
1233
  {
1193
1234
  icon: /* @__PURE__ */ React7.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
1194
1235
  size: "small",
@@ -1262,7 +1303,7 @@ function BlurInput(props) {
1262
1303
 
1263
1304
  // src/components/json-schema-editor/index.tsx
1264
1305
  function JsonSchemaEditor(props) {
1265
- const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
1306
+ const { value = { type: "object" }, config = {}, onChange: onChangeProps, readonly } = props;
1266
1307
  const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
1267
1308
  value,
1268
1309
  onChangeProps
@@ -1270,6 +1311,7 @@ function JsonSchemaEditor(props) {
1270
1311
  return /* @__PURE__ */ React9.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React9.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
1271
1312
  PropertyEdit,
1272
1313
  {
1314
+ readonly,
1273
1315
  key: _property.key,
1274
1316
  value: _property,
1275
1317
  config,
@@ -1282,8 +1324,9 @@ function JsonSchemaEditor(props) {
1282
1324
  }
1283
1325
  }
1284
1326
  ))), /* @__PURE__ */ React9.createElement(
1285
- Button2,
1327
+ Button,
1286
1328
  {
1329
+ disabled: readonly,
1287
1330
  size: "small",
1288
1331
  style: { marginTop: 10, marginLeft: 16 },
1289
1332
  icon: /* @__PURE__ */ React9.createElement(IconPlus, null),
@@ -1296,6 +1339,7 @@ function PropertyEdit(props) {
1296
1339
  const {
1297
1340
  value,
1298
1341
  config,
1342
+ readonly,
1299
1343
  $level = 0,
1300
1344
  onChange: onChangeProps,
1301
1345
  onRemove,
@@ -1342,6 +1386,7 @@ function PropertyEdit(props) {
1342
1386
  /* @__PURE__ */ React9.createElement(UIRow, null, /* @__PURE__ */ React9.createElement(UIName, null, /* @__PURE__ */ React9.createElement(
1343
1387
  BlurInput,
1344
1388
  {
1389
+ disabled: readonly,
1345
1390
  placeholder: config?.placeholder ?? "Input Variable Name",
1346
1391
  size: "small",
1347
1392
  value: name,
@@ -1351,6 +1396,7 @@ function PropertyEdit(props) {
1351
1396
  TypeSelector,
1352
1397
  {
1353
1398
  value: typeSelectorValue,
1399
+ readonly,
1354
1400
  onChange: (_value) => {
1355
1401
  onChangeProps?.({
1356
1402
  ...value || {},
@@ -1361,12 +1407,14 @@ function PropertyEdit(props) {
1361
1407
  )), /* @__PURE__ */ React9.createElement(UIRequired, null, /* @__PURE__ */ React9.createElement(
1362
1408
  Checkbox,
1363
1409
  {
1410
+ disabled: readonly,
1364
1411
  checked: isPropertyRequired,
1365
1412
  onChange: (e) => onChange("isPropertyRequired", e.target.checked)
1366
1413
  }
1367
1414
  )), /* @__PURE__ */ React9.createElement(UIActions, null, /* @__PURE__ */ React9.createElement(
1368
- IconButton2,
1415
+ IconButton3,
1369
1416
  {
1417
+ disabled: readonly,
1370
1418
  size: "small",
1371
1419
  theme: "borderless",
1372
1420
  icon: expand ? /* @__PURE__ */ React9.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconExpand, { size: "small" }),
@@ -1375,8 +1423,9 @@ function PropertyEdit(props) {
1375
1423
  }
1376
1424
  }
1377
1425
  ), isDrilldownObject && /* @__PURE__ */ React9.createElement(
1378
- IconButton2,
1426
+ IconButton3,
1379
1427
  {
1428
+ disabled: readonly,
1380
1429
  size: "small",
1381
1430
  theme: "borderless",
1382
1431
  icon: /* @__PURE__ */ React9.createElement(IconAddChildren, null),
@@ -1386,8 +1435,9 @@ function PropertyEdit(props) {
1386
1435
  }
1387
1436
  }
1388
1437
  ), /* @__PURE__ */ React9.createElement(
1389
- IconButton2,
1438
+ IconButton3,
1390
1439
  {
1440
+ disabled: readonly,
1391
1441
  size: "small",
1392
1442
  theme: "borderless",
1393
1443
  icon: /* @__PURE__ */ React9.createElement(IconMinus, { size: "small" }),
@@ -1397,6 +1447,7 @@ function PropertyEdit(props) {
1397
1447
  expand && /* @__PURE__ */ React9.createElement(UIExpandDetail, null, /* @__PURE__ */ React9.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React9.createElement(
1398
1448
  BlurInput,
1399
1449
  {
1450
+ disabled: readonly,
1400
1451
  size: "small",
1401
1452
  value: description,
1402
1453
  onChange: (value2) => onChange("description", value2),
@@ -1416,6 +1467,7 @@ function PropertyEdit(props) {
1416
1467
  ), showCollapse && /* @__PURE__ */ React9.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React9.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
1417
1468
  PropertyEdit,
1418
1469
  {
1470
+ readonly,
1419
1471
  key: _property.key,
1420
1472
  value: _property,
1421
1473
  config,
@@ -1448,16 +1500,84 @@ function BatchVariableSelector(props) {
1448
1500
  }
1449
1501
 
1450
1502
  // src/components/dynamic-value-input/index.tsx
1451
- import React11, { useMemo as useMemo6 } from "react";
1452
- import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
1503
+ import React11, { useMemo as useMemo6, useState as useState5 } from "react";
1504
+ import { useScopeAvailable } from "@flowgram.ai/editor";
1505
+ import { IconButton as IconButton4 } from "@douyinfe/semi-ui";
1453
1506
  import { IconSetting } from "@douyinfe/semi-icons";
1454
1507
 
1508
+ // src/utils/format-legacy-refs/index.ts
1509
+ import { isObject } from "lodash";
1510
+ function formatLegacyRefOnSubmit(value) {
1511
+ if (isObject(value)) {
1512
+ if (isLegacyFlowRefValueSchema(value)) {
1513
+ return formatLegacyRefToNewRef(value);
1514
+ }
1515
+ return Object.fromEntries(
1516
+ Object.entries(value).map(([key, value2]) => [
1517
+ key,
1518
+ formatLegacyRefOnSubmit(value2)
1519
+ ])
1520
+ );
1521
+ }
1522
+ if (Array.isArray(value)) {
1523
+ return value.map(formatLegacyRefOnSubmit);
1524
+ }
1525
+ return value;
1526
+ }
1527
+ function formatLegacyRefOnInit(value) {
1528
+ if (isObject(value)) {
1529
+ if (isNewFlowRefValueSchema(value)) {
1530
+ return formatNewRefToLegacyRef(value);
1531
+ }
1532
+ return Object.fromEntries(
1533
+ Object.entries(value).map(([key, value2]) => [
1534
+ key,
1535
+ formatLegacyRefOnInit(value2)
1536
+ ])
1537
+ );
1538
+ }
1539
+ if (Array.isArray(value)) {
1540
+ return value.map(formatLegacyRefOnInit);
1541
+ }
1542
+ return value;
1543
+ }
1544
+ function isLegacyFlowRefValueSchema(value) {
1545
+ return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
1546
+ }
1547
+ function isNewFlowRefValueSchema(value) {
1548
+ return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
1549
+ }
1550
+ function formatLegacyRefToNewRef(value) {
1551
+ const keyPath = value.content.split(".");
1552
+ if (keyPath[1] === "outputs") {
1553
+ return {
1554
+ type: "ref",
1555
+ content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
1556
+ };
1557
+ }
1558
+ return {
1559
+ type: "ref",
1560
+ content: keyPath
1561
+ };
1562
+ }
1563
+ function formatNewRefToLegacyRef(value) {
1564
+ return {
1565
+ type: "ref",
1566
+ content: value.content.join(".")
1567
+ };
1568
+ }
1569
+
1455
1570
  // src/components/dynamic-value-input/styles.tsx
1456
1571
  import styled3 from "styled-components";
1457
1572
  var UIContainer2 = styled3.div`
1458
1573
  display: flex;
1459
1574
  align-items: center;
1460
- gap: 5px;
1575
+ border-radius: 4px;
1576
+ border: 1px solid var(--semi-color-border);
1577
+
1578
+ overflow: hidden;
1579
+
1580
+ background-color: var(--semi-color-fill-0);
1461
1581
  `;
1462
1582
  var UIMain = styled3.div`
1463
1583
  flex-grow: 1;
@@ -1468,9 +1588,29 @@ var UIMain = styled3.div`
1468
1588
  & .semi-input-number,
1469
1589
  & .semi-select {
1470
1590
  width: 100%;
1591
+ border: none;
1592
+ border-radius: 0;
1593
+ }
1594
+
1595
+ & .semi-input-wrapper {
1596
+ border: none;
1597
+ border-radius: 0;
1598
+ }
1599
+ `;
1600
+ var UIType2 = styled3.div`
1601
+ border-right: 1px solid #e5e5e5;
1602
+
1603
+ & .semi-button {
1604
+ border-radius: 0;
1605
+ }
1606
+ `;
1607
+ var UITrigger = styled3.div`
1608
+ border-left: 1px solid #e5e5e5;
1609
+
1610
+ & .semi-button {
1611
+ border-radius: 0;
1471
1612
  }
1472
1613
  `;
1473
- var UITrigger = styled3.div``;
1474
1614
 
1475
1615
  // src/components/dynamic-value-input/index.tsx
1476
1616
  function DynamicValueInput({
@@ -1478,15 +1618,44 @@ function DynamicValueInput({
1478
1618
  onChange,
1479
1619
  readonly,
1480
1620
  style,
1481
- schema,
1621
+ schema: schemaFromProps,
1482
1622
  constantProps
1483
1623
  }) {
1624
+ const available = useScopeAvailable();
1625
+ const refVariable = useMemo6(() => {
1626
+ if (value?.type === "ref") {
1627
+ return available.getByKeyPath(value.content);
1628
+ }
1629
+ }, [value, available]);
1630
+ const [selectSchema, setSelectSchema] = useState5(
1631
+ schemaFromProps || constantProps?.schema || { type: "string" }
1632
+ );
1633
+ const renderTypeSelector = () => {
1634
+ if (schemaFromProps) {
1635
+ return /* @__PURE__ */ React11.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
1636
+ }
1637
+ if (value?.type === "ref") {
1638
+ const schema = refVariable?.type ? JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
1639
+ return /* @__PURE__ */ React11.createElement(TypeSelector, { value: schema, readonly: true });
1640
+ }
1641
+ return /* @__PURE__ */ React11.createElement(
1642
+ TypeSelector,
1643
+ {
1644
+ value: selectSchema,
1645
+ onChange: (_v) => setSelectSchema(_v || { type: "string" }),
1646
+ readonly
1647
+ }
1648
+ );
1649
+ };
1484
1650
  const includeSchema = useMemo6(() => {
1485
- if (schema?.type === "number") {
1486
- return [schema, { type: "integer" }];
1651
+ if (!schemaFromProps) {
1652
+ return;
1487
1653
  }
1488
- return schema;
1489
- }, [schema]);
1654
+ if (schemaFromProps?.type === "number") {
1655
+ return [schemaFromProps, { type: "integer" }];
1656
+ }
1657
+ return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
1658
+ }, [schemaFromProps]);
1490
1659
  const renderMain = () => {
1491
1660
  if (value?.type === "ref") {
1492
1661
  return /* @__PURE__ */ React11.createElement(
@@ -1500,13 +1669,24 @@ function DynamicValueInput({
1500
1669
  }
1501
1670
  );
1502
1671
  }
1672
+ const constantSchema = schemaFromProps || selectSchema || { type: "string" };
1503
1673
  return /* @__PURE__ */ React11.createElement(
1504
1674
  ConstantInput,
1505
1675
  {
1506
1676
  value: value?.content,
1507
- onChange: (_v) => onChange({ type: "constant", content: _v }),
1508
- schema: schema || { type: "string" },
1677
+ onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
1678
+ schema: constantSchema || { type: "string" },
1509
1679
  readonly,
1680
+ strategies: [...constantProps?.strategies || []],
1681
+ fallbackRenderer: () => /* @__PURE__ */ React11.createElement(
1682
+ VariableSelector,
1683
+ {
1684
+ style: { width: "100%" },
1685
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1686
+ includeSchema,
1687
+ readonly
1688
+ }
1689
+ ),
1510
1690
  ...constantProps
1511
1691
  }
1512
1692
  );
@@ -1519,10 +1699,10 @@ function DynamicValueInput({
1519
1699
  onChange: (_v) => onChange({ type: "ref", content: _v }),
1520
1700
  includeSchema,
1521
1701
  readonly,
1522
- triggerRender: () => /* @__PURE__ */ React11.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React11.createElement(IconSetting, { size: "small" }) })
1702
+ triggerRender: () => /* @__PURE__ */ React11.createElement(IconButton4, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React11.createElement(IconSetting, { size: "small" }) })
1523
1703
  }
1524
1704
  );
1525
- return /* @__PURE__ */ React11.createElement(UIContainer2, { style }, /* @__PURE__ */ React11.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React11.createElement(UITrigger, null, renderTrigger()));
1705
+ return /* @__PURE__ */ React11.createElement(UIContainer2, { style }, /* @__PURE__ */ React11.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ React11.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React11.createElement(UITrigger, null, renderTrigger()));
1526
1706
  }
1527
1707
 
1528
1708
  // src/components/condition-row/index.tsx
@@ -1553,7 +1733,7 @@ var UIValues = styled4.div`
1553
1733
 
1554
1734
  // src/components/condition-row/hooks/useRule.ts
1555
1735
  import { useMemo as useMemo7 } from "react";
1556
- import { useScopeAvailable } from "@flowgram.ai/editor";
1736
+ import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
1557
1737
 
1558
1738
  // src/components/condition-row/constants.ts
1559
1739
  var rules = {
@@ -1677,71 +1857,9 @@ var opConfigs = {
1677
1857
  }
1678
1858
  };
1679
1859
 
1680
- // src/utils/format-legacy-refs/index.ts
1681
- import { isObject } from "lodash";
1682
- function formatLegacyRefOnSubmit(value) {
1683
- if (isObject(value)) {
1684
- if (isLegacyFlowRefValueSchema(value)) {
1685
- return formatLegacyRefToNewRef(value);
1686
- }
1687
- return Object.fromEntries(
1688
- Object.entries(value).map(([key, value2]) => [
1689
- key,
1690
- formatLegacyRefOnSubmit(value2)
1691
- ])
1692
- );
1693
- }
1694
- if (Array.isArray(value)) {
1695
- return value.map(formatLegacyRefOnSubmit);
1696
- }
1697
- return value;
1698
- }
1699
- function formatLegacyRefOnInit(value) {
1700
- if (isObject(value)) {
1701
- if (isNewFlowRefValueSchema(value)) {
1702
- return formatNewRefToLegacyRef(value);
1703
- }
1704
- return Object.fromEntries(
1705
- Object.entries(value).map(([key, value2]) => [
1706
- key,
1707
- formatLegacyRefOnInit(value2)
1708
- ])
1709
- );
1710
- }
1711
- if (Array.isArray(value)) {
1712
- return value.map(formatLegacyRefOnInit);
1713
- }
1714
- return value;
1715
- }
1716
- function isLegacyFlowRefValueSchema(value) {
1717
- return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
1718
- }
1719
- function isNewFlowRefValueSchema(value) {
1720
- return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
1721
- }
1722
- function formatLegacyRefToNewRef(value) {
1723
- const keyPath = value.content.split(".");
1724
- if (keyPath[1] === "outputs") {
1725
- return {
1726
- type: "ref",
1727
- content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
1728
- };
1729
- }
1730
- return {
1731
- type: "ref",
1732
- content: keyPath
1733
- };
1734
- }
1735
- function formatNewRefToLegacyRef(value) {
1736
- return {
1737
- type: "ref",
1738
- content: value.content.join(".")
1739
- };
1740
- }
1741
-
1742
1860
  // src/components/condition-row/hooks/useRule.ts
1743
1861
  function useRule(left) {
1744
- const available = useScopeAvailable();
1862
+ const available = useScopeAvailable2();
1745
1863
  const variable = useMemo7(() => {
1746
1864
  if (!left) return void 0;
1747
1865
  return available.getByKeyPath(left.content);
@@ -1756,7 +1874,7 @@ function useRule(left) {
1756
1874
 
1757
1875
  // src/components/condition-row/hooks/useOp.tsx
1758
1876
  import React12, { useMemo as useMemo8 } from "react";
1759
- import { Button as Button3, Select as Select2 } from "@douyinfe/semi-ui";
1877
+ import { Button as Button2, Select as Select2 } from "@douyinfe/semi-ui";
1760
1878
  import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
1761
1879
  function useOp({ rule, op, onChange }) {
1762
1880
  const options2 = useMemo8(
@@ -1777,7 +1895,7 @@ function useOp({ rule, op, onChange }) {
1777
1895
  onChange: (v) => {
1778
1896
  onChange(v);
1779
1897
  },
1780
- triggerRender: ({ value }) => /* @__PURE__ */ React12.createElement(Button3, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React12.createElement(IconChevronDownStroked2, { size: "small" }))
1898
+ triggerRender: ({ value }) => /* @__PURE__ */ React12.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React12.createElement(IconChevronDownStroked2, { size: "small" }))
1781
1899
  }
1782
1900
  );
1783
1901
  return { renderOpSelect, opConfig };
@@ -1831,18 +1949,21 @@ function ConditionRow({ style, value, onChange, readonly }) {
1831
1949
 
1832
1950
  // src/components/batch-outputs/index.tsx
1833
1951
  import React14 from "react";
1834
- import { Button as Button4, Input as Input4 } from "@douyinfe/semi-ui";
1952
+ import { Button as Button3, Input as Input4 } from "@douyinfe/semi-ui";
1835
1953
  import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
1836
1954
 
1837
- // src/components/batch-outputs/use-list.ts
1838
- import { useEffect as useEffect3, useState as useState5 } from "react";
1955
+ // src/hooks/use-object-list/index.tsx
1956
+ import { useEffect as useEffect3, useState as useState6 } from "react";
1957
+ import { nanoid } from "nanoid";
1839
1958
  import { difference } from "lodash";
1840
- var _id2 = 0;
1841
1959
  function genId2() {
1842
- return _id2++;
1960
+ return nanoid();
1843
1961
  }
1844
- function useList({ value, onChange }) {
1845
- const [list, setList] = useState5([]);
1962
+ function useObjectList({
1963
+ value,
1964
+ onChange
1965
+ }) {
1966
+ const [list, setList] = useState6([]);
1846
1967
  useEffect3(() => {
1847
1968
  setList((_prevList) => {
1848
1969
  const newKeys = Object.keys(value || {});
@@ -1851,7 +1972,7 @@ function useList({ value, onChange }) {
1851
1972
  return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
1852
1973
  id: item.id,
1853
1974
  key: item.key,
1854
- value: item.key ? value?.[item.key] : void 0
1975
+ value: item.key ? value?.[item.key] : item.value
1855
1976
  })).concat(
1856
1977
  addKeys.map((_key) => ({
1857
1978
  id: genId2(),
@@ -1869,17 +1990,39 @@ function useList({ value, onChange }) {
1869
1990
  }
1870
1991
  ]);
1871
1992
  };
1872
- const update = (item) => {
1993
+ const updateValue = (itemId, value2) => {
1873
1994
  setList((prevList) => {
1874
1995
  const nextList = prevList.map((_item) => {
1875
- if (_item.id === item.id) {
1876
- return item;
1996
+ if (_item.id === itemId) {
1997
+ return {
1998
+ ..._item,
1999
+ value: value2
2000
+ };
1877
2001
  }
1878
2002
  return _item;
1879
2003
  });
1880
2004
  onChange(
1881
2005
  Object.fromEntries(
1882
- nextList.filter((item2) => item2.key).map((item2) => [item2.key, item2.value])
2006
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value])
2007
+ )
2008
+ );
2009
+ return nextList;
2010
+ });
2011
+ };
2012
+ const updateKey = (itemId, key) => {
2013
+ setList((prevList) => {
2014
+ const nextList = prevList.map((_item) => {
2015
+ if (_item.id === itemId) {
2016
+ return {
2017
+ ..._item,
2018
+ key
2019
+ };
2020
+ }
2021
+ return _item;
2022
+ });
2023
+ onChange(
2024
+ Object.fromEntries(
2025
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value])
1883
2026
  )
1884
2027
  );
1885
2028
  return nextList;
@@ -1896,7 +2039,7 @@ function useList({ value, onChange }) {
1896
2039
  return nextList;
1897
2040
  });
1898
2041
  };
1899
- return { list, add, update, remove };
2042
+ return { list, add, updateKey, updateValue, remove };
1900
2043
  }
1901
2044
 
1902
2045
  // src/components/batch-outputs/styles.tsx
@@ -1916,7 +2059,7 @@ var UIRow2 = styled5.div`
1916
2059
  // src/components/batch-outputs/index.tsx
1917
2060
  function BatchOutputs(props) {
1918
2061
  const { readonly, style } = props;
1919
- const { list, add, update, remove } = useList(props);
2062
+ const { list, add, updateKey, updateValue, remove } = useObjectList(props);
1920
2063
  return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React14.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React14.createElement(
1921
2064
  Input4,
1922
2065
  {
@@ -1924,7 +2067,7 @@ function BatchOutputs(props) {
1924
2067
  disabled: readonly,
1925
2068
  size: "small",
1926
2069
  value: item.key,
1927
- onChange: (v) => update({ ...item, key: v })
2070
+ onChange: (v) => updateKey(item.id, v)
1928
2071
  }
1929
2072
  ), /* @__PURE__ */ React14.createElement(
1930
2073
  VariableSelector,
@@ -1932,23 +2075,17 @@ function BatchOutputs(props) {
1932
2075
  style: { flexGrow: 1 },
1933
2076
  readonly,
1934
2077
  value: item.value?.content,
1935
- onChange: (v) => update({
1936
- ...item,
1937
- value: {
1938
- type: "ref",
1939
- content: v
1940
- }
1941
- })
2078
+ onChange: (v) => updateValue(item.id, { type: "ref", content: v })
1942
2079
  }
1943
2080
  ), /* @__PURE__ */ React14.createElement(
1944
- Button4,
2081
+ Button3,
1945
2082
  {
1946
2083
  disabled: readonly,
1947
2084
  icon: /* @__PURE__ */ React14.createElement(IconDelete, null),
1948
2085
  size: "small",
1949
2086
  onClick: () => remove(item.id)
1950
2087
  }
1951
- )))), /* @__PURE__ */ React14.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React14.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
2088
+ )))), /* @__PURE__ */ React14.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React14.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
1952
2089
  }
1953
2090
 
1954
2091
  // src/components/prompt-editor/index.tsx
@@ -1957,13 +2094,13 @@ import { Renderer, EditorProvider, ActiveLinePlaceholder } from "@coze-editor/ed
1957
2094
  import preset from "@coze-editor/editor/preset-prompt";
1958
2095
 
1959
2096
  // src/components/prompt-editor/styles.tsx
1960
- import styled6, { css as css2 } from "styled-components";
2097
+ import styled6, { css as css3 } from "styled-components";
1961
2098
  var UIContainer4 = styled6.div`
1962
2099
  background-color: var(--semi-color-fill-0);
1963
2100
  padding-left: 10px;
1964
2101
  padding-right: 6px;
1965
2102
 
1966
- ${({ $hasError }) => $hasError && css2`
2103
+ ${({ $hasError }) => $hasError && css3`
1967
2104
  border: 1px solid var(--semi-color-danger-6);
1968
2105
  `}
1969
2106
  `;
@@ -2126,8 +2263,8 @@ function PromptEditor(props) {
2126
2263
  import React18 from "react";
2127
2264
 
2128
2265
  // src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
2129
- import React16, { useEffect as useEffect5, useState as useState6 } from "react";
2130
- import { Popover, Tree } from "@douyinfe/semi-ui";
2266
+ import React16, { useEffect as useEffect5, useState as useState7 } from "react";
2267
+ import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
2131
2268
  import {
2132
2269
  Mention,
2133
2270
  getCurrentMentionReplaceRange,
@@ -2135,9 +2272,9 @@ import {
2135
2272
  PositionMirror
2136
2273
  } from "@coze-editor/editor/react";
2137
2274
  function VariableTree() {
2138
- const [posKey, setPosKey] = useState6("");
2139
- const [visible, setVisible] = useState6(false);
2140
- const [position, setPosition] = useState6(-1);
2275
+ const [posKey, setPosKey] = useState7("");
2276
+ const [visible, setVisible] = useState7(false);
2277
+ const [position, setPosition] = useState7(-1);
2141
2278
  const editor = useEditor();
2142
2279
  function insert(variablePath) {
2143
2280
  const range = getCurrentMentionReplaceRange(editor.$view.state);
@@ -2161,7 +2298,7 @@ function VariableTree() {
2161
2298
  }, [editor, visible]);
2162
2299
  const treeData = useVariableTree({});
2163
2300
  return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React16.createElement(
2164
- Popover,
2301
+ Popover2,
2165
2302
  {
2166
2303
  visible,
2167
2304
  trigger: "custom",
@@ -2196,7 +2333,7 @@ import {
2196
2333
  DisposableCollection,
2197
2334
  useCurrentScope
2198
2335
  } from "@flowgram.ai/editor";
2199
- import { Popover as Popover2 } from "@douyinfe/semi-ui";
2336
+ import { Popover as Popover3 } from "@douyinfe/semi-ui";
2200
2337
  import { IconIssueStroked as IconIssueStroked2 } from "@douyinfe/semi-icons";
2201
2338
  import { useInjector as useInjector4 } from "@coze-editor/editor/react";
2202
2339
  import {
@@ -2237,7 +2374,7 @@ var UITag2 = styled7(Tag2)`
2237
2374
  margin: 0 5px;
2238
2375
  }
2239
2376
  `;
2240
- var UIPopoverContent = styled7.div`
2377
+ var UIPopoverContent2 = styled7.div`
2241
2378
  padding: 10px;
2242
2379
  display: inline-flex;
2243
2380
  align-items: center;
@@ -2273,9 +2410,9 @@ var VariableTagWidget = class extends WidgetType {
2273
2410
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2274
2411
  this.renderReact(
2275
2412
  /* @__PURE__ */ React17.createElement(
2276
- Popover2,
2413
+ Popover3,
2277
2414
  {
2278
- content: /* @__PURE__ */ React17.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2415
+ content: /* @__PURE__ */ React17.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2279
2416
  },
2280
2417
  /* @__PURE__ */ React17.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.key))
2281
2418
  )
@@ -2358,8 +2495,8 @@ function PromptEditorWithVariables(props) {
2358
2495
  import React21 from "react";
2359
2496
 
2360
2497
  // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2361
- import React20, { useEffect as useEffect6, useState as useState7 } from "react";
2362
- import { Popover as Popover3 } from "@douyinfe/semi-ui";
2498
+ import React20, { useEffect as useEffect6, useState as useState8 } from "react";
2499
+ import { Popover as Popover4 } from "@douyinfe/semi-ui";
2363
2500
  import {
2364
2501
  Mention as Mention2,
2365
2502
  getCurrentMentionReplaceRange as getCurrentMentionReplaceRange2,
@@ -2372,14 +2509,14 @@ import React19, { useMemo as useMemo10 } from "react";
2372
2509
  import { last as last2 } from "lodash";
2373
2510
  import {
2374
2511
  ASTMatch as ASTMatch3,
2375
- useScopeAvailable as useScopeAvailable2
2512
+ useScopeAvailable as useScopeAvailable3
2376
2513
  } from "@flowgram.ai/editor";
2377
2514
  import { Tree as Tree2 } from "@douyinfe/semi-ui";
2378
2515
  function InputsPicker({
2379
2516
  inputsValues,
2380
2517
  onSelect
2381
2518
  }) {
2382
- const available = useScopeAvailable2();
2519
+ const available = useScopeAvailable3();
2383
2520
  const getArrayDrilldown = (type, depth = 1) => {
2384
2521
  if (ASTMatch3.isArray(type.items)) {
2385
2522
  return getArrayDrilldown(type.items, depth + 1);
@@ -2414,7 +2551,7 @@ function InputsPicker({
2414
2551
  };
2415
2552
  const treeData = useMemo10(
2416
2553
  () => Object.entries(inputsValues).map(([key, value]) => {
2417
- if (value.type === "ref") {
2554
+ if (value?.type === "ref") {
2418
2555
  const variable = available.getByKeyPath(value.content || []);
2419
2556
  if (variable) {
2420
2557
  return renderVariable(variable, [key]);
@@ -2433,9 +2570,9 @@ function InputsPicker({
2433
2570
 
2434
2571
  // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2435
2572
  function InputsTree({ inputsValues }) {
2436
- const [posKey, setPosKey] = useState7("");
2437
- const [visible, setVisible] = useState7(false);
2438
- const [position, setPosition] = useState7(-1);
2573
+ const [posKey, setPosKey] = useState8("");
2574
+ const [visible, setVisible] = useState8(false);
2575
+ const [position, setPosition] = useState8(-1);
2439
2576
  const editor = useEditor2();
2440
2577
  function insert(variablePath) {
2441
2578
  const range = getCurrentMentionReplaceRange2(editor.$view.state);
@@ -2458,7 +2595,7 @@ function InputsTree({ inputsValues }) {
2458
2595
  }
2459
2596
  }, [editor, visible]);
2460
2597
  return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React20.createElement(
2461
- Popover3,
2598
+ Popover4,
2462
2599
  {
2463
2600
  visible,
2464
2601
  trigger: "custom",
@@ -2747,11 +2884,14 @@ themes.register("light", lightTheme);
2747
2884
 
2748
2885
  // src/components/code-editor/language-features.ts
2749
2886
  import { languages } from "@coze-editor/editor/preset-code";
2887
+ import { typescript } from "@coze-editor/editor/language-typescript";
2750
2888
  import { shell } from "@coze-editor/editor/language-shell";
2751
2889
  import { python } from "@coze-editor/editor/language-python";
2752
2890
  import { json } from "@coze-editor/editor/language-json";
2753
2891
  import { mixLanguages } from "@coze-editor/editor";
2754
2892
  languages.register("python", python);
2893
+ languages.register("typescript", typescript);
2894
+ languages.register("shell", shell);
2755
2895
  languages.register("json", {
2756
2896
  // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
2757
2897
  language: mixLanguages({
@@ -2759,7 +2899,6 @@ languages.register("json", {
2759
2899
  }),
2760
2900
  languageService: json.languageService
2761
2901
  });
2762
- languages.register("shell", shell);
2763
2902
 
2764
2903
  // src/components/code-editor/index.tsx
2765
2904
  var OriginCodeEditor = createRenderer(preset2, [
@@ -2814,8 +2953,8 @@ import React25 from "react";
2814
2953
  import { transformerCreator } from "@coze-editor/editor/preset-code";
2815
2954
 
2816
2955
  // src/components/json-editor-with-variables/extensions/variable-tree.tsx
2817
- import React23, { useEffect as useEffect8, useState as useState8 } from "react";
2818
- import { Popover as Popover4, Tree as Tree3 } from "@douyinfe/semi-ui";
2956
+ import React23, { useEffect as useEffect8, useState as useState9 } from "react";
2957
+ import { Popover as Popover5, Tree as Tree3 } from "@douyinfe/semi-ui";
2819
2958
  import {
2820
2959
  Mention as Mention3,
2821
2960
  getCurrentMentionReplaceRange as getCurrentMentionReplaceRange3,
@@ -2823,9 +2962,9 @@ import {
2823
2962
  PositionMirror as PositionMirror3
2824
2963
  } from "@coze-editor/editor/react";
2825
2964
  function VariableTree2() {
2826
- const [posKey, setPosKey] = useState8("");
2827
- const [visible, setVisible] = useState8(false);
2828
- const [position, setPosition] = useState8(-1);
2965
+ const [posKey, setPosKey] = useState9("");
2966
+ const [visible, setVisible] = useState9(false);
2967
+ const [position, setPosition] = useState9(-1);
2829
2968
  const editor = useEditor3();
2830
2969
  function insert(variablePath) {
2831
2970
  const range = getCurrentMentionReplaceRange3(editor.$view.state);
@@ -2849,7 +2988,7 @@ function VariableTree2() {
2849
2988
  }, [editor, visible]);
2850
2989
  const treeData = useVariableTree({});
2851
2990
  return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React23.createElement(
2852
- Popover4,
2991
+ Popover5,
2853
2992
  {
2854
2993
  visible,
2855
2994
  trigger: "custom",
@@ -2884,7 +3023,7 @@ import {
2884
3023
  DisposableCollection as DisposableCollection2,
2885
3024
  useCurrentScope as useCurrentScope2
2886
3025
  } from "@flowgram.ai/editor";
2887
- import { Popover as Popover5 } from "@douyinfe/semi-ui";
3026
+ import { Popover as Popover6 } from "@douyinfe/semi-ui";
2888
3027
  import { IconIssueStroked as IconIssueStroked3 } from "@douyinfe/semi-icons";
2889
3028
  import { useInjector as useInjector5 } from "@coze-editor/editor/react";
2890
3029
  import {
@@ -2925,7 +3064,7 @@ var UITag3 = styled8(Tag3)`
2925
3064
  margin: 0 5px;
2926
3065
  }
2927
3066
  `;
2928
- var UIPopoverContent2 = styled8.div`
3067
+ var UIPopoverContent3 = styled8.div`
2929
3068
  padding: 10px;
2930
3069
  display: inline-flex;
2931
3070
  align-items: center;
@@ -2958,9 +3097,9 @@ var VariableTagWidget2 = class extends WidgetType2 {
2958
3097
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2959
3098
  this.root.render(
2960
3099
  /* @__PURE__ */ React24.createElement(
2961
- Popover5,
3100
+ Popover6,
2962
3101
  {
2963
- content: /* @__PURE__ */ React24.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
3102
+ content: /* @__PURE__ */ React24.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
2964
3103
  },
2965
3104
  /* @__PURE__ */ React24.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.key))
2966
3105
  )
@@ -3080,6 +3219,64 @@ function JsonEditorWithVariables(props) {
3080
3219
  );
3081
3220
  }
3082
3221
 
3222
+ // src/components/inputs-values/index.tsx
3223
+ import React26 from "react";
3224
+ import { Button as Button4, IconButton as IconButton5, Input as Input5 } from "@douyinfe/semi-ui";
3225
+ import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
3226
+
3227
+ // src/components/inputs-values/styles.tsx
3228
+ import styled9 from "styled-components";
3229
+ var UIRows2 = styled9.div`
3230
+ display: flex;
3231
+ flex-direction: column;
3232
+ gap: 10px;
3233
+ margin-bottom: 10px;
3234
+ `;
3235
+ var UIRow3 = styled9.div`
3236
+ display: flex;
3237
+ align-items: center;
3238
+ gap: 5px;
3239
+ `;
3240
+
3241
+ // src/components/inputs-values/index.tsx
3242
+ function InputsValues({ value, onChange, style, readonly, constantProps }) {
3243
+ const { list, updateKey, updateValue, remove, add } = useObjectList({
3244
+ value,
3245
+ onChange
3246
+ });
3247
+ return /* @__PURE__ */ React26.createElement("div", null, /* @__PURE__ */ React26.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React26.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React26.createElement(
3248
+ Input5,
3249
+ {
3250
+ style: { width: 100, minWidth: 100, maxWidth: 100 },
3251
+ disabled: readonly,
3252
+ size: "small",
3253
+ value: item.key,
3254
+ onChange: (v) => updateKey(item.id, v)
3255
+ }
3256
+ ), /* @__PURE__ */ React26.createElement(
3257
+ DynamicValueInput,
3258
+ {
3259
+ style: { flexGrow: 1 },
3260
+ readonly,
3261
+ value: item.value,
3262
+ onChange: (v) => updateValue(item.id, v),
3263
+ constantProps: {
3264
+ ...constantProps,
3265
+ strategies: [...constantProps?.strategies || []]
3266
+ }
3267
+ }
3268
+ ), /* @__PURE__ */ React26.createElement(
3269
+ IconButton5,
3270
+ {
3271
+ disabled: readonly,
3272
+ theme: "borderless",
3273
+ icon: /* @__PURE__ */ React26.createElement(IconDelete2, { size: "small" }),
3274
+ size: "small",
3275
+ onClick: () => remove(item.id)
3276
+ }
3277
+ )))), /* @__PURE__ */ React26.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React26.createElement(IconPlus3, null), size: "small", onClick: add }, "Add"));
3278
+ }
3279
+
3083
3280
  // src/effects/provide-batch-input/index.ts
3084
3281
  import {
3085
3282
  ASTFactory as ASTFactory2,
@@ -3115,38 +3312,8 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
3115
3312
  ]
3116
3313
  });
3117
3314
 
3118
- // src/effects/provide-batch-outputs/index.ts
3119
- import {
3120
- ASTFactory as ASTFactory3,
3121
- createEffectFromVariableProvider as createEffectFromVariableProvider2,
3122
- getNodeForm as getNodeForm2
3123
- } from "@flowgram.ai/editor";
3124
- var provideBatchOutputsEffect = createEffectFromVariableProvider2({
3125
- parse: (value, ctx) => [
3126
- ASTFactory3.createVariableDeclaration({
3127
- key: `${ctx.node.id}`,
3128
- meta: {
3129
- title: getNodeForm2(ctx.node)?.getValueIn("title"),
3130
- icon: ctx.node.getNodeRegistry().info?.icon
3131
- },
3132
- type: ASTFactory3.createObject({
3133
- properties: Object.entries(value).map(
3134
- ([_key, value2]) => ASTFactory3.createProperty({
3135
- key: _key,
3136
- initializer: ASTFactory3.createWrapArrayExpression({
3137
- wrapFor: ASTFactory3.createKeyPathExpression({
3138
- keyPath: value2.content || []
3139
- })
3140
- })
3141
- })
3142
- )
3143
- })
3144
- })
3145
- ]
3146
- });
3147
-
3148
3315
  // src/effects/auto-rename-ref/index.ts
3149
- import { isArray, isObject as isObject2 } from "lodash";
3316
+ import { isArray, isObject as isObject2, uniq } from "lodash";
3150
3317
  import {
3151
3318
  DataEvent,
3152
3319
  VariableFieldKeyRenameService
@@ -3167,9 +3334,30 @@ var autoRenameRefEffect = [
3167
3334
  after.key
3168
3335
  ];
3169
3336
  traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
3170
- if (isRefMatch(_v, beforeKeyPath)) {
3171
- _v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
3172
- form.setValueIn(_drilldownName, _v);
3337
+ if (_v.type === "ref") {
3338
+ if (isKeyPathMatch(_v.content, beforeKeyPath)) {
3339
+ _v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
3340
+ form.setValueIn(_drilldownName, _v);
3341
+ }
3342
+ } else if (_v.type === "template") {
3343
+ const templateKeyPaths = getTemplateKeyPaths(_v);
3344
+ let hasMatch = false;
3345
+ templateKeyPaths.forEach((_keyPath) => {
3346
+ if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
3347
+ hasMatch = true;
3348
+ const nextKeyPath = [
3349
+ ...afterKeyPath,
3350
+ ...(_keyPath || [])?.slice(beforeKeyPath.length)
3351
+ ];
3352
+ _v.content = _v.content?.replace(
3353
+ `{{${_keyPath.join(".")}}`,
3354
+ `{{${nextKeyPath.join(".")}}`
3355
+ );
3356
+ }
3357
+ });
3358
+ if (hasMatch) {
3359
+ form.setValueIn(_drilldownName, { ..._v });
3360
+ }
3173
3361
  }
3174
3362
  });
3175
3363
  });
@@ -3179,18 +3367,31 @@ var autoRenameRefEffect = [
3179
3367
  }
3180
3368
  }
3181
3369
  ];
3182
- function isRefMatch(value, targetKeyPath) {
3183
- return targetKeyPath.every((_key, index) => _key === value.content?.[index]);
3370
+ function isKeyPathMatch(keyPath = [], targetKeyPath) {
3371
+ return targetKeyPath.every((_key, index) => _key === keyPath[index]);
3372
+ }
3373
+ function getTemplateKeyPaths(value) {
3374
+ const keyPathReg = /{{(.*?)}}/g;
3375
+ return uniq(value.content?.match(keyPathReg) || []).map(
3376
+ (_keyPath) => _keyPath.slice(2, -2).split(".")
3377
+ );
3184
3378
  }
3185
3379
  function isRef(value) {
3186
3380
  return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3187
3381
  }
3382
+ function isTemplate(value) {
3383
+ return value?.type === "template" && typeof value?.content === "string";
3384
+ }
3188
3385
  function traverseRef(name, value, cb) {
3189
3386
  if (isObject2(value)) {
3190
3387
  if (isRef(value)) {
3191
3388
  cb(name, value);
3192
3389
  return;
3193
3390
  }
3391
+ if (isTemplate(value)) {
3392
+ cb(name, value);
3393
+ return;
3394
+ }
3194
3395
  Object.entries(value).forEach(([_key, _value]) => {
3195
3396
  traverseRef(`${name}.${_key}`, _value, cb);
3196
3397
  });
@@ -3207,16 +3408,16 @@ function traverseRef(name, value, cb) {
3207
3408
 
3208
3409
  // src/effects/provide-json-schema-outputs/index.ts
3209
3410
  import {
3210
- ASTFactory as ASTFactory4,
3211
- createEffectFromVariableProvider as createEffectFromVariableProvider3,
3212
- getNodeForm as getNodeForm3
3411
+ ASTFactory as ASTFactory3,
3412
+ createEffectFromVariableProvider as createEffectFromVariableProvider2,
3413
+ getNodeForm as getNodeForm2
3213
3414
  } from "@flowgram.ai/editor";
3214
- var provideJsonSchemaOutputs = createEffectFromVariableProvider3({
3415
+ var provideJsonSchemaOutputs = createEffectFromVariableProvider2({
3215
3416
  parse: (value, ctx) => [
3216
- ASTFactory4.createVariableDeclaration({
3417
+ ASTFactory3.createVariableDeclaration({
3217
3418
  key: `${ctx.node.id}`,
3218
3419
  meta: {
3219
- title: getNodeForm3(ctx.node)?.getValueIn("title") || ctx.node.id,
3420
+ title: getNodeForm2(ctx.node)?.getValueIn("title") || ctx.node.id,
3220
3421
  icon: ctx.node.getNodeRegistry().info?.icon
3221
3422
  },
3222
3423
  type: JsonSchemaUtils.schemaToAST(value)
@@ -3247,29 +3448,29 @@ var syncVariableTitle = [
3247
3448
 
3248
3449
  // src/form-plugins/batch-outputs-plugin/index.ts
3249
3450
  import {
3250
- ASTFactory as ASTFactory5,
3251
- createEffectFromVariableProvider as createEffectFromVariableProvider4,
3451
+ ASTFactory as ASTFactory4,
3452
+ createEffectFromVariableProvider as createEffectFromVariableProvider3,
3252
3453
  defineFormPluginCreator,
3253
- getNodeForm as getNodeForm4,
3454
+ getNodeForm as getNodeForm3,
3254
3455
  getNodePrivateScope,
3255
3456
  getNodeScope,
3256
3457
  ScopeChainTransformService,
3257
3458
  FlowNodeScopeType
3258
3459
  } from "@flowgram.ai/editor";
3259
- var provideBatchOutputsEffect2 = createEffectFromVariableProvider4({
3460
+ var provideBatchOutputsEffect = createEffectFromVariableProvider3({
3260
3461
  parse: (value, ctx) => [
3261
- ASTFactory5.createVariableDeclaration({
3462
+ ASTFactory4.createVariableDeclaration({
3262
3463
  key: `${ctx.node.id}`,
3263
3464
  meta: {
3264
- title: getNodeForm4(ctx.node)?.getValueIn("title"),
3465
+ title: getNodeForm3(ctx.node)?.getValueIn("title"),
3265
3466
  icon: ctx.node.getNodeRegistry().info?.icon
3266
3467
  },
3267
- type: ASTFactory5.createObject({
3468
+ type: ASTFactory4.createObject({
3268
3469
  properties: Object.entries(value).map(
3269
- ([_key, value2]) => ASTFactory5.createProperty({
3470
+ ([_key, value2]) => ASTFactory4.createProperty({
3270
3471
  key: _key,
3271
- initializer: ASTFactory5.createWrapArrayExpression({
3272
- wrapFor: ASTFactory5.createKeyPathExpression({
3472
+ initializer: ASTFactory4.createWrapArrayExpression({
3473
+ wrapFor: ASTFactory4.createKeyPathExpression({
3273
3474
  keyPath: value2?.content || []
3274
3475
  })
3275
3476
  })
@@ -3283,7 +3484,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3283
3484
  name: "batch-outputs-plugin",
3284
3485
  onSetupFormMeta({ mergeEffect }, { outputKey }) {
3285
3486
  mergeEffect({
3286
- [outputKey]: provideBatchOutputsEffect2
3487
+ [outputKey]: provideBatchOutputsEffect
3287
3488
  });
3288
3489
  },
3289
3490
  onInit(ctx, { outputKey }) {
@@ -3319,6 +3520,85 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3319
3520
  });
3320
3521
  }
3321
3522
  });
3523
+
3524
+ // src/form-plugins/infer-inputs-plugin/index.ts
3525
+ import { get as get2, set } from "lodash";
3526
+ import {
3527
+ defineFormPluginCreator as defineFormPluginCreator2,
3528
+ getNodePrivateScope as getNodePrivateScope2,
3529
+ getNodeScope as getNodeScope2
3530
+ } from "@flowgram.ai/editor";
3531
+ var createInferInputsPlugin = defineFormPluginCreator2({
3532
+ onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
3533
+ if (!sourceKey || !targetKey) {
3534
+ return;
3535
+ }
3536
+ addFormatOnSubmit((formData, ctx) => {
3537
+ set(
3538
+ formData,
3539
+ targetKey,
3540
+ infer(
3541
+ get2(formData, sourceKey),
3542
+ scope === "private" ? getNodePrivateScope2(ctx.node) : getNodeScope2(ctx.node)
3543
+ )
3544
+ );
3545
+ return formData;
3546
+ });
3547
+ }
3548
+ });
3549
+ function isRef2(value) {
3550
+ return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3551
+ }
3552
+ function isTemplate2(value) {
3553
+ return value?.type === "template" && typeof value?.content === "string";
3554
+ }
3555
+ function isConstant(value) {
3556
+ return value?.type === "constant" && typeof value?.content !== "undefined";
3557
+ }
3558
+ var infer = (values, scope) => {
3559
+ if (typeof values === "object") {
3560
+ if (isConstant(values)) {
3561
+ if (values?.schema) {
3562
+ return values.schema;
3563
+ }
3564
+ if (typeof values.content === "string") {
3565
+ return {
3566
+ type: "string"
3567
+ };
3568
+ }
3569
+ if (typeof values.content === "number") {
3570
+ return {
3571
+ type: "number"
3572
+ };
3573
+ }
3574
+ if (typeof values.content === "boolean") {
3575
+ return {
3576
+ type: "boolean"
3577
+ };
3578
+ }
3579
+ }
3580
+ if (isRef2(values)) {
3581
+ const variable = scope.available.getByKeyPath(values?.content);
3582
+ const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : void 0;
3583
+ return schema;
3584
+ }
3585
+ if (isTemplate2(values)) {
3586
+ return {
3587
+ type: "string"
3588
+ };
3589
+ }
3590
+ return {
3591
+ type: "object",
3592
+ properties: Object.keys(values).reduce((acc, key) => {
3593
+ const schema = infer(values[key], scope);
3594
+ if (schema) {
3595
+ acc[key] = schema;
3596
+ }
3597
+ return acc;
3598
+ }, {})
3599
+ };
3600
+ }
3601
+ };
3322
3602
  export {
3323
3603
  ArrayIcons,
3324
3604
  BatchOutputs,
@@ -3327,6 +3607,7 @@ export {
3327
3607
  ConditionRow,
3328
3608
  ConstantInput,
3329
3609
  DynamicValueInput,
3610
+ InputsValues,
3330
3611
  JsonEditorWithVariables,
3331
3612
  JsonSchemaEditor,
3332
3613
  JsonSchemaUtils,
@@ -3338,6 +3619,7 @@ export {
3338
3619
  VariableTypeIcons,
3339
3620
  autoRenameRefEffect,
3340
3621
  createBatchOutputsFormPlugin,
3622
+ createInferInputsPlugin,
3341
3623
  formatLegacyRefOnInit,
3342
3624
  formatLegacyRefOnSubmit,
3343
3625
  formatLegacyRefToNewRef,