@metad/contracts 3.7.0 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1,31 +1,32 @@
1
1
  'use strict';
2
2
 
3
3
  var ShortUniqueId = require('short-unique-id');
4
+ var chatkitTypes = require('@xpert-ai/chatkit-types');
4
5
 
5
- function _array_like_to_array$5(arr, len) {
6
+ function _array_like_to_array$6(arr, len) {
6
7
  if (len == null || len > arr.length) len = arr.length;
7
8
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8
9
  return arr2;
9
10
  }
10
- function _array_without_holes$1(arr) {
11
- if (Array.isArray(arr)) return _array_like_to_array$5(arr);
11
+ function _array_without_holes$2(arr) {
12
+ if (Array.isArray(arr)) return _array_like_to_array$6(arr);
12
13
  }
13
- function _iterable_to_array$2(iter) {
14
+ function _iterable_to_array$3(iter) {
14
15
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
15
16
  }
16
- function _non_iterable_spread$1() {
17
+ function _non_iterable_spread$2() {
17
18
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
18
19
  }
19
- function _to_consumable_array$1(arr) {
20
- return _array_without_holes$1(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$1();
20
+ function _to_consumable_array$2(arr) {
21
+ return _array_without_holes$2(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$2();
21
22
  }
22
- function _unsupported_iterable_to_array$5(o, minLen) {
23
+ function _unsupported_iterable_to_array$6(o, minLen) {
23
24
  if (!o) return;
24
- if (typeof o === "string") return _array_like_to_array$5(o, minLen);
25
+ if (typeof o === "string") return _array_like_to_array$6(o, minLen);
25
26
  var n = Object.prototype.toString.call(o).slice(8, -1);
26
27
  if (n === "Object" && o.constructor) n = o.constructor.name;
27
28
  if (n === "Map" || n === "Set") return Array.from(n);
28
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
29
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
29
30
  }
30
31
  var _uuidGenerator;
31
32
  var uuidGenerator = new ShortUniqueId({
@@ -35,7 +36,7 @@ var uuid = function() {
35
36
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
36
37
  args[_key] = arguments[_key];
37
38
  }
38
- return (_uuidGenerator = uuidGenerator).randomUUID.apply(_uuidGenerator, _to_consumable_array$1(args));
39
+ return (_uuidGenerator = uuidGenerator).randomUUID.apply(_uuidGenerator, _to_consumable_array$2(args));
39
40
  };
40
41
  exports.ParameterTypeEnum = void 0;
41
42
  (function(ParameterTypeEnum) {
@@ -1473,32 +1474,6 @@ exports.ChatGatewayEvent = void 0;
1473
1474
  ChatGatewayEvent["Agent"] = "agent";
1474
1475
  })(exports.ChatGatewayEvent || (exports.ChatGatewayEvent = {}));
1475
1476
 
1476
- exports.ChatMessageStepCategory = void 0;
1477
- (function(ChatMessageStepCategory) {
1478
- /**
1479
- * List of items: urls, files, etc.
1480
- */ ChatMessageStepCategory["List"] = "list";
1481
- /**
1482
- * Websearch results
1483
- */ ChatMessageStepCategory["WebSearch"] = "web_search";
1484
- /**
1485
- * Files list
1486
- */ ChatMessageStepCategory["Files"] = "files";
1487
- /**
1488
- * View a file
1489
- */ ChatMessageStepCategory["File"] = "file";
1490
- /**
1491
- * Program Execution
1492
- */ ChatMessageStepCategory["Program"] = "program";
1493
- /**
1494
- * Iframe
1495
- */ ChatMessageStepCategory["Iframe"] = "iframe";
1496
- ChatMessageStepCategory["Memory"] = "memory";
1497
- ChatMessageStepCategory["Tasks"] = "tasks";
1498
- /**
1499
- * Knowledges (knowledge base retriever results)
1500
- */ ChatMessageStepCategory["Knowledges"] = "knowledges";
1501
- })(exports.ChatMessageStepCategory || (exports.ChatMessageStepCategory = {}));
1502
1477
  // Type guards
1503
1478
  /**
1504
1479
  * @deprecated use content in message
@@ -1515,6 +1490,8 @@ exports.ChatMessageFeedbackRatingEnum = void 0;
1515
1490
  var MEMORY_QA_PROMPT = "Summarize the experience of the above conversation and output a short question and answer.";
1516
1491
  var MEMORY_PROFILE_PROMPT = "Extract new user profile information from the above conversation in one short sentence. If no new information is available, return nothing.";
1517
1492
 
1493
+ var USAGE_HOUR_FORMAT = "yyyy-MM-dd HH";
1494
+
1518
1495
  exports.AiProviderRole = void 0;
1519
1496
  (function(AiProviderRole) {
1520
1497
  AiProviderRole["Primary"] = "primary";
@@ -1582,6 +1559,8 @@ var KDocumentWebTypeOptions = [
1582
1559
 
1583
1560
  exports.WorkflowNodeTypeEnum = void 0;
1584
1561
  (function(WorkflowNodeTypeEnum) {
1562
+ WorkflowNodeTypeEnum["START"] = "start";
1563
+ WorkflowNodeTypeEnum["END"] = "end";
1585
1564
  /**
1586
1565
  * Trigger
1587
1566
  */ WorkflowNodeTypeEnum["TRIGGER"] = "trigger";
@@ -1593,7 +1572,10 @@ exports.WorkflowNodeTypeEnum = void 0;
1593
1572
  */ WorkflowNodeTypeEnum["IF_ELSE"] = "if-else";
1594
1573
  WorkflowNodeTypeEnum["LIST_OPERATOR"] = "list-operator";
1595
1574
  WorkflowNodeTypeEnum["VARIABLE_AGGREGATOR"] = "variable-aggregator";
1596
- WorkflowNodeTypeEnum["ITERATING"] = "iterating";
1575
+ /**
1576
+ * @deprecated use ITERATOR instead
1577
+ */ WorkflowNodeTypeEnum["ITERATING"] = "iterating";
1578
+ WorkflowNodeTypeEnum["ITERATOR"] = "iterator";
1597
1579
  WorkflowNodeTypeEnum["HTTP"] = "http";
1598
1580
  WorkflowNodeTypeEnum["SUBFLOW"] = "subflow";
1599
1581
  WorkflowNodeTypeEnum["TOOL"] = "tool";
@@ -1650,9 +1632,15 @@ exports.VariableOperationEnum = void 0;
1650
1632
  VariableOperationEnum["CLEAR"] = "clear";
1651
1633
  })(exports.VariableOperationEnum || (exports.VariableOperationEnum = {}));
1652
1634
  /**
1653
- * The parameter name that represents the entire current element in array
1635
+ * @deprecated use `IteratorItemParameterName` instead
1654
1636
  */ var IteratingItemParameterName = "$item";
1655
- var IteratingIndexParameterName = "$index";
1637
+ /**
1638
+ * @deprecated use `IteratorIndexParameterName` instead
1639
+ */ var IteratingIndexParameterName = "$index";
1640
+ /**
1641
+ * The parameter name that represents the entire current element in array
1642
+ */ var IteratorItemParameterName = "$item";
1643
+ var IteratorIndexParameterName = "$index";
1656
1644
  exports.WorkflowLogicalOperator = void 0;
1657
1645
  (function(WorkflowLogicalOperator) {
1658
1646
  WorkflowLogicalOperator["AND"] = "and";
@@ -1692,17 +1680,25 @@ function genJSONStringifyKey() {
1692
1680
  function genJSONParseKey() {
1693
1681
  return letterStartSUID("JSONParse_");
1694
1682
  }
1683
+ function genXpertIteratorKey() {
1684
+ return letterStartSUID("Iterator_");
1685
+ }
1686
+ function genXpertStartKey(key) {
1687
+ return key + "_start";
1688
+ }
1695
1689
  function isAgentKey(key) {
1696
1690
  return key === null || key === void 0 ? void 0 : key.toLowerCase().startsWith("agent_");
1697
1691
  }
1698
1692
  function isRouterKey(key) {
1699
1693
  return key === null || key === void 0 ? void 0 : key.toLowerCase().startsWith("router_");
1700
1694
  }
1701
- function isIteratingKey(key) {
1695
+ /**
1696
+ * @deprecated use `isIteratorKey` instead
1697
+ */ function isIteratingKey(key) {
1702
1698
  return key === null || key === void 0 ? void 0 : key.toLowerCase().startsWith("iterating_");
1703
1699
  }
1704
- function isWorkflowKey(key) {
1705
- return isRouterKey(key) || isIteratingKey(key);
1700
+ function isIteratorKey(key) {
1701
+ return key === null || key === void 0 ? void 0 : key.toLowerCase().startsWith("iterator_");
1706
1702
  }
1707
1703
  function workflowNodeIdentifier(node) {
1708
1704
  return node.title || node.key;
@@ -1746,33 +1742,12 @@ exports.XpertParameterTypeEnum = void 0;
1746
1742
  XpertParameterTypeEnum["BOOLEAN"] = "boolean";
1747
1743
  XpertParameterTypeEnum["SECRET"] = "secret";
1748
1744
  })(exports.XpertParameterTypeEnum || (exports.XpertParameterTypeEnum = {}));
1749
- exports.ChatMessageTypeEnum = void 0;
1750
- (function(ChatMessageTypeEnum) {
1751
- // LOG = 'log',
1752
- ChatMessageTypeEnum["MESSAGE"] = "message";
1753
- ChatMessageTypeEnum["EVENT"] = "event";
1754
- })(exports.ChatMessageTypeEnum || (exports.ChatMessageTypeEnum = {}));
1755
- exports.ChatMessageEventTypeEnum = void 0;
1756
- (function(ChatMessageEventTypeEnum) {
1757
- ChatMessageEventTypeEnum["ON_CONVERSATION_START"] = "on_conversation_start";
1758
- ChatMessageEventTypeEnum["ON_CONVERSATION_END"] = "on_conversation_end";
1759
- ChatMessageEventTypeEnum["ON_MESSAGE_START"] = "on_message_start";
1760
- ChatMessageEventTypeEnum["ON_MESSAGE_END"] = "on_message_end";
1761
- ChatMessageEventTypeEnum["ON_TOOL_START"] = "on_tool_start";
1762
- ChatMessageEventTypeEnum["ON_TOOL_END"] = "on_tool_end";
1763
- ChatMessageEventTypeEnum["ON_TOOL_ERROR"] = "on_tool_error";
1764
- /**
1765
- * Step message in tool call
1766
- */ ChatMessageEventTypeEnum["ON_TOOL_MESSAGE"] = "on_tool_message";
1767
- ChatMessageEventTypeEnum["ON_AGENT_START"] = "on_agent_start";
1768
- ChatMessageEventTypeEnum["ON_AGENT_END"] = "on_agent_end";
1769
- ChatMessageEventTypeEnum["ON_RETRIEVER_START"] = "on_retriever_start";
1770
- ChatMessageEventTypeEnum["ON_RETRIEVER_END"] = "on_retriever_end";
1771
- ChatMessageEventTypeEnum["ON_RETRIEVER_ERROR"] = "on_retriever_error";
1772
- ChatMessageEventTypeEnum["ON_INTERRUPT"] = "on_interrupt";
1773
- ChatMessageEventTypeEnum["ON_ERROR"] = "on_error";
1774
- ChatMessageEventTypeEnum["ON_CHAT_EVENT"] = "on_chat_event";
1775
- })(exports.ChatMessageEventTypeEnum || (exports.ChatMessageEventTypeEnum = {}));
1745
+ // Helper guards
1746
+ function isXpertNodeType(type) {
1747
+ return function(node) {
1748
+ return node.type === type;
1749
+ };
1750
+ }
1776
1751
 
1777
1752
  function agentLabel(agent) {
1778
1753
  return agent.title || agent.name || agent.key;
@@ -1816,15 +1791,15 @@ var VariableOperations = [
1816
1791
  }
1817
1792
  ];
1818
1793
 
1819
- function _array_like_to_array$4(arr, len) {
1794
+ function _array_like_to_array$5(arr, len) {
1820
1795
  if (len == null || len > arr.length) len = arr.length;
1821
1796
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1822
1797
  return arr2;
1823
1798
  }
1824
- function _array_with_holes$3(arr) {
1799
+ function _array_with_holes$4(arr) {
1825
1800
  if (Array.isArray(arr)) return arr;
1826
1801
  }
1827
- function _define_property$3(obj, key, value) {
1802
+ function _define_property$4(obj, key, value) {
1828
1803
  if (key in obj) {
1829
1804
  Object.defineProperty(obj, key, {
1830
1805
  value: value,
@@ -1837,7 +1812,7 @@ function _define_property$3(obj, key, value) {
1837
1812
  }
1838
1813
  return obj;
1839
1814
  }
1840
- function _iterable_to_array_limit$2(arr, i) {
1815
+ function _iterable_to_array_limit$3(arr, i) {
1841
1816
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1842
1817
  if (_i == null) return;
1843
1818
  var _arr = [];
@@ -1861,10 +1836,10 @@ function _iterable_to_array_limit$2(arr, i) {
1861
1836
  }
1862
1837
  return _arr;
1863
1838
  }
1864
- function _non_iterable_rest$3() {
1839
+ function _non_iterable_rest$4() {
1865
1840
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1866
1841
  }
1867
- function _object_spread$2(target) {
1842
+ function _object_spread$3(target) {
1868
1843
  for(var i = 1; i < arguments.length; i++){
1869
1844
  var source = arguments[i] != null ? arguments[i] : {};
1870
1845
  var ownKeys = Object.keys(source);
@@ -1874,12 +1849,12 @@ function _object_spread$2(target) {
1874
1849
  }));
1875
1850
  }
1876
1851
  ownKeys.forEach(function(key) {
1877
- _define_property$3(target, key, source[key]);
1852
+ _define_property$4(target, key, source[key]);
1878
1853
  });
1879
1854
  }
1880
1855
  return target;
1881
1856
  }
1882
- function ownKeys$1(object, enumerableOnly) {
1857
+ function ownKeys$2(object, enumerableOnly) {
1883
1858
  var keys = Object.keys(object);
1884
1859
  if (Object.getOwnPropertySymbols) {
1885
1860
  var symbols = Object.getOwnPropertySymbols(object);
@@ -1887,40 +1862,43 @@ function ownKeys$1(object, enumerableOnly) {
1887
1862
  }
1888
1863
  return keys;
1889
1864
  }
1890
- function _object_spread_props$1(target, source) {
1865
+ function _object_spread_props$2(target, source) {
1891
1866
  source = source != null ? source : {};
1892
1867
  if (Object.getOwnPropertyDescriptors) {
1893
1868
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1894
1869
  } else {
1895
- ownKeys$1(Object(source)).forEach(function(key) {
1870
+ ownKeys$2(Object(source)).forEach(function(key) {
1896
1871
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1897
1872
  });
1898
1873
  }
1899
1874
  return target;
1900
1875
  }
1901
- function _sliced_to_array$2(arr, i) {
1902
- return _array_with_holes$3(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$3();
1876
+ function _sliced_to_array$3(arr, i) {
1877
+ return _array_with_holes$4(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$4();
1903
1878
  }
1904
- function _unsupported_iterable_to_array$4(o, minLen) {
1879
+ function _unsupported_iterable_to_array$5(o, minLen) {
1905
1880
  if (!o) return;
1906
- if (typeof o === "string") return _array_like_to_array$4(o, minLen);
1881
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
1907
1882
  var n = Object.prototype.toString.call(o).slice(8, -1);
1908
1883
  if (n === "Object" && o.constructor) n = o.constructor.name;
1909
1884
  if (n === "Map" || n === "Set") return Array.from(n);
1910
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
1885
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
1911
1886
  }
1912
1887
  /**
1913
1888
  * @deprecated can use getCurrentTaskInput instead?
1914
1889
  */ var CONTEXT_VARIABLE_CURRENTSTATE = "currentState";
1915
1890
  var STATE_VARIABLE_SYS = "sys";
1916
- var STATE_VARIABLE_HUMAN = "human";
1917
1891
  var GRAPH_NODE_SUMMARIZE_CONVERSATION = "summarize_conversation";
1918
1892
  var GRAPH_NODE_TITLE_CONVERSATION = "title_conversation";
1919
1893
  var STATE_VARIABLE_FILES = "files";
1920
1894
  var STATE_VARIABLE_INPUT = "input";
1921
1895
  var STATE_SYS_VOLUME = "volume";
1922
- var STATE_SYS_WORKSPACE_PATH = "workspace_path";
1923
- var STATE_SYS_WORKSPACE_URL = "workspace_url";
1896
+ /**
1897
+ * Workspace path in sandbox environment
1898
+ */ var STATE_SYS_WORKSPACE_PATH = "workspace_path";
1899
+ /**
1900
+ * URL for workspace files in sandbox environment
1901
+ */ var STATE_SYS_WORKSPACE_URL = "workspace_url";
1924
1902
  var STATE_VARIABLE_TITLE_CHANNEL = channelName("title");
1925
1903
  // Helpers
1926
1904
  function channelName(name) {
@@ -1929,7 +1907,12 @@ function channelName(name) {
1929
1907
  function messageContentText(content) {
1930
1908
  return typeof content === "string" ? content : content.type === "text" ? content.text : "";
1931
1909
  }
1932
- function getWorkspaceFromRunnable(configurable) {
1910
+ /**
1911
+ * Get workspace folder for sandbox from runnable configurable
1912
+ *
1913
+ * @param configurable
1914
+ * @returns
1915
+ */ function getWorkspaceFromRunnable(configurable) {
1933
1916
  return (configurable === null || configurable === void 0 ? void 0 : configurable.projectId) ? {
1934
1917
  type: "project",
1935
1918
  id: ""
@@ -1973,10 +1956,10 @@ function configurableStoreNamespace(configurable) {
1973
1956
  * @param value
1974
1957
  * @returns
1975
1958
  */ function setStateVariable(state, varName, value) {
1976
- var _varName_split = _sliced_to_array$2(varName.split("."), 2), agentChannelName = _varName_split[0], variableName = _varName_split[1];
1959
+ var _varName_split = _sliced_to_array$3(varName.split("."), 2), agentChannelName = _varName_split[0], variableName = _varName_split[1];
1977
1960
  if (variableName) {
1978
1961
  var _state_agentChannelName;
1979
- state[agentChannelName] = _object_spread_props$1(_object_spread$2({}, (_state_agentChannelName = state[agentChannelName]) !== null && _state_agentChannelName !== void 0 ? _state_agentChannelName : {}), _define_property$3({}, variableName, value));
1962
+ state[agentChannelName] = _object_spread_props$2(_object_spread$3({}, (_state_agentChannelName = state[agentChannelName]) !== null && _state_agentChannelName !== void 0 ? _state_agentChannelName : {}), _define_property$4({}, variableName, value));
1980
1963
  } else {
1981
1964
  state[agentChannelName] = value;
1982
1965
  }
@@ -2143,7 +2126,7 @@ function genPipelineKnowledgeBaseKey() {
2143
2126
  return letterStartSUID("KnowledgeBase_");
2144
2127
  }
2145
2128
 
2146
- function _define_property$2(obj, key, value) {
2129
+ function _define_property$3(obj, key, value) {
2147
2130
  if (key in obj) {
2148
2131
  Object.defineProperty(obj, key, {
2149
2132
  value: value,
@@ -2156,7 +2139,7 @@ function _define_property$2(obj, key, value) {
2156
2139
  }
2157
2140
  return obj;
2158
2141
  }
2159
- function _object_spread$1(target) {
2142
+ function _object_spread$2(target) {
2160
2143
  for(var i = 1; i < arguments.length; i++){
2161
2144
  var source = arguments[i] != null ? arguments[i] : {};
2162
2145
  var ownKeys = Object.keys(source);
@@ -2166,7 +2149,7 @@ function _object_spread$1(target) {
2166
2149
  }));
2167
2150
  }
2168
2151
  ownKeys.forEach(function(key) {
2169
- _define_property$2(target, key, source[key]);
2152
+ _define_property$3(target, key, source[key]);
2170
2153
  });
2171
2154
  }
2172
2155
  return target;
@@ -2181,7 +2164,7 @@ exports.DocumentTypeEnum = void 0;
2181
2164
  * @deprecated use DocumentSourceProviderCategoryEnum local file type instead
2182
2165
  */ DocumentTypeEnum["FILE"] = "file";
2183
2166
  })(exports.DocumentTypeEnum || (exports.DocumentTypeEnum = {}));
2184
- var KDocumentSourceType = _object_spread$1({}, exports.DocumentSourceProviderCategoryEnum, exports.DocumentTypeEnum);
2167
+ var KDocumentSourceType = _object_spread$2({}, exports.DocumentSourceProviderCategoryEnum, exports.DocumentTypeEnum);
2185
2168
  exports.KBDocumentCategoryEnum = void 0;
2186
2169
  (function(KBDocumentCategoryEnum) {
2187
2170
  KBDocumentCategoryEnum["Text"] = "text";
@@ -2468,23 +2451,23 @@ function genXpertDBSqlKey() {
2468
2451
  return letterStartSUID("DBSql_");
2469
2452
  }
2470
2453
 
2471
- function _array_like_to_array$3(arr, len) {
2454
+ function _array_like_to_array$4(arr, len) {
2472
2455
  if (len == null || len > arr.length) len = arr.length;
2473
2456
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2474
2457
  return arr2;
2475
2458
  }
2476
- function _array_without_holes(arr) {
2477
- if (Array.isArray(arr)) return _array_like_to_array$3(arr);
2459
+ function _array_without_holes$1(arr) {
2460
+ if (Array.isArray(arr)) return _array_like_to_array$4(arr);
2478
2461
  }
2479
- function _iterable_to_array$1(iter) {
2462
+ function _iterable_to_array$2(iter) {
2480
2463
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
2481
2464
  }
2482
- function _non_iterable_spread() {
2465
+ function _non_iterable_spread$1() {
2483
2466
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2484
2467
  }
2485
- function _object_without_properties(source, excluded) {
2468
+ function _object_without_properties$1(source, excluded) {
2486
2469
  if (source == null) return {};
2487
- var target = _object_without_properties_loose(source, excluded);
2470
+ var target = _object_without_properties_loose$1(source, excluded);
2488
2471
  var key, i;
2489
2472
  if (Object.getOwnPropertySymbols) {
2490
2473
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -2497,7 +2480,7 @@ function _object_without_properties(source, excluded) {
2497
2480
  }
2498
2481
  return target;
2499
2482
  }
2500
- function _object_without_properties_loose(source, excluded) {
2483
+ function _object_without_properties_loose$1(source, excluded) {
2501
2484
  if (source == null) return {};
2502
2485
  var target = {};
2503
2486
  var sourceKeys = Object.keys(source);
@@ -2509,21 +2492,21 @@ function _object_without_properties_loose(source, excluded) {
2509
2492
  }
2510
2493
  return target;
2511
2494
  }
2512
- function _to_consumable_array(arr) {
2513
- return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread();
2495
+ function _to_consumable_array$1(arr) {
2496
+ return _array_without_holes$1(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$1();
2514
2497
  }
2515
- function _unsupported_iterable_to_array$3(o, minLen) {
2498
+ function _unsupported_iterable_to_array$4(o, minLen) {
2516
2499
  if (!o) return;
2517
- if (typeof o === "string") return _array_like_to_array$3(o, minLen);
2500
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
2518
2501
  var n = Object.prototype.toString.call(o).slice(8, -1);
2519
2502
  if (n === "Object" && o.constructor) n = o.constructor.name;
2520
2503
  if (n === "Map" || n === "Set") return Array.from(n);
2521
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
2504
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
2522
2505
  }
2523
2506
  // Helpers
2524
2507
  function omitXpertRelations(xpert) {
2525
2508
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2526
- var _ref = xpert !== null && xpert !== void 0 ? xpert : {}; _ref.draft; _ref.agent; _ref.agents; _ref.executors; _ref.leaders; _ref.knowledgebases; _ref.knowledgebase; _ref.environment; _ref.integrations; _ref.toolsets; _ref.managers; var rest = _object_without_properties(_ref, [
2509
+ var _ref = xpert !== null && xpert !== void 0 ? xpert : {}; _ref.draft; _ref.agent; _ref.agents; _ref.executors; _ref.leaders; _ref.knowledgebases; _ref.knowledgebase; _ref.environment; _ref.integrations; _ref.toolsets; _ref.managers; var rest = _object_without_properties$1(_ref, [
2527
2510
  "draft",
2528
2511
  "agent",
2529
2512
  "agents",
@@ -2538,7 +2521,13 @@ function omitXpertRelations(xpert) {
2538
2521
  ]);
2539
2522
  return rest;
2540
2523
  }
2541
- function figureOutXpert(xpert, isDraft) {
2524
+ /**
2525
+ * Figure out latest xpert or draft xpert.
2526
+ *
2527
+ * @param xpert
2528
+ * @param isDraft Is draft
2529
+ * @returns
2530
+ */ function figureOutXpert(xpert, isDraft) {
2542
2531
  var _xpert_draft;
2543
2532
  var _ref;
2544
2533
  return (_ref = isDraft ? (_xpert_draft = xpert.draft) === null || _xpert_draft === void 0 ? void 0 : _xpert_draft.team : xpert) !== null && _ref !== void 0 ? _ref : xpert;
@@ -2581,12 +2570,12 @@ function locateNodes(nodes, position) {
2581
2570
  }) // Node height min 70
2582
2571
  ;
2583
2572
  var xRange = {
2584
- min: (_Math = Math).min.apply(_Math, _to_consumable_array(x0Positions)),
2585
- max: (_Math1 = Math).max.apply(_Math1, _to_consumable_array(x1Positions))
2573
+ min: (_Math = Math).min.apply(_Math, _to_consumable_array$1(x0Positions)),
2574
+ max: (_Math1 = Math).max.apply(_Math1, _to_consumable_array$1(x1Positions))
2586
2575
  };
2587
2576
  var yRange = {
2588
- min: (_Math2 = Math).min.apply(_Math2, _to_consumable_array(y0Positions)),
2589
- max: (_Math3 = Math).max.apply(_Math3, _to_consumable_array(y1Positions))
2577
+ min: (_Math2 = Math).min.apply(_Math2, _to_consumable_array$1(y0Positions)),
2578
+ max: (_Math3 = Math).max.apply(_Math3, _to_consumable_array$1(y1Positions))
2590
2579
  };
2591
2580
  var size = {
2592
2581
  width: xRange.max - xRange.min + 50,
@@ -2623,9 +2612,9 @@ function locateNodes(nodes, position) {
2623
2612
  }
2624
2613
  if ((_xpert_agents = xpert.agents) === null || _xpert_agents === void 0 ? void 0 : _xpert_agents.length) {
2625
2614
  var _agents;
2626
- (_agents = agents).push.apply(_agents, _to_consumable_array(xpert.agents));
2615
+ (_agents = agents).push.apply(_agents, _to_consumable_array$1(xpert.agents));
2627
2616
  }
2628
- (_nodes = nodes).push.apply(_nodes, _to_consumable_array(agents.map(function(_) {
2617
+ (_nodes = nodes).push.apply(_nodes, _to_consumable_array$1(agents.map(function(_) {
2629
2618
  var _xpert_options_agent___key, _xpert_options_agent, _xpert_options, _xpert_options_agent___key1, _xpert_options_agent1, _xpert_options1;
2630
2619
  var _xpert_options_agent___key_position;
2631
2620
  return {
@@ -2657,7 +2646,7 @@ function locateNodes(nodes, position) {
2657
2646
  });
2658
2647
  });
2659
2648
  var _xpert_knowledgebases;
2660
- (_nodes1 = nodes).push.apply(_nodes1, _to_consumable_array(((_xpert_knowledgebases = xpert.knowledgebases) !== null && _xpert_knowledgebases !== void 0 ? _xpert_knowledgebases : []).map(function(x) {
2649
+ (_nodes1 = nodes).push.apply(_nodes1, _to_consumable_array$1(((_xpert_knowledgebases = xpert.knowledgebases) !== null && _xpert_knowledgebases !== void 0 ? _xpert_knowledgebases : []).map(function(x) {
2661
2650
  var _xpert_options_knowledge_x_id, _xpert_options_knowledge, _xpert_options, _xpert_options_knowledge_x_id1, _xpert_options_knowledge1, _xpert_options1;
2662
2651
  var _xpert_options_knowledge_x_id_position;
2663
2652
  return {
@@ -2672,7 +2661,7 @@ function locateNodes(nodes, position) {
2672
2661
  };
2673
2662
  })));
2674
2663
  var _xpert_toolsets;
2675
- (_nodes2 = nodes).push.apply(_nodes2, _to_consumable_array(((_xpert_toolsets = xpert.toolsets) !== null && _xpert_toolsets !== void 0 ? _xpert_toolsets : []).map(function(x) {
2664
+ (_nodes2 = nodes).push.apply(_nodes2, _to_consumable_array$1(((_xpert_toolsets = xpert.toolsets) !== null && _xpert_toolsets !== void 0 ? _xpert_toolsets : []).map(function(x) {
2676
2665
  var _xpert_options_toolset_x_id, _xpert_options_toolset, _xpert_options, _xpert_options_toolset_x_id1, _xpert_options_toolset1, _xpert_options1;
2677
2666
  var _xpert_options_toolset_x_id_position;
2678
2667
  return {
@@ -2709,12 +2698,12 @@ function locateNodes(nodes, position) {
2709
2698
  }) // Node height min 70
2710
2699
  ;
2711
2700
  var xRange = {
2712
- min: (_Math = Math).min.apply(_Math, _to_consumable_array(x0Positions)),
2713
- max: (_Math1 = Math).max.apply(_Math1, _to_consumable_array(x1Positions))
2701
+ min: (_Math = Math).min.apply(_Math, _to_consumable_array$1(x0Positions)),
2702
+ max: (_Math1 = Math).max.apply(_Math1, _to_consumable_array$1(x1Positions))
2714
2703
  };
2715
2704
  var yRange = {
2716
- min: (_Math2 = Math).min.apply(_Math2, _to_consumable_array(y0Positions)),
2717
- max: (_Math3 = Math).max.apply(_Math3, _to_consumable_array(y1Positions))
2705
+ min: (_Math2 = Math).min.apply(_Math2, _to_consumable_array$1(y0Positions)),
2706
+ max: (_Math3 = Math).max.apply(_Math3, _to_consumable_array$1(y1Positions))
2718
2707
  };
2719
2708
  var size = {
2720
2709
  width: xRange.max - xRange.min + 50,
@@ -2852,9 +2841,10 @@ exports.MCPServerType = void 0;
2852
2841
  MCPServerType["SSE"] = "sse";
2853
2842
  MCPServerType["STDIO"] = "stdio";
2854
2843
  MCPServerType["CODE"] = "code";
2844
+ MCPServerType["HTTP"] = "http";
2855
2845
  })(exports.MCPServerType || (exports.MCPServerType = {}));
2856
2846
 
2857
- function _define_property$1(obj, key, value) {
2847
+ function _define_property$2(obj, key, value) {
2858
2848
  if (key in obj) {
2859
2849
  Object.defineProperty(obj, key, {
2860
2850
  value: value,
@@ -2867,7 +2857,7 @@ function _define_property$1(obj, key, value) {
2867
2857
  }
2868
2858
  return obj;
2869
2859
  }
2870
- function _object_spread(target) {
2860
+ function _object_spread$1(target) {
2871
2861
  for(var i = 1; i < arguments.length; i++){
2872
2862
  var source = arguments[i] != null ? arguments[i] : {};
2873
2863
  var ownKeys = Object.keys(source);
@@ -2877,12 +2867,12 @@ function _object_spread(target) {
2877
2867
  }));
2878
2868
  }
2879
2869
  ownKeys.forEach(function(key) {
2880
- _define_property$1(target, key, source[key]);
2870
+ _define_property$2(target, key, source[key]);
2881
2871
  });
2882
2872
  }
2883
2873
  return target;
2884
2874
  }
2885
- function ownKeys(object, enumerableOnly) {
2875
+ function ownKeys$1(object, enumerableOnly) {
2886
2876
  var keys = Object.keys(object);
2887
2877
  if (Object.getOwnPropertySymbols) {
2888
2878
  var symbols = Object.getOwnPropertySymbols(object);
@@ -2890,12 +2880,12 @@ function ownKeys(object, enumerableOnly) {
2890
2880
  }
2891
2881
  return keys;
2892
2882
  }
2893
- function _object_spread_props(target, source) {
2883
+ function _object_spread_props$1(target, source) {
2894
2884
  source = source != null ? source : {};
2895
2885
  if (Object.getOwnPropertyDescriptors) {
2896
2886
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2897
2887
  } else {
2898
- ownKeys(Object(source)).forEach(function(key) {
2888
+ ownKeys$1(Object(source)).forEach(function(key) {
2899
2889
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2900
2890
  });
2901
2891
  }
@@ -2918,8 +2908,8 @@ function _object_spread_props(target, source) {
2918
2908
  var doc = _step.value;
2919
2909
  var _doc_metadata;
2920
2910
  if ((_doc_metadata = doc.metadata) === null || _doc_metadata === void 0 ? void 0 : _doc_metadata.chunkId) {
2921
- map.set(doc.metadata.chunkId, _object_spread_props(_object_spread({}, doc), {
2922
- metadata: _object_spread_props(_object_spread({}, doc.metadata), {
2911
+ map.set(doc.metadata.chunkId, _object_spread_props$1(_object_spread$1({}, doc), {
2912
+ metadata: _object_spread_props$1(_object_spread$1({}, doc.metadata), {
2923
2913
  children: []
2924
2914
  })
2925
2915
  }));
@@ -3032,6 +3022,12 @@ function genXpertSkillKey() {
3032
3022
  return letterStartSUID("Skill_");
3033
3023
  }
3034
3024
 
3025
+ function isMiddlewareToolEnabled(config) {
3026
+ if (typeof config === "boolean") {
3027
+ return config;
3028
+ }
3029
+ return (config === null || config === void 0 ? void 0 : config.enabled) !== false;
3030
+ }
3035
3031
  function genXpertMiddlewareKey() {
3036
3032
  return letterStartSUID("Middleware_");
3037
3033
  }
@@ -3056,6 +3052,444 @@ function getAgentMiddlewareNodes(graph, agentKey) {
3056
3052
  return middlewares;
3057
3053
  }
3058
3054
 
3055
+ function _array_like_to_array$3(arr, len) {
3056
+ if (len == null || len > arr.length) len = arr.length;
3057
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3058
+ return arr2;
3059
+ }
3060
+ function _array_with_holes$3(arr) {
3061
+ if (Array.isArray(arr)) return arr;
3062
+ }
3063
+ function _array_without_holes(arr) {
3064
+ if (Array.isArray(arr)) return _array_like_to_array$3(arr);
3065
+ }
3066
+ function _define_property$1(obj, key, value) {
3067
+ if (key in obj) {
3068
+ Object.defineProperty(obj, key, {
3069
+ value: value,
3070
+ enumerable: true,
3071
+ configurable: true,
3072
+ writable: true
3073
+ });
3074
+ } else {
3075
+ obj[key] = value;
3076
+ }
3077
+ return obj;
3078
+ }
3079
+ function _iterable_to_array$1(iter) {
3080
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
3081
+ }
3082
+ function _iterable_to_array_limit$2(arr, i) {
3083
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
3084
+ if (_i == null) return;
3085
+ var _arr = [];
3086
+ var _n = true;
3087
+ var _d = false;
3088
+ var _s, _e;
3089
+ try {
3090
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
3091
+ _arr.push(_s.value);
3092
+ if (i && _arr.length === i) break;
3093
+ }
3094
+ } catch (err) {
3095
+ _d = true;
3096
+ _e = err;
3097
+ } finally{
3098
+ try {
3099
+ if (!_n && _i["return"] != null) _i["return"]();
3100
+ } finally{
3101
+ if (_d) throw _e;
3102
+ }
3103
+ }
3104
+ return _arr;
3105
+ }
3106
+ function _non_iterable_rest$3() {
3107
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3108
+ }
3109
+ function _non_iterable_spread() {
3110
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3111
+ }
3112
+ function _object_spread(target) {
3113
+ for(var i = 1; i < arguments.length; i++){
3114
+ var source = arguments[i] != null ? arguments[i] : {};
3115
+ var ownKeys = Object.keys(source);
3116
+ if (typeof Object.getOwnPropertySymbols === "function") {
3117
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3118
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3119
+ }));
3120
+ }
3121
+ ownKeys.forEach(function(key) {
3122
+ _define_property$1(target, key, source[key]);
3123
+ });
3124
+ }
3125
+ return target;
3126
+ }
3127
+ function ownKeys(object, enumerableOnly) {
3128
+ var keys = Object.keys(object);
3129
+ if (Object.getOwnPropertySymbols) {
3130
+ var symbols = Object.getOwnPropertySymbols(object);
3131
+ keys.push.apply(keys, symbols);
3132
+ }
3133
+ return keys;
3134
+ }
3135
+ function _object_spread_props(target, source) {
3136
+ source = source != null ? source : {};
3137
+ if (Object.getOwnPropertyDescriptors) {
3138
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3139
+ } else {
3140
+ ownKeys(Object(source)).forEach(function(key) {
3141
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3142
+ });
3143
+ }
3144
+ return target;
3145
+ }
3146
+ function _object_without_properties(source, excluded) {
3147
+ if (source == null) return {};
3148
+ var target = _object_without_properties_loose(source, excluded);
3149
+ var key, i;
3150
+ if (Object.getOwnPropertySymbols) {
3151
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3152
+ for(i = 0; i < sourceSymbolKeys.length; i++){
3153
+ key = sourceSymbolKeys[i];
3154
+ if (excluded.indexOf(key) >= 0) continue;
3155
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3156
+ target[key] = source[key];
3157
+ }
3158
+ }
3159
+ return target;
3160
+ }
3161
+ function _object_without_properties_loose(source, excluded) {
3162
+ if (source == null) return {};
3163
+ var target = {};
3164
+ var sourceKeys = Object.keys(source);
3165
+ var key, i;
3166
+ for(i = 0; i < sourceKeys.length; i++){
3167
+ key = sourceKeys[i];
3168
+ if (excluded.indexOf(key) >= 0) continue;
3169
+ target[key] = source[key];
3170
+ }
3171
+ return target;
3172
+ }
3173
+ function _sliced_to_array$2(arr, i) {
3174
+ return _array_with_holes$3(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
3175
+ }
3176
+ function _to_consumable_array(arr) {
3177
+ return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread();
3178
+ }
3179
+ function _unsupported_iterable_to_array$3(o, minLen) {
3180
+ if (!o) return;
3181
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
3182
+ var n = Object.prototype.toString.call(o).slice(8, -1);
3183
+ if (n === "Object" && o.constructor) n = o.constructor.name;
3184
+ if (n === "Map" || n === "Set") return Array.from(n);
3185
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
3186
+ }
3187
+ function isNil(value) {
3188
+ return value === null || value === undefined;
3189
+ }
3190
+ function isTextContent(content) {
3191
+ return !!content && typeof content === "object" && content.type === "text";
3192
+ }
3193
+ function isReasoningContent(content) {
3194
+ return !!content && typeof content === "object" && content.type === "reasoning";
3195
+ }
3196
+ function isComponentContent(content) {
3197
+ return !!content && typeof content === "object" && content.type === "component";
3198
+ }
3199
+ function inferContentSource(content) {
3200
+ if (typeof content === "string") {
3201
+ return "text";
3202
+ }
3203
+ switch(content === null || content === void 0 ? void 0 : content.type){
3204
+ case "text":
3205
+ return "text";
3206
+ case "reasoning":
3207
+ return "reasoning";
3208
+ case "component":
3209
+ return "component";
3210
+ case "memory":
3211
+ return "memory";
3212
+ default:
3213
+ return "content";
3214
+ }
3215
+ }
3216
+ function mapJoinHint(hint) {
3217
+ switch(hint){
3218
+ case "none":
3219
+ return "";
3220
+ case "space":
3221
+ return " ";
3222
+ case "line":
3223
+ return "\n";
3224
+ case "paragraph":
3225
+ return "\n\n";
3226
+ default:
3227
+ return "";
3228
+ }
3229
+ }
3230
+ function endsWithCodeFence(text) {
3231
+ var normalized = (text !== null && text !== void 0 ? text : "").replace(/[ \t]+$/g, "");
3232
+ return normalized.endsWith("```");
3233
+ }
3234
+ function shouldJoinWithoutSeparator(previous, current) {
3235
+ return !!(previous === null || previous === void 0 ? void 0 : previous.streamId) && previous.source === current.source && previous.streamId === current.streamId;
3236
+ }
3237
+ function getSeparator(previousType, previousText, nextText, joinHint) {
3238
+ if (!nextText || /^\s/.test(nextText)) {
3239
+ return "";
3240
+ }
3241
+ if (joinHint) {
3242
+ return mapJoinHint(joinHint);
3243
+ }
3244
+ if (previousType === "component") {
3245
+ return "\n\n";
3246
+ }
3247
+ if (endsWithCodeFence(previousText)) {
3248
+ return "\n";
3249
+ }
3250
+ if (previousText && !/[\s\n]$/.test(previousText)) {
3251
+ return "\n";
3252
+ }
3253
+ return "";
3254
+ }
3255
+ function normalizeIncomingContent(content, context) {
3256
+ if (typeof content !== "string") {
3257
+ return content;
3258
+ }
3259
+ return _object_spread({
3260
+ type: "text",
3261
+ text: content
3262
+ }, context.streamId ? {
3263
+ id: context.streamId
3264
+ } : {});
3265
+ }
3266
+ function ensureArrayContent(content) {
3267
+ if (Array.isArray(content)) {
3268
+ return content;
3269
+ }
3270
+ if (typeof content === "string" && content.length > 0) {
3271
+ return [
3272
+ {
3273
+ type: "text",
3274
+ text: content
3275
+ }
3276
+ ];
3277
+ }
3278
+ return [];
3279
+ }
3280
+ function stringifySingle(content) {
3281
+ if (content.type === "text") {
3282
+ return content.text;
3283
+ }
3284
+ if (content.type === "component") {
3285
+ return JSON.stringify(content.data);
3286
+ }
3287
+ return JSON.stringify(content);
3288
+ }
3289
+ function filterText(content) {
3290
+ if (typeof content === "string") {
3291
+ return content;
3292
+ }
3293
+ if ((content === null || content === void 0 ? void 0 : content.type) === "text") {
3294
+ return content.text;
3295
+ }
3296
+ return "";
3297
+ }
3298
+ function mergeComponentData(previous, incoming) {
3299
+ var _previous_data, _incoming_data;
3300
+ var _incoming_data1;
3301
+ var mergedIncomingData = Object.entries((_incoming_data1 = incoming.data) !== null && _incoming_data1 !== void 0 ? _incoming_data1 : {}).reduce(function(acc, param) {
3302
+ var _param = _sliced_to_array$2(param, 2), key = _param[0], value = _param[1];
3303
+ if (!isNil(value)) {
3304
+ acc[key] = value;
3305
+ }
3306
+ return acc;
3307
+ }, {});
3308
+ var _previous_data1;
3309
+ return _object_spread_props(_object_spread({}, previous, incoming), {
3310
+ data: _object_spread_props(_object_spread({}, (_previous_data1 = previous.data) !== null && _previous_data1 !== void 0 ? _previous_data1 : {}, mergedIncomingData), {
3311
+ created_date: ((_previous_data = previous.data) === null || _previous_data === void 0 ? void 0 : _previous_data.created_date) || ((_incoming_data = incoming.data) === null || _incoming_data === void 0 ? void 0 : _incoming_data.created_date)
3312
+ })
3313
+ });
3314
+ }
3315
+ function inferMessageAppendContext(content, fallbackSource) {
3316
+ return _object_spread({
3317
+ source: fallbackSource !== null && fallbackSource !== void 0 ? fallbackSource : inferContentSource(content)
3318
+ }, typeof content !== "string" && (content === null || content === void 0 ? void 0 : content.id) ? {
3319
+ streamId: String(content.id)
3320
+ } : {});
3321
+ }
3322
+ function resolveMessageAppendContext(options) {
3323
+ var inferredContext = inferMessageAppendContext(options.incoming, options.fallbackSource);
3324
+ var appendContext = typeof options.incoming === "string" && !inferredContext.streamId && options.fallbackStreamId ? _object_spread_props(_object_spread({}, inferredContext), {
3325
+ streamId: options.fallbackStreamId
3326
+ }) : inferredContext;
3327
+ var messageContext = shouldJoinWithoutSeparator(options.previous, appendContext) ? _object_spread_props(_object_spread({}, appendContext), {
3328
+ joinHint: "none"
3329
+ }) : appendContext;
3330
+ return {
3331
+ appendContext: appendContext,
3332
+ messageContext: messageContext
3333
+ };
3334
+ }
3335
+ /**
3336
+ * Stateful helper for streaming append.
3337
+ *
3338
+ * It keeps the previous append context and resolves the current one, so callers
3339
+ * can avoid passing `previous` manually for every chunk and still get stable
3340
+ * join behavior (for example, same source + same stream -> `joinHint: 'none'`).
3341
+ *
3342
+ * Call `reset()` at turn/session boundaries to prevent cross-turn contamination.
3343
+ */ function createMessageAppendContextTracker() {
3344
+ var initial = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
3345
+ var previous = initial;
3346
+ return {
3347
+ resolve: function resolve(options) {
3348
+ var resolved = resolveMessageAppendContext(_object_spread_props(_object_spread({}, options), {
3349
+ previous: previous
3350
+ }));
3351
+ previous = resolved.appendContext;
3352
+ return resolved;
3353
+ },
3354
+ reset: function reset() {
3355
+ previous = null;
3356
+ },
3357
+ current: function current() {
3358
+ return previous;
3359
+ }
3360
+ };
3361
+ }
3362
+ /**
3363
+ * Append one incoming chunk into a chat message in place.
3364
+ *
3365
+ * Behavior:
3366
+ * - Keeps `aiMessage` object reference stable (caller may hold this object).
3367
+ * - Updates message properties with new references (`content`/`reasoning` arrays)
3368
+ * so UI change detection that relies on reference changes can react reliably.
3369
+ * - Applies context-aware merge rules for text/reasoning/component chunks.
3370
+ * - `previous` must be supplied by caller when same-stream join inference is needed.
3371
+ */ function appendMessageContent(aiMessage, incoming, context) {
3372
+ aiMessage.status = "answering";
3373
+ var _ref = context !== null && context !== void 0 ? context : {}, previous = _ref.previous, contextWithoutPrevious = _object_without_properties(_ref, [
3374
+ "previous"
3375
+ ]);
3376
+ var resolvedContext = _object_spread({}, inferMessageAppendContext(incoming), contextWithoutPrevious);
3377
+ var content = normalizeIncomingContent(incoming, resolvedContext);
3378
+ if (isReasoningContent(content)) {
3379
+ var _aiMessage_reasoning;
3380
+ var reasoning = (_aiMessage_reasoning = aiMessage.reasoning) !== null && _aiMessage_reasoning !== void 0 ? _aiMessage_reasoning : [];
3381
+ var lastReasoning = reasoning[reasoning.length - 1];
3382
+ if ((lastReasoning === null || lastReasoning === void 0 ? void 0 : lastReasoning.id) === content.id) {
3383
+ var mergedReasoning = _object_spread_props(_object_spread({}, lastReasoning), {
3384
+ text: "".concat(lastReasoning.text).concat(content.text)
3385
+ });
3386
+ aiMessage.reasoning = _to_consumable_array(reasoning.slice(0, reasoning.length - 1)).concat([
3387
+ mergedReasoning
3388
+ ]);
3389
+ } else {
3390
+ aiMessage.reasoning = _to_consumable_array(reasoning).concat([
3391
+ content
3392
+ ]);
3393
+ }
3394
+ aiMessage.status = "reasoning";
3395
+ return;
3396
+ }
3397
+ var chunks = ensureArrayContent(aiMessage.content);
3398
+ if (isTextContent(content)) {
3399
+ var _resolvedContext_joinHint;
3400
+ var joinHint = (_resolvedContext_joinHint = resolvedContext.joinHint) !== null && _resolvedContext_joinHint !== void 0 ? _resolvedContext_joinHint : shouldJoinWithoutSeparator(previous, resolvedContext) ? "none" : undefined;
3401
+ var lastContent = chunks[chunks.length - 1];
3402
+ if (isTextContent(lastContent) && (joinHint === "none" || !!content.id && !!lastContent.id && lastContent.id === content.id)) {
3403
+ var mergedLastContent = _object_spread(_object_spread_props(_object_spread({}, lastContent), {
3404
+ text: "".concat(lastContent.text).concat(content.text)
3405
+ }), !lastContent.id && content.id ? {
3406
+ id: content.id
3407
+ } : {});
3408
+ aiMessage.content = _to_consumable_array(chunks.slice(0, chunks.length - 1)).concat([
3409
+ mergedLastContent
3410
+ ]);
3411
+ return;
3412
+ }
3413
+ var _lastContent_type;
3414
+ var previousType = (_lastContent_type = lastContent === null || lastContent === void 0 ? void 0 : lastContent.type) !== null && _lastContent_type !== void 0 ? _lastContent_type : null;
3415
+ var previousText = isTextContent(lastContent) ? lastContent.text : "";
3416
+ var separator = getSeparator(previousType, previousText, content.text, joinHint);
3417
+ var appended = _object_spread_props(_object_spread({}, content), {
3418
+ text: separator + content.text
3419
+ });
3420
+ aiMessage.content = _to_consumable_array(chunks).concat([
3421
+ appended
3422
+ ]);
3423
+ return;
3424
+ }
3425
+ var nextChunks = _to_consumable_array(chunks);
3426
+ if (isComponentContent(content) && content.id) {
3427
+ var index = nextChunks.findIndex(function(item) {
3428
+ return isComponentContent(item) && item.id === content.id;
3429
+ });
3430
+ if (index > -1) {
3431
+ nextChunks[index] = mergeComponentData(nextChunks[index], content);
3432
+ } else {
3433
+ nextChunks.push(content);
3434
+ }
3435
+ } else {
3436
+ nextChunks.push(content);
3437
+ }
3438
+ aiMessage.content = nextChunks;
3439
+ }
3440
+ function appendMessagePlainText(accumulator, incoming, context) {
3441
+ var resolvedContext = _object_spread({}, inferMessageAppendContext(incoming), context !== null && context !== void 0 ? context : {});
3442
+ var nextText = filterText(incoming);
3443
+ if (!nextText) {
3444
+ return accumulator !== null && accumulator !== void 0 ? accumulator : "";
3445
+ }
3446
+ var previous = accumulator !== null && accumulator !== void 0 ? accumulator : "";
3447
+ var separator = getSeparator("text", previous, nextText, resolvedContext.joinHint);
3448
+ return previous + separator + nextText;
3449
+ }
3450
+ function stringifyMessageContent(content) {
3451
+ if (typeof content === "string") {
3452
+ return content;
3453
+ }
3454
+ if (Array.isArray(content)) {
3455
+ var result = "";
3456
+ var previousContext = null;
3457
+ content.forEach(function(item) {
3458
+ var itemContext = inferMessageAppendContext(item);
3459
+ var joinHint = shouldJoinWithoutSeparator(previousContext, itemContext) ? "none" : undefined;
3460
+ result = appendMessagePlainText(result, stringifySingle(item), _object_spread({}, itemContext, joinHint ? {
3461
+ joinHint: joinHint
3462
+ } : {}));
3463
+ previousContext = itemContext;
3464
+ });
3465
+ return result;
3466
+ }
3467
+ return stringifySingle(content);
3468
+ }
3469
+ function filterMessageText(content) {
3470
+ if (typeof content === "string") {
3471
+ return content;
3472
+ }
3473
+ if (Array.isArray(content)) {
3474
+ var result = "";
3475
+ var previousContext = null;
3476
+ content.forEach(function(item) {
3477
+ var nextText = filterText(item);
3478
+ if (!nextText) {
3479
+ return;
3480
+ }
3481
+ var itemContext = inferMessageAppendContext(item);
3482
+ var joinHint = shouldJoinWithoutSeparator(previousContext, itemContext) ? "none" : undefined;
3483
+ result = appendMessagePlainText(result, nextText, _object_spread({}, itemContext, joinHint ? {
3484
+ joinHint: joinHint
3485
+ } : {}));
3486
+ previousContext = itemContext;
3487
+ });
3488
+ return result || null;
3489
+ }
3490
+ return filterText(content) || null;
3491
+ }
3492
+
3059
3493
  exports.PermissionsEnum = void 0;
3060
3494
  (function(PermissionsEnum) {
3061
3495
  PermissionsEnum["PROFILE_EDIT"] = "PROFILE_EDIT";
@@ -3368,7 +3802,9 @@ var IntegrationGitHubProvider = {
3368
3802
  };
3369
3803
  };
3370
3804
 
3371
- var IntegrationLarkProvider = {
3805
+ /**
3806
+ * @deprecated use plugin
3807
+ */ var IntegrationLarkProvider = {
3372
3808
  name: exports.IntegrationEnum.LARK,
3373
3809
  label: {
3374
3810
  en_US: "Lark",
@@ -3750,11 +4186,12 @@ function _unsupported_iterable_to_array$1(o, minLen) {
3750
4186
  var __group, __group1;
3751
4187
  return rest.length ? ((__group = _.group) === null || __group === void 0 ? void 0 : __group.name) === groupName : !((__group1 = _.group) === null || __group1 === void 0 ? void 0 : __group1.name);
3752
4188
  });
4189
+ var selectVariable = group === null || group === void 0 ? void 0 : group.variables.find(function(_) {
4190
+ return _.name === (rest.join(".") || groupName);
4191
+ });
3753
4192
  return {
3754
4193
  group: group,
3755
- variable: group === null || group === void 0 ? void 0 : group.variables.find(function(_) {
3756
- return _.name === (rest.join(".") || groupName);
3757
- })
4194
+ variable: selectVariable
3758
4195
  };
3759
4196
  }
3760
4197
  var FILE_VARIABLES = [
@@ -3800,6 +4237,10 @@ var FILE_VARIABLES = [
3800
4237
  }
3801
4238
  ];
3802
4239
 
4240
+ function isInterruptMessage(obj) {
4241
+ return obj && typeof obj === "object" && "type" in obj && "category" in obj;
4242
+ }
4243
+
3803
4244
  function _array_like_to_array(arr, len) {
3804
4245
  if (len == null || len > arr.length) len = arr.length;
3805
4246
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -3908,6 +4349,11 @@ exports.InterruptMessageType = void 0;
3908
4349
  InterruptMessageType["Select"] = "select";
3909
4350
  })(exports.InterruptMessageType || (exports.InterruptMessageType = {}));
3910
4351
 
4352
+ var PLUGIN_LEVEL = {
4353
+ SYSTEM: "system",
4354
+ ORGANIZATION: "organization"
4355
+ };
4356
+
3911
4357
  exports.AI_MODEL_TYPE_VARIABLE = AI_MODEL_TYPE_VARIABLE;
3912
4358
  exports.Attachment_Type_Options = Attachment_Type_Options;
3913
4359
  exports.CONTEXT_VARIABLE_CURRENTSTATE = CONTEXT_VARIABLE_CURRENTSTATE;
@@ -3929,6 +4375,8 @@ exports.IntegrationGitHubProvider = IntegrationGitHubProvider;
3929
4375
  exports.IntegrationLarkProvider = IntegrationLarkProvider;
3930
4376
  exports.IteratingIndexParameterName = IteratingIndexParameterName;
3931
4377
  exports.IteratingItemParameterName = IteratingItemParameterName;
4378
+ exports.IteratorIndexParameterName = IteratorIndexParameterName;
4379
+ exports.IteratorItemParameterName = IteratorItemParameterName;
3932
4380
  exports.KDocumentSourceType = KDocumentSourceType;
3933
4381
  exports.KDocumentWebTypeOptions = KDocumentWebTypeOptions;
3934
4382
  exports.KNOWLEDGE_DOCUMENTS_NAME = KNOWLEDGE_DOCUMENTS_NAME;
@@ -3943,6 +4391,7 @@ exports.MEMORY_PROFILE_PROMPT = MEMORY_PROFILE_PROMPT;
3943
4391
  exports.MEMORY_QA_PROMPT = MEMORY_QA_PROMPT;
3944
4392
  exports.OllamaEmbeddingsProviders = OllamaEmbeddingsProviders;
3945
4393
  exports.OpenAIEmbeddingsProviders = OpenAIEmbeddingsProviders;
4394
+ exports.PLUGIN_LEVEL = PLUGIN_LEVEL;
3946
4395
  exports.PermissionApprovalStatus = PermissionApprovalStatus;
3947
4396
  exports.PermissionGroups = PermissionGroups;
3948
4397
  exports.STANDARD_METADATA_FIELDS = STANDARD_METADATA_FIELDS;
@@ -3950,7 +4399,6 @@ exports.STATE_SYS_VOLUME = STATE_SYS_VOLUME;
3950
4399
  exports.STATE_SYS_WORKSPACE_PATH = STATE_SYS_WORKSPACE_PATH;
3951
4400
  exports.STATE_SYS_WORKSPACE_URL = STATE_SYS_WORKSPACE_URL;
3952
4401
  exports.STATE_VARIABLE_FILES = STATE_VARIABLE_FILES;
3953
- exports.STATE_VARIABLE_HUMAN = STATE_VARIABLE_HUMAN;
3954
4402
  exports.STATE_VARIABLE_INPUT = STATE_VARIABLE_INPUT;
3955
4403
  exports.STATE_VARIABLE_SYS = STATE_VARIABLE_SYS;
3956
4404
  exports.STATE_VARIABLE_TITLE_CHANNEL = STATE_VARIABLE_TITLE_CHANNEL;
@@ -3959,10 +4407,13 @@ exports.TASK_DESCRIPTION_SUFFIX = TASK_DESCRIPTION_SUFFIX;
3959
4407
  exports.TENANT_AGENT_LOCAL_URL = TENANT_AGENT_LOCAL_URL;
3960
4408
  exports.TOOL_NAME_REGEX = TOOL_NAME_REGEX;
3961
4409
  exports.TranslationLanguageMap = TranslationLanguageMap;
4410
+ exports.USAGE_HOUR_FORMAT = USAGE_HOUR_FORMAT;
3962
4411
  exports.VariableOperations = VariableOperations;
3963
4412
  exports.agentLabel = agentLabel;
3964
4413
  exports.agentUniqueName = agentUniqueName;
3965
4414
  exports.allChannels = allChannels;
4415
+ exports.appendMessageContent = appendMessageContent;
4416
+ exports.appendMessagePlainText = appendMessagePlainText;
3966
4417
  exports.buildChunkTree = buildChunkTree;
3967
4418
  exports.channelName = channelName;
3968
4419
  exports.classificateDocumentCategory = classificateDocumentCategory;
@@ -3970,11 +4421,13 @@ exports.collectTreeLeaves = collectTreeLeaves;
3970
4421
  exports.configurableStoreNamespace = configurableStoreNamespace;
3971
4422
  exports.convertToUrlPath = convertToUrlPath;
3972
4423
  exports.createAgentConnections = createAgentConnections;
4424
+ exports.createMessageAppendContextTracker = createMessageAppendContextTracker;
3973
4425
  exports.createXpertGraph = createXpertGraph;
3974
4426
  exports.createXpertNodes = createXpertNodes;
3975
4427
  exports.embeddingCubeCollectionName = embeddingCubeCollectionName;
3976
4428
  exports.extractSemanticModelDraft = extractSemanticModelDraft;
3977
4429
  exports.figureOutXpert = figureOutXpert;
4430
+ exports.filterMessageText = filterMessageText;
3978
4431
  exports.findStartNodes = findStartNodes;
3979
4432
  exports.genJSONParseKey = genJSONParseKey;
3980
4433
  exports.genJSONStringifyKey = genJSONStringifyKey;
@@ -3990,8 +4443,10 @@ exports.genXpertDBInsertKey = genXpertDBInsertKey;
3990
4443
  exports.genXpertDBQueryKey = genXpertDBQueryKey;
3991
4444
  exports.genXpertDBSqlKey = genXpertDBSqlKey;
3992
4445
  exports.genXpertDBUpdateKey = genXpertDBUpdateKey;
4446
+ exports.genXpertIteratorKey = genXpertIteratorKey;
3993
4447
  exports.genXpertMiddlewareKey = genXpertMiddlewareKey;
3994
4448
  exports.genXpertSkillKey = genXpertSkillKey;
4449
+ exports.genXpertStartKey = genXpertStartKey;
3995
4450
  exports.genXpertTriggerKey = genXpertTriggerKey;
3996
4451
  exports.generateCronExpression = generateCronExpression;
3997
4452
  exports.getAgentMiddlewareNodes = getAgentMiddlewareNodes;
@@ -4006,25 +4461,37 @@ exports.getToolLabel = getToolLabel;
4006
4461
  exports.getVariableSchema = getVariableSchema;
4007
4462
  exports.getWorkflowTriggers = getWorkflowTriggers;
4008
4463
  exports.getWorkspaceFromRunnable = getWorkspaceFromRunnable;
4464
+ exports.inferMessageAppendContext = inferMessageAppendContext;
4009
4465
  exports.isAgentKey = isAgentKey;
4010
4466
  exports.isAudioType = isAudioType;
4011
4467
  exports.isDocumentSheet = isDocumentSheet;
4012
4468
  exports.isEnableTool = isEnableTool;
4013
4469
  exports.isImageType = isImageType;
4470
+ exports.isInterruptMessage = isInterruptMessage;
4014
4471
  exports.isIteratingKey = isIteratingKey;
4472
+ exports.isIteratorKey = isIteratorKey;
4015
4473
  exports.isMessageGroup = isMessageGroup;
4474
+ exports.isMiddlewareToolEnabled = isMiddlewareToolEnabled;
4016
4475
  exports.isRouterKey = isRouterKey;
4017
4476
  exports.isToolEnabled = isToolEnabled;
4018
4477
  exports.isVideoType = isVideoType;
4019
- exports.isWorkflowKey = isWorkflowKey;
4478
+ exports.isXpertNodeType = isXpertNodeType;
4020
4479
  exports.letterStartSUID = letterStartSUID;
4021
4480
  exports.locateNodes = locateNodes;
4022
4481
  exports.mapTranslationLanguage = mapTranslationLanguage;
4023
4482
  exports.messageContentText = messageContentText;
4024
4483
  exports.omitXpertRelations = omitXpertRelations;
4484
+ exports.resolveMessageAppendContext = resolveMessageAppendContext;
4025
4485
  exports.setStateVariable = setStateVariable;
4026
4486
  exports.shortTitle = shortTitle;
4487
+ exports.stringifyMessageContent = stringifyMessageContent;
4027
4488
  exports.transformInstallation = transformInstallation;
4028
4489
  exports.uuid = uuid;
4029
4490
  exports.workflowNodeIdentifier = workflowNodeIdentifier;
4030
4491
  exports.xpertLabel = xpertLabel;
4492
+ Object.keys(chatkitTypes).forEach(function (k) {
4493
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
4494
+ enumerable: true,
4495
+ get: function () { return chatkitTypes[k]; }
4496
+ });
4497
+ });