nolo-cli 0.54.0-alpha.2 → 0.61.0-alpha.2

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 (172) hide show
  1. package/README.md +3 -3
  2. package/{_executeModel-ANY4SIAS.js → _executeModel-CKT6RGTL.js} +58 -49
  3. package/{action-Q4W5JPI5.js → action-76JX3JX3.js} +9 -8
  4. package/{addContentAction-O25HFR37.js → addContentAction-V3NAZRTJ.js} +9 -7
  5. package/{addDialogAgentAction-GH7AUPPB.js → addDialogAgentAction-RZOAF46K.js} +11 -9
  6. package/{agentDeleteCommand-JWIKNWWI.js → agentDeleteCommand-VN7NPXQ4.js} +37 -32
  7. package/{agentEmailCommands-PL22BEU5.js → agentEmailCommands-F2TNAV4A.js} +73 -65
  8. package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-R3VQEZJR.js} +1 -1
  9. package/{agentListCommands-6NR7AQEK.js → agentListCommands-OSM2ANI3.js} +78 -39
  10. package/{agentMachineCommands-TASPU6OA.js → agentMachineCommands-MTPWYVRV.js} +38 -33
  11. package/{agentPullCommand-M552CYSI.js → agentPullCommand-N7L2CT7L.js} +2 -2
  12. package/agentRecordCommands-VWAWTVVC.js +122 -0
  13. package/agentRunCommand-PLZOBNVK.js +149 -0
  14. package/{agentRunControl-4GHHSXFZ.js → agentRunControl-WECMOO6O.js} +13 -6
  15. package/{agentRuntimeLocal-PCJJ56J2.js → agentRuntimeLocal-XCJLRWQE.js} +35 -28
  16. package/{agentSlice-KYLDUSNN.js → agentSlice-F6DOP4IW.js} +10 -9
  17. package/{appDeleteCommands-WLHMJAVT.js → appDeleteCommands-3BCFTRFJ.js} +37 -32
  18. package/{appDeployCommands-CKON7N2E.js → appDeployCommands-B4GMHCYA.js} +37 -32
  19. package/{appDeployStatusCommands-PXRLDASH.js → appDeployStatusCommands-4MN36WIG.js} +37 -32
  20. package/{appGetCommands-RAB5RM4M.js → appGetCommands-4GJIEUAX.js} +37 -32
  21. package/{appListCommands-GU57FB62.js → appListCommands-CHU53GSX.js} +37 -32
  22. package/{authCommand-QOPOEYEK.js → authCommand-WOTWLJNF.js} +38 -32
  23. package/{authCommands-SBQVTD6V.js → authCommands-ILTBI6JV.js} +8 -6
  24. package/{chatQueueReduxAdapter-5O2WLITN.js → chatQueueReduxAdapter-HNSQXNIR.js} +29 -24
  25. package/{chunk-WL3UOGYO.js → chunk-22BTGNSP.js} +151 -155
  26. package/{chunk-7CH6U3FL.js → chunk-2GRGFCF6.js} +2 -4
  27. package/{chunk-V4KZGLOI.js → chunk-2HPRMEEZ.js} +3059 -1079
  28. package/{chunk-UNZDCI3O.js → chunk-2KDR4CWE.js} +35 -4
  29. package/{chunk-VRZIH5JO.js → chunk-2PGGC63K.js} +1 -1
  30. package/{chunk-T27IEBNQ.js → chunk-2QDDKFG5.js} +74 -1
  31. package/{chunk-7K5VMB4Q.js → chunk-37QVS7BU.js} +21 -8
  32. package/{chunk-UITMHBVK.js → chunk-37XDGCY7.js} +1 -1
  33. package/chunk-3BLB7QKO.js +433 -0
  34. package/{chunk-NQ4N4IGO.js → chunk-3JQ2NRYU.js} +33 -10
  35. package/{chunk-UW4INMD2.js → chunk-3JWKQDA4.js} +2 -2
  36. package/{chunk-IKTHA3JH.js → chunk-3QGUVVX5.js} +2 -2
  37. package/{chunk-WHVQA7PJ.js → chunk-45YO6H7P.js} +97 -35
  38. package/chunk-4C4ST2YE.js +20015 -0
  39. package/{chunk-32I5RVMY.js → chunk-4NJEIGBQ.js} +5 -5
  40. package/{chunk-KUUTWU4I.js → chunk-5ZYA4JJ3.js} +90 -22
  41. package/chunk-6YTOJY35.js +352 -0
  42. package/{chunk-INXBNYCG.js → chunk-7A3RRUCQ.js} +155 -12
  43. package/{chunk-GV35EHNA.js → chunk-7O7KH4X5.js} +1262 -971
  44. package/{chunk-Y7LNKP32.js → chunk-7UF7CQ6B.js} +4 -6
  45. package/{chunk-2BWU4ORW.js → chunk-AQMVUA7N.js} +2 -1
  46. package/{chunk-LA4IDAK7.js → chunk-AVE2YR4F.js} +1056 -3591
  47. package/{chunk-TI5BCZCH.js → chunk-B7DXRX7F.js} +59 -121
  48. package/chunk-BFU6C242.js +66 -0
  49. package/{chunk-FA4SY4F5.js → chunk-BYEJ7K2Z.js} +1 -1
  50. package/chunk-BYXBJQAS.js +0 -0
  51. package/{chunk-IA3A5373.js → chunk-C3FZR5EC.js} +1 -1
  52. package/{chunk-IWUMSAQF.js → chunk-CJCJF5XB.js} +26 -3
  53. package/{chunk-PAHILFNT.js → chunk-CP7VIDZ7.js} +4 -4
  54. package/{chunk-OYNDYVSE.js → chunk-CTCW7U7N.js} +1 -1
  55. package/{chunk-BJLYCOZK.js → chunk-D5XKNNUV.js} +135 -795
  56. package/{chunk-AV6KQCM5.js → chunk-DNNSCSA2.js} +19 -14
  57. package/{chunk-3AOLVADY.js → chunk-DVINR3PL.js} +1 -1
  58. package/{chunk-NI2BS6UD.js → chunk-DWUCB2A3.js} +1 -1
  59. package/{chunk-AA564GBL.js → chunk-DZZL7UBV.js} +1 -1
  60. package/{chunk-6FGXGFAH.js → chunk-E6RGHPDR.js} +6 -4
  61. package/chunk-EDKF7RX4.js +30 -0
  62. package/{chunk-6SZ52ORL.js → chunk-ES6CVKVD.js} +24 -30
  63. package/{chunk-DQLYEGP7.js → chunk-FHAGENAS.js} +3 -4
  64. package/{chunk-56W233KG.js → chunk-FKFMIBTT.js} +5 -1
  65. package/{chunk-INZZJSQF.js → chunk-FZGV4FGK.js} +24 -12
  66. package/{chunk-D3JQPONH.js → chunk-GAL47RNP.js} +1 -1
  67. package/{chunk-6FQ2552G.js → chunk-HBPV76EK.js} +1085 -1150
  68. package/{chunk-LN3OQJGG.js → chunk-HLU5Q2GV.js} +4 -4
  69. package/{chunk-U2A47SVI.js → chunk-HQP7HJDL.js} +7 -7
  70. package/{chunk-H2G6JXTR.js → chunk-HQUORJTM.js} +1 -1
  71. package/{chunk-3Z3DXZBD.js → chunk-IYCUMIYS.js} +24 -20
  72. package/{chunk-7APQB6R6.js → chunk-JX5PJCWS.js} +8 -6
  73. package/{chunk-LYGNQHUW.js → chunk-JYYZCK2Z.js} +2 -4
  74. package/{chunk-PYKV6FSC.js → chunk-KWSQR2KK.js} +16 -31
  75. package/{chunk-VULELK4T.js → chunk-L7B47JXR.js} +37 -64
  76. package/{chunk-4NN3EK7H.js → chunk-LAFC3B2I.js} +1 -1
  77. package/{chunk-VRJUIUIY.js → chunk-LJKICKVC.js} +2 -2
  78. package/chunk-M3JEW6N6.js +193 -0
  79. package/chunk-MBOEV4L2.js +301 -0
  80. package/{chunk-QDHZCAH3.js → chunk-MMZ6ZTVO.js} +229 -74
  81. package/{chunk-JDSUTNYY.js → chunk-MP64VFGD.js} +2 -2
  82. package/{chunk-U5Z7LFZF.js → chunk-MXUDQZXQ.js} +47 -8
  83. package/chunk-N4G4PKQ6.js +23 -0
  84. package/{chunk-SVEUG45B.js → chunk-NHRQCXIQ.js} +0 -24
  85. package/{chunk-KXKQO4Q6.js → chunk-NTW5GWDM.js} +58 -1
  86. package/chunk-ONXOABJR.js +215 -0
  87. package/{chunk-BANYWEYY.js → chunk-OZX2IPKM.js} +8 -3
  88. package/{chunk-Q24S4NDF.js → chunk-P7OOB7QP.js} +1 -1
  89. package/{chunk-GLGD2JGY.js → chunk-PEZJEQAO.js} +7 -7
  90. package/{chunk-GBADO3SM.js → chunk-PQDIDWGX.js} +1 -1
  91. package/chunk-PSCNXBYA.js +11 -0
  92. package/chunk-QEFJJS2I.js +508 -0
  93. package/{chunk-757BGY6Y.js → chunk-QEW2MFDQ.js} +1 -1
  94. package/{chunk-SP3DPVBH.js → chunk-RDBARW6T.js} +8 -3
  95. package/{chunk-TNPCQNGQ.js → chunk-RJ2SAFB5.js} +83 -41
  96. package/{chunk-FGEYVPPR.js → chunk-RVWRKFUB.js} +8 -65
  97. package/{chunk-43CXXVJD.js → chunk-RXX4GDIH.js} +1 -1
  98. package/chunk-SEJ5OS6F.js +49 -0
  99. package/{chunk-MFI4FGHX.js → chunk-SOJM57FX.js} +5 -2
  100. package/{chunk-EKLRRZIN.js → chunk-SPAQ4PVV.js} +0 -5
  101. package/{chunk-L7NG2M6H.js → chunk-TRV2MIDW.js} +89 -74
  102. package/chunk-UAD2WT54.js +64 -0
  103. package/{chunk-RTLJUGQH.js → chunk-UZPQSVM6.js} +2 -2
  104. package/{chunk-3QJTD6DO.js → chunk-VMWYBIXG.js} +9 -7
  105. package/{chunk-ZHXJ6M7T.js → chunk-W7XHHYWM.js} +4 -0
  106. package/{chunk-5WADL4O7.js → chunk-XAVSS3KE.js} +21 -3
  107. package/{chunk-CVT7L2WZ.js → chunk-XOKOSO35.js} +13 -22
  108. package/{chunk-6BYAXNH5.js → chunk-XTJTN3RW.js} +57 -4
  109. package/{chunk-T5HJEUQN.js → chunk-YCDWJX45.js} +1 -1
  110. package/{chunk-MRWGHF56.js → chunk-YDH3FDFQ.js} +12 -356
  111. package/{chunk-H4RYESI6.js → chunk-Z4QSJILV.js} +85 -13
  112. package/chunk-ZJ7UHBJS.js +89 -0
  113. package/{chunk-O5FLGN2L.js → chunk-ZRSJ3JEH.js} +6 -2
  114. package/{cliExecutor-BBUVQU4L.js → cliExecutor-HG3S345O.js} +1 -1
  115. package/{codingSkills-BCQXRZOI.js → codingSkills-VDXQYWX4.js} +2 -2
  116. package/contentThunks-7YG2ZYQC.js +73 -0
  117. package/{cooldownCommands-GI5NNWGL.js → cooldownCommands-BSCH2W7P.js} +2 -2
  118. package/{createAgentAutomationAction-UJLNFFFC.js → createAgentAutomationAction-PJQSCAIO.js} +32 -26
  119. package/createDialogAction-SFEJX6SP.js +64 -0
  120. package/{createPageAction-N3IYABHV.js → createPageAction-B7WRHOQO.js} +35 -28
  121. package/{dbSlice-D5CNGWPD.js → dbSlice-IBVOBVMS.js} +7 -6
  122. package/{deleteFile-44TUM34Y.js → deleteFile-FWP2PSBG.js} +4 -3
  123. package/{dialogCommands-35M6RBAC.js → dialogCommands-VL2X22QC.js} +38 -33
  124. package/{dialogSlice-KO7ADD7H.js → dialogSlice-ANMACABO.js} +29 -24
  125. package/{docCreateCommands-VXHZWQ3P.js → docCreateCommands-ITLGZ5YI.js} +40 -35
  126. package/{docDeleteCommands-4WFAJR6A.js → docDeleteCommands-LH3YNL4C.js} +37 -32
  127. package/{docReadCommands-OYREEFAR.js → docReadCommands-YAJ77F36.js} +36 -31
  128. package/{docStore-5BU76DFK.js → docStore-D4HGHPWI.js} +9 -33
  129. package/{docUpdateCommands-A7QERSME.js → docUpdateCommands-DQBOMH2G.js} +40 -35
  130. package/{fetchMessages-KZQVBXKY.js → fetchMessages-DRABNDPZ.js} +3 -3
  131. package/{getPricing-HAU62AFM.js → getPricing-NM3NUTAS.js} +5 -5
  132. package/handleSendMessageAction-DF2OABGW.js +675 -0
  133. package/index.js +79 -88
  134. package/{lib-2ZTNRXR4.js → lib-FRRS27KN.js} +63 -28
  135. package/{localDialogRead-NQ33HBSI.js → localDialogRead-PUQKFI73.js} +1 -1
  136. package/{localRuntimeAuthority-KQDAE64E.js → localRuntimeAuthority-R5UBODT3.js} +6 -4
  137. package/{localRuntimeDb-PF7CFKDL.js → localRuntimeDb-P37ZTX55.js} +1 -1
  138. package/{machineCommands-J43U3TX5.js → machineCommands-JXDYQ5LB.js} +309 -87
  139. package/{machineWsRunDispatch-Z2Z6STXZ.js → machineWsRunDispatch-3QHI7JX5.js} +67 -59
  140. package/memberThunks-VZI6G7YZ.js +640 -0
  141. package/{models-4QF4BJVY.js → models-FAMINFZ7.js} +2 -2
  142. package/package.json +3 -2
  143. package/{read-RGNPI5H2.js → read-2BYWW7AA.js} +4 -3
  144. package/{readDocTool-6ESWKTXD.js → readDocTool-LC3A7QTB.js} +1 -1
  145. package/{readlineWorkspace-YRPV6JPN.js → readlineWorkspace-KVZTEAHB.js} +4609 -2698
  146. package/{removeDialogAgentAction-JYT73FU2.js → removeDialogAgentAction-SFYZXHNK.js} +14 -12
  147. package/{runAgentClientLoop-5YM5WMAY.js → runAgentClientLoop-KGTEL7ZP.js} +60 -50
  148. package/{runtimeDoctorCommands-JKTTN723.js → runtimeDoctorCommands-CROTMULY.js} +7 -5
  149. package/{setDialogExtraReferencesAction-D564LMYQ.js → setDialogExtraReferencesAction-Q32RGFTA.js} +10 -8
  150. package/{setPrimaryDialogAgentAction-ACY3BLYA.js → setPrimaryDialogAgentAction-BFYJHUJS.js} +14 -12
  151. package/{settingSlice-MKI3MNZJ.js → settingSlice-IRUU4VFB.js} +8 -7
  152. package/{skillDiscovery-GPUDHDTZ.js → skillDiscovery-NTRLM6KP.js} +3 -3
  153. package/{spaceCommands-MY26V52L.js → spaceCommands-KNAYWMCZ.js} +40 -220
  154. package/{streamAgentChatTurn-XV5X5TNQ.js → streamAgentChatTurn-FLYPTXKZ.js} +140 -95
  155. package/{switchDialogAgentAction-CJ5H6SAR.js → switchDialogAgentAction-L2KOKCGG.js} +11 -9
  156. package/{tableCommands-R6WFRDYF.js → tableCommands-SUNTHAYX.js} +1 -1
  157. package/{toolApiClient-B2MFXMEG.js → toolApiClient-VGYUB4P5.js} +4 -2
  158. package/{tools-MIMELA2Y.js → tools-CVLUXK6P.js} +46 -38
  159. package/{tuiSummaryLlmCaller-XJ5BKNNS.js → tuiSummaryLlmCaller-F3DPFFZM.js} +20 -16
  160. package/{updateCommands-IYKLF3JX.js → updateCommands-AJYSD73Y.js} +2 -2
  161. package/{updateDialogTitleAction-EIZUSWHR.js → updateDialogTitleAction-HWJIZEIV.js} +33 -27
  162. package/agentRecordCommands-Z64TA63M.js +0 -114
  163. package/agentRunCommand-4QJQLPRW.js +0 -134
  164. package/agentSuperviseCommands-VB6BUS5H.js +0 -640
  165. package/chunk-6BGAQ3KR.js +0 -7081
  166. package/chunk-FD36SCCD.js +0 -105
  167. package/chunk-J3UALFHL.js +0 -370
  168. package/chunk-RU5D3B22.js +0 -230
  169. package/chunk-YBV6QJKM.js +0 -441
  170. package/createDialogAction-TJCX6GUE.js +0 -58
  171. package/handleSendMessageAction-OSGQJQ45.js +0 -406
  172. package/spaceSlice-JUIXC365.js +0 -127
@@ -54,18 +54,43 @@ function loadProfileConfig(path = getDefaultProfileConfigPath()) {
54
54
  }
55
55
  return parsed;
56
56
  }
57
+ function normalizeProfileTokens(profile) {
58
+ const tokens = Array.isArray(profile.tokens) ? profile.tokens.filter((token) => typeof token === "string" && token.trim().length > 0) : [];
59
+ if (tokens.length > 0) return tokens;
60
+ return typeof profile.authToken === "string" && profile.authToken.trim() ? [profile.authToken.trim()] : [];
61
+ }
57
62
  function clearProfileAuthToken(path = getDefaultProfileConfigPath()) {
58
63
  if (isProtectedHomeProfileWrite(path)) return false;
59
64
  const config = loadProfileConfig(path);
60
65
  if (!config) return false;
61
66
  const profile = config.profiles[config.currentProfile];
62
- if (!profile?.authToken?.trim()) return false;
67
+ if (!profile || normalizeProfileTokens(profile).length === 0) return false;
63
68
  delete profile.authToken;
69
+ delete profile.tokens;
64
70
  mkdirSync(dirname(path), { recursive: true });
65
71
  writeFileSync(path, `${JSON.stringify(config, null, 2)}
66
72
  `, "utf8");
67
73
  return true;
68
74
  }
75
+ function getProfileTokens(config) {
76
+ if (!config) return [];
77
+ const profile = config.profiles[config.currentProfile];
78
+ return profile ? normalizeProfileTokens(profile) : [];
79
+ }
80
+ function saveProfileTokens(tokens, path = getDefaultProfileConfigPath()) {
81
+ if (isProtectedHomeProfileWrite(path)) return null;
82
+ const config = loadProfileConfig(path);
83
+ if (!config) return null;
84
+ const profile = config.profiles[config.currentProfile];
85
+ if (!profile) return null;
86
+ const normalized = [...new Set(tokens.map((token) => token.trim()).filter(Boolean))];
87
+ profile.tokens = normalized;
88
+ delete profile.authToken;
89
+ mkdirSync(dirname(path), { recursive: true });
90
+ writeFileSync(path, `${JSON.stringify(config, null, 2)}
91
+ `, "utf8");
92
+ return config;
93
+ }
69
94
  function saveDefaultProfile(path, profile) {
70
95
  if (isProtectedHomeProfileWrite(path)) {
71
96
  throw new Error(
@@ -73,10 +98,14 @@ function saveDefaultProfile(path, profile) {
73
98
  );
74
99
  }
75
100
  const existing = loadProfileConfig(path);
101
+ const existingDefault = existing?.profiles?.default;
102
+ const existingTokens = existingDefault ? normalizeProfileTokens(existingDefault) : [];
103
+ const authToken = profile.authToken.trim();
104
+ const { authToken: _legacyAuthToken, ...preserved } = existingDefault ?? {};
76
105
  const mergedDefault = {
77
- ...existing?.profiles?.default ?? {},
106
+ ...preserved,
78
107
  serverUrl: normalizeProfileServerUrl(profile.serverUrl),
79
- authToken: profile.authToken.trim()
108
+ tokens: [authToken, ...existingTokens.filter((token) => token !== authToken)]
80
109
  };
81
110
  const config = {
82
111
  currentProfile: "default",
@@ -97,7 +126,7 @@ function buildEnvFromProfile(config) {
97
126
  return {
98
127
  NOLO_PROFILE: config.currentProfile,
99
128
  NOLO_SERVER: profile.serverUrl,
100
- ...profile.authToken?.trim() ? { AUTH_TOKEN: profile.authToken.trim() } : {},
129
+ ...getProfileTokens(config)[0] ? { AUTH_TOKEN: getProfileTokens(config)[0] } : {},
101
130
  ...profile.agentKey ? { NOLO_AGENT: profile.agentKey } : {},
102
131
  ...profile.agentName ? { NOLO_AGENT_NAME: profile.agentName } : {},
103
132
  ...profile.locale ? { NOLO_LANG: profile.locale } : {}
@@ -261,6 +290,8 @@ export {
261
290
  getDefaultProfileConfigPath,
262
291
  loadProfileConfig,
263
292
  clearProfileAuthToken,
293
+ getProfileTokens,
294
+ saveProfileTokens,
264
295
  saveDefaultProfile,
265
296
  buildEnvFromProfile,
266
297
  buildCliRuntimeEnv,
@@ -199,7 +199,7 @@ async function readDocFunc(args, thunkApi) {
199
199
  throw new Error(`\u65E0\u6548\u7684\u9875\u9762 ID: ${id}\u3002\u9875\u9762 ID \u901A\u5E38\u4EE5 "page-" \u5F00\u5934\u3002`);
200
200
  }
201
201
  try {
202
- const { readAction } = await import("./read-RGNPI5H2.js");
202
+ const { readAction } = await import("./read-2BYWW7AA.js");
203
203
  const pageData = await readAction({ dbKey: id }, thunkApi);
204
204
  if (!pageData) {
205
205
  throw new Error(`\u672A\u627E\u5230 ID \u4E3A ${id} \u7684\u9875\u9762\u3002`);
@@ -70,6 +70,9 @@ function sanitizeOutboundHistory(messages, options) {
70
70
  const name = call?.function?.name;
71
71
  const declaredAllows = !declared || isString(name) && declared.has(name);
72
72
  if (!declaredAllows) return;
73
+ if (!hasParsableObjectArguments(call?.function?.arguments)) {
74
+ return;
75
+ }
73
76
  const id = isNonEmptyString(call?.id) ? call.id : stableToolCallId(i, callIndex);
74
77
  candidateCallIds.add(id);
75
78
  });
@@ -143,7 +146,77 @@ ${extra}` : extra;
143
146
  }
144
147
  return extra;
145
148
  }
149
+ function hasParsableObjectArguments(raw) {
150
+ if (raw === void 0) return true;
151
+ if (raw === null || typeof raw === "number" || typeof raw === "boolean") {
152
+ return false;
153
+ }
154
+ if (typeof raw !== "string") return true;
155
+ if (raw.trim() === "") return true;
156
+ try {
157
+ const parsed = JSON.parse(raw);
158
+ return parsed !== null && typeof parsed === "object";
159
+ } catch {
160
+ return false;
161
+ }
162
+ }
163
+ function downgradeUnparsableToolCalls(messages) {
164
+ if (!Array.isArray(messages) || messages.length === 0) {
165
+ return { messages, downgraded: 0 };
166
+ }
167
+ const poisonIds = /* @__PURE__ */ new Set();
168
+ for (let i = 0; i < messages.length; i++) {
169
+ const m = messages[i];
170
+ if (m.role !== "assistant" || !Array.isArray(m.tool_calls)) continue;
171
+ m.tool_calls.forEach((call, callIndex) => {
172
+ if (!hasParsableObjectArguments(call?.function?.arguments)) {
173
+ const id = isNonEmptyString(call?.id) ? call.id : stableToolCallId(i, callIndex);
174
+ poisonIds.add(id);
175
+ }
176
+ });
177
+ }
178
+ if (poisonIds.size === 0) return { messages, downgraded: 0 };
179
+ let downgraded = 0;
180
+ const out = [];
181
+ for (const m of messages) {
182
+ if (m.role === "assistant" && Array.isArray(m.tool_calls) && m.tool_calls.length > 0) {
183
+ const kept = [];
184
+ const lines = [];
185
+ for (const call of m.tool_calls) {
186
+ if (!hasParsableObjectArguments(call?.function?.arguments)) {
187
+ lines.push(renderToolCallAsText(call));
188
+ downgraded++;
189
+ } else {
190
+ kept.push(call);
191
+ }
192
+ }
193
+ if (lines.length === 0) {
194
+ out.push(m);
195
+ continue;
196
+ }
197
+ const sanitized = {
198
+ ...m,
199
+ content: combineContentWithText(m.content, joinLines(...lines)),
200
+ tool_calls: kept.length > 0 ? kept : void 0
201
+ };
202
+ if (kept.length === 0) delete sanitized.tool_calls;
203
+ out.push(sanitized);
204
+ continue;
205
+ }
206
+ if (m.role === "tool") {
207
+ const id = isNonEmptyString(m.tool_call_id) ? m.tool_call_id : "";
208
+ if (id && poisonIds.has(id)) {
209
+ out.push({ role: "assistant", content: renderToolResultAsText(m) });
210
+ continue;
211
+ }
212
+ }
213
+ out.push(m);
214
+ }
215
+ return { messages: out, downgraded };
216
+ }
146
217
 
147
218
  export {
148
- sanitizeForOutbound
219
+ sanitizeForOutbound,
220
+ hasParsableObjectArguments,
221
+ downgradeUnparsableToolCalls
149
222
  };
@@ -1,16 +1,19 @@
1
1
  import {
2
2
  createCliLocalRuntimeAdapter,
3
3
  summarizeEndpoint
4
- } from "./chunk-GV35EHNA.js";
4
+ } from "./chunk-7O7KH4X5.js";
5
5
  import {
6
6
  clipMultilineText
7
- } from "./chunk-V4KZGLOI.js";
7
+ } from "./chunk-2HPRMEEZ.js";
8
8
  import {
9
9
  runLocalAgentTurn
10
- } from "./chunk-6BGAQ3KR.js";
10
+ } from "./chunk-4C4ST2YE.js";
11
+ import {
12
+ applyToolSurfaceConstraints
13
+ } from "./chunk-RJ2SAFB5.js";
11
14
  import {
12
15
  resolveLocalRuntimeEnvFromPolicy
13
- } from "./chunk-NQ4N4IGO.js";
16
+ } from "./chunk-3JQ2NRYU.js";
14
17
  import {
15
18
  toErrorMessage
16
19
  } from "./chunk-HNMXYYJR.js";
@@ -33,15 +36,15 @@ import {
33
36
  import {
34
37
  ownedAgentKey
35
38
  } from "./chunk-BJIRLHJR.js";
36
- import {
37
- isRecord
38
- } from "./chunk-KUG52IAP.js";
39
39
  import {
40
40
  asTrimmedString
41
41
  } from "./chunk-3EUW3WEO.js";
42
42
  import {
43
43
  asOptionalPositiveFiniteNumber
44
44
  } from "./chunk-U6VC4MU4.js";
45
+ import {
46
+ isRecord
47
+ } from "./chunk-KUG52IAP.js";
45
48
  import {
46
49
  asOptionalTrimmedString
47
50
  } from "./chunk-G3SUCT4W.js";
@@ -431,12 +434,21 @@ async function defaultRunConnectorLocalRuntimeAgent(args) {
431
434
  const agentConfigRaw = readField(payload, "agentConfig");
432
435
  const payloadAgentConfig = asRecordOrEmpty(agentConfigRaw);
433
436
  const policy = runtimePolicyFromConnectorPayload(args.parsed);
434
- const toolNames = mergeToolNames(
437
+ const candidateToolNames = mergeToolNames(
435
438
  readField(payloadAgentConfig, "toolNames"),
436
439
  readField(payloadAgentConfig, "tools"),
437
440
  policy?.agentTools,
438
441
  policy?.runtimeTools
439
442
  );
443
+ const runtimeContext = asRecordOrEmpty(readField(payload, "runtimeContext"));
444
+ const constrainedSurface = applyToolSurfaceConstraints(
445
+ { explicitToolNames: candidateToolNames, injectedToolNames: [], finalToolNames: candidateToolNames },
446
+ {
447
+ allowedToolNames: Array.isArray(readField(runtimeContext, "allowedToolNames")) ? readField(runtimeContext, "allowedToolNames") : void 0,
448
+ blockedToolNames: Array.isArray(readField(runtimeContext, "blockedToolNames")) ? readField(runtimeContext, "blockedToolNames") : void 0
449
+ }
450
+ );
451
+ const toolNames = constrainedSurface.finalToolNames;
440
452
  const apiSourceRaw = readField(payloadAgentConfig, "apiSource");
441
453
  const providerRaw = readField(payloadAgentConfig, "provider");
442
454
  const agentRecord = {
@@ -447,6 +459,7 @@ async function defaultRunConnectorLocalRuntimeAgent(args) {
447
459
  apiSource: typeof apiSourceRaw === "string" ? apiSourceRaw : "platform",
448
460
  provider: typeof providerRaw === "string" ? providerRaw : typeof apiSourceRaw === "string" ? apiSourceRaw : "openai",
449
461
  toolNames,
462
+ runScopedToolSurface: constrainedSurface,
450
463
  ...policy ? { runtimeToolPolicy: policy } : {}
451
464
  };
452
465
  const dispatchUserId = String(args.runtimeEnv.NOLO_USER_ID || "local");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  requireTokenUser
3
- } from "./chunk-RTLJUGQH.js";
3
+ } from "./chunk-UZPQSVM6.js";
4
4
  import {
5
5
  resolveServerUrl
6
6
  } from "./chunk-A7GB5UGH.js";
@@ -0,0 +1,433 @@
1
+ import {
2
+ isOAuthApiKeyRef
3
+ } from "./chunk-YYLHWIW6.js";
4
+ import {
5
+ compareAgentSelection
6
+ } from "./chunk-RJ2SAFB5.js";
7
+ import {
8
+ getModelAbility
9
+ } from "./chunk-FKFMIBTT.js";
10
+ import {
11
+ isOwnedAgentKey,
12
+ ownedAgentKey,
13
+ publicAgentKey
14
+ } from "./chunk-BJIRLHJR.js";
15
+
16
+ // packages/ai/agent/agentBilling.ts
17
+ function resolveBillingSource(candidate) {
18
+ if (candidate?.local === true || candidate?.isLocal === true || candidate?.cliProvider === "local" || candidate?.apiSource === "local" || candidate?.provider === "local" || candidate?.billingSource === "local") return "local";
19
+ if (candidate?.isOwned !== true) return "platform_credits";
20
+ if (candidate?.isOAuth === true || candidate?.billingSource === "user_subscription" || candidate?.apiSource === "oauth" || isOAuthApiKeyRef(candidate?.apiKeyRef)) return "user_subscription";
21
+ if (candidate?.apiSource === "custom" || candidate?.billingSource === "user_api") {
22
+ return "user_api";
23
+ }
24
+ return "platform_credits";
25
+ }
26
+
27
+ // packages/ai/economics/economicsPolicy.ts
28
+ var DEEPSEEK_PRICING_DOC = "https://api-docs.deepseek.com/quick_start/pricing";
29
+ var BIGMODEL_CODING_PLAN_USAGE_NOTES = "https://docs.bigmodel.cn/cn/coding-plan/usage-notes";
30
+ var WEEKDAYS_MON_FRI = [1, 2, 3, 4, 5];
31
+ var DEEPSEEK_API_POLICY = {
32
+ id: "deepseek_api",
33
+ version: "2026-09-weekday-utc-peak-2x",
34
+ windows: [
35
+ { timezone: "UTC", weekdays: WEEKDAYS_MON_FRI, startMinute: 60, endMinute: 240 },
36
+ { timezone: "UTC", weekdays: WEEKDAYS_MON_FRI, startMinute: 360, endMinute: 600 }
37
+ ],
38
+ effectiveFrom: Date.UTC(2026, 7, 16, 16, 0, 0),
39
+ peakPriceMultiplier: 2,
40
+ offPeakPriceMultiplier: 1,
41
+ sourceUrl: DEEPSEEK_PRICING_DOC
42
+ };
43
+ var BIGMODEL_GLM_CODING_PLAN_POLICY = {
44
+ id: "bigmodel_glm_coding_plan",
45
+ version: "2026-09-coding-plan-sh-peak-14-18",
46
+ windows: [
47
+ { timezone: "Asia/Shanghai", weekdays: WEEKDAYS_MON_FRI, startMinute: 840, endMinute: 1080 }
48
+ ],
49
+ peakQuotaMultiplier: 1,
50
+ offPeakQuotaMultiplier: 0.5,
51
+ sourceUrl: BIGMODEL_CODING_PLAN_USAGE_NOTES
52
+ };
53
+ var ECONOMICS_POLICIES = [
54
+ DEEPSEEK_API_POLICY,
55
+ BIGMODEL_GLM_CODING_PLAN_POLICY
56
+ ];
57
+ function resolveEconomicsSourceId(input) {
58
+ const provider = typeof input?.provider === "string" ? input.provider.trim().toLowerCase() : "";
59
+ if (input?.apiSource?.trim().toLowerCase() === "platform") return null;
60
+ const rawUrl = typeof input?.customProviderUrl === "string" ? input.customProviderUrl.trim() : "";
61
+ let hostname = "";
62
+ let pathname = "";
63
+ if (rawUrl) {
64
+ try {
65
+ const parsed = new URL(rawUrl);
66
+ hostname = parsed.hostname.toLowerCase();
67
+ pathname = parsed.pathname;
68
+ } catch {
69
+ return null;
70
+ }
71
+ }
72
+ if (provider === "deepseek") {
73
+ if (rawUrl && hostname !== "api.deepseek.com") return null;
74
+ return rawUrl ? "deepseek_api" : null;
75
+ }
76
+ if (provider === "bigmodel") {
77
+ if (hostname === "open.bigmodel.cn" && pathname.startsWith("/api/coding/")) {
78
+ return "bigmodel_glm_coding_plan";
79
+ }
80
+ return null;
81
+ }
82
+ return null;
83
+ }
84
+
85
+ // packages/ai/economics/economicsSnapshot.ts
86
+ var wallClockFormatterCache = /* @__PURE__ */ new Map();
87
+ function getWallClockFormatter(timezone) {
88
+ let formatter = wallClockFormatterCache.get(timezone);
89
+ if (!formatter) {
90
+ formatter = new Intl.DateTimeFormat("en-US", {
91
+ timeZone: timezone,
92
+ hourCycle: "h23",
93
+ year: "numeric",
94
+ month: "2-digit",
95
+ day: "2-digit",
96
+ hour: "2-digit",
97
+ minute: "2-digit",
98
+ second: "2-digit"
99
+ });
100
+ wallClockFormatterCache.set(timezone, formatter);
101
+ }
102
+ return formatter;
103
+ }
104
+ function getZonedWallClock(timezone, at) {
105
+ const parts = getWallClockFormatter(timezone).formatToParts(new Date(at));
106
+ const values = {};
107
+ for (const part of parts) {
108
+ if (part.type !== "literal") values[part.type] = Number(part.value);
109
+ }
110
+ const year = values.year;
111
+ const month = values.month;
112
+ const day = values.day;
113
+ const hour = values.hour;
114
+ const minute = values.minute;
115
+ const second = values.second;
116
+ const weekday = new Date(Date.UTC(year, month - 1, day)).getUTCDay();
117
+ return { year, month, day, hour, minute, second, weekday, minutesOfDay: hour * 60 + minute };
118
+ }
119
+ function getTimeZoneOffsetMs(timezone, at) {
120
+ const atSecond = Math.floor(at / 1e3) * 1e3;
121
+ const clock = getZonedWallClock(timezone, atSecond);
122
+ return Date.UTC(clock.year, clock.month - 1, clock.day, clock.hour, clock.minute, clock.second) - atSecond;
123
+ }
124
+ function zonedWallClockToEpochMs(timezone, year, month, day, minutesOfDay) {
125
+ const guess = Date.UTC(year, month - 1, day, Math.floor(minutesOfDay / 60), minutesOfDay % 60);
126
+ let instant = guess - getTimeZoneOffsetMs(timezone, guess);
127
+ instant = guess - getTimeZoneOffsetMs(timezone, instant);
128
+ return instant;
129
+ }
130
+ function resolveEconomicsPeriod(policy, at) {
131
+ for (const window of policy.windows) {
132
+ const clock = getZonedWallClock(window.timezone, at);
133
+ if (!window.weekdays.includes(clock.weekday)) continue;
134
+ if (clock.minutesOfDay >= window.startMinute && clock.minutesOfDay < window.endMinute) {
135
+ return "peak";
136
+ }
137
+ }
138
+ return "off_peak";
139
+ }
140
+ function findNextEconomicsBoundary(policy, at) {
141
+ let best;
142
+ for (const window of policy.windows) {
143
+ const anchor = getZonedWallClock(window.timezone, at);
144
+ for (let dayOffset = 0; dayOffset <= 7; dayOffset++) {
145
+ const dayUtc = new Date(Date.UTC(anchor.year, anchor.month - 1, anchor.day + dayOffset));
146
+ const weekday = dayUtc.getUTCDay();
147
+ if (!window.weekdays.includes(weekday)) continue;
148
+ const year = dayUtc.getUTCFullYear();
149
+ const month = dayUtc.getUTCMonth() + 1;
150
+ const day = dayUtc.getUTCDate();
151
+ for (const edge of [window.startMinute, window.endMinute]) {
152
+ const instant = zonedWallClockToEpochMs(window.timezone, year, month, day, edge);
153
+ if (instant > at && (best === void 0 || instant < best)) best = instant;
154
+ }
155
+ }
156
+ }
157
+ return best;
158
+ }
159
+ function selectEconomicsPolicyVersion(policies, sourceId, at) {
160
+ const applicable = policies.filter(
161
+ (policy) => policy.id === sourceId && (policy.effectiveFrom === void 0 || policy.effectiveFrom <= at) && (policy.effectiveUntil === void 0 || at < policy.effectiveUntil)
162
+ );
163
+ if (applicable.length === 0) return null;
164
+ return applicable.reduce(
165
+ (latest, candidate) => (candidate.effectiveFrom ?? -Infinity) >= (latest.effectiveFrom ?? -Infinity) ? candidate : latest
166
+ );
167
+ }
168
+ function findNextPolicyBoundary(policy, at, policies) {
169
+ const boundaries = [
170
+ policy.effectiveUntil,
171
+ ...policies.filter((candidate) => candidate.id === policy.id).map((candidate) => candidate.effectiveFrom).filter((value) => value !== void 0 && value > at)
172
+ ].filter((value) => value !== void 0 && value > at);
173
+ return boundaries.length > 0 ? Math.min(...boundaries) : void 0;
174
+ }
175
+ function resolveEconomicsSnapshot(input, at, policies = ECONOMICS_POLICIES) {
176
+ const sourceId = resolveEconomicsSourceId(input);
177
+ if (!sourceId) return null;
178
+ const policy = selectEconomicsPolicyVersion(policies, sourceId, at);
179
+ if (!policy) return null;
180
+ const period = resolveEconomicsPeriod(policy, at);
181
+ const priceMultiplier = period === "peak" ? policy.peakPriceMultiplier : policy.offPeakPriceMultiplier;
182
+ const quotaMultiplier = period === "peak" ? policy.peakQuotaMultiplier : policy.offPeakQuotaMultiplier;
183
+ const windowBoundary = findNextEconomicsBoundary(policy, at);
184
+ const policyBoundary = findNextPolicyBoundary(policy, at, policies);
185
+ const changesAt = [windowBoundary, policyBoundary].filter((value) => value !== void 0).sort((a, b) => a - b)[0];
186
+ return {
187
+ source: sourceId,
188
+ policyVersion: policy.version,
189
+ period,
190
+ ...priceMultiplier !== void 0 ? { priceMultiplier } : {},
191
+ ...quotaMultiplier !== void 0 ? { quotaMultiplier } : {},
192
+ ...changesAt !== void 0 ? { changesAt } : {}
193
+ };
194
+ }
195
+
196
+ // packages/ai/agent/safeAgentSummary.ts
197
+ function parseTimestamp(val) {
198
+ if (typeof val === "number" && Number.isFinite(val)) return val;
199
+ if (typeof val === "string") return Date.parse(val) || 0;
200
+ return 0;
201
+ }
202
+ function safeTimestamp(val) {
203
+ if (typeof val === "number" && Number.isFinite(val)) return val;
204
+ if (typeof val === "string") return val;
205
+ return null;
206
+ }
207
+ function parseAgentRecordId(privateKey, explicitId) {
208
+ if (explicitId && typeof explicitId === "string" && explicitId.trim()) {
209
+ return explicitId.trim();
210
+ }
211
+ if (privateKey && typeof privateKey === "string") {
212
+ const match = privateKey.match(/^agent-[^-]+-(.+)$/i);
213
+ if (match?.[1]) return match[1];
214
+ }
215
+ return null;
216
+ }
217
+ function resolveFavoriteStatus(record, options) {
218
+ if (options?.isFavorite !== void 0) {
219
+ return {
220
+ isFavorite: !!options.isFavorite,
221
+ favoritedAt: safeTimestamp(options.favoritedAt)
222
+ };
223
+ }
224
+ if (record?.isFavorite === true) {
225
+ return {
226
+ isFavorite: true,
227
+ favoritedAt: safeTimestamp(record?.favoritedAt)
228
+ };
229
+ }
230
+ const favoritesMap = options?.favoritesMap;
231
+ if (!favoritesMap) {
232
+ return { isFavorite: false, favoritedAt: null };
233
+ }
234
+ const candidateKeys = [];
235
+ if (typeof record?.dbKey === "string" && record.dbKey) candidateKeys.push(record.dbKey);
236
+ if (typeof record?.privateKey === "string" && record.privateKey) candidateKeys.push(record.privateKey);
237
+ if (typeof record?.publicKey === "string" && record.publicKey) candidateKeys.push(record.publicKey);
238
+ if (typeof record?.id === "string" && record.id) {
239
+ candidateKeys.push(record.id);
240
+ candidateKeys.push(publicAgentKey(record.id));
241
+ if (options?.userId) {
242
+ candidateKeys.push(ownedAgentKey(options.userId, record.id));
243
+ }
244
+ }
245
+ let matched = false;
246
+ let highestFavAt = null;
247
+ let highestFavTime = -1;
248
+ for (const key of candidateKeys) {
249
+ const val = favoritesMap instanceof Map ? favoritesMap.get(key) : favoritesMap[key];
250
+ if (val !== void 0 && val !== false && val !== null) {
251
+ const favAt = val === true ? 1 : safeTimestamp(val);
252
+ if (favAt === null) continue;
253
+ matched = true;
254
+ const time = parseTimestamp(favAt);
255
+ if (time > highestFavTime) {
256
+ highestFavTime = time;
257
+ highestFavAt = favAt;
258
+ }
259
+ }
260
+ }
261
+ if (matched) {
262
+ return {
263
+ isFavorite: true,
264
+ favoritedAt: highestFavAt ?? 1
265
+ };
266
+ }
267
+ return { isFavorite: false, favoritedAt: null };
268
+ }
269
+ function toSafeAgentSummary(record, options) {
270
+ const rawId = parseAgentRecordId(
271
+ typeof record?.privateKey === "string" ? record.privateKey : record?.dbKey,
272
+ typeof record?.id === "string" ? record.id : void 0
273
+ );
274
+ const id = rawId ?? (typeof record?.id === "string" ? record.id : null);
275
+ const publicRecordDenied = record?.publicRecordExists === false || options?.publicRecordExists === false;
276
+ const publicRecordConfirmed = record?.publicRecordExists === true || options?.publicRecordExists === true;
277
+ let publicKey;
278
+ if (typeof record?.publicKey === "string" && record.publicKey && !publicRecordDenied) {
279
+ publicKey = record.publicKey;
280
+ } else if (publicRecordConfirmed && id) {
281
+ publicKey = publicAgentKey(id);
282
+ }
283
+ const name = typeof record?.name === "string" && record.name ? record.name : "(unnamed)";
284
+ const handle = typeof record?.handle === "string" && record.handle ? record.handle : null;
285
+ const introduction = typeof record?.introduction === "string" && record.introduction ? record.introduction : typeof record?.description === "string" && record.description ? record.description : null;
286
+ const model = typeof record?.model === "string" && record.model ? record.model : null;
287
+ const provider = typeof record?.provider === "string" && record.provider ? record.provider : typeof record?.apiSource === "string" && record.apiSource ? record.apiSource : null;
288
+ const apiSource = typeof record?.apiSource === "string" && record.apiSource ? record.apiSource : null;
289
+ const cliProvider = typeof record?.cliProvider === "string" && record.cliProvider ? record.cliProvider : null;
290
+ const tools = Array.isArray(record?.tools) ? record.tools.filter((t) => typeof t === "string") : [];
291
+ const inputPrice = typeof record?.inputPrice === "number" && Number.isFinite(record.inputPrice) ? record.inputPrice : null;
292
+ const outputPrice = typeof record?.outputPrice === "number" && Number.isFinite(record.outputPrice) ? record.outputPrice : null;
293
+ const modelAbility = model ? getModelAbility(model) ?? null : null;
294
+ const favStatus = resolveFavoriteStatus(record, options);
295
+ const isPublic = record?.isPublic === true || record?.isPublicFlag === true || record?.publicRecordExists === true;
296
+ const updatedAt = safeTimestamp(record?.updatedAt ?? record?.createdAt ?? record?.created);
297
+ const nextAvailableAt = typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? record.nextAvailableAt : void 0;
298
+ const currentUserId = options?.userId;
299
+ const isOwnedByRecord = Boolean(currentUserId) && (typeof record?.userId === "string" && record.userId === currentUserId || typeof record?.ownerId === "string" && record.ownerId === currentUserId);
300
+ const ownedKey = currentUserId ? [record?.dbKey, record?.privateKey].find(
301
+ (key) => isOwnedAgentKey(key, currentUserId)
302
+ ) : void 0;
303
+ const isOwned = isOwnedByRecord || Boolean(ownedKey);
304
+ const isOAuth = isOAuthApiKeyRef(record?.apiKeyRef);
305
+ const billingSource = resolveBillingSource({
306
+ ...record,
307
+ isOAuth,
308
+ isOwned,
309
+ apiSource,
310
+ cliProvider,
311
+ provider,
312
+ isPublic
313
+ });
314
+ const economics = resolveEconomicsSnapshot(
315
+ {
316
+ provider,
317
+ apiSource,
318
+ customProviderUrl: typeof record?.customProviderUrl === "string" ? record.customProviderUrl : null
319
+ },
320
+ options?.now ?? Date.now()
321
+ );
322
+ let agentKey;
323
+ if (currentUserId) {
324
+ if (isOwned) {
325
+ agentKey = ownedKey ?? (id ? ownedAgentKey(currentUserId, id) : void 0);
326
+ } else if (publicKey) {
327
+ agentKey = publicKey;
328
+ }
329
+ }
330
+ return {
331
+ id,
332
+ ...agentKey !== void 0 ? { agentKey } : {},
333
+ ...publicKey !== void 0 ? { publicKey } : {},
334
+ name,
335
+ handle,
336
+ introduction,
337
+ model,
338
+ provider,
339
+ apiSource,
340
+ cliProvider,
341
+ billingSource,
342
+ tools,
343
+ inputPrice,
344
+ outputPrice,
345
+ modelAbility,
346
+ isFavorite: favStatus.isFavorite,
347
+ favoritedAt: favStatus.favoritedAt,
348
+ isPublic,
349
+ ...economics ? { economics } : {},
350
+ isOwned,
351
+ isOAuth,
352
+ ...nextAvailableAt !== void 0 ? { nextAvailableAt } : {},
353
+ updatedAt
354
+ };
355
+ }
356
+ function sortSafeAgentSummaries(agents) {
357
+ return [...agents].sort(compareAgentSelection);
358
+ }
359
+ var COMPACT_AGENT_SUMMARY_FIELDS = [
360
+ "agentKey",
361
+ "name",
362
+ "model",
363
+ "provider",
364
+ "apiSource",
365
+ "billingSource",
366
+ "isFavorite",
367
+ "isOAuth",
368
+ "isOwned",
369
+ "isPublic",
370
+ "tools",
371
+ // Phase 2A economics 快照(period/multipliers/changesAt 等小对象)。
372
+ // 只对 DeepSeek API / BigModel GLM Coding Plan 存在;不含完整 policy/windows。
373
+ "economics",
374
+ // 仅限流中的 agent 才会带(可用 agent 上不存在)。对"现在能不能选它"是
375
+ // 决策信息(CLI --show-unavailable 场景);默认列表已把这类 agent 过滤掉,
376
+ // 所以通常根本不占字节。
377
+ "nextAvailableAt"
378
+ ];
379
+ function omitNullishAgentSummaryFields(summary) {
380
+ const result = {};
381
+ for (const [key, value] of Object.entries(summary)) {
382
+ if (value !== null && value !== void 0) {
383
+ result[key] = value;
384
+ }
385
+ }
386
+ return result;
387
+ }
388
+ function toCompactAgentSummary(summary) {
389
+ const compact = {};
390
+ for (const field of COMPACT_AGENT_SUMMARY_FIELDS) {
391
+ const value = summary[field];
392
+ if (value !== null && value !== void 0) {
393
+ compact[field] = value;
394
+ }
395
+ }
396
+ return compact;
397
+ }
398
+ var UNAVAILABLE_AGENT_SUMMARY_FIELDS = [
399
+ "agentKey",
400
+ "name",
401
+ "model",
402
+ "provider",
403
+ "apiSource",
404
+ "isFavorite",
405
+ "isOAuth",
406
+ "isOwned",
407
+ "nextAvailableAt",
408
+ "favoritedAt",
409
+ "updatedAt"
410
+ ];
411
+ function toUnavailableAgentSummary(summary) {
412
+ const item = {
413
+ name: summary.name,
414
+ isFavorite: summary.isFavorite,
415
+ isOAuth: summary.isOAuth,
416
+ isOwned: summary.isOwned
417
+ };
418
+ for (const field of UNAVAILABLE_AGENT_SUMMARY_FIELDS) {
419
+ const value = summary[field];
420
+ if (value !== null && value !== void 0) {
421
+ item[field] = value;
422
+ }
423
+ }
424
+ return item;
425
+ }
426
+
427
+ export {
428
+ toSafeAgentSummary,
429
+ sortSafeAgentSummaries,
430
+ omitNullishAgentSummaryFields,
431
+ toCompactAgentSummary,
432
+ toUnavailableAgentSummary
433
+ };