nolo-cli 0.19.0 → 0.24.0-alpha.13

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 (134) hide show
  1. package/README.md +9 -18
  2. package/{_executeModel-X5PCIZN6.js → _executeModel-ZPNYAEFW.js} +46 -44
  3. package/{action-LT7BRFLK.js → action-5MNAXR5B.js} +7 -6
  4. package/{addContentAction-PL3KKBDH.js → addContentAction-UNSYTVTB.js} +5 -5
  5. package/{addDialogAgentAction-FCMSKYAF.js → addDialogAgentAction-LJGNP2AO.js} +5 -5
  6. package/{agentDeleteCommand-2BZDQV36.js → agentDeleteCommand-5ZV4433K.js} +27 -26
  7. package/{agentEmailCommands-2QJDGRMB.js → agentEmailCommands-Z7KOYDVQ.js} +57 -55
  8. package/{agentListCommands-6VEPTKBI.js → agentListCommands-UQUXJYUN.js} +30 -26
  9. package/{agentMachineCommands-NVVHNWYI.js → agentMachineCommands-53O6P6L5.js} +25 -24
  10. package/{agentRecordCommands-4GGRDMD4.js → agentRecordCommands-ZRYNBSSS.js} +52 -50
  11. package/{agentRunCommand-XOLQNKBZ.js → agentRunCommand-B73MKVOG.js} +55 -54
  12. package/{agentRunControl-Y5AFH5PQ.js → agentRunControl-SNUKXN6J.js} +6 -2
  13. package/{agentRuntimeLocal-7WYWCGL4.js → agentRuntimeLocal-GVNERRKQ.js} +21 -18
  14. package/{agentSlice-EAXPGEYV.js → agentSlice-OJBHIL34.js} +5 -5
  15. package/{appDeleteCommands-77KR2RJ4.js → appDeleteCommands-23Z3Z6KE.js} +23 -22
  16. package/{appDeployCommands-K7CAHGBI.js → appDeployCommands-3MFAR4Z7.js} +23 -22
  17. package/{appDeployStatusCommands-4OEKLTBT.js → appDeployStatusCommands-JHU6GSN4.js} +23 -22
  18. package/{appGetCommands-VM2WDLAZ.js → appGetCommands-24J55H2Y.js} +23 -22
  19. package/{appListCommands-GX6BBA6U.js → appListCommands-HE5KP3PH.js} +23 -22
  20. package/{authCommand-DY6UUL6O.js → authCommand-KGRK6MNU.js} +12 -13
  21. package/{authCommands-XTBV7OFZ.js → authCommands-JSOG2H4E.js} +4 -5
  22. package/{chunk-OWOHNGCN.js → chunk-2MBTWINN.js} +42 -3
  23. package/{chunk-MVQ4TBSD.js → chunk-54VHTARN.js} +1 -1
  24. package/{chunk-RQN4SEKL.js → chunk-5DWZ46RJ.js} +1 -1
  25. package/{chunk-VYHDJEQD.js → chunk-5EDKWSQN.js} +136 -78
  26. package/{chunk-Z4NR32XR.js → chunk-5RGU3J7P.js} +13 -0
  27. package/{chunk-7BUYEZ6U.js → chunk-7H3UTGPM.js} +12 -72
  28. package/{chunk-3ZX7PERL.js → chunk-AAWJ5S3G.js} +20 -7
  29. package/{chunk-SCTYAHYK.js → chunk-ADE6577S.js} +237 -142
  30. package/{chunk-PJSV3IZ5.js → chunk-AOPOTHFK.js} +1 -1
  31. package/{chunk-3ND52WIL.js → chunk-ATWUOTJP.js} +180 -24
  32. package/{chunk-SWDPIPOY.js → chunk-AZW5AHMW.js} +1 -1
  33. package/chunk-CF7S2RYZ.js +376 -0
  34. package/{chunk-L4F3I4SR.js → chunk-CV6BM7LU.js} +4 -6
  35. package/{chunk-G5U6LDLG.js → chunk-CWTT2NZ6.js} +6 -6
  36. package/{chunk-MKA6QE5E.js → chunk-CZHE6LLV.js} +135 -55
  37. package/{chunk-KFEVY3ST.js → chunk-D34RI6NI.js} +18 -8
  38. package/{chunk-XRZJGPFI.js → chunk-FON47ACC.js} +4 -4
  39. package/{chunk-K6EUAOW3.js → chunk-FXFGNOT2.js} +67 -1
  40. package/{chunk-LLWKHDG4.js → chunk-G36SUBHA.js} +14 -6
  41. package/{chunk-REA4JLBH.js → chunk-GD23ZX7Z.js} +7 -6
  42. package/{chunk-ROWQEJRP.js → chunk-GE6IWA5N.js} +12 -4
  43. package/{chunk-EDV7EBOI.js → chunk-GGB6MPHD.js} +2155 -1503
  44. package/{chunk-IYEXFJPC.js → chunk-GNGOZMU2.js} +64 -57
  45. package/{chunk-4T5F7YZQ.js → chunk-I6RJGORZ.js} +1 -1
  46. package/{chunk-DFCFMCY6.js → chunk-J2WT5CEO.js} +2 -2
  47. package/{chunk-AHCY2S2I.js → chunk-JJ2WUBFN.js} +1 -1
  48. package/{chunk-UGUW3FHG.js → chunk-JMSCXQUG.js} +2 -2
  49. package/{chunk-VDXCXCXH.js → chunk-KURQBS7S.js} +1 -1
  50. package/{chunk-FQZZLA3C.js → chunk-KXKQO4Q6.js} +17 -0
  51. package/{chunk-3Q7WHGCB.js → chunk-L65QKSVJ.js} +1 -1
  52. package/{chunk-UAIVG4J6.js → chunk-LEHTC2FI.js} +1 -8
  53. package/{chunk-UBHAWFQ6.js → chunk-LLDGWLML.js} +42 -19
  54. package/{chunk-JLA4FXYC.js → chunk-MALVZUYL.js} +1 -1
  55. package/{chunk-N54HIJVJ.js → chunk-MCXQNEJ3.js} +101 -9
  56. package/{chunk-GFUIQ4RY.js → chunk-MXFQHRSS.js} +1 -1
  57. package/{chunk-LSFAWXKC.js → chunk-N7J63Q6C.js} +1 -0
  58. package/{chunk-6Y7A3OQQ.js → chunk-NRY4GCKJ.js} +2 -0
  59. package/{chunk-ELT65PZW.js → chunk-OXLLFZNF.js} +1 -1
  60. package/{chunk-YGW4G5W5.js → chunk-P3RZ6DHN.js} +133 -25
  61. package/{chunk-5MIDPSSK.js → chunk-PB7G5MAM.js} +3 -3
  62. package/{chunk-HEGV7BH3.js → chunk-PMCKFQYC.js} +1 -1
  63. package/{chunk-23FZYPLC.js → chunk-PTKI7TIN.js} +911 -1064
  64. package/{chunk-MHSGJW4Z.js → chunk-PXPISYEH.js} +44 -14
  65. package/{chunk-I2ZJKTG5.js → chunk-PY7VGC5M.js} +29 -10
  66. package/{chunk-PIZYJVHQ.js → chunk-RM464B7I.js} +4 -4
  67. package/{chunk-XHG22OEX.js → chunk-ROJI6DRT.js} +2 -2
  68. package/{chunk-VNAEBGDK.js → chunk-RZNYL4LW.js} +123 -26
  69. package/{chunk-RVOUXDFU.js → chunk-S6KVFOUG.js} +6 -34
  70. package/{chunk-BV4VEE3W.js → chunk-S7AV3NCK.js} +277 -357
  71. package/{chunk-R35XMF6F.js → chunk-SIUEKVK4.js} +484 -67
  72. package/{chunk-B5TOXZAK.js → chunk-SIZQB7BD.js} +1 -1
  73. package/{chunk-DFFIZ25G.js → chunk-SLOGKB7M.js} +4 -1
  74. package/{chunk-MPVYDS7I.js → chunk-TLYHUIWF.js} +3 -3
  75. package/{chunk-HWW2M4SN.js → chunk-TNM27YZ7.js} +5 -4
  76. package/{chunk-OK6YSWLH.js → chunk-TWA4L7J7.js} +1 -1
  77. package/chunk-UZ6XXCVR.js +50 -0
  78. package/{chunk-DKZFOK24.js → chunk-WCP5FDTF.js} +16 -304
  79. package/{chunk-TRT4I4UD.js → chunk-WSQLK2KR.js} +2 -2
  80. package/{chunk-FXUSIQC2.js → chunk-XNZJVYFS.js} +1 -1
  81. package/{chunk-V3ED5AWK.js → chunk-YJY7HODU.js} +27 -16
  82. package/chunk-YYLHWIW6.js +48 -0
  83. package/{chunk-CZ6NYQTV.js → chunk-ZFL3LTU7.js} +2 -2
  84. package/{chunk-34WPV75U.js → chunk-ZUXIXYJI.js} +1 -1
  85. package/{chunk-VC6OZXO5.js → chunk-ZWJOGMKH.js} +2 -26
  86. package/{cliExecutor-DNE7TCC4.js → cliExecutor-K3F7DMRO.js} +2 -2
  87. package/{codingSkills-36KN5NQT.js → codingSkills-EN6Z6G6U.js} +4 -4
  88. package/{createAgentAutomationAction-GNFF524X.js → createAgentAutomationAction-PO62NUR7.js} +19 -18
  89. package/{createDialogAction-RB55KCLO.js → createDialogAction-ORFRYI3C.js} +22 -20
  90. package/{createPageAction-Y7343GLU.js → createPageAction-XWVMNTYH.js} +20 -19
  91. package/{db-W3O47YGF.js → db-W5UHK4P3.js} +150 -0
  92. package/{dbSlice-CGSRFJN3.js → dbSlice-5BKDURDL.js} +4 -4
  93. package/{dialogCommands-IAZK6YHQ.js → dialogCommands-XTJHROXM.js} +24 -23
  94. package/{dialogSlice-UQAXF23P.js → dialogSlice-DJXC53YW.js} +24 -18
  95. package/{docCreateCommands-I2EWZGCI.js → docCreateCommands-T2XRVXYS.js} +24 -27
  96. package/{docDeleteCommands-IZ45UZKG.js → docDeleteCommands-L7RXFXY3.js} +25 -24
  97. package/{docReadCommands-R6Z4QJYU.js → docReadCommands-M5PYNADQ.js} +24 -23
  98. package/{docStore-5HOJ4D7D.js → docStore-6LKLLFDW.js} +20 -19
  99. package/{docUpdateCommands-2LRBKQPY.js → docUpdateCommands-OA5EGPLQ.js} +24 -27
  100. package/{fetchMessages-BMGVZVSE.js → fetchMessages-W4IKHPCS.js} +2 -3
  101. package/{getPricing-G7DLAST6.js → getPricing-6C3C47Y4.js} +3 -3
  102. package/{handleSendMessageAction-Q4HY35WX.js → handleSendMessageAction-ILFGZTN5.js} +23 -20
  103. package/index.js +74 -74
  104. package/{localDialogRead-4H3QJFLW.js → localDialogRead-JXTAHW2E.js} +2 -2
  105. package/{machineCommands-PKBPQKTY.js → machineCommands-AKAQGPAO.js} +59 -57
  106. package/{machineWsRunDispatch-UZAW4OXJ.js → machineWsRunDispatch-RSBERM64.js} +51 -49
  107. package/{models-DJFSJ7SW.js → models-ILWKIX2Y.js} +2 -2
  108. package/package.json +1 -1
  109. package/{read-3FMPZPER.js → read-F3L3T2WJ.js} +2 -1
  110. package/{readDocTool-VSYHKK3V.js → readDocTool-FOHWVA4R.js} +1 -1
  111. package/{readlineWorkspace-Y2RDOFZG.js → readlineWorkspace-TUH3SFHO.js} +937 -430
  112. package/{removeDialogAgentAction-OAGA2G3U.js → removeDialogAgentAction-QCFGIUIH.js} +8 -7
  113. package/{runAgentClientLoop-NBPIKJ6J.js → runAgentClientLoop-C3QB2EXV.js} +45 -38
  114. package/{setDialogExtraReferencesAction-JZEXA5SL.js → setDialogExtraReferencesAction-DK4CKERU.js} +5 -5
  115. package/{setPrimaryDialogAgentAction-4ZUQQKDG.js → setPrimaryDialogAgentAction-SJSO6N27.js} +8 -7
  116. package/{settingSlice-7MNKHZ6R.js → settingSlice-XNM5AFPU.js} +6 -5
  117. package/{spaceCommands-DHCZ7J5I.js → spaceCommands-SXYOFGUJ.js} +25 -24
  118. package/{spaceSlice-ZXLLG3CR.js → spaceSlice-6BHMRP5O.js} +21 -18
  119. package/{streamAgentChatTurn-L3YW6LSB.js → streamAgentChatTurn-GF5W5OIP.js} +140 -98
  120. package/switchDialogAgentAction-4OAC6QRN.js +61 -0
  121. package/{tableCommands-BEQAGE4I.js → tableCommands-QSZILI7I.js} +1 -1
  122. package/{toolApiClient-QI3YBNWB.js → toolApiClient-ISM4ZQX4.js} +2 -2
  123. package/{tools-ECGXR5QF.js → tools-KBCLJ43G.js} +36 -33
  124. package/{tuiSummaryLlmCaller-OMSCNHXA.js → tuiSummaryLlmCaller-ARIMGILF.js} +6 -6
  125. package/{updateCommands-XTW55TOT.js → updateCommands-AK2RDOFR.js} +8 -2
  126. package/{updateDialogTitleAction-HQ2EUDFT.js → updateDialogTitleAction-LMHZUY4Q.js} +28 -27
  127. package/chunk-DL6EPNIK.js +0 -50
  128. package/chunk-V5R4NZP2.js +0 -78
  129. package/chunk-X4Q4UZEY.js +0 -26
  130. package/queryRunOverlay-O4LOMMPO.js +0 -161
  131. package/runOverlayPresentation-ZO4VCWEU.js +0 -11
  132. package/types-ZSTJ7MPR.js +0 -7
  133. package/{chunk-X7W4TNB4.js → chunk-CMKUBIGW.js} +3 -3
  134. package/{runtimeDoctorCommands-E2OUORHK.js → runtimeDoctorCommands-HSU632DY.js} +3 -3
@@ -1,6 +1,10 @@
1
1
  import {
2
2
  getModelConfig
3
- } from "./chunk-UAIVG4J6.js";
3
+ } from "./chunk-LEHTC2FI.js";
4
+ import {
5
+ isPlatformHostedClaudeModel,
6
+ isPlatformHostedGrokModel
7
+ } from "./chunk-CZHE6LLV.js";
4
8
  import {
5
9
  asTrimmedLowercaseString
6
10
  } from "./chunk-QSJ3HFEF.js";
@@ -28,11 +32,10 @@ function pickAgentRuntimeInferenceOptions(agentConfig) {
28
32
 
29
33
  // packages/agent-runtime/platformProviderEndpoints.ts
30
34
  var OPENAI_RESPONSES_ENDPOINT = "https://api.openai.com/v1/responses";
35
+ var DEEPSEEK_RESPONSES_ENDPOINT = "https://api.deepseek.com/responses";
36
+ var XAI_CHAT_COMPLETIONS_ENDPOINT = "https://api.x.ai/v1/chat/completions";
31
37
  var PLATFORM_CHAT_COMPLETIONS_ENDPOINTS = {
32
38
  deepinfra: "https://api.deepinfra.com/v1/openai/chat/completions",
33
- // DeepSeek official API endpoint removed — all DeepSeek models now route
34
- // through the nolo provider (Ollama Cloud). See providerRegistry.ts.
35
- // deepseek: "https://api.deepseek.com/chat/completions",
36
39
  fireworks: "https://api.fireworks.ai/inference/v1/chat/completions",
37
40
  google: "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",
38
41
  openai: "https://api.openai.com/v1/chat/completions",
@@ -41,12 +44,16 @@ var PLATFORM_CHAT_COMPLETIONS_ENDPOINTS = {
41
44
  qwen: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
42
45
  // Moonshot AI(月之暗面)开放平台 OpenAI 兼容模式(按量计费)
43
46
  moonshot: "https://api.moonshot.cn/v1/chat/completions",
44
- // Open-source default: nolo provider 中转 ollama cloud。
45
- // 内部多后端组合路由不开源,由内部 provider 路由层接管。
47
+ // Non-DeepSeek hosted models use Ollama Cloud. DeepSeek Flash is routed
48
+ // separately to the official DeepSeek Responses endpoint.
46
49
  nolo: "https://ollama.com/v1/chat/completions"
47
50
  };
48
51
  function isOpenAiResponsesModel(args) {
49
52
  const provider = asTrimmedLowercaseString(args.provider);
53
+ if (provider === "nolo" || provider === "deepseek") {
54
+ const model = args.model?.trim().toLowerCase();
55
+ return model === "deepseek-v4-flash" || model === "deepseek-v4-pro";
56
+ }
50
57
  if (provider !== "openai") return false;
51
58
  if (args.endpointKey === "responses") return true;
52
59
  if (!args.model) return false;
@@ -57,16 +64,27 @@ function isOpenAiResponsesModel(args) {
57
64
  }
58
65
  }
59
66
  function resolvePlatformResponsesEndpoint(provider) {
60
- return asTrimmedLowercaseString(provider) === "openai" ? OPENAI_RESPONSES_ENDPOINT : void 0;
67
+ const normalized = asTrimmedLowercaseString(provider);
68
+ if (normalized === "openai") return OPENAI_RESPONSES_ENDPOINT;
69
+ if (normalized === "nolo" || normalized === "deepseek") {
70
+ return DEEPSEEK_RESPONSES_ENDPOINT;
71
+ }
72
+ return void 0;
61
73
  }
62
74
  var PLATFORM_PROVIDER_ENDPOINT_ALIASES = {
63
75
  "ollama-cloud": "nolo",
64
76
  deepseek: "nolo"
65
77
  };
66
- function resolvePlatformChatCompletionsEndpoint(provider) {
78
+ function resolvePlatformChatCompletionsEndpoint(provider, model) {
67
79
  const key = asTrimmedLowercaseString(provider);
68
80
  if (!key) return void 0;
69
81
  const aliased = PLATFORM_PROVIDER_ENDPOINT_ALIASES[key] ?? key;
82
+ if (aliased === "nolo" && isPlatformHostedClaudeModel(model)) {
83
+ return PLATFORM_CHAT_COMPLETIONS_ENDPOINTS.deepinfra;
84
+ }
85
+ if (aliased === "nolo" && isPlatformHostedGrokModel(model)) {
86
+ return XAI_CHAT_COMPLETIONS_ENDPOINT;
87
+ }
70
88
  return PLATFORM_CHAT_COMPLETIONS_ENDPOINTS[aliased];
71
89
  }
72
90
 
@@ -87,7 +105,10 @@ function resolvePlatformProviderEndpoint(agentConfig) {
87
105
  })) {
88
106
  return resolvePlatformResponsesEndpoint(provider) ?? "";
89
107
  }
90
- const endpoint = resolvePlatformChatCompletionsEndpoint(provider);
108
+ const endpoint = resolvePlatformChatCompletionsEndpoint(
109
+ provider,
110
+ agentConfig.model
111
+ );
91
112
  if (!endpoint) {
92
113
  throw new Error(`Platform chat provider does not support provider "${provider}".`);
93
114
  }
@@ -228,7 +249,11 @@ async function buildProviderExecutionPlan(args) {
228
249
  }
229
250
  }
230
251
  if (!apiKey2 && agentConfig.credentialSynced && args.syncFetcher && credentialRef2) {
231
- const synced = await args.syncFetcher(credentialRef2);
252
+ let synced = null;
253
+ try {
254
+ synced = await args.syncFetcher(credentialRef2);
255
+ } catch {
256
+ }
232
257
  const trimmed = asTrimmedString(synced);
233
258
  if (trimmed) {
234
259
  try {
@@ -295,9 +320,10 @@ async function buildProviderExecutionPlan(args) {
295
320
  serverUrl: resolvePlatformServerUrl(env),
296
321
  authToken: resolvePlatformAuthToken(env),
297
322
  agentKey: agentConfig.key,
298
- ...agentConfig.apiSource ? { apiSource: agentConfig.apiSource } : {},
299
- ...agentConfig.apiKey?.trim() ? { apiKey: agentConfig.apiKey.trim() } : {},
300
- ...agentConfig.apiKeyHeader?.trim() ? { apiKeyHeader: agentConfig.apiKeyHeader.trim() } : {}
323
+ ...agentConfig.apiSource ? { apiSource: agentConfig.apiSource } : {}
324
+ // Platform agents use the server-managed provider credential. Never
325
+ // forward a raw credential from a stale/local agent record through the
326
+ // platform proxy; credentials are resolved by the platform server.
301
327
  };
302
328
  }
303
329
  let apiKey = "";
@@ -309,7 +335,11 @@ async function buildProviderExecutionPlan(args) {
309
335
  }
310
336
  }
311
337
  if (!apiKey && agentConfig.credentialSynced && args.syncFetcher && credentialRef) {
312
- const synced = await args.syncFetcher(credentialRef);
338
+ let synced = null;
339
+ try {
340
+ synced = await args.syncFetcher(credentialRef);
341
+ } catch {
342
+ }
313
343
  const trimmed = asTrimmedString(synced);
314
344
  if (trimmed) {
315
345
  try {
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  MODEL_LOOKUP_MAP
3
- } from "./chunk-UAIVG4J6.js";
4
- import {
5
- addContentAction
6
- } from "./chunk-ELT65PZW.js";
3
+ } from "./chunk-LEHTC2FI.js";
7
4
  import {
8
5
  ALL_MODELS
9
- } from "./chunk-LLWKHDG4.js";
6
+ } from "./chunk-G36SUBHA.js";
7
+ import {
8
+ addContentAction
9
+ } from "./chunk-OXLLFZNF.js";
10
10
  import {
11
11
  upload
12
- } from "./chunk-XRZJGPFI.js";
12
+ } from "./chunk-FON47ACC.js";
13
13
  import {
14
14
  PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
15
15
  PUBLIC_KIMI_K26_IMAGE_AGENT_KEY
16
- } from "./chunk-3ND52WIL.js";
16
+ } from "./chunk-ATWUOTJP.js";
17
17
  import {
18
18
  getRuntimeServerContext
19
19
  } from "./chunk-XMLRJUU5.js";
@@ -463,6 +463,11 @@ var classifyConversationLoad = (msgs) => {
463
463
  }
464
464
  return "medium";
465
465
  };
466
+ var normalizeContextUsageRatio = (value) => {
467
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
468
+ const ratio = value > 1 ? value / 100 : value;
469
+ return ratio >= 0 && ratio <= 1 ? ratio : void 0;
470
+ };
466
471
  var emptyPlan = (startIndex) => ({
467
472
  shouldCompress: false,
468
473
  compressCount: 0,
@@ -478,7 +483,8 @@ function planCompression(input) {
478
483
  summary,
479
484
  contextWindow,
480
485
  force = false,
481
- reason
486
+ reason,
487
+ realContextUsagePercent
482
488
  } = input;
483
489
  let startIndex = 0;
484
490
  if (summarizedBeforeId) {
@@ -504,8 +510,20 @@ function planCompression(input) {
504
510
  summaryTokens: adjustedSummaryTokens,
505
511
  recentLoad
506
512
  });
513
+ let shouldTriggerByUsage = false;
514
+ const usageRatio = normalizeContextUsageRatio(realContextUsagePercent);
515
+ if (usageRatio !== void 0) {
516
+ if (usageRatio >= 0.78) {
517
+ shouldTriggerByUsage = true;
518
+ } else if (usageRatio >= 0.65 && isActiveSummaryWorthDoing(pendingTokens, contextWindow)) {
519
+ shouldTriggerByUsage = true;
520
+ }
521
+ }
522
+ if (totalUsed >= historyBudget) {
523
+ shouldTriggerByUsage = true;
524
+ }
507
525
  const shouldRunActiveSummary = force && reason === "manual" && !hasOpenEndedToolCall(pendingMsgs[pendingMsgs.length - 1]) && isActiveSummaryWorthDoing(pendingTokens, contextWindow);
508
- if (totalUsed < historyBudget && !shouldRunActiveSummary) {
526
+ if (!shouldTriggerByUsage && !shouldRunActiveSummary) {
509
527
  return emptyPlan(startIndex);
510
528
  }
511
529
  let tokensToKeep = 0;
@@ -516,7 +534,8 @@ function planCompression(input) {
516
534
  tokensToKeep += t;
517
535
  keepCount++;
518
536
  }
519
- let compressCount = shouldRunActiveSummary && totalUsed < historyBudget ? Math.max(0, pendingMsgs.length - ACTIVE_SUMMARY_TAIL_KEEP_COUNT) : pendingMsgs.length - keepCount;
537
+ const triggeredByRealUsage = usageRatio !== void 0 && shouldTriggerByUsage;
538
+ let compressCount = (shouldRunActiveSummary || triggeredByRealUsage) && totalUsed < historyBudget ? Math.max(0, pendingMsgs.length - ACTIVE_SUMMARY_TAIL_KEEP_COUNT) : pendingMsgs.length - keepCount;
520
539
  while (compressCount > 0 && compressCount < pendingMsgs.length && pendingMsgs[compressCount].role === "tool") {
521
540
  compressCount--;
522
541
  }
@@ -1,3 +1,6 @@
1
+ import {
2
+ clearCliLocalRuntimePreparedAgentCache
3
+ } from "./chunk-PTKI7TIN.js";
1
4
  import {
2
5
  getReadableCliDb
3
6
  } from "./chunk-WFHXMLHZ.js";
@@ -9,10 +12,7 @@ import {
9
12
  resolveAgentRecordFromHybridStore,
10
13
  sanitizeAgentRecordForCliOutput,
11
14
  writeAgentRecord
12
- } from "./chunk-DFCFMCY6.js";
13
- import {
14
- clearCliLocalRuntimePreparedAgentCache
15
- } from "./chunk-23FZYPLC.js";
15
+ } from "./chunk-J2WT5CEO.js";
16
16
  import {
17
17
  resolveCliAgentKeyInput
18
18
  } from "./chunk-VHBWHNVT.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  selectCurrentServer
3
- } from "./chunk-RVOUXDFU.js";
3
+ } from "./chunk-S6KVFOUG.js";
4
4
  import {
5
5
  patch
6
- } from "./chunk-XRZJGPFI.js";
6
+ } from "./chunk-FON47ACC.js";
7
7
  import {
8
8
  selectIdentityToken
9
9
  } from "./chunk-XMLRJUU5.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isAgentRunTerminalStatus
3
- } from "./chunk-FQZZLA3C.js";
3
+ } from "./chunk-KXKQO4Q6.js";
4
4
  import {
5
5
  isCompiledBinary,
6
6
  resolveCliEntrypointPath
@@ -45,11 +45,58 @@ function defaultGenerateBatchId() {
45
45
  const random = Math.random().toString(36).slice(2, 8);
46
46
  return `batch-${timestamp}-${random}`;
47
47
  }
48
+ var LOCK_STALE_MS = 5e3;
49
+ var TMP_STALE_MS = 6e4;
50
+ function withRunRecordLock(runId, deps, fn) {
51
+ const fs = deps.fs ?? nodeFs;
52
+ const now = deps.now ?? (() => /* @__PURE__ */ new Date());
53
+ const lockPath = `${resolveRunRecordPath(runId, deps.env, deps.homedir)}.lock`;
54
+ let held = false;
55
+ try {
56
+ try {
57
+ fs.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
58
+ held = true;
59
+ } catch {
60
+ try {
61
+ const stat = fs.statSync?.(lockPath);
62
+ const ageMs = stat ? now().getTime() - stat.mtimeMs : Number.POSITIVE_INFINITY;
63
+ if (ageMs > LOCK_STALE_MS) {
64
+ fs.unlinkSync(lockPath);
65
+ fs.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
66
+ held = true;
67
+ }
68
+ } catch {
69
+ }
70
+ }
71
+ return fn();
72
+ } finally {
73
+ if (held) {
74
+ try {
75
+ fs.unlinkSync(lockPath);
76
+ } catch {
77
+ }
78
+ }
79
+ }
80
+ }
48
81
  function writeRunRecord(record, deps = {}) {
49
82
  const fs = deps.fs ?? nodeFs;
50
83
  const path = resolveRunRecordPath(record.runId, deps.env, deps.homedir);
51
84
  fs.mkdirSync(resolveRunsDir(deps.env, deps.homedir), { recursive: true });
52
- fs.writeFileSync(path, JSON.stringify(record, null, 2));
85
+ const payload = JSON.stringify(record, null, 2);
86
+ if (typeof fs.renameSync === "function") {
87
+ const tmp = `${path}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
88
+ try {
89
+ fs.writeFileSync(tmp, payload);
90
+ fs.renameSync(tmp, path);
91
+ return;
92
+ } catch {
93
+ try {
94
+ fs.unlinkSync(tmp);
95
+ } catch {
96
+ }
97
+ }
98
+ }
99
+ fs.writeFileSync(path, payload);
53
100
  }
54
101
  var FILE_EDIT_TOOL_NAMES = /* @__PURE__ */ new Set(["writeFile", "editFile"]);
55
102
  var DEFAULT_ACTIVITY_WRITE_INTERVAL_MS = 2e3;
@@ -130,11 +177,14 @@ function createRunActivityTracker(runId, deps = {}, options = {}) {
130
177
  function readRunRecord(runId, deps = {}) {
131
178
  const fs = deps.fs ?? nodeFs;
132
179
  const path = resolveRunRecordPath(runId, deps.env, deps.homedir);
133
- try {
134
- return JSON.parse(fs.readFileSync(path, "utf8"));
135
- } catch {
136
- return null;
180
+ for (let attempt = 0; attempt < 2; attempt += 1) {
181
+ try {
182
+ return JSON.parse(fs.readFileSync(path, "utf8"));
183
+ } catch {
184
+ if (attempt === 1) return null;
185
+ }
137
186
  }
187
+ return null;
138
188
  }
139
189
  function listRunRecords(deps = {}) {
140
190
  const fs = deps.fs ?? nodeFs;
@@ -248,6 +298,22 @@ function gcRunRecords(deps = {}, options = {}) {
248
298
  failedIds.push(record.runId);
249
299
  }
250
300
  }
301
+ try {
302
+ const dir = resolveRunsDir(deps.env, deps.homedir);
303
+ const statSync = fs.statSync;
304
+ for (const entry of fs.readdirSync(dir)) {
305
+ if (typeof entry !== "string" || !entry.endsWith(".tmp")) continue;
306
+ const tmpPath = join(dir, entry);
307
+ try {
308
+ const stat = statSync?.(tmpPath);
309
+ if (stat && nowMs - stat.mtimeMs <= TMP_STALE_MS) continue;
310
+ } catch {
311
+ continue;
312
+ }
313
+ tryUnlinkFile(fs, tmpPath);
314
+ }
315
+ } catch {
316
+ }
251
317
  return { swept: sweptIds.length, sweptIds, failedIds };
252
318
  }
253
319
  function stripBackgroundFlag(args) {
@@ -367,28 +433,39 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
367
433
  record.pid = proc.pid;
368
434
  const processStartedAt = (deps.getProcessStartTime ?? defaultGetProcessStartTime)(proc.pid);
369
435
  if (processStartedAt) record.processStartedAt = processStartedAt.toISOString();
370
- fs.writeFileSync(recordPath, JSON.stringify(record, null, 2));
436
+ writeRunRecord(record, deps);
371
437
  }
372
438
  return { runId, pid: proc.pid, logPath, batchId };
373
439
  }
440
+ function ackRunRecord(runId, deps = {}) {
441
+ withRunRecordLock(runId, deps, () => {
442
+ const record = readRunRecord(runId, deps);
443
+ if (!record) return;
444
+ if (record.ack) return;
445
+ record.ack = true;
446
+ writeRunRecord(record, deps);
447
+ });
448
+ }
374
449
  function finalizeRunRecord(runId, update, deps = {}) {
375
- const record = readRunRecord(runId, deps);
376
- if (!record) return;
377
- const now = deps.now ?? (() => /* @__PURE__ */ new Date());
378
- record.status = update.status;
379
- if (typeof update.exitCode === "number") record.exitCode = update.exitCode;
380
- if (update.dialogId) record.dialogId = update.dialogId;
381
- record.endedAt = now().toISOString();
382
- writeRunRecord(record, deps);
450
+ withRunRecordLock(runId, deps, () => {
451
+ const record = readRunRecord(runId, deps);
452
+ if (!record) return;
453
+ const now = deps.now ?? (() => /* @__PURE__ */ new Date());
454
+ record.status = update.status;
455
+ if (typeof update.exitCode === "number") record.exitCode = update.exitCode;
456
+ if (update.dialogId) record.dialogId = update.dialogId;
457
+ record.endedAt = now().toISOString();
458
+ if (record.note?.startsWith("orphaned:")) record.note = void 0;
459
+ writeRunRecord(record, deps);
460
+ });
383
461
  }
384
462
  function isPidGone(pid, deps = {}) {
385
463
  const kill = deps.kill ?? ((p, s) => process.kill(p, s));
386
464
  try {
387
- kill(pid, "0");
465
+ kill(pid, 0);
388
466
  return false;
389
467
  } catch (error) {
390
- const code = error.code;
391
- return code === "ESRCH";
468
+ return error.code === "ESRCH";
392
469
  }
393
470
  }
394
471
  function defaultGetProcessStartTime(pid) {
@@ -406,7 +483,13 @@ function defaultGetProcessStartTime(pid) {
406
483
  }
407
484
  }
408
485
  var MAX_PROCESS_START_TIME_DIFF_MS = 3e4;
409
- var MAX_PERSISTED_PROCESS_START_TIME_DIFF_MS = 1e3;
486
+ var MAX_PERSISTED_PROCESS_START_TIME_DIFF_MS = 2e3;
487
+ var ORPHAN_HEARTBEAT_GRACE_MS = 1e4;
488
+ function readTimestampMs(value) {
489
+ if (!value) return null;
490
+ const ms = new Date(value).getTime();
491
+ return Number.isNaN(ms) ? null : ms;
492
+ }
410
493
  function isPidReused(pid, expectedStartedAt, deps = {}, maxDiffMs = MAX_PROCESS_START_TIME_DIFF_MS) {
411
494
  const getStartTime = deps.getProcessStartTime ?? defaultGetProcessStartTime;
412
495
  const procStartTime = getStartTime(pid);
@@ -429,13 +512,25 @@ function checkStaleRun(runId, deps = {}) {
429
512
  const pidReused = !pidGone && isPidReused(record.pid, expectedStartedAt, deps, maxStartTimeDiffMs);
430
513
  if (!pidGone && !pidReused) return record;
431
514
  const now = deps.now ?? (() => /* @__PURE__ */ new Date());
432
- record.status = "orphaned";
433
- record.note = pidReused ? "orphaned: process gone (pid reused by another process)" : "orphaned: process gone without writing terminal status";
434
- record.endedAt = now().toISOString();
435
- record.reconciledAt = now().toISOString();
436
- record.pid = void 0;
437
- writeRunRecord(record, deps);
438
- return record;
515
+ const heartbeatAt = readTimestampMs(record.activity?.updatedAt);
516
+ if (heartbeatAt !== null) {
517
+ const silentMs = now().getTime() - heartbeatAt;
518
+ if (silentMs < ORPHAN_HEARTBEAT_GRACE_MS) return record;
519
+ }
520
+ return withRunRecordLock(runId, deps, () => {
521
+ const latest = readRunRecord(runId, deps);
522
+ if (!latest) return record;
523
+ if (latest.status !== "running") return latest;
524
+ if (latest.activity?.updatedAt !== record.activity?.updatedAt) return latest;
525
+ const at = now().toISOString();
526
+ latest.status = "orphaned";
527
+ latest.note = pidReused ? "orphaned: process gone (pid reused by another process)" : "orphaned: process gone without writing terminal status";
528
+ latest.endedAt = at;
529
+ latest.reconciledAt = at;
530
+ latest.pid = void 0;
531
+ writeRunRecord(latest, deps);
532
+ return latest;
533
+ });
439
534
  }
440
535
  function formatDuration(startedAt, endedAt) {
441
536
  const start = new Date(startedAt).getTime();
@@ -812,10 +907,12 @@ export {
812
907
  absolutizeSkillArgs,
813
908
  rewriteMsgFileArg,
814
909
  spawnLocalBackgroundRun,
910
+ ackRunRecord,
815
911
  finalizeRunRecord,
816
912
  isPidGone,
817
913
  defaultGetProcessStartTime,
818
914
  MAX_PROCESS_START_TIME_DIFF_MS,
915
+ ORPHAN_HEARTBEAT_GRACE_MS,
819
916
  isPidReused,
820
917
  checkStaleRun,
821
918
  runAgentPsCommand,
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  parsePositiveFiniteNumberOrFallback
3
3
  } from "./chunk-Y5GCAMGP.js";
4
+ import {
5
+ DEFAULT_SYSTEM_AGENT_CAPABILITIES
6
+ } from "./chunk-UZ6XXCVR.js";
4
7
  import {
5
8
  asRecordOrEmpty
6
9
  } from "./chunk-KX6YBIHG.js";
@@ -10,18 +13,18 @@ import {
10
13
  toTimestampMs,
11
14
  upsert,
12
15
  write
13
- } from "./chunk-XRZJGPFI.js";
16
+ } from "./chunk-FON47ACC.js";
14
17
  import {
15
18
  createUserKey,
16
19
  createUserPreferenceKey,
17
20
  ulid
18
- } from "./chunk-6Y7A3OQQ.js";
21
+ } from "./chunk-NRY4GCKJ.js";
19
22
  import {
20
23
  asTrimmedLowercaseString
21
24
  } from "./chunk-QSJ3HFEF.js";
22
25
  import {
23
26
  BUILTIN_NOLO_AGENT_KEY
24
- } from "./chunk-3ND52WIL.js";
27
+ } from "./chunk-ATWUOTJP.js";
25
28
  import {
26
29
  asyncThunkCreator,
27
30
  buildCreateSlice,
@@ -65,35 +68,6 @@ var DEFAULT_USER_PREFERENCE_PROFILE = {
65
68
  spaceContextLevel: 3
66
69
  };
67
70
 
68
- // packages/ai/tools/agentCapabilities.ts
69
- var SYSTEM_AGENT_CAPABILITIES = [
70
- {
71
- id: "web-search",
72
- label: "\u8054\u7F51\u641C\u7D22",
73
- description: "\u8BA9 agent \u80FD\u641C\u7D22\u4E92\u8054\u7F51\u3001\u6293\u53D6\u7F51\u9875\u5185\u5BB9\uFF0C\u83B7\u53D6\u6700\u65B0\u4FE1\u606F\u3002",
74
- tools: ["exa_search", "fetchWebpage"],
75
- defaultEnabled: true,
76
- icon: "\u{1F310}"
77
- },
78
- {
79
- id: "agent-orchestration",
80
- label: "\u591A agent \u7F16\u6392",
81
- description: "\u5148\u6309\u6536\u85CF\u3001\u7B80\u4ECB\u3001\u80FD\u529B\u548C\u6210\u672C\u5217\u51FA\u5B89\u5168 agent \u6458\u8981\uFF0C\u6309\u9700\u8BFB\u53D6\u5019\u9009\u914D\u7F6E\u89E3\u6790\u53EF\u8FD0\u884C key\uFF0C\u518D\u540E\u53F0\u542F\u52A8\u5176\u4ED6 agent \u6267\u884C\u5B50\u4EFB\u52A1\uFF0C\u5E76\u89C2\u5BDF\u3001\u67E5\u8BE2\u3001\u505C\u6B62\u8FD0\u884C\u4E2D\u7684 agent run\u2014\u2014\u9002\u5408\u5E76\u884C\u6D3E\u53D1\u3001\u957F\u4EFB\u52A1\u8DDF\u8E2A\u3001\u4E2D\u9014\u53EB\u505C\u7B49\u7F16\u6392\u573A\u666F\u3002",
82
- tools: ["startAgentRun", "controlAgentRun", "listAgents"],
83
- defaultEnabled: true,
84
- icon: "\u{1F9E9}"
85
- }
86
- ];
87
- var SYSTEM_AGENT_CAPABILITY_IDS = SYSTEM_AGENT_CAPABILITIES.map(
88
- ({ id }) => id
89
- );
90
- var DEFAULT_SYSTEM_AGENT_CAPABILITIES = Object.fromEntries(
91
- SYSTEM_AGENT_CAPABILITIES.map(({ id, defaultEnabled }) => [
92
- id,
93
- defaultEnabled
94
- ])
95
- );
96
-
97
71
  // packages/ai/policy/selfUpdateFields.ts
98
72
  var AGENT_UPDATE_FIELD_NAMES = [
99
73
  "name",
@@ -2015,8 +1989,6 @@ var settingSlice_default = settingSlice.reducer;
2015
1989
  export {
2016
1990
  DEFAULT_AGENT_BASE_POLICY,
2017
1991
  DEFAULT_USER_PREFERENCE_PROFILE,
2018
- SYSTEM_AGENT_CAPABILITIES,
2019
- SYSTEM_AGENT_CAPABILITY_IDS,
2020
1992
  AGENT_UPDATE_FIELD_NAMES,
2021
1993
  normalizeAgentUpdateFieldList,
2022
1994
  SYSTEM_DEFAULT_AGENT_ID,