nolo-cli 0.33.0-alpha.3 → 0.33.0-alpha.31

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 (157) hide show
  1. package/{_executeModel-RWPVI3YV.js → _executeModel-BTZJ6QKO.js} +56 -58
  2. package/{action-SMLG6OTB.js → action-LKQAGKHH.js} +11 -11
  3. package/{addContentAction-SFO244QN.js → addContentAction-IP2B6UUB.js} +9 -9
  4. package/{addDialogAgentAction-W44ZCEHB.js → addDialogAgentAction-JNIAUFE6.js} +8 -8
  5. package/{agentDeleteCommand-KU2RXQPP.js → agentDeleteCommand-WG6T4OTP.js} +48 -44
  6. package/{agentEmailCommands-MPCMDENS.js → agentEmailCommands-4CEZD4JW.js} +83 -80
  7. package/{agentListCommands-EPD4N6FX.js → agentListCommands-2YHWZHLD.js} +56 -43
  8. package/{agentMachineCommands-AF7C3YRT.js → agentMachineCommands-LKCUIDHA.js} +46 -42
  9. package/agentProviderCommands-65ZC2WB4.js +122 -0
  10. package/{agentPullCommand-YH5GEBK4.js → agentPullCommand-NYHSK6EW.js} +3 -3
  11. package/{agentRecordCommands-EYE6MZZG.js → agentRecordCommands-VSBYJUBN.js} +74 -71
  12. package/{agentRunCommand-LL22SGTN.js → agentRunCommand-LAD7TRWT.js} +80 -76
  13. package/{agentRuntimeLocal-JX34G47Z.js → agentRuntimeLocal-TEJECMTH.js} +34 -31
  14. package/{agentSlice-TNMFQQOV.js → agentSlice-3U3H657P.js} +11 -11
  15. package/{appDeleteCommands-43K5VXQB.js → appDeleteCommands-5QCUYGTX.js} +41 -37
  16. package/{appDeployCommands-FEEJSVDZ.js → appDeployCommands-GMIAIMDB.js} +41 -37
  17. package/{appDeployStatusCommands-H76CG45R.js → appDeployStatusCommands-ZTJ6APB6.js} +41 -37
  18. package/{appGetCommands-MDZYFTYZ.js → appGetCommands-PI4NTPKT.js} +41 -37
  19. package/{appListCommands-TUJJXPWG.js → appListCommands-QMRCLRJ6.js} +41 -37
  20. package/{authCommand-T7UK4CWS.js → authCommand-4ICNA46V.js} +21 -20
  21. package/{authCommands-EAPFGNHN.js → authCommands-W74NRPA6.js} +6 -6
  22. package/{chatQueueReduxAdapter-LVQXC4ZY.js → chatQueueReduxAdapter-5GNVXJ5T.js} +25 -24
  23. package/{chunk-JZ5AMMXU.js → chunk-244YJUYS.js} +4 -4
  24. package/{chunk-2UECQ7RE.js → chunk-3AOLVADY.js} +1 -1
  25. package/{chunk-AFV4FOT2.js → chunk-3GDKZAPT.js} +4 -91
  26. package/{chunk-M4NC7NF6.js → chunk-3H3FPUCI.js} +2 -2
  27. package/chunk-3Z32AD6X.js +22 -0
  28. package/{chunk-B2BSG6QQ.js → chunk-4EXK5Q2M.js} +18 -18
  29. package/{chunk-UK5JGQVU.js → chunk-52DHSNJC.js} +14 -20
  30. package/{chunk-LOD75GOS.js → chunk-6PI2635O.js} +3884 -1562
  31. package/{chunk-HDKRSRYU.js → chunk-7CH6ONWB.js} +636 -210
  32. package/{chunk-FMEVI5TG.js → chunk-7CH6U3FL.js} +1 -1
  33. package/{chunk-FSSX3XRY.js → chunk-7URTEFXJ.js} +1 -1
  34. package/{chunk-JTSGWTYZ.js → chunk-ASA3CJSG.js} +2 -2
  35. package/{chunk-6SXC35F4.js → chunk-AXCXE35O.js} +13 -13
  36. package/{chunk-2QTEYCR7.js → chunk-C2UKEL7P.js} +17 -7
  37. package/{chunk-I6N2UVVY.js → chunk-CBYBNR2K.js} +1 -1
  38. package/{chunk-WHD6BG7M.js → chunk-DMOWI2S7.js} +48 -44
  39. package/{chunk-3GZXL6FM.js → chunk-DZPK4YQY.js} +1 -1
  40. package/{chunk-6HYVJV7B.js → chunk-ESHYE7WU.js} +2 -1
  41. package/{chunk-TFPUAELY.js → chunk-ET4UZQN3.js} +3 -3
  42. package/{chunk-3WXRAHCG.js → chunk-EU7POTD4.js} +3 -3
  43. package/{chunk-DPMBNHOJ.js → chunk-FAMAQ3A7.js} +1 -1
  44. package/{chunk-JZPBVBIY.js → chunk-FD36SCCD.js} +19 -8
  45. package/{chunk-57QJXIB6.js → chunk-FEDK54U6.js} +10 -10
  46. package/{chunk-MPZJVZDC.js → chunk-FL3KRU3X.js} +41 -2674
  47. package/{chunk-ZURFOV5J.js → chunk-FS5VNMPF.js} +3 -3
  48. package/{chunk-2H3XIBY4.js → chunk-FSOCQPX7.js} +4 -82
  49. package/{chunk-M2YMQOLC.js → chunk-G34SHBSK.js} +11 -11
  50. package/{chunk-U4TRT5V4.js → chunk-GEPHJJW4.js} +1 -1
  51. package/{chunk-OIQPORYI.js → chunk-GN6ENM54.js} +178 -2
  52. package/{chunk-X664KVEV.js → chunk-HHBXCRJS.js} +204 -123
  53. package/chunk-HJ23CUHW.js +109 -0
  54. package/{chunk-RAZOLMJR.js → chunk-HXV5GJFC.js} +15 -8
  55. package/{chunk-OR2HNLVO.js → chunk-HYQSSY7V.js} +71 -79
  56. package/{chunk-WLH5BAKX.js → chunk-IIOHYLIG.js} +9 -4
  57. package/{chunk-2IVEXF7P.js → chunk-ISQZFROX.js} +2 -9
  58. package/{chunk-IHEC7VBF.js → chunk-J36P3SH5.js} +1 -1
  59. package/{chunk-PREQU5QV.js → chunk-J5STUEYU.js} +1 -1
  60. package/{chunk-O6GEBMIY.js → chunk-JE4J3T7A.js} +5296 -4981
  61. package/{chunk-VH2F7ZB6.js → chunk-JG43PNFR.js} +1 -1
  62. package/{chunk-GTYM4HKV.js → chunk-JZ6JDSWD.js} +5 -5
  63. package/{chunk-X2DAEZ3X.js → chunk-KWPXU3W5.js} +1 -1
  64. package/{chunk-WJSW43QZ.js → chunk-L3JWI7WX.js} +0 -1
  65. package/{chunk-NNWHHCVP.js → chunk-LI6SNQF6.js} +2 -3
  66. package/{chunk-GM6PU7B6.js → chunk-MEYIRKDN.js} +0 -1
  67. package/{chunk-Q5ITEGIN.js → chunk-N4XRDM26.js} +1 -1
  68. package/{chunk-7E72JMBB.js → chunk-N543Q3VR.js} +57 -16
  69. package/{chunk-YDTYDA5W.js → chunk-NBIS3WYT.js} +8 -6
  70. package/{chunk-JMPYDFHY.js → chunk-NI72ISCU.js} +21 -8
  71. package/{chunk-5CS33IBL.js → chunk-NQ4N4IGO.js} +11 -12
  72. package/chunk-OH4Q4VVA.js +38 -0
  73. package/{chunk-CLP2K7U4.js → chunk-OS63QEVB.js} +7 -7
  74. package/{chunk-DFUPZE6V.js → chunk-P35OZHD4.js} +3 -16
  75. package/{chunk-GMXWYXAF.js → chunk-PJT3CCBL.js} +4 -4
  76. package/{chunk-3VAQHAXT.js → chunk-PYLC3472.js} +27 -27
  77. package/{chunk-ADLYMQB6.js → chunk-QUK7UZW7.js} +137 -0
  78. package/{chunk-37V5LNEQ.js → chunk-RRYRKT7X.js} +1 -1
  79. package/{chunk-AAGCMVFT.js → chunk-S6QP3AK4.js} +895 -175
  80. package/{chunk-73GINUCW.js → chunk-SQPMYIR5.js} +135 -56
  81. package/{chunk-XCCGU6QB.js → chunk-SSK4QDFL.js} +1 -1
  82. package/{chunk-IL545V3E.js → chunk-TACRGJZO.js} +7 -7
  83. package/chunk-TVXJEOU2.js +78 -0
  84. package/{chunk-NUO3QFWD.js → chunk-UNHKVD2N.js} +1 -1
  85. package/{chunk-GE6IWA5N.js → chunk-UNZDCI3O.js} +126 -1
  86. package/chunk-UOLENXLQ.js +1132 -0
  87. package/{chunk-5SBK2MTI.js → chunk-UOVE5ZHK.js} +24 -71
  88. package/{chunk-ZJMME4DS.js → chunk-VBJVODPE.js} +6 -6
  89. package/{chunk-FXFGNOT2.js → chunk-VFVCYIRQ.js} +1 -1
  90. package/{chunk-AOXVOC6D.js → chunk-W2DNU6FK.js} +3 -3
  91. package/chunk-X6WFECZY.js +97 -0
  92. package/{chunk-RY57GLGW.js → chunk-YPREESF4.js} +42 -5
  93. package/{chunk-HUCT7HID.js → chunk-YXB5JR6N.js} +1 -1
  94. package/{chunk-BQXOGBFN.js → chunk-YZ2WE6CW.js} +2 -2
  95. package/{cliExecutor-DW3PHGEL.js → cliExecutor-BBUVQU4L.js} +2 -2
  96. package/{codingSkills-DY5MINPG.js → codingSkills-FXKII4C6.js} +3 -3
  97. package/{createAgentAutomationAction-INQT23LX.js → createAgentAutomationAction-CMOMDO6G.js} +25 -26
  98. package/{createDialogAction-LDCPDI73.js → createDialogAction-QG7DKUA7.js} +28 -29
  99. package/{createPageAction-5YXOG2M4.js → createPageAction-JCMCNMTK.js} +30 -31
  100. package/{dbSlice-3SD5L5H2.js → dbSlice-ZNHRC4BK.js} +8 -8
  101. package/{deleteFile-XQXPBFFB.js → deleteFile-NPZ64DFN.js} +5 -5
  102. package/{dialogCommands-CHJO47AX.js → dialogCommands-T43TTFWR.js} +40 -36
  103. package/{dialogSlice-DOWKOILN.js → dialogSlice-5VZFBHCA.js} +24 -23
  104. package/{docCreateCommands-OVZARUFX.js → docCreateCommands-DQBKKPOC.js} +42 -38
  105. package/{docDeleteCommands-E2XJ62LD.js → docDeleteCommands-ULM4MTP3.js} +43 -39
  106. package/{docReadCommands-I7OSREPJ.js → docReadCommands-3FXTVWVJ.js} +42 -38
  107. package/{docStore-UAWSKZ2Y.js → docStore-LTAGA6XZ.js} +26 -27
  108. package/{docUpdateCommands-X4Z26VJM.js → docUpdateCommands-ZE6B3SLE.js} +44 -40
  109. package/emscripten-module-EDQBMDVK.js +576 -0
  110. package/emscripten-module-LCBQ7VWY.js +1506 -0
  111. package/emscripten-module-OFHQ7EL3.js +482 -0
  112. package/emscripten-module-XM7NDJQA.js +4536 -0
  113. package/fetchMessages-7QRCCRYK.js +1 -1
  114. package/ffi-6ZSX3QJ4.js +80 -0
  115. package/ffi-742Y76PE.js +92 -0
  116. package/ffi-AEYWSYLM.js +80 -0
  117. package/ffi-KQC27OUM.js +92 -0
  118. package/{getPricing-L2ENXWHV.js → getPricing-5R7P4JLI.js} +4 -4
  119. package/{handleSendMessageAction-C3TSDWKH.js → handleSendMessageAction-7GF5IU4J.js} +26 -25
  120. package/index.js +78 -76
  121. package/{localRuntimeAuthority-E3R24J4T.js → localRuntimeAuthority-S77B5QVB.js} +6 -2
  122. package/{localRuntimeDb-DDZCJFQZ.js → localRuntimeDb-N3H3HQ7G.js} +1 -1
  123. package/{machineCommands-BUOIYJAD.js → machineCommands-57UG5TRO.js} +84 -81
  124. package/{machineInfo-M6KB6HZN.js → machineInfo-66ZFUMLE.js} +1 -1
  125. package/{machineWsRunDispatch-7CRWAA6O.js → machineWsRunDispatch-L3GQ7ASL.js} +72 -69
  126. package/{models-OX2S5C6Q.js → models-CQOLEOPZ.js} +2 -2
  127. package/module-ES6BEMUI-AFCVSBMS.js +14 -0
  128. package/module-asyncify-2EFITU5U-DEP2F2QP.js +9 -0
  129. package/package.json +1 -1
  130. package/{read-6G73BMEY.js → read-QOLSHOT5.js} +6 -6
  131. package/{readDocTool-DK4EI2GA.js → readDocTool-X7HLXXBW.js} +1 -1
  132. package/{readlineWorkspace-ZDWEASJV.js → readlineWorkspace-SFUQOD4C.js} +3746 -3155
  133. package/{removeDialogAgentAction-E7H557UO.js → removeDialogAgentAction-UBYX7RVR.js} +12 -12
  134. package/{runAgentClientLoop-U7HYA3O5.js → runAgentClientLoop-VCTFHJVP.js} +53 -54
  135. package/{runtimeDoctorCommands-KIKM6BIO.js → runtimeDoctorCommands-HT4O2PXL.js} +6 -6
  136. package/{setDialogExtraReferencesAction-RMMGBR5F.js → setDialogExtraReferencesAction-GMXZTTQA.js} +9 -9
  137. package/{setPrimaryDialogAgentAction-FWBKKLVA.js → setPrimaryDialogAgentAction-JKVEILI3.js} +12 -12
  138. package/{settingSlice-73PV4KG4.js → settingSlice-EQKEXSTU.js} +10 -10
  139. package/{skillDiscovery-KLLKXPUO.js → skillDiscovery-6YSTRCQ7.js} +3 -3
  140. package/{slateUtils-VO2FU36K.js → slateUtils-RIZES3PV.js} +1 -1
  141. package/{spaceCommands-GEWZXGHM.js → spaceCommands-3PVSEEGH.js} +235 -46
  142. package/{spaceSlice-B6MOVY4N.js → spaceSlice-OEBVDZGG.js} +25 -26
  143. package/{streamAgentChatTurn-T527EQTT.js → streamAgentChatTurn-YLUPK5CI.js} +107 -120
  144. package/{switchDialogAgentAction-US6QNL3N.js → switchDialogAgentAction-DSC2T3JW.js} +8 -8
  145. package/{chunk-IDAU4UFS.js → syncMapping-N6RGXGBW.js} +11 -11
  146. package/{tableCommands-QE47K72R.js → tableCommands-SQSOF2XK.js} +9 -9
  147. package/{tools-XMWCVMPM.js → tools-IZUS4UM5.js} +41 -42
  148. package/{tuiSummaryLlmCaller-NCAJSVSD.js → tuiSummaryLlmCaller-ZFPTFGXJ.js} +17 -16
  149. package/{updateCommands-AK2RDOFR.js → updateCommands-MNDUIKN7.js} +2 -2
  150. package/{updateDialogTitleAction-XPJZRJEL.js → updateDialogTitleAction-BB53DOCT.js} +31 -32
  151. package/chunk-6PO2SYCS.js +0 -1800
  152. package/chunk-M3JEW6N6.js +0 -193
  153. package/syncMapping-RK2MANUX.js +0 -43
  154. package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-OPIGFRDO.js} +2 -2
  155. package/{chunk-ZHYK3N56.js → chunk-G7HTVVFL.js} +3 -3
  156. package/{chunk-SAQQLJZ5.js → chunk-JDSUTNYY.js} +3 -3
  157. package/{offlineMarxistsAgentCommand-GEH6SNNA.js → offlineMarxistsAgentCommand-HDIQVGKN.js} +3 -3
@@ -8,15 +8,15 @@ import {
8
8
  import {
9
9
  isOAuthApiKeyRef
10
10
  } from "./chunk-YYLHWIW6.js";
11
+ import {
12
+ runLlm
13
+ } from "./chunk-VBJVODPE.js";
11
14
  import {
12
15
  getApproxPricePerImage
13
16
  } from "./chunk-CWMSB67P.js";
14
- import {
15
- runLlm
16
- } from "./chunk-ZJMME4DS.js";
17
17
  import {
18
18
  cleanupCliSessionForDialog
19
- } from "./chunk-JZ5AMMXU.js";
19
+ } from "./chunk-244YJUYS.js";
20
20
  import {
21
21
  getActiveDialogAgentId,
22
22
  getDialogAgentIds,
@@ -26,16 +26,27 @@ import {
26
26
  require_date_fns
27
27
  } from "./chunk-M76ECQRD.js";
28
28
  import {
29
- fetchMessages
30
- } from "./chunk-KSRFVP36.js";
29
+ abortActiveControllers,
30
+ addPageReferenceToRuntime,
31
+ applyClearDialogStateRuntime,
32
+ applyUpdateTokensFulfilled,
33
+ clearActiveControllers,
34
+ deleteDialogRuntime,
35
+ getActiveDialogKey,
36
+ getDialogRuntimeTokens,
37
+ require_react,
38
+ resetDialogRuntimeSessionState,
39
+ selectCurrentDialogKey,
40
+ setActiveDialogKey,
41
+ setDialogConfigError
42
+ } from "./chunk-MRWGHF56.js";
31
43
  import {
32
44
  DEFAULT_AUTO_EXECUTION_PROFILE,
33
45
  DEFAULT_CONTEXT_WINDOW,
34
46
  getModelContextWindow,
35
47
  getModelInfo,
36
- resolveAutoExecutionProfile,
37
- resolveBuiltinPlatformAgentRecord
38
- } from "./chunk-2H3XIBY4.js";
48
+ resolveAutoExecutionProfile
49
+ } from "./chunk-FSOCQPX7.js";
39
50
  import {
40
51
  COMPACTION_SUMMARY_SYSTEM_PROMPT,
41
52
  buildCompactionMetricsFromPlan,
@@ -47,36 +58,24 @@ import {
47
58
  normalizeAssistantContentBuffer,
48
59
  planCompression,
49
60
  serializeMessageContent
50
- } from "./chunk-AOXVOC6D.js";
61
+ } from "./chunk-W2DNU6FK.js";
51
62
  import {
52
63
  findModelConfig,
53
64
  getModelConfig
54
- } from "./chunk-DFUPZE6V.js";
55
- import {
56
- abortActiveControllers,
57
- addPageReferenceToRuntime,
58
- applyClearDialogStateRuntime,
59
- applyUpdateTokensFulfilled,
60
- clearActiveControllers,
61
- deleteDialogRuntime,
62
- getActiveDialogKey,
63
- getDialogRuntimeTokens,
64
- require_react,
65
- resetDialogRuntimeSessionState,
66
- selectCurrentDialogKey,
67
- setActiveDialogKey,
68
- setDialogConfigError
69
- } from "./chunk-MRWGHF56.js";
65
+ } from "./chunk-P35OZHD4.js";
70
66
  import {
71
67
  toErrorMessage
72
68
  } from "./chunk-HNMXYYJR.js";
69
+ import {
70
+ fetchMessages
71
+ } from "./chunk-KSRFVP36.js";
73
72
  import {
74
73
  getPlatformHostedDeepSeekV4Price,
75
74
  isPlatformHostedDeepSeekV4Model
76
- } from "./chunk-OR2HNLVO.js";
75
+ } from "./chunk-HYQSSY7V.js";
77
76
  import {
78
77
  nolotusId
79
- } from "./chunk-CLP2K7U4.js";
78
+ } from "./chunk-OS63QEVB.js";
80
79
  import {
81
80
  asRecordOrEmpty
82
81
  } from "./chunk-KX6YBIHG.js";
@@ -86,7 +85,7 @@ import {
86
85
  remove,
87
86
  selectById,
88
87
  write
89
- } from "./chunk-57QJXIB6.js";
88
+ } from "./chunk-FEDK54U6.js";
90
89
  import {
91
90
  buildDialogAgentListIndexDeleteOps,
92
91
  createDialogMessageKeyAndId,
@@ -107,6 +106,17 @@ import {
107
106
  import {
108
107
  asTrimmedLowercaseString
109
108
  } from "./chunk-QSJ3HFEF.js";
109
+ import {
110
+ builtinAgentCatalogEntryById,
111
+ builtinRuntimeFallbackEntries,
112
+ isBuiltinPlatformAgentKey
113
+ } from "./chunk-52DHSNJC.js";
114
+ import {
115
+ extractCustomId,
116
+ extractUserId,
117
+ parsePublicAgentId,
118
+ publicAgentKey
119
+ } from "./chunk-BJIRLHJR.js";
110
120
  import {
111
121
  asyncThunkCreator,
112
122
  buildCreateSlice,
@@ -117,25 +127,21 @@ import {
117
127
  parseOwnerUserIdFromDbKey,
118
128
  scheduleDeleteReplication,
119
129
  selectIdentityUserId
120
- } from "./chunk-X664KVEV.js";
130
+ } from "./chunk-HHBXCRJS.js";
121
131
  import {
122
132
  createClientLogger,
123
133
  isAbortError
124
- } from "./chunk-WJSW43QZ.js";
134
+ } from "./chunk-L3JWI7WX.js";
125
135
  import {
126
136
  isTombstoneRecord,
127
137
  shouldReplaceWithNextRecord
128
138
  } from "./chunk-GBRG75BQ.js";
129
- import {
130
- asTrimmedString
131
- } from "./chunk-3EUW3WEO.js";
132
- import {
133
- extractCustomId,
134
- extractUserId
135
- } from "./chunk-BJIRLHJR.js";
136
139
  import {
137
140
  isRecord
138
141
  } from "./chunk-KUG52IAP.js";
142
+ import {
143
+ asTrimmedString
144
+ } from "./chunk-3EUW3WEO.js";
139
145
  import {
140
146
  asOptionalTrimmedString
141
147
  } from "./chunk-G3SUCT4W.js";
@@ -1525,6 +1531,10 @@ var uiAskChoiceFunctionSchema = {
1525
1531
  type: "string",
1526
1532
  description: "\u95EE\u9898\u6807\u8BC6\u3002"
1527
1533
  },
1534
+ header: {
1535
+ type: "string",
1536
+ description: "\u591A\u95EE\u9898 tab \u680F\u663E\u793A\u7684\u77ED\u6807\u7B7E\uFF08\u226412 \u5B57\u7B26\uFF0C\u5982\u201C\u683C\u5F0F/\u8BED\u8A00/\u8303\u56F4\u201D\uFF09\uFF0C\u7F3A\u7701\u7528 Qn\u3002"
1537
+ },
1528
1538
  question: {
1529
1539
  type: "string",
1530
1540
  description: "\u95EE\u9898\u6587\u6848\u3002"
@@ -1643,6 +1653,76 @@ var buildPersonalizationDialogPolicyContext = () => [
1643
1653
  "\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF0C\u5426\u5219\u4E0D\u8981\u521B\u5EFA\u6587\u6863\uFF0C\u4E0D\u8981\u521B\u5EFA\u6216\u4FEE\u6539\u4EFB\u4F55 agent\u3002"
1644
1654
  ].join("\n");
1645
1655
 
1656
+ // packages/agent-runtime/builtinPlatformAgentRoute.ts
1657
+ function resolveBuiltinAgentRuntimeFields(agentKey) {
1658
+ if (!isBuiltinPlatformAgentKey(agentKey)) return null;
1659
+ const entry = builtinAgentCatalogEntryById(parsePublicAgentId(agentKey));
1660
+ if (!entry) return null;
1661
+ return { provider: entry.provider, model: entry.model };
1662
+ }
1663
+
1664
+ // packages/agent-runtime/builtinPlatformAgentConfigs.ts
1665
+ function buildConfig(e) {
1666
+ const key = publicAgentKey(e.id);
1667
+ const rawRecord = {
1668
+ dbKey: key,
1669
+ isPublic: true,
1670
+ provider: e.provider,
1671
+ model: e.model,
1672
+ apiSource: e.apiSource ?? "platform",
1673
+ useServerProxy: e.useServerProxy ?? true
1674
+ };
1675
+ if (e.hasImageOutput) rawRecord.hasImageOutput = true;
1676
+ if (e.imageModel) rawRecord.imageModel = e.imageModel;
1677
+ if (e.imageWorkflow) rawRecord.imageWorkflow = e.imageWorkflow;
1678
+ if (e.imageConfig) rawRecord.imageConfig = e.imageConfig;
1679
+ return {
1680
+ key,
1681
+ name: e.name,
1682
+ provider: e.provider,
1683
+ model: e.model,
1684
+ apiSource: e.apiSource ?? "platform",
1685
+ useServerProxy: e.useServerProxy ?? true,
1686
+ rawRecord
1687
+ };
1688
+ }
1689
+ var BUILTIN_PLATFORM_AGENT_CONFIGS = Object.fromEntries(
1690
+ builtinRuntimeFallbackEntries().map((e) => [publicAgentKey(e.id), buildConfig(e)])
1691
+ );
1692
+ function resolveBuiltinPlatformAgentConfig(agentRef) {
1693
+ return BUILTIN_PLATFORM_AGENT_CONFIGS[agentRef] ?? null;
1694
+ }
1695
+ function resolveBuiltinPlatformAgentRecord(agentRef) {
1696
+ const config = resolveBuiltinPlatformAgentConfig(agentRef);
1697
+ if (!config) return null;
1698
+ return {
1699
+ ...config.rawRecord,
1700
+ dbKey: agentRef,
1701
+ ...config.name ? { name: config.name } : {}
1702
+ };
1703
+ }
1704
+ function applyBuiltinAgentRuntimeOverride(agentKey, record) {
1705
+ const fields = resolveBuiltinAgentRuntimeFields(agentKey);
1706
+ if (!fields) return record;
1707
+ const current = record;
1708
+ const rawNeedsOverride = current.rawRecord != null && (current.rawRecord.provider !== fields.provider || current.rawRecord.model !== fields.model);
1709
+ if (current.provider === fields.provider && current.model === fields.model && !rawNeedsOverride) {
1710
+ return record;
1711
+ }
1712
+ return {
1713
+ ...record,
1714
+ provider: fields.provider,
1715
+ model: fields.model,
1716
+ ...current.rawRecord ? {
1717
+ rawRecord: {
1718
+ ...current.rawRecord,
1719
+ provider: fields.provider,
1720
+ model: fields.model
1721
+ }
1722
+ } : {}
1723
+ };
1724
+ }
1725
+
1646
1726
  // packages/chat/dialog/dialogAgentPolicy.ts
1647
1727
  var resolveDialogAgentMode = (dialog) => {
1648
1728
  if (dialog?.agentMode === "auto") return "auto";
@@ -3444,7 +3524,7 @@ var messageSlice = createSliceWithThunks({
3444
3524
  runtimeOptions: args.runtimeOptions
3445
3525
  });
3446
3526
  if (agentKeyToUse) {
3447
- const { streamAgentChatTurn } = await import("./agentSlice-TNMFQQOV.js");
3527
+ const { streamAgentChatTurn } = await import("./agentSlice-3U3H657P.js");
3448
3528
  await dispatch(
3449
3529
  streamAgentChatTurn({
3450
3530
  agentKey: agentKeyToUse,
@@ -3886,13 +3966,11 @@ var calculateBasicCost = (model, usage, provider, externalPrice, billingServiceT
3886
3966
  case "openai":
3887
3967
  case "deepinfra":
3888
3968
  return calculateCacheBasedCost(resolvedPrice, usage, externalPrice);
3889
- // nolo/crof: honor inputCacheHit only when the model defines it (K3 has
3890
- // inputCacheHit=2, K2.6 has 0.32 from its OpenRouter upstream). Models
3891
3969
  // without it keep simple full-price billing so cached tokens are not
3892
3970
  // priced at 0 — but a platform-hosted model用于 agentic 循环时必须补上
3893
3971
  // 这一项,否则每轮重放的上下文会被按 input 原价重复计费。
3894
3972
  case "nolo":
3895
- case "crof":
3973
+ case "upstream-k3":
3896
3974
  return typeof resolvedPrice.inputCacheHit === "number" ? calculateCacheBasedCost(resolvedPrice, usage, externalPrice) : calculateSimpleCost(resolvedPrice, usage, externalPrice);
3897
3975
  case "anthropic":
3898
3976
  return calculateAnthropicCost(resolvedPrice, usage, externalPrice);
@@ -4641,7 +4719,7 @@ var deleteOwnedDialogAttachments = async (args) => {
4641
4719
  metadataReadFailures
4642
4720
  });
4643
4721
  if (!plan.deleteCandidates.length) return plan;
4644
- const { deleteFileAction } = await import("./deleteFile-XQXPBFFB.js");
4722
+ const { deleteFileAction } = await import("./deleteFile-NPZ64DFN.js");
4645
4723
  for (const candidate of plan.deleteCandidates) {
4646
4724
  if (candidate.fileDbKey) {
4647
4725
  await deleteFileAction(candidate.fileDbKey, args.thunkApi);
@@ -4703,7 +4781,7 @@ var deleteDialogThunk = async (payload, thunkApi) => {
4703
4781
  }
4704
4782
  if (isCurrentDialog) {
4705
4783
  await thunkApi.dispatch(resetMsgs());
4706
- const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-DOWKOILN.js");
4784
+ const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-5VZFBHCA.js");
4707
4785
  dispatch(clearPendingAttachments2());
4708
4786
  clearWorkflow();
4709
4787
  }
@@ -4712,39 +4790,39 @@ var deleteDialogThunk = async (payload, thunkApi) => {
4712
4790
 
4713
4791
  // packages/chat/dialog/dialogSlice.ts
4714
4792
  var runCreateDialogAction = async (args, thunkApi) => {
4715
- const { createDialogAction } = await import("./createDialogAction-LDCPDI73.js");
4793
+ const { createDialogAction } = await import("./createDialogAction-QG7DKUA7.js");
4716
4794
  return createDialogAction(args, thunkApi);
4717
4795
  };
4718
4796
  var runCreateAgentAutomationAction = async (args, thunkApi) => {
4719
- const { createAgentAutomationAction } = await import("./createAgentAutomationAction-INQT23LX.js");
4797
+ const { createAgentAutomationAction } = await import("./createAgentAutomationAction-CMOMDO6G.js");
4720
4798
  return createAgentAutomationAction(args, thunkApi);
4721
4799
  };
4722
4800
  var runUpdateDialogTitleAction = async (args, thunkApi) => {
4723
- const { updateDialogTitleAction } = await import("./updateDialogTitleAction-XPJZRJEL.js");
4801
+ const { updateDialogTitleAction } = await import("./updateDialogTitleAction-BB53DOCT.js");
4724
4802
  return updateDialogTitleAction(args, thunkApi);
4725
4803
  };
4726
4804
  var runAddDialogAgentAction = async (args, thunkApi) => {
4727
- const { addDialogAgentAction } = await import("./addDialogAgentAction-W44ZCEHB.js");
4805
+ const { addDialogAgentAction } = await import("./addDialogAgentAction-JNIAUFE6.js");
4728
4806
  return addDialogAgentAction(args, thunkApi);
4729
4807
  };
4730
4808
  var runRemoveDialogAgentAction = async (args, thunkApi) => {
4731
- const { removeDialogAgentAction } = await import("./removeDialogAgentAction-E7H557UO.js");
4809
+ const { removeDialogAgentAction } = await import("./removeDialogAgentAction-UBYX7RVR.js");
4732
4810
  return removeDialogAgentAction(args, thunkApi);
4733
4811
  };
4734
4812
  var runSetPrimaryDialogAgentAction = async (args, thunkApi) => {
4735
- const { setPrimaryDialogAgentAction } = await import("./setPrimaryDialogAgentAction-FWBKKLVA.js");
4813
+ const { setPrimaryDialogAgentAction } = await import("./setPrimaryDialogAgentAction-JKVEILI3.js");
4736
4814
  return setPrimaryDialogAgentAction(args, thunkApi);
4737
4815
  };
4738
4816
  var runSwitchDialogAgentAction = async (args, thunkApi) => {
4739
- const { switchDialogAgentAction } = await import("./switchDialogAgentAction-US6QNL3N.js");
4817
+ const { switchDialogAgentAction } = await import("./switchDialogAgentAction-DSC2T3JW.js");
4740
4818
  return switchDialogAgentAction(args, thunkApi);
4741
4819
  };
4742
4820
  var runSetDialogExtraReferencesAction = async (args, thunkApi) => {
4743
- const { setDialogExtraReferencesAction } = await import("./setDialogExtraReferencesAction-RMMGBR5F.js");
4821
+ const { setDialogExtraReferencesAction } = await import("./setDialogExtraReferencesAction-GMXZTTQA.js");
4744
4822
  return setDialogExtraReferencesAction(args, thunkApi);
4745
4823
  };
4746
4824
  var runHandleSendMessageAction = async (args, thunkApi) => {
4747
- const { handleSendMessageAction } = await import("./handleSendMessageAction-C3TSDWKH.js");
4825
+ const { handleSendMessageAction } = await import("./handleSendMessageAction-7GF5IU4J.js");
4748
4826
  return handleSendMessageAction(args, thunkApi);
4749
4827
  };
4750
4828
  function clearDialogState() {
@@ -4757,7 +4835,7 @@ var createPageAndAddReference = createAsyncThunk(
4757
4835
  async (payload, { dispatch, getState, rejectWithValue }) => {
4758
4836
  const { slateData, jsonData, title, type, fileId, groupId, dialogKey } = payload;
4759
4837
  try {
4760
- const { createDocState } = await import("./docStore-UAWSKZ2Y.js");
4838
+ const { createDocState } = await import("./docStore-LTAGA6XZ.js");
4761
4839
  const pageKey = await createDocState(
4762
4840
  { slateData, title },
4763
4841
  { dispatch, getState }
@@ -4927,6 +5005,9 @@ export {
4927
5005
  parseUiAskChoiceContent,
4928
5006
  PERSONALIZATION_DIALOG_CATEGORY,
4929
5007
  buildPersonalizationDialogPolicyContext,
5008
+ resolveBuiltinPlatformAgentConfig,
5009
+ resolveBuiltinPlatformAgentRecord,
5010
+ applyBuiltinAgentRuntimeOverride,
4930
5011
  resolveDialogRuntimeAgentKey,
4931
5012
  resolveHandleSendMessageContext,
4932
5013
  estimateMissingUsage,
@@ -4935,7 +5016,6 @@ export {
4935
5016
  selectMsgById,
4936
5017
  addUserMessage,
4937
5018
  messageStreaming,
4938
- resetMsgs,
4939
5019
  removeTransientMessage,
4940
5020
  finalizeTransientMessageOnError,
4941
5021
  prepareAndPersistMessage,
@@ -4947,7 +5027,6 @@ export {
4947
5027
  updateStep,
4948
5028
  incrementStepsExecuted,
4949
5029
  incrementFailedSteps,
4950
- clearWorkflow,
4951
5030
  toast,
4952
5031
  API_REPORTED_COST_MULTIPLIER,
4953
5032
  normalizeUsage,
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  patch,
9
9
  selectById
10
- } from "./chunk-57QJXIB6.js";
10
+ } from "./chunk-FEDK54U6.js";
11
11
  import {
12
12
  __toESM
13
13
  } from "./chunk-4VNS5WPM.js";
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  readDbRecord,
3
3
  writeAgentRecord
4
- } from "./chunk-YDTYDA5W.js";
4
+ } from "./chunk-NBIS3WYT.js";
5
5
  import {
6
6
  buildSkillSummaryMarker
7
7
  } from "./chunk-VF4K2QE6.js";
8
+ import {
9
+ createSpaceKey
10
+ } from "./chunk-ASA3CJSG.js";
11
+ import {
12
+ asTrimmedLowercaseString
13
+ } from "./chunk-QSJ3HFEF.js";
8
14
  import {
9
15
  parseUserIdFromAuthToken,
10
16
  readOption,
11
17
  resolveAuthToken,
12
18
  resolveServerUrl
13
19
  } from "./chunk-A7GB5UGH.js";
14
- import {
15
- createSpaceKey
16
- } from "./chunk-JTSGWTYZ.js";
17
- import {
18
- asTrimmedLowercaseString
19
- } from "./chunk-QSJ3HFEF.js";
20
20
  import {
21
21
  NOLO_CLUSTER_SERVERS
22
22
  } from "./chunk-LCBAMY2M.js";
@@ -0,0 +1,78 @@
1
+ import {
2
+ Lifetime,
3
+ QuickJSContext,
4
+ QuickJSNotImplemented,
5
+ QuickJSRuntime,
6
+ QuickJSWASMModule,
7
+ Scope,
8
+ applyBaseRuntimeOptions,
9
+ applyModuleEvalRuntimeOptions,
10
+ evalOptionsToFlags,
11
+ intrinsicsToFlags
12
+ } from "./chunk-UOLENXLQ.js";
13
+
14
+ // node_modules/quickjs-emscripten-core/dist/chunk-TAV5CUKK.mjs
15
+ var QuickJSAsyncContext = class extends QuickJSContext {
16
+ async evalCodeAsync(code, filename = "eval.js", options) {
17
+ let detectModule = options === void 0 ? 1 : 0, flags = evalOptionsToFlags(options), resultPtr = 0;
18
+ try {
19
+ resultPtr = await this.memory.newHeapCharPointer(code).consume((charHandle) => this.ffi.QTS_Eval_MaybeAsync(this.ctx.value, charHandle.value.ptr, charHandle.value.strlen, filename, detectModule, flags));
20
+ } catch (error) {
21
+ throw this.runtime.debugLog("QTS_Eval_MaybeAsync threw", error), error;
22
+ }
23
+ let errorPtr = this.ffi.QTS_ResolveException(this.ctx.value, resultPtr);
24
+ return errorPtr ? (this.ffi.QTS_FreeValuePointer(this.ctx.value, resultPtr), this.fail(this.memory.heapValueHandle(errorPtr))) : this.success(this.memory.heapValueHandle(resultPtr));
25
+ }
26
+ newAsyncifiedFunction(name, fn) {
27
+ return this.newFunction(name, fn);
28
+ }
29
+ };
30
+ var QuickJSAsyncRuntime = class extends QuickJSRuntime {
31
+ constructor(args) {
32
+ super(args);
33
+ }
34
+ newContext(options = {}) {
35
+ let intrinsics = intrinsicsToFlags(options.intrinsics), ctx = new Lifetime(this.ffi.QTS_NewContext(this.rt.value, intrinsics), void 0, (ctx_ptr) => {
36
+ this.contextMap.delete(ctx_ptr), this.callbacks.deleteContext(ctx_ptr), this.ffi.QTS_FreeContext(ctx_ptr);
37
+ }), context = new QuickJSAsyncContext({ module: this.module, ctx, ffi: this.ffi, rt: this.rt, ownedLifetimes: [], runtime: this, callbacks: this.callbacks });
38
+ return this.contextMap.set(ctx.value, context), context;
39
+ }
40
+ setModuleLoader(moduleLoader, moduleNormalizer) {
41
+ super.setModuleLoader(moduleLoader, moduleNormalizer);
42
+ }
43
+ setMaxStackSize(stackSize) {
44
+ return super.setMaxStackSize(stackSize);
45
+ }
46
+ };
47
+ var QuickJSAsyncWASMModule = class extends QuickJSWASMModule {
48
+ constructor(module, ffi) {
49
+ super(module, ffi);
50
+ this.ffi = ffi, this.module = module;
51
+ }
52
+ newRuntime(options = {}) {
53
+ let rt = new Lifetime(this.ffi.QTS_NewRuntime(), void 0, (rt_ptr) => {
54
+ this.callbacks.deleteRuntime(rt_ptr), this.ffi.QTS_FreeRuntime(rt_ptr);
55
+ }), runtime = new QuickJSAsyncRuntime({ module: this.module, ffi: this.ffi, rt, callbacks: this.callbacks });
56
+ return applyBaseRuntimeOptions(runtime, options), options.moduleLoader && runtime.setModuleLoader(options.moduleLoader), runtime;
57
+ }
58
+ newContext(options = {}) {
59
+ let runtime = this.newRuntime(), lifetimes = options.ownedLifetimes ? options.ownedLifetimes.concat([runtime]) : [runtime], context = runtime.newContext({ ...options, ownedLifetimes: lifetimes });
60
+ return runtime.context = context, context;
61
+ }
62
+ evalCode() {
63
+ throw new QuickJSNotImplemented("QuickJSWASMModuleAsyncify.evalCode: use evalCodeAsync instead");
64
+ }
65
+ evalCodeAsync(code, options) {
66
+ return Scope.withScopeAsync(async (scope) => {
67
+ let vm = scope.manage(this.newContext());
68
+ applyModuleEvalRuntimeOptions(vm.runtime, options);
69
+ let result = await vm.evalCodeAsync(code, "eval.js");
70
+ if (options.memoryLimitBytes !== void 0 && vm.runtime.setMemoryLimit(-1), result.error) throw vm.dump(scope.manage(result.error));
71
+ return vm.dump(scope.manage(result.value));
72
+ });
73
+ }
74
+ };
75
+
76
+ export {
77
+ QuickJSAsyncWASMModule
78
+ };
@@ -4,7 +4,7 @@ import {
4
4
 
5
5
  // packages/cli/agentCommandSupport.ts
6
6
  async function getDefaultCliDb() {
7
- const { getDefaultCliLocalRuntimeDb } = await import("./localRuntimeDb-DDZCJFQZ.js");
7
+ const { getDefaultCliLocalRuntimeDb } = await import("./localRuntimeDb-N3H3HQ7G.js");
8
8
  return getDefaultCliLocalRuntimeDb();
9
9
  }
10
10
  function createNullCliDb() {
@@ -1,5 +1,13 @@
1
1
  // packages/cli/client/profileConfig.ts
2
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import {
3
+ appendFileSync,
4
+ chmodSync,
5
+ existsSync,
6
+ mkdirSync,
7
+ readFileSync,
8
+ statSync,
9
+ writeFileSync
10
+ } from "node:fs";
3
11
  import { dirname, join } from "node:path";
4
12
  import { homedir } from "node:os";
5
13
 
@@ -27,6 +35,10 @@ function canonicalizeNoloServerUrl(value) {
27
35
 
28
36
  // packages/cli/client/profileConfig.ts
29
37
  var normalizeProfileServerUrl = canonicalizeNoloServerUrl;
38
+ function isProtectedHomeProfileWrite(path) {
39
+ if (process.env.NODE_ENV !== "test") return false;
40
+ return path === join(homedir(), ".nolo", "config.json");
41
+ }
30
42
  function getDefaultProfileConfigPath() {
31
43
  const noloHome = process.env.NOLO_HOME?.trim();
32
44
  return noloHome ? join(noloHome, "config.json") : join(homedir(), ".nolo", "config.json");
@@ -43,6 +55,7 @@ function loadProfileConfig(path = getDefaultProfileConfigPath()) {
43
55
  return parsed;
44
56
  }
45
57
  function clearProfileAuthToken(path = getDefaultProfileConfigPath()) {
58
+ if (isProtectedHomeProfileWrite(path)) return false;
46
59
  const config = loadProfileConfig(path);
47
60
  if (!config) return false;
48
61
  const profile = config.profiles[config.currentProfile];
@@ -54,6 +67,11 @@ function clearProfileAuthToken(path = getDefaultProfileConfigPath()) {
54
67
  return true;
55
68
  }
56
69
  function saveDefaultProfile(path, profile) {
70
+ if (isProtectedHomeProfileWrite(path)) {
71
+ throw new Error(
72
+ `Refusing to write the developer's real profile from a test process: ${path}. Pass a temp path or set NOLO_HOME.`
73
+ );
74
+ }
57
75
  const existing = loadProfileConfig(path);
58
76
  const mergedDefault = {
59
77
  ...existing?.profiles?.default ?? {},
@@ -89,9 +107,11 @@ function buildCliRuntimeEnv(processEnv, config) {
89
107
  const profileEnv = buildEnvFromProfile(config);
90
108
  const explicitAuthToken = processEnv.AUTH_TOKEN || processEnv.AUTH;
91
109
  const explicitServerUrl = processEnv.NOLO_SERVER || processEnv.NOLO_SERVER_URL || processEnv.BASE_URL;
110
+ const agentSource = processEnv.NOLO_AGENT?.trim() ? "env" : profileEnv.NOLO_AGENT ? "profile" : void 0;
92
111
  return {
93
112
  ...profileEnv,
94
113
  ...processEnv,
114
+ NOLO_AGENT_SOURCE: agentSource,
95
115
  ...explicitAuthToken ? { AUTH_TOKEN: explicitAuthToken } : {},
96
116
  ...explicitServerUrl ? {
97
117
  NOLO_SERVER: explicitServerUrl,
@@ -104,6 +124,7 @@ function getCurrentProfile(config) {
104
124
  return config.profiles[config.currentProfile] ?? null;
105
125
  }
106
126
  function saveProfileLocale(locale, path = getDefaultProfileConfigPath()) {
127
+ if (isProtectedHomeProfileWrite(path)) return null;
107
128
  const config = loadProfileConfig(path);
108
129
  if (!config) return null;
109
130
  const profile = config.profiles[config.currentProfile];
@@ -114,13 +135,115 @@ function saveProfileLocale(locale, path = getDefaultProfileConfigPath()) {
114
135
  `, "utf8");
115
136
  return config;
116
137
  }
138
+ function getAgentSelectionAuditPath(configPath = getDefaultProfileConfigPath()) {
139
+ return join(dirname(configPath), "agent-selection.log");
140
+ }
141
+ var AGENT_SELECTION_AUDIT_MAX_BYTES = 512 * 1024;
142
+ var AGENT_SELECTION_AUDIT_KEEP_LINES = 200;
143
+ var SECRET_ARGV_FLAGS = /* @__PURE__ */ new Set([
144
+ "--token",
145
+ "--auth",
146
+ "--auth-token",
147
+ "--key",
148
+ "--api-key",
149
+ "--app-key",
150
+ "--machine-key",
151
+ "--provider-api-key",
152
+ "--invite-token",
153
+ "--password",
154
+ "--secret"
155
+ ]);
156
+ function redactArgvSecrets(argv) {
157
+ const redacted = [];
158
+ let maskNext = false;
159
+ for (const arg of argv) {
160
+ if (maskNext) {
161
+ maskNext = false;
162
+ redacted.push("[REDACTED]");
163
+ continue;
164
+ }
165
+ const equals = arg.indexOf("=");
166
+ if (equals > 0 && SECRET_ARGV_FLAGS.has(arg.slice(0, equals))) {
167
+ redacted.push(`${arg.slice(0, equals)}=[REDACTED]`);
168
+ continue;
169
+ }
170
+ maskNext = SECRET_ARGV_FLAGS.has(arg);
171
+ redacted.push(arg);
172
+ }
173
+ return redacted;
174
+ }
175
+ function appendAgentSelectionAudit(entry, auditPath = getAgentSelectionAuditPath(entry.configPath)) {
176
+ try {
177
+ const stack = (new Error().stack ?? "").split("\n").slice(2, 8).map((line2) => line2.trim()).filter(Boolean);
178
+ const line = `${JSON.stringify({
179
+ at: (/* @__PURE__ */ new Date()).toISOString(),
180
+ pid: process.pid,
181
+ // Distinguishes repo source / installed binary / bundled desktop build —
182
+ // the field that says whether a stale build is doing the writing.
183
+ execPath: process.execPath,
184
+ argv: redactArgvSecrets(process.argv),
185
+ cwd: process.cwd(),
186
+ previous: entry.previous,
187
+ next: entry.next,
188
+ stack
189
+ })}
190
+ `;
191
+ mkdirSync(dirname(auditPath), { recursive: true });
192
+ const auditMode = 384;
193
+ if (existsSync(auditPath) && statSync(auditPath).size > AGENT_SELECTION_AUDIT_MAX_BYTES) {
194
+ const kept = readFileSync(auditPath, "utf8").split("\n").filter((entry2) => entry2.trim()).slice(-AGENT_SELECTION_AUDIT_KEEP_LINES).join("\n");
195
+ writeFileSync(auditPath, `${kept}
196
+ `, {
197
+ encoding: "utf8",
198
+ mode: auditMode
199
+ });
200
+ }
201
+ appendFileSync(auditPath, line, { encoding: "utf8", mode: auditMode });
202
+ try {
203
+ chmodSync(auditPath, auditMode);
204
+ } catch {
205
+ }
206
+ } catch {
207
+ }
208
+ }
209
+ function readLastAgentSelectionAudit(auditPath = getAgentSelectionAuditPath()) {
210
+ try {
211
+ if (!existsSync(auditPath)) return { logExists: false, last: null };
212
+ const lines = readFileSync(auditPath, "utf8").trim().split("\n");
213
+ for (let index = lines.length - 1; index >= 0; index -= 1) {
214
+ const raw = lines[index]?.trim();
215
+ if (!raw) continue;
216
+ const parsed = JSON.parse(raw);
217
+ if (!parsed.next) continue;
218
+ return {
219
+ logExists: true,
220
+ last: {
221
+ agentKey: parsed.next.agentKey ?? "",
222
+ agentName: parsed.next.agentName ?? ""
223
+ }
224
+ };
225
+ }
226
+ return { logExists: true, last: null };
227
+ } catch {
228
+ return { logExists: false, last: null };
229
+ }
230
+ }
117
231
  function saveProfileAgentSelection(selection, path = getDefaultProfileConfigPath()) {
232
+ if (isProtectedHomeProfileWrite(path)) return null;
118
233
  const config = loadProfileConfig(path);
119
234
  if (!config) return null;
120
235
  const profile = config.profiles[config.currentProfile];
121
236
  if (!profile) return null;
122
237
  const agentKey = selection.agentKey.trim();
123
238
  const agentName = selection.agentName.trim();
239
+ appendAgentSelectionAudit({
240
+ previous: {
241
+ ...profile.agentKey ? { agentKey: profile.agentKey } : {},
242
+ ...profile.agentName ? { agentName: profile.agentName } : {}
243
+ },
244
+ next: { agentKey, agentName },
245
+ configPath: path
246
+ });
124
247
  if (!agentKey) {
125
248
  delete profile.agentKey;
126
249
  delete profile.agentName;
@@ -143,5 +266,7 @@ export {
143
266
  buildCliRuntimeEnv,
144
267
  getCurrentProfile,
145
268
  saveProfileLocale,
269
+ getAgentSelectionAuditPath,
270
+ readLastAgentSelectionAudit,
146
271
  saveProfileAgentSelection
147
272
  };