nolo-cli 0.8.0-alpha.2 → 0.8.0-alpha.21

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 (188) hide show
  1. package/README.md +1 -1
  2. package/_executeModel-42U3VOVZ.js +205 -0
  3. package/action-TLI3V62L.js +28 -0
  4. package/addContentAction-57RSIIMR.js +26 -0
  5. package/addDialogAgentAction-G3VWEA6E.js +68 -0
  6. package/agentDeleteCommand-5DD2IM3J.js +327 -0
  7. package/agentEmailCommands-6FACJBU4.js +628 -0
  8. package/agentListCommands-I6KZYCIG.js +223 -0
  9. package/agentMachineCommands-VKLIGMZA.js +425 -0
  10. package/agentPullCommand-O2MTUAFR.js +122 -0
  11. package/agentRecordCommands-7TZICYDT.js +96 -0
  12. package/agentRunCommand-L4OM23KV.js +114 -0
  13. package/agentRunControl-K4VKNEHF.js +57 -0
  14. package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
  15. package/agentSlice-BX7GXSNO.js +42 -0
  16. package/authCommand-EB5JSOX5.js +581 -0
  17. package/authCommands-XPEHTKSM.js +35 -0
  18. package/chunk-25LCXTML.js +175 -0
  19. package/chunk-2ECQG4YX.js +22296 -0
  20. package/chunk-2FTTDCD4.js +675 -0
  21. package/chunk-2JCXITPK.js +1078 -0
  22. package/chunk-3ASDTTEI.js +1774 -0
  23. package/chunk-3EUW3WEO.js +8 -0
  24. package/chunk-3LY4F7SV.js +9293 -0
  25. package/chunk-4CQLVGRV.js +50 -0
  26. package/chunk-4IJYA27C.js +342 -0
  27. package/chunk-4O3CARJ4.js +231 -0
  28. package/chunk-4QEWT7KD.js +933 -0
  29. package/chunk-4SN6J65J.js +38 -0
  30. package/chunk-4VNS5WPM.js +42 -0
  31. package/chunk-4XENYTF5.js +222 -0
  32. package/chunk-4ZDM73SD.js +34 -0
  33. package/chunk-5CS33IBL.js +301 -0
  34. package/chunk-5EFXE3O7.js +138 -0
  35. package/chunk-5KLGBAAR.js +386 -0
  36. package/chunk-5MIDPSSK.js +206 -0
  37. package/chunk-5MMAK75Q.js +15 -0
  38. package/chunk-63W5N6P3.js +150 -0
  39. package/chunk-6HYVJV7B.js +102 -0
  40. package/chunk-6KHNO3SK.js +1948 -0
  41. package/chunk-6WD3OOJS.js +20 -0
  42. package/chunk-7DAJ4AI4.js +191 -0
  43. package/chunk-7GNGZRLZ.js +1939 -0
  44. package/chunk-7KCUSYT2.js +354 -0
  45. package/chunk-7U44LYTR.js +238 -0
  46. package/chunk-AFON4QUU.js +112 -0
  47. package/chunk-AGFH73SK.js +239 -0
  48. package/chunk-AL2KDGR2.js +27339 -0
  49. package/chunk-AS4PVWA4.js +221 -0
  50. package/chunk-ATNTHIZI.js +13 -0
  51. package/chunk-AVMKZHBC.js +85 -0
  52. package/chunk-AZPCASRE.js +36 -0
  53. package/chunk-BBYVOSU2.js +792 -0
  54. package/chunk-C3RUNRHT.js +51 -0
  55. package/chunk-C4FTUXVF.js +146 -0
  56. package/chunk-CF2WZF4N.js +134 -0
  57. package/chunk-CF7PE763.js +10 -0
  58. package/chunk-CKOJQDKR.js +198 -0
  59. package/chunk-CMKUBIGW.js +1550 -0
  60. package/chunk-CWMSB67P.js +34 -0
  61. package/chunk-DCOA4QSN.js +105 -0
  62. package/chunk-DFFIZ25G.js +30 -0
  63. package/chunk-DSZUWUYB.js +478 -0
  64. package/chunk-DWLEOOGR.js +8 -0
  65. package/chunk-DZ3XJVET.js +231 -0
  66. package/chunk-EHLHSX7R.js +1433 -0
  67. package/chunk-ENOG22KJ.js +939 -0
  68. package/chunk-FSO5B7GH.js +171 -0
  69. package/chunk-FVYY6MCS.js +1447 -0
  70. package/chunk-G3SUCT4W.js +8 -0
  71. package/chunk-GAKEBQD6.js +30 -0
  72. package/chunk-GBRG75BQ.js +86 -0
  73. package/chunk-GU3PEVGZ.js +4723 -0
  74. package/chunk-H33743XH.js +25 -0
  75. package/chunk-HNMXYYJR.js +12 -0
  76. package/chunk-HNW7IJSK.js +71 -0
  77. package/chunk-I42VC5KR.js +15 -0
  78. package/chunk-I6XMPTMR.js +113 -0
  79. package/chunk-IDZTNRP2.js +85 -0
  80. package/chunk-ISNCLGUZ.js +146 -0
  81. package/chunk-IWX4UW2E.js +548 -0
  82. package/chunk-JBTJAPUF.js +35 -0
  83. package/chunk-JEXVIMYZ.js +55 -0
  84. package/chunk-JRKKFRAV.js +537 -0
  85. package/chunk-JZPBVBIY.js +94 -0
  86. package/chunk-KKY4B2Q2.js +21 -0
  87. package/chunk-KQHGZWSV.js +63 -0
  88. package/chunk-KUG52IAP.js +8 -0
  89. package/chunk-KX6YBIHG.js +8 -0
  90. package/chunk-LCBAMY2M.js +60 -0
  91. package/chunk-LM6IYQ3F.js +16 -0
  92. package/chunk-LTRXGFMS.js +83 -0
  93. package/chunk-M76ECQRD.js +13658 -0
  94. package/chunk-MRC4Q34M.js +188 -0
  95. package/chunk-MTU75CZ2.js +91 -0
  96. package/chunk-N54XAP77.js +19 -0
  97. package/chunk-O2ZNTTET.js +3272 -0
  98. package/chunk-O4BU24WZ.js +3212 -0
  99. package/chunk-OLZBQWZU.js +6 -0
  100. package/chunk-OOSFSFMA.js +271 -0
  101. package/chunk-OPZYGHUC.js +89 -0
  102. package/chunk-OWOHNGCN.js +50 -0
  103. package/chunk-P3PKED2I.js +962 -0
  104. package/chunk-QSJ3HFEF.js +8 -0
  105. package/chunk-RCSJFQPB.js +9036 -0
  106. package/chunk-RL776AGR.js +190 -0
  107. package/chunk-ROWQEJRP.js +139 -0
  108. package/chunk-S7Z2HMCN.js +25 -0
  109. package/chunk-SDJDLO5W.js +628 -0
  110. package/chunk-SOTZ6RDN.js +69 -0
  111. package/chunk-TILFE6LV.js +381 -0
  112. package/chunk-U4TRT5V4.js +246 -0
  113. package/chunk-U6VC4MU4.js +8 -0
  114. package/chunk-UAD2WT54.js +64 -0
  115. package/chunk-UB6SN4NJ.js +421 -0
  116. package/chunk-URUUZLPA.js +807 -0
  117. package/chunk-UTLZINAP.js +3066 -0
  118. package/chunk-VC6OZXO5.js +298 -0
  119. package/chunk-VF4K2QE6.js +21 -0
  120. package/chunk-VHBWHNVT.js +59 -0
  121. package/chunk-VIDPVFP3.js +20 -0
  122. package/chunk-VP4WJWKW.js +8882 -0
  123. package/chunk-VUW5FBDB.js +573 -0
  124. package/chunk-VVX233PH.js +482 -0
  125. package/chunk-VX3SXJ3N.js +2052 -0
  126. package/chunk-W4NVOSFF.js +37 -0
  127. package/chunk-WWC7I6TA.js +8 -0
  128. package/chunk-WZSRQNQG.js +2587 -0
  129. package/chunk-XBUBEFNX.js +34 -0
  130. package/chunk-XENYHRUE.js +104 -0
  131. package/chunk-Y5GCAMGP.js +9 -0
  132. package/chunk-YPRZSPF3.js +148 -0
  133. package/chunk-Z4NR32XR.js +50 -0
  134. package/chunk-ZNFJWEN4.js +56 -0
  135. package/cliExecutor-K3F7DMRO.js +36 -0
  136. package/clipboardy-BVE3LVEH.js +12001 -0
  137. package/createAgentAutomationAction-RJF3N2QY.js +866 -0
  138. package/createDialogAction-DRSPS6CE.js +55 -0
  139. package/createPageAction-6B2WMNO3.js +172 -0
  140. package/db-HCJ5PRB5.js +271 -0
  141. package/dbSlice-Q3TM2FJV.js +60 -0
  142. package/deleteFile-OW53A6BX.js +41 -0
  143. package/dialogCommands-4IX4XIZE.js +63 -0
  144. package/dialogSlice-3M7KX2TX.js +148 -0
  145. package/docCreateCommands-SIL3NPGT.js +220 -0
  146. package/docDeleteCommands-7IOMLUS4.js +181 -0
  147. package/docReadCommands-FNFXUA5L.js +134 -0
  148. package/docStore-SV7E34D4.js +98 -0
  149. package/docUpdateCommands-X2HNDVUC.js +318 -0
  150. package/fetchMessages-KTNM7QAR.js +17 -0
  151. package/getPricing-3E6UNPKL.js +30 -0
  152. package/handleSendMessageAction-JYETO5RZ.js +185 -0
  153. package/index.js +188 -112958
  154. package/lib-FYYBQIXS.js +19839 -0
  155. package/localDialogRead-2VRI24F4.js +26 -0
  156. package/localFirstLog-DHNOY2NA.js +19 -0
  157. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  158. package/localRuntimeDb-LGDF6FQP.js +12 -0
  159. package/machineCommands-RIO3RP5Q.js +781 -0
  160. package/machineInfo-M6KB6HZN.js +10 -0
  161. package/machineWsRunDispatch-W7UYLGB5.js +112 -0
  162. package/memoryCommands-O4MIPIWQ.js +476 -0
  163. package/models-4OPOOLFS.js +9 -0
  164. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  165. package/package.json +4 -24
  166. package/read-GW7ZEI23.js +17 -0
  167. package/readDocTool-HUFU6OCT.js +16 -0
  168. package/readlineWorkspace-27JR7WPW.js +5682 -0
  169. package/removeDialogAgentAction-CXKR4NJI.js +73 -0
  170. package/runAgentClientLoop-HZFAPJHS.js +293 -0
  171. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  172. package/setDialogExtraReferencesAction-6RKUSXHX.js +60 -0
  173. package/setPrimaryDialogAgentAction-T3UTBEFG.js +80 -0
  174. package/settingSlice-IVKXJXMG.js +199 -0
  175. package/skillDiscovery-UGSQGX2U.js +16 -0
  176. package/skillSummaryMarker-42HKSXYY.js +9 -0
  177. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  178. package/slateUtils-2M7MUTWX.js +19 -0
  179. package/spaceCommands-E7VOF4LO.js +450 -0
  180. package/spaceSlice-TSVROA5U.js +149 -0
  181. package/streamAgentChatTurn-3C5RQZJF.js +4510 -0
  182. package/tableCommands-O7O2LBEG.js +1286 -0
  183. package/toolApiClient-QI3YBNWB.js +26 -0
  184. package/tools-EQDEKR6N.js +87 -0
  185. package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
  186. package/understanding-3CUQQ6SV.js +271 -0
  187. package/updateCommands-VOSPKXFF.js +31 -0
  188. package/updateDialogTitleAction-3XV7VWSZ.js +188 -0
@@ -0,0 +1,939 @@
1
+ import {
2
+ chooseMemoryOwners,
3
+ loadMemoryCandidatesFromDb
4
+ } from "./chunk-XENYHRUE.js";
5
+ import {
6
+ addContentToSpace,
7
+ prepareAndPersistMessage,
8
+ uiAskChoiceFunc,
9
+ uiAskChoiceFunctionSchema
10
+ } from "./chunk-2ECQG4YX.js";
11
+ import {
12
+ require_date_fns
13
+ } from "./chunk-M76ECQRD.js";
14
+ import {
15
+ PLATFORM_HOSTED_GLM_52_MODEL,
16
+ PLATFORM_HOSTED_GLM_PRICE
17
+ } from "./chunk-BBYVOSU2.js";
18
+ import {
19
+ PLATFORM_HOSTED_KIMI_PROVIDER
20
+ } from "./chunk-IWX4UW2E.js";
21
+ import {
22
+ extractCustomId
23
+ } from "./chunk-DFFIZ25G.js";
24
+ import {
25
+ read,
26
+ readAndWait,
27
+ removeCachedEntity,
28
+ upsertSSREntity,
29
+ write
30
+ } from "./chunk-URUUZLPA.js";
31
+ import {
32
+ createAgentKey,
33
+ createDialogKey,
34
+ createKey,
35
+ dialogMessageRange
36
+ } from "./chunk-O4BU24WZ.js";
37
+ import {
38
+ selectIdentityUserId
39
+ } from "./chunk-UTLZINAP.js";
40
+ import {
41
+ asTrimmedString
42
+ } from "./chunk-3EUW3WEO.js";
43
+ import {
44
+ asOptionalPositiveFiniteNumber
45
+ } from "./chunk-U6VC4MU4.js";
46
+ import {
47
+ asOptionalTrimmedString
48
+ } from "./chunk-G3SUCT4W.js";
49
+ import {
50
+ isRecord
51
+ } from "./chunk-KUG52IAP.js";
52
+ import {
53
+ __toESM
54
+ } from "./chunk-4VNS5WPM.js";
55
+
56
+ // packages/chat/dialog/actions/createDialogAction.ts
57
+ var import_date_fns = __toESM(require_date_fns());
58
+
59
+ // packages/ai/skills/builtinObjectSkills.ts
60
+ var BUILTIN_OBJECT_SKILL_IDS = {
61
+ table: "builtin-table-skill-v1",
62
+ doc: "builtin-doc-skill-v1",
63
+ code: "builtin-code-skill-v1",
64
+ image: "builtin-image-skill-v1",
65
+ file: "builtin-file-skill-v1"
66
+ };
67
+ var SKILL_DEFS = {
68
+ doc: {
69
+ id: BUILTIN_OBJECT_SKILL_IDS.doc,
70
+ name: "\u6587\u6863\u7F16\u8F91\u6280\u80FD",
71
+ description: "\u63D0\u4F9B\u6587\u6863\u8BFB\u53D6\u4E0E\u66F4\u65B0\u80FD\u529B\uFF0C\u4F9B\u6587\u6863\u52A9\u624B\u4F7F\u7528\u3002",
72
+ toolNames: ["readDoc", "updateDoc"],
73
+ promptPatch: [
74
+ "\u6587\u6863\u7F16\u8F91\u6307\u5357\uFF1A",
75
+ "1. \u4FEE\u6539\u524D\u5148 readDoc \u8BFB\u53D6\u5F53\u524D\u6587\u6863\u771F\u503C\uFF0C\u518D\u57FA\u4E8E\u73B0\u6709\u5185\u5BB9\u7528 updateDoc \u505A\u5B9A\u70B9\u589E\u91CF\u7F16\u8F91\u3002",
76
+ "2. \u4E0D\u8981\u8131\u79BB\u73B0\u6709\u5185\u5BB9\u7A7A\u60F3\u91CD\u5199\uFF1B\u6DA6\u8272/\u6539\u5199/\u7EED\u5199\u90FD\u5E94\u4FDD\u7559\u7528\u6237\u539F\u6709\u7684\u7ED3\u6784\u4E0E\u4E8B\u5B9E\u3002"
77
+ ].join("\n"),
78
+ keywords: ["\u6587\u6863", "\u6DA6\u8272", "\u6539\u5199", "\u7EED\u5199", "\u6392\u7248", "\u6587\u7AE0", "document", "polish"]
79
+ },
80
+ table: {
81
+ id: BUILTIN_OBJECT_SKILL_IDS.table,
82
+ name: "\u8868\u683C\u7F16\u8F91\u6280\u80FD",
83
+ description: "\u63D0\u4F9B\u8868\u683C\u521B\u5EFA\u3001\u67E5\u8BE2\u3001\u65B0\u589E\u3001\u66F4\u65B0\u4E0E\u5220\u9664\u80FD\u529B\uFF0C\u4F9B\u8868\u683C\u52A9\u624B\u4F7F\u7528\u3002",
84
+ toolNames: [
85
+ "createTable",
86
+ "addTableRow",
87
+ "addTableRows",
88
+ "queryTableRows",
89
+ "updateTableRow",
90
+ "deleteTableRow"
91
+ ],
92
+ promptPatch: [
93
+ "\u8868\u683C\u64CD\u4F5C\u6307\u5357\uFF1A",
94
+ "1. \u7528\u6237\u8981\u65B0\u5EFA\u8868\u683C\u65F6\uFF0C\u8C03\u7528 createTable\uFF0C\u5E76\u4ECE\u9700\u6C42\u63A8\u65AD\u5408\u7406\u7684\u5B57\u6BB5\u8BBE\u8BA1\uFF08\u5B57\u6BB5\u540D\u3001\u7C7B\u578B\u3001\u5FC5\u586B\u3001\u53EF\u9009\u503C\uFF09\u3002",
95
+ "2. \u65B0\u589E\u8BB0\u5F55\u5FC5\u987B\u8C03\u7528 addTableRow / addTableRows\uFF0C\u4E0D\u8981\u53EA\u5728\u56DE\u7B54\u91CC\u53E3\u5934\u63CF\u8FF0\u3002",
96
+ "3. addTableRow \u7684 values \u662F\u5BF9\u8C61\uFF0Ckey \u5FC5\u987B\u7528\u5B57\u6BB5\u540D\uFF08name\uFF0C\u4E0D\u662F\u663E\u793A\u540D label\uFF09\uFF1B\u5C3D\u91CF\u4ECE\u7528\u6237\u81EA\u7136\u8BED\u8A00\u63A8\u65AD\u5E76\u586B\u6EE1\u76F8\u5173\u5B57\u6BB5\uFF0C\u5FC5\u586B\u5B57\u6BB5\u5C24\u5176\u6CE8\u610F\uFF1B\u7528\u6237\u6CA1\u63D0\u5230\u7684\u5B57\u6BB5\u53EF\u7528\u7A7A\u5B57\u7B26\u4E32\u6216 null \u5360\u4F4D\uFF1B\u7EDD\u4E0D\u8981\u4F20\u7A7A\u5BF9\u8C61 {}\u3002",
97
+ "4. \u66F4\u65B0\u6216\u5220\u9664\u524D\uFF0C\u5148\u7528 queryTableRows \u786E\u8BA4\u76EE\u6807\u884C\uFF0C\u5FC5\u8981\u65F6\u5411\u7528\u6237\u786E\u8BA4\u76EE\u6807\u884C/\u5B57\u6BB5\u3002"
98
+ ].join("\n"),
99
+ keywords: ["\u8868\u683C", "\u5EFA\u8868", "\u65B0\u589E\u4E00\u884C", "\u8BB0\u5F55", "\u5B57\u6BB5", "table", "spreadsheet", "csv"]
100
+ },
101
+ code: {
102
+ id: BUILTIN_OBJECT_SKILL_IDS.code,
103
+ name: "\u7F16\u7801\u98CE\u683C\u6280\u80FD",
104
+ description: "\u63D0\u4F9B\u7F16\u7801\u89C4\u8303\u4E0E\u98CE\u683C\u7EA6\u675F\uFF0C\u4F9B\u4EE3\u7801\u4EFB\u52A1\u4F7F\u7528\u3002",
105
+ toolNames: [],
106
+ promptPatch: [
107
+ "\u7F16\u7801\u98CE\u683C\u4E0E\u89C4\u8303\u6307\u5357\uFF1A",
108
+ "1. \u6587\u4EF6\u62C6\u5206\uFF1A\u4F18\u5148\u62C6\u5206\u4E3A\u591A\u6587\u4EF6\uFF08MANY SMALL FILES\uFF09\uFF0C\u5178\u578B\u957F\u5EA6 200-400 \u884C\uFF0C\u5355\u6587\u4EF6\u6700\u591A 800 \u884C\uFF08800 max\uFF09\u3002",
109
+ "2. \u51FD\u6570\u4E0E\u5D4C\u5957\uFF1A\u51FD\u6570\u4FDD\u6301\u77ED\u5C0F\uFF08<50 lines\uFF09\uFF0C\u4F18\u5148\u4F7F\u7528 early returns \u63D0\u524D\u8FD4\u56DE\uFF0C\u5D4C\u5957\u5C42\u7EA7\u4E0D\u8D85\u8FC7 4 \u5C42\uFF08nesting \u22644\uFF09\u3002",
110
+ "3. \u4E0D\u53EF\u53D8\u6027\uFF08immutability\uFF09\uFF1A\u4FDD\u6301\u6570\u636E\u4E0D\u53EF\u53D8\uFF0C\u4E0D\u8981\u539F\u5730 mutate \u73B0\u6709\u5BF9\u8C61\u6216\u6570\u7EC4\uFF0C\u5FC5\u987B\u8FD4\u56DE\u65B0\u5BF9\u8C61/\u6570\u7EC4\u3002",
111
+ "4. \u9519\u8BEF\u5904\u7406\u4E0E\u6821\u9A8C\uFF1A\u663E\u5F0F\u5904\u7406\u6240\u6709\u9519\u8BEF\uFF08explicit error handling\uFF09\uFF0C\u5728\u7CFB\u7EDF\u8FB9\u754C\u5B8C\u6210\u6821\u9A8C\uFF08validate at boundaries\uFF09\uFF0C\u4E0D\u9690\u5F0F\u541E\u9519\u3002",
112
+ "5. \u5B8C\u6210\u524D Checklist\uFF1A\u5B8C\u6210\u524D\u81EA\u67E5\u51FD\u6570/\u6587\u4EF6\u5C3A\u5BF8\u3001\u5D4C\u5957\u6DF1\u5EA6\u3001\u4E0D\u53EF\u53D8\u6027\u4E0E\u8FB9\u754C\u9519\u8BEF\u5904\u7406\u3002"
113
+ ].join("\n"),
114
+ keywords: ["\u4EE3\u7801", "\u7F16\u7801", "\u91CD\u6784", "\u4FEEbug", "code", "refactor", "bugfix", "coding-style"]
115
+ },
116
+ image: {
117
+ id: BUILTIN_OBJECT_SKILL_IDS.image,
118
+ name: "\u56FE\u7247\u5206\u6790\u6280\u80FD",
119
+ description: "\u63D0\u4F9B\u56FE\u7247\u7406\u89E3\u3001\u63CF\u8FF0\u4E0E\u6574\u7406\u5EFA\u8BAE\u80FD\u529B\uFF0C\u4F9B\u56FE\u7247\u52A9\u624B\u4F7F\u7528\u3002",
120
+ toolNames: [],
121
+ promptPatch: [
122
+ "\u56FE\u7247\u5206\u6790\u6307\u5357\uFF1A",
123
+ "1. \u5F53\u524D\u9636\u6BB5\u91CD\u70B9\u56F4\u7ED5\u5F53\u524D\u56FE\u7247\u505A\u7406\u89E3\u3001\u63CF\u8FF0\u3001\u63D0\u70BC\u91CD\u70B9\u3001\u7ED9\u51FA\u547D\u540D/\u6574\u7406\u5EFA\u8BAE\u548C\u540E\u7EED\u5904\u7406\u5EFA\u8BAE\u3002",
124
+ "2. \u4E0D\u8981\u5047\u88C5\u5DF2\u7ECF\u5177\u5907\u590D\u6742\u56FE\u7247\u7F16\u8F91\u80FD\u529B\uFF1B\u5982\u679C\u7528\u6237\u8981\u66F4\u5F3A\u64CD\u4F5C\uFF0C\u660E\u786E\u8BF4\u660E\u5F53\u524D\u53EF\u505A\u7684\u662F\u5206\u6790\u4E0E\u7EC4\u7EC7\u3002"
125
+ ].join("\n"),
126
+ keywords: ["\u56FE\u7247", "\u56FE\u50CF", "\u5206\u6790", "\u63CF\u8FF0", "\u547D\u540D", "\u6574\u7406", "image", "photo", "picture"]
127
+ },
128
+ file: {
129
+ id: BUILTIN_OBJECT_SKILL_IDS.file,
130
+ name: "\u6587\u4EF6\u5904\u7406\u6280\u80FD",
131
+ description: "\u63D0\u4F9B\u6587\u4EF6\u7406\u89E3\u3001\u6574\u7406\u4E0E\u5904\u7406\u5EFA\u8BAE\u80FD\u529B\uFF0C\u4F9B\u6587\u4EF6\u52A9\u624B\u4F7F\u7528\u3002",
132
+ toolNames: [],
133
+ promptPatch: [
134
+ "\u6587\u4EF6\u5904\u7406\u6307\u5357\uFF1A",
135
+ "1. \u5F53\u524D\u9636\u6BB5\u91CD\u70B9\u56F4\u7ED5\u5F53\u524D\u6587\u4EF6\u63D0\u4F9B\u7406\u89E3\u3001\u6574\u7406\u3001\u63D0\u53D6\u4E0E\u540E\u7EED\u5904\u7406\u5EFA\u8BAE\u3002",
136
+ "2. \u4E0D\u8981\u5047\u88C5\u5DF2\u7ECF\u5B8C\u6210\u6587\u4EF6\u5185\u5BB9\u89E3\u6790\uFF1B\u5FC5\u8981\u65F6\u660E\u786E\u544A\u8BC9\u7528\u6237\u5F53\u524D\u66F4\u591A\u662F\u5360\u4F4D\u578B\u5DE5\u4F5C\u6D41\u5165\u53E3\uFF0C\u7B49\u5F85\u540E\u7EED\u63A5\u5165\u66F4\u5B8C\u6574\u7684\u6587\u4EF6\u5904\u7406\u80FD\u529B\u3002"
137
+ ].join("\n"),
138
+ keywords: ["\u6587\u4EF6", "\u89E3\u6790", "\u63D0\u53D6", "\u6574\u7406", "\u5904\u7406", "file", "document", "pdf"]
139
+ }
140
+ };
141
+ function buildBuiltinObjectSkillDbKey(kind, userId) {
142
+ return createKey("page" /* DOC */, userId, BUILTIN_OBJECT_SKILL_IDS[kind]);
143
+ }
144
+ function buildBuiltinObjectSkillReference(kind, userId) {
145
+ return {
146
+ dbKey: buildBuiltinObjectSkillDbKey(kind, userId),
147
+ title: SKILL_DEFS[kind].name,
148
+ type: "instruction"
149
+ };
150
+ }
151
+
152
+ // packages/chat/dialog/objectAssistantRegistry.ts
153
+ var OBJECT_ASSISTANT_TO_SKILL = {
154
+ page: "doc",
155
+ table: "table",
156
+ image: "image",
157
+ file: "file"
158
+ };
159
+ var BUILTIN_OBJECT_ASSISTANT_IDS = {
160
+ page: "builtin-doc-assistant-v1",
161
+ table: "builtin-table-assistant-v1",
162
+ image: "builtin-image-assistant-v1",
163
+ file: "builtin-file-assistant-v1"
164
+ };
165
+ var resolveBuiltinObjectAssistantKindByKey = (agentKey, userId) => {
166
+ if (!agentKey || !userId) return null;
167
+ const entries = Object.entries(BUILTIN_OBJECT_ASSISTANT_IDS);
168
+ for (const [kind, id] of entries) {
169
+ if (agentKey === createAgentKey.private(userId, id)) {
170
+ return kind;
171
+ }
172
+ }
173
+ return null;
174
+ };
175
+ var buildBuiltinObjectAssistantAgent = (kind, userId) => {
176
+ const id = BUILTIN_OBJECT_ASSISTANT_IDS[kind];
177
+ const dbKey = createAgentKey.private(userId, id);
178
+ const now = Date.now();
179
+ const common = {
180
+ id,
181
+ dbKey,
182
+ type: "agent" /* AGENT */,
183
+ userId,
184
+ isPublic: false,
185
+ provider: PLATFORM_HOSTED_KIMI_PROVIDER,
186
+ model: PLATFORM_HOSTED_GLM_52_MODEL,
187
+ apiSource: "platform",
188
+ useServerProxy: true,
189
+ inputPrice: PLATFORM_HOSTED_GLM_PRICE.input,
190
+ outputPrice: PLATFORM_HOSTED_GLM_PRICE.output,
191
+ createdAt: now,
192
+ updatedAt: String(now),
193
+ dialogCount: 0,
194
+ messageCount: 0,
195
+ tokenCount: 0,
196
+ tags: ["builtin", "sidebar-assistant", kind],
197
+ references: [buildBuiltinObjectSkillReference(OBJECT_ASSISTANT_TO_SKILL[kind], userId)]
198
+ };
199
+ switch (kind) {
200
+ case "page":
201
+ return {
202
+ ...common,
203
+ name: "\u6587\u6863\u52A9\u624B",
204
+ introduction: "\u5E2E\u4F60\u6DA6\u8272\u3001\u6539\u5199\u3001\u7EED\u5199\u3001\u6574\u7406\u7ED3\u6784\u4E0E\u6392\u7248\u7684\u6587\u6863\u52A9\u624B\u3002",
205
+ greeting: {
206
+ text: "\u4F60\u597D\uFF0C\u6211\u662F\u6587\u6863\u52A9\u624B \u270D\uFE0F\n\n\u4F60\u53EF\u4EE5\u76F4\u63A5\u5BF9\u6211\u8BF4\uFF1A\n\u2022 \u5E2E\u6211\u6DA6\u8272\u8FD9\u7BC7\u6587\u7AE0\n\u2022 \u628A\u7ED3\u6784\u6574\u7406\u5F97\u66F4\u6E05\u695A\n\u2022 \u7ED9\u8FD9\u4E00\u6BB5\u6539\u6210\u66F4\u53E3\u8BED/\u66F4\u4E13\u4E1A\n\u2022 \u5E2E\u6211\u8865\u4E00\u4E2A\u5F00\u5934\u6216\u7ED3\u5C3E",
207
+ menu: [
208
+ { id: "polish", label: "\u6DA6\u8272\u5F53\u524D\u6587\u6863", userMessage: "\u5E2E\u6211\u6DA6\u8272\u5F53\u524D\u6587\u6863\uFF0C\u8BA9\u8868\u8FBE\u66F4\u987A" },
209
+ { id: "structure", label: "\u6574\u7406\u7ED3\u6784", userMessage: "\u5E2E\u6211\u6574\u7406\u5F53\u524D\u6587\u6863\u7ED3\u6784\uFF0C\u770B\u770B\u6807\u9898\u548C\u6BB5\u843D\u600E\u4E48\u66F4\u6E05\u695A" },
210
+ { id: "continue", label: "\u7EE7\u7EED\u5199", userMessage: "\u57FA\u4E8E\u5F53\u524D\u6587\u6863\u7EE7\u7EED\u5F80\u4E0B\u5199" }
211
+ ]
212
+ },
213
+ prompt: "\u4F60\u662F\u4E00\u4E2A\u6587\u6863\u7F16\u8F91\u52A9\u624B\u3002\u4F18\u5148\u57FA\u4E8E\u5F53\u524D\u6587\u6863\u505A\u589E\u91CF\u4FEE\u6539\uFF0C\u4E0D\u8981\u8131\u79BB\u73B0\u6709\u5185\u5BB9\u7A7A\u60F3\u91CD\u5199\u3002\u91CD\u70B9\u5E2E\u52A9\u7528\u6237\u6DA6\u8272\u3001\u6539\u5199\u3001\u7EED\u5199\u3001\u91CD\u7EC4\u7ED3\u6784\u3001\u751F\u6210\u6807\u9898\u548C\u6458\u8981\u3002\u6D89\u53CA\u4FEE\u6539\u65F6\uFF0C\u4F18\u5148\u8BFB\u53D6\u5F53\u524D\u6587\u6863\u771F\u503C\uFF0C\u518D\u8FDB\u884C\u5B9A\u70B9\u7F16\u8F91\u3002"
214
+ };
215
+ case "table":
216
+ return {
217
+ ...common,
218
+ name: "\u8868\u683C\u52A9\u624B",
219
+ introduction: "\u5E2E\u4F60\u7406\u89E3\u8868\u7ED3\u6784\u3001\u8865\u6570\u636E\u3001\u6539\u6570\u636E\u548C\u6574\u7406\u5B57\u6BB5\u7684\u8868\u683C\u52A9\u624B\u3002",
220
+ greeting: {
221
+ text: "\u4F60\u597D\uFF0C\u6211\u662F\u8868\u683C\u52A9\u624B \u{1F4CA}\n\n\u4F60\u53EF\u4EE5\u76F4\u63A5\u5BF9\u6211\u8BF4\uFF1A\n\u2022 \u5E2E\u6211\u770B\u770B\u8FD9\u5F20\u8868\u8FD8\u7F3A\u4EC0\u4E48\u5B57\u6BB5\n\u2022 \u7ED9\u8868\u91CC\u52A0\u4E00\u6761\u8BB0\u5F55\n\u2022 \u628A\u67D0\u4E00\u5217\u7EDF\u4E00\u6539\u4E00\u4E0B\n\u2022 \u6309\u8FD9\u4E2A\u6761\u4EF6\u5E2E\u6211\u6574\u7406\u6570\u636E",
222
+ menu: [
223
+ { id: "inspect", label: "\u770B\u770B\u8FD9\u5F20\u8868", userMessage: "\u5E2E\u6211\u770B\u770B\u5F53\u524D\u8FD9\u5F20\u8868\u7684\u7ED3\u6784\u548C\u53EF\u6539\u8FDB\u70B9" },
224
+ { id: "add-row", label: "\u65B0\u589E\u6570\u636E", userMessage: "\u6211\u60F3\u5F80\u5F53\u524D\u8868\u91CC\u65B0\u589E\u4E00\u6761\u6570\u636E" },
225
+ { id: "fix-data", label: "\u6279\u91CF\u6539\u6570\u636E", userMessage: "\u6211\u60F3\u4FEE\u6539\u5F53\u524D\u8868\u91CC\u7684\u90E8\u5206\u6570\u636E" }
226
+ ]
227
+ },
228
+ prompt: "\u4F60\u662F\u4E00\u4E2A\u8868\u683C\u7F16\u8F91\u52A9\u624B\u3002\u4F18\u5148\u5E2E\u52A9\u7528\u6237\u7406\u89E3\u5F53\u524D\u8868\u7684\u5B57\u6BB5\u3001\u8BB0\u5F55\u548C\u7ED3\u6784\uFF0C\u7136\u540E\u518D\u505A\u65B0\u589E\u3001\u67E5\u8BE2\u3001\u66F4\u65B0\u6216\u5220\u9664\u3002\u5BF9\u7528\u6237\u8BF4\u201C\u8FD9\u4E2A\u8868\u91CC\u7684 xxx \u600E\u4E48\u600E\u4E48\u6539\u201D\u65F6\uFF0C\u9ED8\u8BA4\u7406\u89E3\u4E3A\u5F53\u524D\u805A\u7126\u6216\u6700\u8FD1\u63D0\u5230\u7684\u8868\uFF1B\u5FC5\u8981\u65F6\u5148\u786E\u8BA4\u76EE\u6807\u884C/\u5B57\u6BB5\u3002"
229
+ };
230
+ case "image":
231
+ return {
232
+ ...common,
233
+ name: "\u56FE\u7247\u52A9\u624B",
234
+ introduction: "\u5F53\u524D\u5148\u4F5C\u4E3A\u56FE\u7247\u5206\u6790\u4E0E\u5904\u7406\u5EFA\u8BAE\u5165\u53E3\uFF0C\u540E\u7EED\u53EF\u6269\u5C55\u4E3A\u66F4\u5B8C\u6574\u7684\u56FE\u7247\u5DE5\u4F5C\u6D41\u52A9\u624B\u3002",
235
+ greeting: "\u4F60\u597D\uFF0C\u6211\u662F\u56FE\u7247\u52A9\u624B \u{1F5BC}\uFE0F\n\n\u76EE\u524D\u6211\u53EF\u4EE5\u5148\u5E2E\u4F60\u5206\u6790\u56FE\u7247\u5185\u5BB9\u3001\u63D0\u70BC\u91CD\u70B9\u3001\u7ED9\u51FA\u547D\u540D/\u6574\u7406\u5EFA\u8BAE\u3002\u540E\u7EED\u6211\u4EEC\u518D\u628A\u66F4\u6DF1\u7684\u56FE\u7247\u7F16\u8F91\u5DE5\u4F5C\u6D41\u63A5\u4E0A\u3002",
236
+ prompt: "\u4F60\u662F\u4E00\u4E2A\u56FE\u7247\u52A9\u624B\u3002\u5F53\u524D\u9636\u6BB5\u91CD\u70B9\u662F\u56F4\u7ED5\u5F53\u524D\u56FE\u7247\u505A\u7406\u89E3\u3001\u63CF\u8FF0\u3001\u6574\u7406\u5EFA\u8BAE\u548C\u540E\u7EED\u5904\u7406\u5EFA\u8BAE\u3002\u4E0D\u8981\u5047\u88C5\u5DF2\u7ECF\u5177\u5907\u590D\u6742\u56FE\u7247\u7F16\u8F91\u80FD\u529B\uFF1B\u5982\u679C\u7528\u6237\u8981\u66F4\u5F3A\u64CD\u4F5C\uFF0C\u660E\u786E\u8BF4\u660E\u5F53\u524D\u53EF\u505A\u7684\u662F\u5206\u6790\u4E0E\u7EC4\u7EC7\u3002"
237
+ };
238
+ case "file":
239
+ return {
240
+ ...common,
241
+ name: "\u6587\u4EF6\u52A9\u624B",
242
+ introduction: "\u5F53\u524D\u5148\u4F5C\u4E3A\u6587\u4EF6\u7406\u89E3\u4E0E\u5904\u7406\u5EFA\u8BAE\u5165\u53E3\uFF0C\u540E\u7EED\u53EF\u6269\u5C55\u4E3A\u66F4\u5B8C\u6574\u7684\u6587\u4EF6\u5DE5\u4F5C\u6D41\u52A9\u624B\u3002",
243
+ greeting: "\u4F60\u597D\uFF0C\u6211\u662F\u6587\u4EF6\u52A9\u624B \u{1F4CE}\n\n\u76EE\u524D\u6211\u53EF\u4EE5\u5148\u5E2E\u4F60\u7406\u89E3\u8FD9\u4E2A\u6587\u4EF6\u9002\u5408\u600E\u4E48\u5904\u7406\u3001\u600E\u4E48\u63D0\u53D6\u4FE1\u606F\u3001\u4E0B\u4E00\u6B65\u5E94\u8BE5\u505A\u4EC0\u4E48\u3002\u540E\u7EED\u6211\u4EEC\u518D\u628A\u66F4\u5B8C\u6574\u7684\u6587\u4EF6\u5904\u7406\u6D41\u7A0B\u63A5\u4E0A\u3002",
244
+ prompt: "\u4F60\u662F\u4E00\u4E2A\u6587\u4EF6\u52A9\u624B\u3002\u5F53\u524D\u9636\u6BB5\u91CD\u70B9\u662F\u56F4\u7ED5\u5F53\u524D\u6587\u4EF6\u63D0\u4F9B\u7406\u89E3\u3001\u6574\u7406\u3001\u63D0\u53D6\u4E0E\u540E\u7EED\u5904\u7406\u5EFA\u8BAE\u3002\u4E0D\u8981\u5047\u88C5\u5DF2\u7ECF\u5B8C\u6210\u6587\u4EF6\u5185\u5BB9\u89E3\u6790\uFF1B\u5FC5\u8981\u65F6\u660E\u786E\u544A\u8BC9\u7528\u6237\u5F53\u524D\u66F4\u591A\u662F\u5360\u4F4D\u578B\u5DE5\u4F5C\u6D41\u5165\u53E3\u3002"
245
+ };
246
+ }
247
+ };
248
+ var buildBuiltinObjectAssistantAgentFromKey = (agentKey, userId) => {
249
+ const kind = resolveBuiltinObjectAssistantKindByKey(agentKey, userId);
250
+ if (!kind || !userId) return null;
251
+ return buildBuiltinObjectAssistantAgent(kind, userId);
252
+ };
253
+
254
+ // packages/ai/memory/policy.ts
255
+ function isPublicAgentKey(agentKey) {
256
+ return typeof agentKey === "string" && /^agent-pub-/i.test(agentKey.trim());
257
+ }
258
+ function resolveAgentMemoryPolicy(input) {
259
+ const publicAgent = input.isPublicAgent === true || isPublicAgentKey(input.agentKey);
260
+ if (publicAgent) {
261
+ return {
262
+ includeUserSubject: false,
263
+ ownerFallback: "onSubjectMiss",
264
+ allowDynamicGreetingMemory: false
265
+ };
266
+ }
267
+ return {
268
+ includeUserSubject: true,
269
+ ownerFallback: "always",
270
+ allowDynamicGreetingMemory: true
271
+ };
272
+ }
273
+ function buildMemorySubjectsForAgent(input) {
274
+ const policy = input.policy ?? resolveAgentMemoryPolicy({ agentKey: input.agentKey });
275
+ return [
276
+ { subjectType: "agent", subjectId: input.agentKey },
277
+ policy.includeUserSubject && input.userId ? { subjectType: "user", subjectId: input.userId } : null,
278
+ input.spaceId ? { subjectType: "space", subjectId: input.spaceId } : null
279
+ ].filter(Boolean);
280
+ }
281
+
282
+ // packages/ai/memory/recentRelationshipRecap.ts
283
+ var MIN_RECAP_LENGTH = 12;
284
+ var MIN_RECAP_GAP_MS = 30 * 60 * 1e3;
285
+ var shouldUseRecentRelationshipRecap = (input) => {
286
+ if (!input.userId || !input.agentKey) return false;
287
+ if (!resolveAgentMemoryPolicy({ agentKey: input.agentKey }).allowDynamicGreetingMemory) {
288
+ return false;
289
+ }
290
+ if ((input.agentsCount ?? 0) !== 1) return false;
291
+ if (input.inheritFromDialogKey) return false;
292
+ if (input.skipGreeting) return false;
293
+ if (input.triggerType && input.triggerType !== "user") return false;
294
+ return true;
295
+ };
296
+ var CONTINUATION_CUE_PATTERNS = [
297
+ "\u8FD8\u6CA1",
298
+ "\u8FD8\u5728",
299
+ "\u7EE7\u7EED",
300
+ "\u63A5\u7740",
301
+ "\u4E0B\u4E00\u6B65",
302
+ "\u540E\u9762",
303
+ "\u4E4B\u540E",
304
+ "\u6253\u7B97",
305
+ "\u51C6\u5907",
306
+ "\u60F3",
307
+ "\u7EA0\u7ED3",
308
+ "\u5361\u4F4F",
309
+ "\u6CA1\u60F3\u597D",
310
+ "\u4E0D\u786E\u5B9A",
311
+ "\u5982\u4F55",
312
+ "\u600E\u4E48",
313
+ "?",
314
+ "\uFF1F"
315
+ ];
316
+ var clip = (text, max = 140) => text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}\u2026`;
317
+ var normalizeText = (value) => asTrimmedString(value);
318
+ var contentToText = (content) => {
319
+ if (typeof content === "string") return content.trim();
320
+ if (Array.isArray(content)) {
321
+ return content.map(
322
+ (part) => part && typeof part === "object" && "text" in part ? normalizeText(part.text) : ""
323
+ ).filter(Boolean).join("\n").trim();
324
+ }
325
+ return "";
326
+ };
327
+ var toTimestamp = (record) => {
328
+ return asOptionalPositiveFiniteNumber(
329
+ Date.parse(normalizeText(record.updatedAt))
330
+ ) ?? asOptionalPositiveFiniteNumber(
331
+ Date.parse(normalizeText(record.createdAt))
332
+ ) ?? 0;
333
+ };
334
+ var chooseRecapText = (record) => {
335
+ const summary = normalizeText(record.summary);
336
+ if (isMeaningfulRecapText(summary)) return clip(summary, 160);
337
+ const title = normalizeText(record.title);
338
+ if (isMeaningfulRecapText(title)) return clip(title, 80);
339
+ return "";
340
+ };
341
+ var loadLastAssistantMessageText = async (db, dialogKey) => {
342
+ const dialogId = extractCustomId(dialogKey);
343
+ if (!dialogId) return "";
344
+ const range = dialogMessageRange(dialogId);
345
+ let iterator = db.iterator({
346
+ gte: range.start,
347
+ lte: range.end,
348
+ reverse: true
349
+ });
350
+ if (iterator && typeof iterator.then === "function") {
351
+ iterator = await iterator;
352
+ }
353
+ for await (const [, value] of iterator) {
354
+ const message = value ?? {};
355
+ const role = normalizeText(message.role ?? message.authorRole);
356
+ if (role !== "assistant") continue;
357
+ const text = contentToText(message.content);
358
+ if (isMeaningfulRecapText(text)) return clip(text, 160);
359
+ }
360
+ return "";
361
+ };
362
+ var isLikelyTimestampTitle = (text) => /^\d{1,2}-\d{1,2}\s+\d{1,2}:\d{2}$/.test(text);
363
+ var isMeaningfulRecapText = (text) => {
364
+ const normalized = normalizeText(text);
365
+ if (!normalized) return false;
366
+ if (normalized.length < MIN_RECAP_LENGTH) return false;
367
+ if (isLikelyTimestampTitle(normalized)) return false;
368
+ if (/^(继续|新对话|测试|test|hello|hi)$/i.test(normalized)) return false;
369
+ return true;
370
+ };
371
+ var resolveRecentRelationshipRecap = async (input) => {
372
+ const { db, userId, agentKey, currentSpaceId, limit = 40 } = input;
373
+ if (!db) return { recap: null, reason: "no-db" };
374
+ if (!userId || !agentKey) return { recap: null, reason: "missing-input" };
375
+ const range = createDialogKey.rangeOfUser(userId);
376
+ const matches = [];
377
+ let scanned = 0;
378
+ let iterator = db.iterator({
379
+ gte: range.start,
380
+ lte: range.end,
381
+ reverse: true
382
+ });
383
+ if (iterator && typeof iterator.then === "function") {
384
+ iterator = await iterator;
385
+ }
386
+ for await (const [, value] of iterator) {
387
+ scanned += 1;
388
+ const record = value ?? {};
389
+ if (!Array.isArray(record.cybots) || !record.cybots.includes(agentKey)) {
390
+ if (scanned >= limit && matches.length > 0) break;
391
+ continue;
392
+ }
393
+ matches.push(record);
394
+ if (matches.length >= limit) break;
395
+ }
396
+ if (matches.length === 0) return { recap: null, reason: "no-match" };
397
+ const sorted = [...matches].sort((a, b) => {
398
+ const aSameSpace = currentSpaceId && a.spaceId === currentSpaceId ? 1 : 0;
399
+ const bSameSpace = currentSpaceId && b.spaceId === currentSpaceId ? 1 : 0;
400
+ if (aSameSpace !== bSameSpace) return bSameSpace - aSameSpace;
401
+ return toTimestamp(b) - toTimestamp(a);
402
+ });
403
+ let sawTooRecent = false;
404
+ let sawLowQuality = false;
405
+ for (const record of sorted) {
406
+ const ts = toTimestamp(record);
407
+ if (ts > 0 && Date.now() - ts < MIN_RECAP_GAP_MS) {
408
+ sawTooRecent = true;
409
+ continue;
410
+ }
411
+ let recap = chooseRecapText(record);
412
+ if (!recap) {
413
+ const dialogKey = normalizeText(record.dbKey);
414
+ if (dialogKey) {
415
+ recap = await loadLastAssistantMessageText(db, dialogKey);
416
+ }
417
+ }
418
+ if (recap) {
419
+ return {
420
+ recap,
421
+ reason: "selected",
422
+ sourceDialogKey: normalizeText(record.dbKey) || void 0,
423
+ sourceUpdatedAt: normalizeText(record.updatedAt) || void 0
424
+ };
425
+ }
426
+ sawLowQuality = true;
427
+ }
428
+ if (sawTooRecent) return { recap: null, reason: "too-recent" };
429
+ if (sawLowQuality) return { recap: null, reason: "low-quality" };
430
+ return { recap: null, reason: "no-match" };
431
+ };
432
+ var mergeGreetingWithRelationshipRecap = (input) => {
433
+ const greetingText = normalizeText(input.greetingText);
434
+ const recentRecap = normalizeText(input.recentRecap);
435
+ if (!greetingText && !recentRecap) return null;
436
+ if (!recentRecap) return greetingText || null;
437
+ const continuationLike = CONTINUATION_CUE_PATTERNS.some(
438
+ (pattern) => recentRecap.includes(pattern)
439
+ );
440
+ if (!continuationLike) return greetingText || null;
441
+ if (!greetingText) {
442
+ return `\u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21\u5728\u804A\uFF1A${recentRecap}
443
+
444
+ \u5982\u679C\u4F60\u8FD8\u60F3\u63A5\u7740\u90A3\u4E2A\u70B9\u7EE7\u7EED\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4ECE\u90A3\u91CC\u5F80\u4E0B\u8D70\uFF1B\u5982\u679C\u60F3\u6362\u4E2A\u65B9\u5411\u4E5F\u53EF\u4EE5\u3002`;
445
+ }
446
+ return `${greetingText}
447
+
448
+ \u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21\u5728\u804A\uFF1A${recentRecap}
449
+ \u5982\u679C\u4F60\u8FD8\u60F3\u63A5\u7740\u90A3\u4E2A\u70B9\u7EE7\u7EED\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4ECE\u90A3\u91CC\u5F80\u4E0B\u8D70\uFF1B\u5982\u679C\u60F3\u6362\u4E2A\u65B9\u5411\u4E5F\u53EF\u4EE5\u3002`;
450
+ };
451
+
452
+ // packages/ai/memory/understandingGreeting.ts
453
+ var UNDERSTANDING_TAG = "understanding-memory";
454
+ var facetPriority = {
455
+ unfinished: 5,
456
+ tension: 4,
457
+ preference: 3,
458
+ style: 2,
459
+ goal: 1
460
+ };
461
+ var anchorFacetPriority = {
462
+ preference: 3,
463
+ style: 2,
464
+ goal: 1,
465
+ tension: 0,
466
+ unfinished: 0
467
+ };
468
+ var normalizeText2 = (value) => value.trim().replace(/[。!?!?]+$/u, "").trim();
469
+ var stripPrefix = (text, prefix) => text.startsWith(prefix) ? text.slice(prefix.length).trim() : text;
470
+ var toTimestamp2 = (item) => {
471
+ const parsed = Date.parse(item.lastActivatedAt || item.createdAt);
472
+ return Number.isFinite(parsed) ? parsed : 0;
473
+ };
474
+ var isUnderstandingItem = (item) => Array.isArray(item.tags) && item.tags.includes(UNDERSTANDING_TAG);
475
+ var GREETING_MIN_CONFIDENCE = 0.75;
476
+ var isGreetingEligible = (item) => item.kind === "semantic" && (item.confidence ?? 0) >= GREETING_MIN_CONFIDENCE;
477
+ var sortByKindAndTime = (left, right) => {
478
+ if (left.kind !== right.kind) return left.kind === "semantic" ? -1 : 1;
479
+ return toTimestamp2(right) - toTimestamp2(left);
480
+ };
481
+ var sameNormalizedContent = (left, right) => normalizeText2(left).toLowerCase() === normalizeText2(right).toLowerCase();
482
+ var pickAnchorItems = (items) => {
483
+ const ranked = [...items].filter((item) => item.facet ? anchorFacetPriority[item.facet] > 0 : false).sort((left, right) => {
484
+ const leftFacet = left.facet ? anchorFacetPriority[left.facet] ?? 0 : 0;
485
+ const rightFacet = right.facet ? anchorFacetPriority[right.facet] ?? 0 : 0;
486
+ if (leftFacet !== rightFacet) return rightFacet - leftFacet;
487
+ if (left.kind !== right.kind) return left.kind === "semantic" ? -1 : 1;
488
+ if (left.content.length !== right.content.length) {
489
+ return left.content.length - right.content.length;
490
+ }
491
+ return toTimestamp2(right) - toTimestamp2(left);
492
+ });
493
+ const selected = [];
494
+ for (const item of ranked) {
495
+ if (selected.some(
496
+ (existing) => sameNormalizedContent(existing.content, item.content) || existing.facet && item.facet && existing.facet === item.facet
497
+ )) {
498
+ continue;
499
+ }
500
+ selected.push(item);
501
+ if (selected.length >= 2) break;
502
+ }
503
+ return selected;
504
+ };
505
+ var pickFollowUpItem = (items) => [...items].filter((item) => item.facet === "unfinished" || item.facet === "tension").sort((left, right) => {
506
+ const leftFacet = left.facet ? facetPriority[left.facet] ?? 0 : 0;
507
+ const rightFacet = right.facet ? facetPriority[right.facet] ?? 0 : 0;
508
+ if (leftFacet !== rightFacet) return rightFacet - leftFacet;
509
+ return sortByKindAndTime(left, right);
510
+ })[0] ?? null;
511
+ var resolveUnderstandingGreetingMemory = async (input) => {
512
+ const owners = chooseMemoryOwners({
513
+ userId: input.userId,
514
+ spaceId: input.spaceId
515
+ });
516
+ if (owners.length === 0) {
517
+ return { item: null, anchorItems: [], followUpItem: null };
518
+ }
519
+ const items = await loadMemoryCandidatesFromDb(input.db, {
520
+ owners,
521
+ subjects: [{ subjectType: "agent", subjectId: input.agentKey }],
522
+ kinds: ["semantic", "episodic"],
523
+ ownerLimit: 40,
524
+ // Greeting memory must stay agent-scoped: a brand-new agent has zero
525
+ // subject hits, and the owner fallback would surface user-level memories
526
+ // from other agents/spaces as this agent's "memory".
527
+ ownerFallback: "never"
528
+ });
529
+ const understandingItems = items.filter(
530
+ (item2) => isUnderstandingItem(item2) && isGreetingEligible(item2)
531
+ );
532
+ if (understandingItems.length === 0) {
533
+ return { item: null, anchorItems: [], followUpItem: null };
534
+ }
535
+ const ranked = [...understandingItems].sort((left, right) => {
536
+ const leftFacet = left.facet ? facetPriority[left.facet] ?? 0 : 0;
537
+ const rightFacet = right.facet ? facetPriority[right.facet] ?? 0 : 0;
538
+ if (leftFacet !== rightFacet) return rightFacet - leftFacet;
539
+ return sortByKindAndTime(left, right);
540
+ });
541
+ const anchorItems = pickAnchorItems(understandingItems);
542
+ const followUpItem = pickFollowUpItem(understandingItems);
543
+ const item = followUpItem ?? anchorItems[0] ?? ranked[0] ?? null;
544
+ return {
545
+ item,
546
+ anchorItems,
547
+ followUpItem
548
+ };
549
+ };
550
+ var renderLeadClause = (item) => {
551
+ const content = normalizeText2(item.content);
552
+ switch (item.facet) {
553
+ case "unfinished":
554
+ return `\u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21\u8FD8\u6CA1\u5B9A\u4E0B\u6765\uFF1A${stripPrefix(content, "\u8FD8\u6CA1\u51B3\u5B9A")}`;
555
+ case "tension":
556
+ return `\u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21\u8FD8\u5728\u6743\u8861${stripPrefix(content, "\u5728\u6743\u8861")}`;
557
+ case "style":
558
+ case "preference":
559
+ return `\u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21${content}`;
560
+ case "goal":
561
+ return `\u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21\u60F3\u63A8\u8FDB\u7684\u662F${content}`;
562
+ default:
563
+ return `\u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21\u63D0\u8FC7${content}`;
564
+ }
565
+ };
566
+ var renderAnchorFragment = (item) => {
567
+ const content = normalizeText2(item.content);
568
+ switch (item.facet) {
569
+ case "preference":
570
+ if (content.startsWith("\u66F4\u5728\u610F")) {
571
+ return `\u66F4\u5728\u610F\u7684\u662F${stripPrefix(content, "\u66F4\u5728\u610F")}`;
572
+ }
573
+ if (content.startsWith("\u66F4\u5173\u5FC3")) {
574
+ return `\u66F4\u5173\u5FC3\u7684\u662F${stripPrefix(content, "\u66F4\u5173\u5FC3")}`;
575
+ }
576
+ if (content.startsWith("\u66F4\u6015")) {
577
+ return `\u66F4\u6015${stripPrefix(content, "\u66F4\u6015")}`;
578
+ }
579
+ if (content.startsWith("\u4E0D\u60F3")) {
580
+ return `\u4E0D\u60F3${stripPrefix(content, "\u4E0D\u60F3")}`;
581
+ }
582
+ if (content.startsWith("\u4E0D\u5E0C\u671B")) {
583
+ return `\u4E0D\u5E0C\u671B${stripPrefix(content, "\u4E0D\u5E0C\u671B")}`;
584
+ }
585
+ return content;
586
+ case "style":
587
+ if (content.startsWith("\u4E0D\u559C\u6B22")) {
588
+ return `\u4E0D\u592A\u559C\u6B22${stripPrefix(content, "\u4E0D\u559C\u6B22")}`;
589
+ }
590
+ if (content.startsWith("\u66F4\u559C\u6B22")) {
591
+ return `\u66F4\u559C\u6B22${stripPrefix(content, "\u66F4\u559C\u6B22")}`;
592
+ }
593
+ return content;
594
+ case "goal":
595
+ if (content.startsWith("\u60F3\u5148")) {
596
+ return `\u60F3\u5148${stripPrefix(content, "\u60F3\u5148")}`;
597
+ }
598
+ return `\u60F3\u63A8\u8FDB\u7684\u662F${content}`;
599
+ default:
600
+ return content;
601
+ }
602
+ };
603
+ var renderAnchorSentence = (items) => {
604
+ if (items.length === 0) return null;
605
+ const fragments = items.map(renderAnchorFragment).map((fragment) => fragment.trim()).filter(Boolean);
606
+ if (fragments.length === 0) return null;
607
+ if (fragments.length === 1) {
608
+ return `\u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21${fragments[0]}\u3002`;
609
+ }
610
+ return `\u6211\u8BB0\u5F97\u4F60\u4E0A\u6B21${fragments[0]}\uFF0C\u4E5F${fragments[1]}\u3002`;
611
+ };
612
+ var splitTradeoff = (value) => {
613
+ const normalized = normalizeText2(value).replace(/^在权衡/u, "").replace(/^还没决定/u, "").replace(/^还不确定/u, "").replace(/^还没想好/u, "").trim();
614
+ if (!normalized.includes("\u8FD8\u662F")) return null;
615
+ const [left, right] = normalized.split(/\s*还是/u, 2);
616
+ const normalizedLeft = normalizeText2((left ?? "").replace(/[,,::]+$/u, "").trim());
617
+ const normalizedRight = normalizeText2((right ?? "").trim());
618
+ if (!normalizedLeft || !normalizedRight) return null;
619
+ return [normalizedLeft, normalizedRight];
620
+ };
621
+ var renderFollowUpLine = (item) => {
622
+ if (!item) {
623
+ return "\u5982\u679C\u4F60\u60F3\uFF0C\u6211\u4EEC\u53EF\u4EE5\u63A5\u7740\u4E0A\u6B21\u90A3\u4E2A\u70B9\uFF1B\u5982\u679C\u4ECA\u5929\u662F\u65B0\u95EE\u9898\uFF0C\u4E5F\u76F4\u63A5\u8BF4\u3002";
624
+ }
625
+ const tradeoff = splitTradeoff(item.content);
626
+ if (tradeoff) {
627
+ return `\u5982\u679C\u4F60\u613F\u610F\uFF0C\u6211\u4EEC\u53EF\u4EE5\u63A5\u7740\u770B\uFF1A${tradeoff[0]}\uFF0C\u8FD8\u662F${tradeoff[1]}\u3002\u5982\u679C\u4ECA\u5929\u662F\u65B0\u95EE\u9898\uFF0C\u4E5F\u76F4\u63A5\u8BF4\u3002`;
628
+ }
629
+ const content = normalizeText2(item.content);
630
+ switch (item.facet) {
631
+ case "unfinished":
632
+ return `\u5982\u679C\u4F60\u613F\u610F\uFF0C\u6211\u4EEC\u53EF\u4EE5\u63A5\u7740\u628A${stripPrefix(content, "\u8FD8\u6CA1\u51B3\u5B9A")}\u5B9A\u4E0B\u6765\uFF1B\u5982\u679C\u4ECA\u5929\u662F\u65B0\u95EE\u9898\uFF0C\u4E5F\u76F4\u63A5\u8BF4\u3002`;
633
+ case "tension":
634
+ return `\u5982\u679C\u4F60\u613F\u610F\uFF0C\u6211\u4EEC\u53EF\u4EE5\u63A5\u7740\u770B${stripPrefix(content, "\u5728\u6743\u8861")}\uFF1B\u5982\u679C\u4ECA\u5929\u662F\u65B0\u95EE\u9898\uFF0C\u4E5F\u76F4\u63A5\u8BF4\u3002`;
635
+ case "goal":
636
+ return `\u5982\u679C\u4F60\u613F\u610F\uFF0C\u6211\u4EEC\u53EF\u4EE5\u7EE7\u7EED\u63A8\u8FDB${stripPrefix(content, "\u60F3\u5148")}\uFF1B\u5982\u679C\u4ECA\u5929\u662F\u65B0\u95EE\u9898\uFF0C\u4E5F\u76F4\u63A5\u8BF4\u3002`;
637
+ default:
638
+ return "\u5982\u679C\u4F60\u60F3\uFF0C\u6211\u4EEC\u53EF\u4EE5\u63A5\u7740\u4E0A\u6B21\u90A3\u4E2A\u70B9\uFF1B\u5982\u679C\u4ECA\u5929\u662F\u65B0\u95EE\u9898\uFF0C\u4E5F\u76F4\u63A5\u8BF4\u3002";
639
+ }
640
+ };
641
+ var mergeGreetingWithUnderstandingMemory = (input) => {
642
+ const greetingText = asTrimmedString(input.greetingText);
643
+ const resolution = input.resolution ?? null;
644
+ const item = input.item ?? resolution?.item ?? null;
645
+ if (!greetingText && !item) return null;
646
+ if (!item) return greetingText || null;
647
+ const anchorItems = resolution?.anchorItems ?? [];
648
+ const followUpItem = resolution?.followUpItem ?? item;
649
+ const leadLine = renderAnchorSentence(anchorItems) ?? `${renderLeadClause(item)}\u3002`;
650
+ const suffix = renderFollowUpLine(followUpItem);
651
+ const memoryBlock = `\u6B22\u8FCE\u56DE\u6765\u3002${leadLine}
652
+ ${suffix}`;
653
+ if (!greetingText) {
654
+ return memoryBlock;
655
+ }
656
+ return `${greetingText}
657
+
658
+ ${memoryBlock}`;
659
+ };
660
+
661
+ // packages/chat/dialog/actions/createDialogAction.ts
662
+ var LOCAL_OWNER_DIALOG_PREFIXES = ["agent-local-", "cybot-local-"];
663
+ var isLocalOwnerDialogAgents = (cybots) => {
664
+ if (!Array.isArray(cybots)) return false;
665
+ for (const agentKey of cybots) {
666
+ if (typeof agentKey !== "string") continue;
667
+ for (const prefix of LOCAL_OWNER_DIALOG_PREFIXES) {
668
+ if (agentKey.startsWith(prefix)) return true;
669
+ }
670
+ }
671
+ return false;
672
+ };
673
+ var notifyUserDataUpdated = () => {
674
+ if (typeof window !== "undefined" && typeof window.dispatchEvent === "function" && typeof window.Event === "function") {
675
+ window.dispatchEvent(new window.Event("nolo-user-data-updated"));
676
+ }
677
+ };
678
+ var createDialogAction = async (args, thunkApi) => {
679
+ const {
680
+ cybots,
681
+ category,
682
+ spaceId: explicitSpaceId,
683
+ inheritFromDialogKey,
684
+ title: titleOverride,
685
+ triggerType,
686
+ schedule,
687
+ taskPrompt,
688
+ skipAgentConfigRead,
689
+ optimisticReturnBeforeWrite,
690
+ preferredServerOrigin
691
+ } = args;
692
+ const { dispatch: dispatchRaw, getState, extra } = thunkApi;
693
+ const dispatch = dispatchRaw;
694
+ const agentKey = cybots[0];
695
+ const currentUserId = selectIdentityUserId(getState()) ?? null;
696
+ const isDeviceLocalDialog = isLocalOwnerDialogAgents(cybots);
697
+ const userId = isDeviceLocalDialog ? "local" : currentUserId && currentUserId.trim().length > 0 ? currentUserId : "local";
698
+ try {
699
+ const { localFirstLog } = await import("./localFirstLog-DHNOY2NA.js");
700
+ localFirstLog("dialog.create", {
701
+ owner: userId,
702
+ agentKey: typeof agentKey === "string" ? agentKey : "",
703
+ isDeviceLocal: isDeviceLocalDialog,
704
+ hasSpace: Boolean(args.spaceId)
705
+ });
706
+ } catch {
707
+ }
708
+ const readAgentConfig = async () => {
709
+ const existing = await dispatch(
710
+ readAndWait({
711
+ dbKey: agentKey,
712
+ preferredServerOrigin
713
+ })
714
+ ).unwrap().catch(() => null);
715
+ if (existing) return existing;
716
+ const recoveredBuiltinAgent = buildBuiltinObjectAssistantAgentFromKey(
717
+ agentKey,
718
+ userId
719
+ );
720
+ if (!recoveredBuiltinAgent) {
721
+ return null;
722
+ }
723
+ await dispatch(
724
+ write({
725
+ data: recoveredBuiltinAgent,
726
+ customKey: recoveredBuiltinAgent.dbKey,
727
+ userId
728
+ })
729
+ ).unwrap();
730
+ return recoveredBuiltinAgent;
731
+ };
732
+ const canSkipAgentConfigRead = !!skipAgentConfigRead && !!args.skipGreeting && !!titleOverride;
733
+ const agentConfig = canSkipAgentConfigRead ? null : await readAgentConfig();
734
+ if (!agentConfig && !canSkipAgentConfigRead) {
735
+ throw new Error(`Agent with key ${agentKey} not found.`);
736
+ }
737
+ const shouldUseRelationshipGreeting = shouldUseRecentRelationshipRecap({
738
+ userId,
739
+ agentKey,
740
+ agentsCount: cybots.length,
741
+ inheritFromDialogKey,
742
+ skipGreeting: args.skipGreeting,
743
+ triggerType
744
+ });
745
+ const understandingGreetingResolution = shouldUseRelationshipGreeting ? await resolveUnderstandingGreetingMemory({
746
+ db: extra?.db,
747
+ userId,
748
+ spaceId: explicitSpaceId,
749
+ agentKey
750
+ }).catch(() => ({ item: null, anchorItems: [], followUpItem: null })) : { item: null, anchorItems: [], followUpItem: null };
751
+ const recentRelationshipRecapResolution = shouldUseRelationshipGreeting && !understandingGreetingResolution.item ? await resolveRecentRelationshipRecap({
752
+ db: extra?.db,
753
+ userId,
754
+ agentKey,
755
+ currentSpaceId: explicitSpaceId
756
+ }).catch(() => ({ recap: null, reason: "no-db", sourceDialogKey: void 0 })) : null;
757
+ if (typeof window !== "undefined" && recentRelationshipRecapResolution && process.env.NODE_ENV !== "production") {
758
+ console.debug("[dialog] recent relationship recap", {
759
+ agentKey,
760
+ userId,
761
+ reason: recentRelationshipRecapResolution.reason,
762
+ sourceDialogKey: recentRelationshipRecapResolution.sourceDialogKey ?? null,
763
+ preview: recentRelationshipRecapResolution.recap ?? null
764
+ });
765
+ }
766
+ const time = (0, import_date_fns.format)(/* @__PURE__ */ new Date(), "MM-dd HH:mm");
767
+ const title = titleOverride || (agentConfig?.name || "Agent") + " " + time;
768
+ const spaceId = explicitSpaceId;
769
+ const dialogPath = createDialogKey(userId);
770
+ const dialogId = extractCustomId(dialogPath);
771
+ let referenceKeys;
772
+ let inheritedFromDialogKey;
773
+ let inheritedFromDialogTitle;
774
+ if (inheritFromDialogKey) {
775
+ inheritedFromDialogKey = inheritFromDialogKey;
776
+ const sourceDialog = await dispatch(
777
+ read({
778
+ dbKey: inheritFromDialogKey
779
+ })
780
+ ).unwrap();
781
+ if (isRecord(sourceDialog)) {
782
+ const sourceDbKey = sourceDialog.dbKey;
783
+ if (typeof sourceDbKey === "string" && sourceDbKey.trim().length > 0) {
784
+ inheritedFromDialogKey = sourceDbKey;
785
+ }
786
+ const sourceTitle = asOptionalTrimmedString(
787
+ sourceDialog.title
788
+ );
789
+ if (sourceTitle) {
790
+ inheritedFromDialogTitle = sourceTitle;
791
+ }
792
+ const candidate = sourceDialog.referenceKeys;
793
+ if (Array.isArray(candidate) && candidate.every((key) => typeof key === "string")) {
794
+ referenceKeys = candidate;
795
+ }
796
+ }
797
+ }
798
+ const dialogData = {
799
+ id: dialogId,
800
+ dbKey: dialogPath,
801
+ userId,
802
+ cybots,
803
+ title,
804
+ type: "dialog" /* DIALOG */,
805
+ createdAt: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date()),
806
+ ...spaceId && { spaceId },
807
+ category,
808
+ referenceKeys,
809
+ ...args.extraReferences && args.extraReferences.length > 0 && { extraReferences: args.extraReferences },
810
+ ...inheritedFromDialogKey && { inheritedFromDialogKey },
811
+ ...inheritedFromDialogTitle && { inheritedFromDialogTitle },
812
+ inputTokens: 0,
813
+ outputTokens: 0,
814
+ totalCost: 0,
815
+ ...triggerType && { triggerType },
816
+ ...triggerType === "scheduled_run" || triggerType === "automation_run" ? {
817
+ executionMode: "background",
818
+ status: "pending"
819
+ } : {},
820
+ ...schedule && { schedule },
821
+ ...taskPrompt && { taskPrompt }
822
+ };
823
+ const canReturnBeforeWrite = canSkipAgentConfigRead && !!optimisticReturnBeforeWrite && !spaceId;
824
+ if (canReturnBeforeWrite) {
825
+ const optimisticDialogData = {
826
+ ...dialogData,
827
+ dbKey: dialogPath,
828
+ userId
829
+ };
830
+ dispatch(upsertSSREntity(optimisticDialogData));
831
+ notifyUserDataUpdated();
832
+ void dispatch(
833
+ write({
834
+ data: { ...dialogData, userId },
835
+ customKey: dialogPath,
836
+ userId
837
+ })
838
+ ).unwrap().catch((error) => {
839
+ console.error("[createDialogAction] optimistic dialog write failed", {
840
+ dialogPath,
841
+ error
842
+ });
843
+ dispatch(removeCachedEntity(dialogPath));
844
+ notifyUserDataUpdated();
845
+ });
846
+ return optimisticDialogData;
847
+ }
848
+ const result = await dispatch(
849
+ write({
850
+ data: { ...dialogData, userId },
851
+ customKey: dialogPath,
852
+ userId
853
+ })
854
+ ).unwrap();
855
+ if (spaceId) {
856
+ await dispatch(
857
+ addContentToSpace({
858
+ spaceId,
859
+ contentKey: dialogPath,
860
+ type: "dialog" /* DIALOG */,
861
+ title,
862
+ categoryId: category,
863
+ ...triggerType && { triggerType }
864
+ })
865
+ );
866
+ }
867
+ notifyUserDataUpdated();
868
+ const rawGreeting = agentConfig?.greeting;
869
+ if (rawGreeting && !args.skipGreeting) {
870
+ const cfg = typeof rawGreeting === "string" ? { text: rawGreeting } : isRecord(rawGreeting) ? rawGreeting : { text: String(rawGreeting) };
871
+ const mergedGreetingText = understandingGreetingResolution?.item ? mergeGreetingWithUnderstandingMemory({
872
+ greetingText: cfg.text,
873
+ resolution: understandingGreetingResolution
874
+ }) : mergeGreetingWithRelationshipRecap({
875
+ greetingText: cfg.text,
876
+ recentRecap: recentRelationshipRecapResolution?.recap
877
+ });
878
+ const effectiveCfg = {
879
+ ...cfg,
880
+ ...mergedGreetingText ? { text: mergedGreetingText } : {}
881
+ };
882
+ const hasMenu = Array.isArray(effectiveCfg.menu) && effectiveCfg.menu.length > 0;
883
+ if (hasMenu) {
884
+ const question = asOptionalTrimmedString(effectiveCfg.text) ?? "\u63A5\u4E0B\u6765\u4F60\u66F4\u5E0C\u671B\u6211\u5E2E\u4F60\u505A\u54EA\u4EF6\u4E8B\uFF1F";
885
+ const choices = effectiveCfg.menu.map((item, idx) => ({
886
+ id: item.id || `choice_${idx + 1}`,
887
+ label: item.label,
888
+ userMessage: item.userMessage ?? item.label
889
+ }));
890
+ const toolResult = await uiAskChoiceFunc(
891
+ {
892
+ question,
893
+ choices,
894
+ blocking: true
895
+ },
896
+ thunkApi
897
+ );
898
+ await dispatch(
899
+ prepareAndPersistMessage({
900
+ message: {
901
+ role: "tool",
902
+ toolName: uiAskChoiceFunctionSchema.name,
903
+ cybotKey: agentKey,
904
+ content: toolResult.rawData,
905
+ displayData: toolResult.displayData
906
+ },
907
+ dialogConfig: {
908
+ id: dialogId,
909
+ dbKey: dialogPath,
910
+ userId
911
+ }
912
+ })
913
+ );
914
+ } else if (effectiveCfg.text) {
915
+ await dispatch(
916
+ prepareAndPersistMessage({
917
+ message: {
918
+ content: effectiveCfg.text,
919
+ role: "assistant",
920
+ cybotKey: agentKey
921
+ },
922
+ dialogConfig: {
923
+ id: dialogId,
924
+ dbKey: dialogPath,
925
+ userId
926
+ }
927
+ })
928
+ );
929
+ }
930
+ }
931
+ return result;
932
+ };
933
+
934
+ export {
935
+ resolveAgentMemoryPolicy,
936
+ buildMemorySubjectsForAgent,
937
+ isLocalOwnerDialogAgents,
938
+ createDialogAction
939
+ };