nolo-cli 0.97.6 → 0.97.8

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 (97) hide show
  1. package/{_executeModel-E64QIKWF.js → _executeModel-V7RANMQR.js} +25 -25
  2. package/{addContentAction-DX6T34JR.js → addContentAction-RBOUD7SJ.js} +5 -5
  3. package/{addDialogAgentAction-6SGG37BF.js → addDialogAgentAction-IODCR6TB.js} +4 -4
  4. package/{agentDeleteCommand-76VXVM3N.js → agentDeleteCommand-CF65LJO2.js} +15 -15
  5. package/{agentEmailCommands-URGNKPPJ.js → agentEmailCommands-HBNZIE5Q.js} +29 -29
  6. package/{agentListCommands-62NGDFOS.js → agentListCommands-5EFAYZ5B.js} +16 -16
  7. package/{agentMachineCommands-SDIABR4D.js → agentMachineCommands-HIGEYGHU.js} +14 -14
  8. package/{agentPullCommand-5DOL6RGF.js → agentPullCommand-B4T2DJ5H.js} +1 -1
  9. package/{agentRecordCommands-ZICUGEEH.js → agentRecordCommands-DIGUK2EV.js} +29 -29
  10. package/{agentRunCommand-66NCRPQ7.js → agentRunCommand-7IYB6QL5.js} +29 -29
  11. package/{agentRuntimeLocal-EZPUCRMS.js → agentRuntimeLocal-IOFBNVIL.js} +12 -12
  12. package/{agentSlice-V2EDVUXC.js → agentSlice-6ON6SBOW.js} +5 -5
  13. package/{appDeleteCommands-7WLUFWPE.js → appDeleteCommands-UZ6MYQJN.js} +12 -12
  14. package/{appDeployCommands-NK22AMAW.js → appDeployCommands-PQD6OJ6V.js} +12 -12
  15. package/{appDeployStatusCommands-PIWSMQET.js → appDeployStatusCommands-4JJSAK6R.js} +12 -12
  16. package/{appGetCommands-J3H6IHUT.js → appGetCommands-4M7DVU5T.js} +12 -12
  17. package/{appListCommands-CF4NYHRY.js → appListCommands-PERJZZRY.js} +12 -12
  18. package/{authCommand-T6UO5KPG.js → authCommand-NHDLY3IB.js} +2 -2
  19. package/{authCommands-KTIUCVVG.js → authCommands-UDBJVSZU.js} +2 -2
  20. package/{chunk-XBIYSBSG.js → chunk-46Y5D2BZ.js} +1 -1
  21. package/{chunk-NVRC52JS.js → chunk-4FFUDT6D.js} +4 -4
  22. package/{chunk-YWLAWZYQ.js → chunk-6RSG6HJR.js} +6 -6
  23. package/{chunk-KFJ7ZWBF.js → chunk-7JIOW5N3.js} +7 -7
  24. package/{chunk-WS2VEVHS.js → chunk-7MMSLEPA.js} +2 -2
  25. package/{chunk-V4UYSDTH.js → chunk-ADBZWMFB.js} +1 -1
  26. package/{chunk-SBFHKTI7.js → chunk-CD7Y7F5H.js} +13 -3
  27. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  28. package/{chunk-Z7A2EDGT.js → chunk-DFX557SE.js} +3 -3
  29. package/{chunk-EPCAQM3U.js → chunk-E73ON47R.js} +1 -1
  30. package/{chunk-ROFPWC4X.js → chunk-FJ5BGMNM.js} +2 -2
  31. package/{chunk-74D5HEDI.js → chunk-FOXQ7BAB.js} +1 -1
  32. package/{chunk-OCZQEXMX.js → chunk-FWBJR7BZ.js} +18 -12
  33. package/{chunk-7MTCBOOS.js → chunk-GARACBQB.js} +1 -1
  34. package/{chunk-ANRWQGOV.js → chunk-GDFA73QZ.js} +45 -11
  35. package/{chunk-SH7KLR4U.js → chunk-I72JY7FP.js} +3 -3
  36. package/{chunk-CERE5KFG.js → chunk-KN25LO6X.js} +1 -1
  37. package/{chunk-JNXHAQPJ.js → chunk-LDCAFLXD.js} +17 -1
  38. package/{chunk-EMQZSES6.js → chunk-LOCNXNOU.js} +1 -1
  39. package/{chunk-4XYBLM4D.js → chunk-LQ4PDQCI.js} +1 -1
  40. package/{chunk-PUOC4YRO.js → chunk-M7VLQGQP.js} +11 -0
  41. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  42. package/{chunk-2TYM4V33.js → chunk-NNCYNBYV.js} +2 -2
  43. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  44. package/{chunk-ELIMCKNX.js → chunk-PCF3QU5Q.js} +1 -1
  45. package/{chunk-RX4HD4H7.js → chunk-PTDYOADJ.js} +1 -1
  46. package/{chunk-RJYTVNWD.js → chunk-RS4ENQ4O.js} +2 -2
  47. package/{chunk-BFWQ65IZ.js → chunk-SNMQMOD2.js} +1 -1
  48. package/{chunk-2LM7XUCX.js → chunk-SPCBJGFO.js} +4 -4
  49. package/{chunk-ZGNDLCYH.js → chunk-TQE6BVFT.js} +22 -22
  50. package/{chunk-SESH42J6.js → chunk-UACUR6N5.js} +1 -1
  51. package/{chunk-PQ6BKMXB.js → chunk-UM4PH574.js} +1 -1
  52. package/{chunk-BS7YHAQP.js → chunk-UWVGKNAL.js} +244 -57
  53. package/{chunk-CV366NXM.js → chunk-V5OWQOJZ.js} +8 -2
  54. package/{chunk-3PELUSVV.js → chunk-WZLHDC7H.js} +2 -2
  55. package/{chunk-LYKHXIQC.js → chunk-X5YVT5HS.js} +2 -2
  56. package/{chunk-QNTL2KFU.js → chunk-XEALKKFF.js} +105 -32
  57. package/{chunk-WGPKQLZO.js → chunk-ZOWXSMIG.js} +7 -7
  58. package/{chunk-OXEHLZNH.js → chunk-ZTZCZV42.js} +3 -3
  59. package/{commandRegistry-N47CRDOH.js → commandRegistry-WSHNW7RD.js} +52 -52
  60. package/{contentThunks-RRD2XMWB.js → contentThunks-2IQTDXY2.js} +12 -12
  61. package/{createAgentAutomationAction-OW4WEVHP.js → createAgentAutomationAction-W42UXDBD.js} +12 -12
  62. package/{createDialogAction-L3WMTD5Z.js → createDialogAction-YWNYTXXK.js} +13 -13
  63. package/{createPageAction-PWG3K3K7.js → createPageAction-UFGCRJ3W.js} +12 -12
  64. package/{dbSlice-BUB77DHH.js → dbSlice-Q25STFGJ.js} +4 -4
  65. package/{deleteFile-HG4BF3CS.js → deleteFile-AJ2EZMHT.js} +2 -2
  66. package/{dialogCommands-CNXJGME5.js → dialogCommands-YQFKAGMA.js} +15 -15
  67. package/{dialogSlice-M7ZWTW5D.js → dialogSlice-34DUPW5Z.js} +11 -11
  68. package/{docCreateCommands-U2TEDZHS.js → docCreateCommands-FCANZT2K.js} +12 -12
  69. package/{docDeleteCommands-K4ME6F6S.js → docDeleteCommands-AJHN65NA.js} +14 -14
  70. package/{docReadCommands-ZUAVR3HH.js → docReadCommands-25KDEVTF.js} +12 -12
  71. package/{docStore-IX7ASJUP.js → docStore-FAQ6XUUA.js} +7 -5
  72. package/{docUpdateCommands-UKEOVRTF.js → docUpdateCommands-KFR7UB3E.js} +12 -12
  73. package/{fetchMessages-N2BW2L62.js → fetchMessages-I5ICDDHM.js} +2 -2
  74. package/{handleSendMessageAction-KMPC6UD4.js → handleSendMessageAction-5XCHOMQH.js} +28 -12
  75. package/index.js +3 -3
  76. package/{localDialogRead-3FHUPYAR.js → localDialogRead-ZHZ3KXDM.js} +1 -1
  77. package/{localRuntimeAuthority-AENMRPGX.js → localRuntimeAuthority-TU6OBC76.js} +5 -2
  78. package/{localRuntimeDb-AXJREE2T.js → localRuntimeDb-VKWVOPPI.js} +1 -1
  79. package/{machineCommands-U4RRZGU6.js → machineCommands-MSUNJQFK.js} +28 -28
  80. package/{machineWsRunDispatch-V3IOP2P2.js → machineWsRunDispatch-VO7TVIB4.js} +28 -28
  81. package/{memberThunks-LEUNURN2.js → memberThunks-R75S3RWP.js} +5 -5
  82. package/package.json +1 -1
  83. package/{read-TBK4DFHP.js → read-SRQMNO26.js} +2 -2
  84. package/{readDocTool-TJFCZ3ND.js → readDocTool-RC3JUNJ2.js} +1 -1
  85. package/{readlineWorkspace-QTCU2BC4.js → readlineWorkspace-QIPJ23JY.js} +33 -33
  86. package/{removeDialogAgentAction-CT5HGRZH.js → removeDialogAgentAction-46XQV5Q7.js} +5 -5
  87. package/{runAgentClientLoop-4VOARXQF.js → runAgentClientLoop-GSJ4FH6L.js} +23 -23
  88. package/{runtimeDoctorCommands-EQJA4MGD.js → runtimeDoctorCommands-PIVSBZRZ.js} +3 -3
  89. package/{setDialogExtraReferencesAction-JOENKFTX.js → setDialogExtraReferencesAction-J4V5ADQF.js} +5 -5
  90. package/{setPrimaryDialogAgentAction-MHWOGXP3.js → setPrimaryDialogAgentAction-UHHV2QZW.js} +5 -5
  91. package/{settingThunks-KLPZNA6L.js → settingThunks-2OFFBLF4.js} +4 -4
  92. package/{spaceCommands-ZESRWSTC.js → spaceCommands-R3SC2VWH.js} +14 -14
  93. package/{streamAgentChatTurn-VDAVK7N3.js → streamAgentChatTurn-IUQH52XL.js} +25 -25
  94. package/{switchDialogAgentAction-JHA4JEYA.js → switchDialogAgentAction-A2TMVGAE.js} +4 -4
  95. package/{tools-VJ3L5V6D.js → tools-BQKPNGWC.js} +19 -19
  96. package/{tuiSummaryLlmCaller-QUCBFGZK.js → tuiSummaryLlmCaller-Q65IBDGO.js} +8 -8
  97. package/{updateDialogTitleAction-GBUSLAQR.js → updateDialogTitleAction-Z7OREKH3.js} +12 -12
@@ -14,10 +14,10 @@ import {
14
14
  } from "./chunk-AGGIDPCZ.js";
15
15
  import {
16
16
  runLlm
17
- } from "./chunk-2LM7XUCX.js";
17
+ } from "./chunk-SPCBJGFO.js";
18
18
  import {
19
19
  cleanupCliSessionForDialog
20
- } from "./chunk-ELIMCKNX.js";
20
+ } from "./chunk-PCF3QU5Q.js";
21
21
  import {
22
22
  getActiveDialogAgentId,
23
23
  getDialogAgentIds,
@@ -48,7 +48,7 @@ import {
48
48
  } from "./chunk-YDH3FDFQ.js";
49
49
  import {
50
50
  fetchMessages
51
- } from "./chunk-V4UYSDTH.js";
51
+ } from "./chunk-ADBZWMFB.js";
52
52
  import {
53
53
  nolotusId
54
54
  } from "./chunk-A4SQRTZ6.js";
@@ -64,7 +64,7 @@ import {
64
64
  getModelInfo,
65
65
  normalizeUsage,
66
66
  resolveAutoExecutionProfile
67
- } from "./chunk-JNXHAQPJ.js";
67
+ } from "./chunk-LDCAFLXD.js";
68
68
  import {
69
69
  COMPACTION_SUMMARY_SYSTEM_PROMPT,
70
70
  buildCompactionMetricsFromPlan,
@@ -75,7 +75,7 @@ import {
75
75
  normalizeAssistantContentBuffer,
76
76
  planCompression,
77
77
  serializeMessageContent
78
- } from "./chunk-WS2VEVHS.js";
78
+ } from "./chunk-7MMSLEPA.js";
79
79
  import {
80
80
  asRecordOrEmpty
81
81
  } from "./chunk-KX6YBIHG.js";
@@ -85,7 +85,7 @@ import {
85
85
  remove,
86
86
  selectById,
87
87
  write
88
- } from "./chunk-NVRC52JS.js";
88
+ } from "./chunk-4FFUDT6D.js";
89
89
  import {
90
90
  findModelConfig,
91
91
  getModelConfig
@@ -111,9 +111,11 @@ import {
111
111
  scheduleDeleteReplication
112
112
  } from "./chunk-UJXNKP5V.js";
113
113
  import {
114
+ getRecordTimestamp,
115
+ getTombstoneTimestamp,
114
116
  isTombstoneRecord,
115
117
  shouldReplaceWithNextRecord
116
- } from "./chunk-GBRG75BQ.js";
118
+ } from "./chunk-D2MDMY2M.js";
117
119
  import {
118
120
  builtinAgentCatalogEntryById,
119
121
  builtinRuntimeFallbackEntries,
@@ -335,7 +337,31 @@ function resolveInitMsgsHasMoreOlder(input) {
335
337
  var isValidMessage = (msg) => !!msg && typeof msg === "object" && typeof msg.id === "string";
336
338
 
337
339
  // packages/chat/messages/fetchConvMsgs.ts
338
- var FETCH_TIMEOUT = 5e3;
340
+ var FETCH_BUDGETS = {
341
+ connectMs: 15e3,
342
+ stallMs: 1e4,
343
+ totalMs: 12e4
344
+ };
345
+ var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
346
+ var readJsonBody = async (response, onChunk) => {
347
+ const body = response.body;
348
+ if (!body) {
349
+ return await response.json();
350
+ }
351
+ const reader = body.getReader();
352
+ const decoder = new TextDecoder();
353
+ let text = "";
354
+ for (; ; ) {
355
+ const { done, value } = await reader.read();
356
+ if (done) break;
357
+ if (value && value.byteLength > 0) {
358
+ text += decoder.decode(value, { stream: true });
359
+ onChunk(value.byteLength);
360
+ }
361
+ }
362
+ text += decoder.decode();
363
+ return JSON.parse(text);
364
+ };
339
365
  var fetchConvMsgs = async (server, token, {
340
366
  dialogId,
341
367
  dialogKey,
@@ -344,9 +370,45 @@ var fetchConvMsgs = async (server, token, {
344
370
  }, options = {}) => {
345
371
  const { signal: externalSignal } = options;
346
372
  const controller = new AbortController();
347
- const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
373
+ const startedAt = now();
374
+ let phase = "connect";
375
+ let receivedBytes = 0;
376
+ let receivedChunks = 0;
377
+ let watchdogCause = null;
378
+ let connectTimer;
379
+ let stallTimer;
380
+ const clearConnectTimer = () => {
381
+ if (connectTimer !== void 0) {
382
+ clearTimeout(connectTimer);
383
+ connectTimer = void 0;
384
+ }
385
+ };
386
+ const clearStallTimer = () => {
387
+ if (stallTimer !== void 0) {
388
+ clearTimeout(stallTimer);
389
+ stallTimer = void 0;
390
+ }
391
+ };
392
+ const armStallTimer = () => {
393
+ clearStallTimer();
394
+ stallTimer = setTimeout(() => {
395
+ watchdogCause = "stall-timeout";
396
+ controller.abort();
397
+ }, FETCH_BUDGETS.stallMs);
398
+ };
399
+ const totalTimer = setTimeout(() => {
400
+ watchdogCause = "total-timeout";
401
+ controller.abort();
402
+ }, FETCH_BUDGETS.totalMs);
403
+ connectTimer = setTimeout(() => {
404
+ watchdogCause = "connect-timeout";
405
+ controller.abort();
406
+ }, FETCH_BUDGETS.connectMs);
348
407
  const onExternalAbort = () => controller.abort();
349
408
  externalSignal?.addEventListener("abort", onExternalAbort);
409
+ if (externalSignal?.aborted) {
410
+ controller.abort();
411
+ }
350
412
  try {
351
413
  const response = await fetch(`${server}/rpc/getConvMsgs`, {
352
414
  method: "POST",
@@ -362,22 +424,36 @@ var fetchConvMsgs = async (server, token, {
362
424
  }),
363
425
  signal: controller.signal
364
426
  });
365
- clearTimeout(timeoutId);
366
- externalSignal?.removeEventListener("abort", onExternalAbort);
427
+ phase = "body";
428
+ clearConnectTimer();
429
+ armStallTimer();
367
430
  if (!response.ok) {
368
431
  console.error(`fetchConvMsgs: Failed ${response.status} from ${server}`);
369
432
  return [];
370
433
  }
371
- const data = await response.json();
434
+ const data = await readJsonBody(response, (byteLength) => {
435
+ receivedBytes += byteLength;
436
+ receivedChunks += 1;
437
+ armStallTimer();
438
+ });
372
439
  return Array.isArray(data) ? data : [];
373
440
  } catch (error) {
374
- clearTimeout(timeoutId);
375
- externalSignal?.removeEventListener("abort", onExternalAbort);
376
441
  if (externalSignal?.aborted) {
377
442
  throw error;
378
443
  }
444
+ if (watchdogCause !== null) {
445
+ console.error(
446
+ `fetchConvMsgs: Error fetching from ${server}: ${watchdogCause} elapsedMs=${Math.round(now() - startedAt)} phase=${phase} receivedBytes=${receivedBytes} chunks=${receivedChunks} \u2014 internal watchdog abort, returning [] (NOT evidence of an empty history)`
447
+ );
448
+ return [];
449
+ }
379
450
  console.error(`fetchConvMsgs: Error fetching from ${server}:`, error);
380
451
  return [];
452
+ } finally {
453
+ clearConnectTimer();
454
+ clearStallTimer();
455
+ clearTimeout(totalTimer);
456
+ externalSignal?.removeEventListener("abort", onExternalAbort);
381
457
  }
382
458
  };
383
459
 
@@ -393,6 +469,25 @@ function swallowNonAbortError(promise, fallback, signal) {
393
469
  }
394
470
 
395
471
  // packages/chat/messages/fetchAndCacheMessages.ts
472
+ var sortByCreatedAtDesc = (a3, b2) => {
473
+ const aCreated = a3 && typeof a3 === "object" && "createdAt" in a3 ? a3.createdAt : void 0;
474
+ const bCreated = b2 && typeof b2 === "object" && "createdAt" in b2 ? b2.createdAt : void 0;
475
+ const tA = new Date(aCreated || 0).getTime();
476
+ const tB = new Date(bCreated || 0).getTime();
477
+ return tB - tA;
478
+ };
479
+ var mergeVisibleRecords = (seed, incoming) => {
480
+ const byId = /* @__PURE__ */ new Map();
481
+ const put = (m3) => {
482
+ if (!m3 || !m3.id) return;
483
+ const existing = byId.get(m3.id);
484
+ if (existing && !shouldReplaceWithNextRecord(m3, existing)) return;
485
+ byId.set(m3.id, m3);
486
+ };
487
+ seed.forEach(put);
488
+ incoming.forEach(put);
489
+ return Array.from(byId.values()).filter((message) => !isTombstoneRecord(message)).sort(sortByCreatedAtDesc);
490
+ };
396
491
  var fetchAndCacheMessagesLocalFirst = async ({
397
492
  db,
398
493
  dialogId,
@@ -411,24 +506,21 @@ var fetchAndCacheMessagesLocalFirst = async ({
411
506
  throwOnError: false,
412
507
  includeDeleted: true
413
508
  }).catch(() => []);
414
- const remotePromise = (async () => {
415
- if (!token || remoteServers.length === 0) return [];
416
- const results = await Promise.all(
417
- remoteServers.map(
418
- (server) => swallowNonAbortError(
419
- fetchConvMsgs(
420
- server,
421
- token,
422
- { dialogId, dialogKey, limit, beforeKey },
423
- { signal }
424
- ),
425
- [],
426
- void 0
427
- )
428
- )
429
- );
430
- return results.flat();
431
- })();
509
+ const serverPromises = token && remoteServers.length > 0 ? remoteServers.map(
510
+ (server) => swallowNonAbortError(
511
+ fetchConvMsgs(
512
+ server,
513
+ token,
514
+ { dialogId, dialogKey, limit, beforeKey },
515
+ { signal }
516
+ ),
517
+ [],
518
+ void 0
519
+ )
520
+ ) : [];
521
+ const remotePromise = Promise.all(serverPromises).then(
522
+ (results) => results.flat()
523
+ );
432
524
  let localSettledAt = null;
433
525
  const localTimingPromise = localPromise.then((value) => {
434
526
  localSettledAt = typeof performance !== "undefined" ? performance.now() : Date.now();
@@ -437,6 +529,30 @@ var fetchAndCacheMessagesLocalFirst = async ({
437
529
  const localMsgs = await localTimingPromise;
438
530
  const localMs = localSettledAt !== null ? Math.round(localSettledAt - startedAt) : null;
439
531
  const earlyReturned = localMsgs.length > 0;
532
+ const partialPromise = (async () => {
533
+ if (!token || remoteServers.length < 2) return [];
534
+ const primaryServerPromise = serverPromises[0];
535
+ if (!primaryServerPromise) return [];
536
+ try {
537
+ const [seedLocal, primaryMsgs] = await Promise.all([
538
+ localTimingPromise,
539
+ primaryServerPromise
540
+ ]);
541
+ if (signal?.aborted) return [];
542
+ if (!primaryMsgs || primaryMsgs.length === 0) return [];
543
+ const freshLocal = await fetchMessages(db, dialogId, {
544
+ limit,
545
+ beforeKey,
546
+ throwOnError: false,
547
+ includeDeleted: true
548
+ }).catch(() => []);
549
+ if (signal?.aborted) return [];
550
+ return mergeVisibleRecords(freshLocal, primaryMsgs);
551
+ } catch {
552
+ return [];
553
+ }
554
+ })();
555
+ const finalTombstonesById = /* @__PURE__ */ new Map();
440
556
  const remotePromiseWithMerge = (async () => {
441
557
  let remoteSettledAt = null;
442
558
  const remoteMsgs = await remotePromise.then((value) => {
@@ -461,6 +577,9 @@ var fetchAndCacheMessagesLocalFirst = async ({
461
577
  localMsgs.forEach((m3) => put(m3));
462
578
  freshLocalMsgs.forEach((m3) => put(m3));
463
579
  remoteMsgs.forEach((m3) => put(m3, true));
580
+ for (const [recordId, record] of uniqueMap) {
581
+ if (isTombstoneRecord(record)) finalTombstonesById.set(recordId, record);
582
+ }
464
583
  if (changedMessagesToCache.size > 0) {
465
584
  try {
466
585
  const ops = Array.from(changedMessagesToCache.values()).map((msg) => {
@@ -495,25 +614,23 @@ var fetchAndCacheMessagesLocalFirst = async ({
495
614
  hasToken: !!token,
496
615
  earlyReturned
497
616
  });
498
- return Array.from(uniqueMap.values()).filter((message) => !isTombstoneRecord(message)).sort((a3, b2) => {
499
- const aCreated = a3 && typeof a3 === "object" && "createdAt" in a3 ? a3.createdAt : void 0;
500
- const bCreated = b2 && typeof b2 === "object" && "createdAt" in b2 ? b2.createdAt : void 0;
501
- const tA = new Date(aCreated || 0).getTime();
502
- const tB = new Date(bCreated || 0).getTime();
503
- return tB - tA;
504
- });
617
+ return Array.from(uniqueMap.values()).filter((message) => !isTombstoneRecord(message)).sort(sortByCreatedAtDesc);
505
618
  })();
506
619
  if (!earlyReturned) {
507
620
  const mergedMessages = await remotePromiseWithMerge;
508
621
  return {
509
622
  localMessages: mergedMessages,
510
623
  remotePromise: Promise.resolve(mergedMessages),
624
+ partialPromise,
625
+ finalTombstonesById,
511
626
  earlyReturned: false
512
627
  };
513
628
  }
514
629
  return {
515
630
  localMessages: localMsgs,
516
631
  remotePromise: remotePromiseWithMerge,
632
+ partialPromise,
633
+ finalTombstonesById,
517
634
  earlyReturned: true
518
635
  };
519
636
  };
@@ -9834,9 +9951,21 @@ var messageSlice = createSliceWithThunks({
9834
9951
  }, thunkApi) => {
9835
9952
  const { db } = thunkApi.extra;
9836
9953
  const { getState, signal, dispatch } = thunkApi;
9954
+ const myInitRequestId = thunkApi.requestId;
9955
+ if (getMessageSession(dialogId).currentInitMsgsRequestId !== myInitRequestId) {
9956
+ patchMessageSession(dialogId, {
9957
+ currentInitMsgsRequestId: myInitRequestId
9958
+ });
9959
+ }
9837
9960
  const state = getState();
9838
9961
  const { currentToken: token, remoteServers } = getRuntimeServerContext(state);
9839
- const { localMessages, remotePromise, earlyReturned } = await fetchAndCacheMessagesLocalFirst({
9962
+ const {
9963
+ localMessages,
9964
+ remotePromise,
9965
+ partialPromise,
9966
+ finalTombstonesById,
9967
+ earlyReturned
9968
+ } = await fetchAndCacheMessagesLocalFirst({
9840
9969
  db,
9841
9970
  dialogId,
9842
9971
  dialogKey,
@@ -9854,11 +9983,72 @@ var messageSlice = createSliceWithThunks({
9854
9983
  isLoadingInitial: false
9855
9984
  })
9856
9985
  );
9986
+ const publishedIds = new Set(
9987
+ validLocalMessages.map((message) => message.id)
9988
+ );
9989
+ const backgroundAllowed = () => {
9990
+ if (signal?.aborted) return false;
9991
+ return getMessageSession(dialogId).currentInitMsgsRequestId === myInitRequestId;
9992
+ };
9993
+ let reconcileApplied = false;
9994
+ const currentEntities = () => {
9995
+ const rootState = getState();
9996
+ const sliceState = rootState?.message ?? rootState;
9997
+ try {
9998
+ return getMessageDialogState(sliceState, dialogId)?.msgs?.entities ?? {};
9999
+ } catch {
10000
+ return {};
10001
+ }
10002
+ };
10003
+ if (partialPromise) {
10004
+ partialPromise.then((partialMessages) => {
10005
+ if (reconcileApplied || !backgroundAllowed()) return;
10006
+ const validPartial = partialMessages.filter(isValidMessage);
10007
+ if (validPartial.length === 0) return;
10008
+ const entities = currentEntities();
10009
+ const additions = validPartial.filter(
10010
+ (message) => !entities[message.id]
10011
+ );
10012
+ if (additions.length === 0) return;
10013
+ additions.forEach((message) => publishedIds.add(message.id));
10014
+ dispatch(
10015
+ messageActions.setMessages({
10016
+ dialogId,
10017
+ messages: additions
10018
+ })
10019
+ );
10020
+ }).catch((err) => {
10021
+ console.error("[initMsgs] early source view failed:", err);
10022
+ });
10023
+ }
9857
10024
  remotePromise.then((finalMessages2) => {
10025
+ if (!backgroundAllowed()) return;
10026
+ reconcileApplied = true;
10027
+ const validFinalMessages = finalMessages2.filter(isValidMessage);
10028
+ const finalIds = new Set(
10029
+ validFinalMessages.map((message) => message.id)
10030
+ );
10031
+ const entities = currentEntities();
10032
+ const removedIds = [...publishedIds].filter((id) => {
10033
+ if (finalIds.has(id)) return false;
10034
+ const tombstone = finalTombstonesById?.get?.(id);
10035
+ if (!tombstone) return false;
10036
+ const current = entities[id];
10037
+ if (!current) return false;
10038
+ return shouldReplaceWithNextRecord(tombstone, current) && getTombstoneTimestamp(tombstone) >= getRecordTimestamp(current);
10039
+ });
10040
+ if (removedIds.length > 0) {
10041
+ dispatch(
10042
+ messageActions.removeMessagesByIds({
10043
+ dialogId,
10044
+ ids: removedIds
10045
+ })
10046
+ );
10047
+ }
9858
10048
  dispatch(
9859
10049
  messageActions.setMessages({
9860
10050
  dialogId,
9861
- messages: finalMessages2.filter(isValidMessage)
10051
+ messages: validFinalMessages
9862
10052
  })
9863
10053
  );
9864
10054
  }).catch((err) => {
@@ -9900,7 +10090,6 @@ var messageSlice = createSliceWithThunks({
9900
10090
  }
9901
10091
  const limit = action2.meta.arg.limit;
9902
10092
  patchMessageSession(dialogId, {
9903
- currentInitMsgsRequestId: void 0,
9904
10093
  isLoadingInitial: false,
9905
10094
  hasMoreOlder: resolveInitMsgsHasMoreOlder({
9906
10095
  limit,
@@ -9931,13 +10120,11 @@ var messageSlice = createSliceWithThunks({
9931
10120
  }
9932
10121
  if (action2.meta?.aborted) {
9933
10122
  patchMessageSession(dialogId, {
9934
- currentInitMsgsRequestId: void 0,
9935
10123
  isLoadingInitial: false
9936
10124
  });
9937
10125
  return;
9938
10126
  }
9939
10127
  patchMessageSession(dialogId, {
9940
- currentInitMsgsRequestId: void 0,
9941
10128
  isLoadingInitial: false,
9942
10129
  error: action2.error instanceof Error ? action2.error : new Error(String(action2.error))
9943
10130
  });
@@ -10332,7 +10519,7 @@ var messageSlice = createSliceWithThunks({
10332
10519
  runtimeOptions: args.runtimeOptions
10333
10520
  });
10334
10521
  if (agentKeyToUse) {
10335
- const { streamAgentChatTurn } = await import("./agentSlice-V2EDVUXC.js");
10522
+ const { streamAgentChatTurn } = await import("./agentSlice-6ON6SBOW.js");
10336
10523
  await dispatch(
10337
10524
  streamAgentChatTurn({
10338
10525
  agentKey: agentKeyToUse,
@@ -13015,7 +13202,7 @@ var deleteOwnedDialogAttachments = async (args) => {
13015
13202
  metadataReadFailures
13016
13203
  });
13017
13204
  if (!plan.deleteCandidates.length) return plan;
13018
- const { deleteFileAction } = await import("./deleteFile-HG4BF3CS.js");
13205
+ const { deleteFileAction } = await import("./deleteFile-AJ2EZMHT.js");
13019
13206
  for (const candidate of plan.deleteCandidates) {
13020
13207
  if (candidate.fileDbKey) {
13021
13208
  await deleteFileAction(candidate.fileDbKey, args.thunkApi);
@@ -13077,7 +13264,7 @@ var deleteDialogThunk = async (payload, thunkApi) => {
13077
13264
  }
13078
13265
  if (isCurrentDialog) {
13079
13266
  await thunkApi.dispatch(resetMsgs());
13080
- const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-M7ZWTW5D.js");
13267
+ const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-34DUPW5Z.js");
13081
13268
  dispatch(clearPendingAttachments2());
13082
13269
  }
13083
13270
  return { dialogKey, isCurrentDialog, attachmentPlan };
@@ -13085,39 +13272,39 @@ var deleteDialogThunk = async (payload, thunkApi) => {
13085
13272
 
13086
13273
  // packages/chat/dialog/dialogSlice.ts
13087
13274
  var runCreateDialogAction = async (args, thunkApi) => {
13088
- const { createDialogAction } = await import("./createDialogAction-L3WMTD5Z.js");
13275
+ const { createDialogAction } = await import("./createDialogAction-YWNYTXXK.js");
13089
13276
  return createDialogAction(args, thunkApi);
13090
13277
  };
13091
13278
  var runCreateAgentAutomationAction = async (args, thunkApi) => {
13092
- const { createAgentAutomationAction } = await import("./createAgentAutomationAction-OW4WEVHP.js");
13279
+ const { createAgentAutomationAction } = await import("./createAgentAutomationAction-W42UXDBD.js");
13093
13280
  return createAgentAutomationAction(args, thunkApi);
13094
13281
  };
13095
13282
  var runUpdateDialogTitleAction = async (args, thunkApi) => {
13096
- const { updateDialogTitleAction } = await import("./updateDialogTitleAction-GBUSLAQR.js");
13283
+ const { updateDialogTitleAction } = await import("./updateDialogTitleAction-Z7OREKH3.js");
13097
13284
  return updateDialogTitleAction(args, thunkApi);
13098
13285
  };
13099
13286
  var runAddDialogAgentAction = async (args, thunkApi) => {
13100
- const { addDialogAgentAction } = await import("./addDialogAgentAction-6SGG37BF.js");
13287
+ const { addDialogAgentAction } = await import("./addDialogAgentAction-IODCR6TB.js");
13101
13288
  return addDialogAgentAction(args, thunkApi);
13102
13289
  };
13103
13290
  var runRemoveDialogAgentAction = async (args, thunkApi) => {
13104
- const { removeDialogAgentAction } = await import("./removeDialogAgentAction-CT5HGRZH.js");
13291
+ const { removeDialogAgentAction } = await import("./removeDialogAgentAction-46XQV5Q7.js");
13105
13292
  return removeDialogAgentAction(args, thunkApi);
13106
13293
  };
13107
13294
  var runSetPrimaryDialogAgentAction = async (args, thunkApi) => {
13108
- const { setPrimaryDialogAgentAction } = await import("./setPrimaryDialogAgentAction-MHWOGXP3.js");
13295
+ const { setPrimaryDialogAgentAction } = await import("./setPrimaryDialogAgentAction-UHHV2QZW.js");
13109
13296
  return setPrimaryDialogAgentAction(args, thunkApi);
13110
13297
  };
13111
13298
  var runSwitchDialogAgentAction = async (args, thunkApi) => {
13112
- const { switchDialogAgentAction } = await import("./switchDialogAgentAction-JHA4JEYA.js");
13299
+ const { switchDialogAgentAction } = await import("./switchDialogAgentAction-A2TMVGAE.js");
13113
13300
  return switchDialogAgentAction(args, thunkApi);
13114
13301
  };
13115
13302
  var runSetDialogExtraReferencesAction = async (args, thunkApi) => {
13116
- const { setDialogExtraReferencesAction } = await import("./setDialogExtraReferencesAction-JOENKFTX.js");
13303
+ const { setDialogExtraReferencesAction } = await import("./setDialogExtraReferencesAction-J4V5ADQF.js");
13117
13304
  return setDialogExtraReferencesAction(args, thunkApi);
13118
13305
  };
13119
13306
  var runHandleSendMessageAction = async (args, thunkApi) => {
13120
- const { handleSendMessageAction } = await import("./handleSendMessageAction-KMPC6UD4.js");
13307
+ const { handleSendMessageAction } = await import("./handleSendMessageAction-5XCHOMQH.js");
13121
13308
  return handleSendMessageAction(args, thunkApi);
13122
13309
  };
13123
13310
  function clearDialogState() {
@@ -13130,7 +13317,7 @@ var createPageAndAddReference = createAsyncThunk(
13130
13317
  async (payload, { dispatch, getState, rejectWithValue }) => {
13131
13318
  const { slateData, jsonData, title, type, fileId, groupId, dialogKey } = payload;
13132
13319
  try {
13133
- const { createDocState } = await import("./docStore-IX7ASJUP.js");
13320
+ const { createDocState } = await import("./docStore-FAQ6XUUA.js");
13134
13321
  const pageKey = await createDocState(
13135
13322
  { slateData, title },
13136
13323
  { dispatch, getState }
@@ -28,11 +28,11 @@ import {
28
28
  stablePromptCacheKey,
29
29
  toOpenAiCompatibleMessages,
30
30
  toResponsesTools
31
- } from "./chunk-PUOC4YRO.js";
31
+ } from "./chunk-M7VLQGQP.js";
32
32
  import {
33
33
  isMeaningfulChatCompletionOutput,
34
34
  isMeaningfulResponsesOutput
35
- } from "./chunk-WS2VEVHS.js";
35
+ } from "./chunk-7MMSLEPA.js";
36
36
  import {
37
37
  clipCompactText
38
38
  } from "./chunk-5MMAK75Q.js";
@@ -463,6 +463,12 @@ async function resolvePlatformChatProviderConfig(args) {
463
463
  };
464
464
  }
465
465
  function buildPlatformChatCompletionRequest(args) {
466
+ if (!args.providerConfig.authToken?.trim()) {
467
+ throw Object.assign(
468
+ new Error("desktop platform provider failed: AUTH_NO_TOKEN"),
469
+ { code: "AUTH_NO_TOKEN", authCode: "AUTH_NO_TOKEN", stage: "provider" }
470
+ );
471
+ }
466
472
  const usesResponsesApi = isResponsesEndpoint(args.providerConfig.endpoint);
467
473
  const requestOptions = usesResponsesApi ? toResponsesRequestOptions(args.providerConfig.requestOptions) : args.providerConfig.requestOptions;
468
474
  const shouldStripReasoning = shouldStripReasoningContentForOutbound(
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  clearCliLocalRuntimePreparedAgentCache
3
- } from "./chunk-QNTL2KFU.js";
3
+ } from "./chunk-XEALKKFF.js";
4
4
  import {
5
5
  getReadableCliDb
6
- } from "./chunk-EMQZSES6.js";
6
+ } from "./chunk-LOCNXNOU.js";
7
7
  import {
8
8
  buildCreatedAgentRecord,
9
9
  buildUpdatedAgentRecord,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  toolRegistry
3
- } from "./chunk-ZGNDLCYH.js";
3
+ } from "./chunk-TQE6BVFT.js";
4
4
  import {
5
5
  runtime_default
6
- } from "./chunk-BS7YHAQP.js";
6
+ } from "./chunk-UWVGKNAL.js";
7
7
  import {
8
8
  canonicalizeToolNames
9
9
  } from "./chunk-XUWRURDF.js";