remote-codex 0.1.8 → 0.1.9

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.
@@ -10711,7 +10711,7 @@ function deferLargeHistoryItemDetails(turn, deferredDetails) {
10711
10711
  };
10712
10712
  }
10713
10713
  function shouldPersistLiveHistoryItem(item) {
10714
- return item.kind === "commandExecution" || item.kind === "fileChange" || item.kind === "hook" || item.kind === "toolCall" || item.kind === "webSearch";
10714
+ return item.kind === "agentMessage" || item.kind === "commandExecution" || item.kind === "fileChange" || item.kind === "hook" || item.kind === "toolCall" || item.kind === "webSearch";
10715
10715
  }
10716
10716
  function parseStoredHistoryItem(value) {
10717
10717
  try {
@@ -10795,10 +10795,10 @@ function sortTurnItemsByRecordedSequence(items) {
10795
10795
  }
10796
10796
  function mergeHistoryItemsBySequence(items, missingItems) {
10797
10797
  if (missingItems.length === 0) {
10798
- return items;
10798
+ return sortTurnItemsByRecordedSequence(items);
10799
10799
  }
10800
10800
  if (!missingItems.some(hasHistoryItemSequence)) {
10801
- return [...items, ...missingItems];
10801
+ return sortTurnItemsByRecordedSequence([...items, ...missingItems]);
10802
10802
  }
10803
10803
  const mergedItems = [...items];
10804
10804
  const orderedMissingItems = sortHistoryItemsBySequence(missingItems);
@@ -10823,16 +10823,20 @@ function mergeHistoryItemsBySequence(items, missingItems) {
10823
10823
  }
10824
10824
  mergedItems.push(missingItem);
10825
10825
  }
10826
- return mergedItems;
10826
+ return sortTurnItemsByRecordedSequence(mergedItems);
10827
+ }
10828
+ function copyPersistedSequence(item, persistedItem) {
10829
+ if (!hasHistoryItemSequence(persistedItem)) {
10830
+ return item;
10831
+ }
10832
+ const sequence = historyItemSequence(persistedItem);
10833
+ return item.sequence === sequence ? item : { ...item, sequence };
10827
10834
  }
10828
10835
  function mergePersistedHistoryItemsIntoTurns(turns, persistedItemsByTurnId, deferredDetails) {
10829
10836
  if (persistedItemsByTurnId.size === 0) {
10830
10837
  return turns;
10831
10838
  }
10832
10839
  return turns.map((turn) => {
10833
- if (turn.status === "inProgress") {
10834
- return turn;
10835
- }
10836
10840
  const persistedItems = persistedItemsByTurnId.get(turn.id);
10837
10841
  if (!persistedItems || persistedItems.length === 0) {
10838
10842
  return turn;
@@ -10841,23 +10845,32 @@ function mergePersistedHistoryItemsIntoTurns(turns, persistedItemsByTurnId, defe
10841
10845
  const persistedItemsById = new Map(persistedItems.map((item) => [item.id, item]));
10842
10846
  const nextItems = turn.items.map((item) => {
10843
10847
  const persistedItem = persistedItemsById.get(item.id);
10844
- if (!persistedItem || item.kind !== persistedItem.kind || persistedItem.kind !== "commandExecution" && persistedItem.kind !== "toolCall") {
10848
+ if (!persistedItem) {
10845
10849
  return item;
10846
10850
  }
10847
- const existingText = item.detailText?.trim() || item.text.trim();
10848
- const persistedText = persistedItem.detailText?.trim() || persistedItem.text.trim();
10849
- if (persistedText.length <= existingText.length) {
10851
+ persistedItemsById.delete(item.id);
10852
+ if (item.kind !== persistedItem.kind) {
10850
10853
  return item;
10851
10854
  }
10852
- changed = true;
10853
- persistedItemsById.delete(item.id);
10854
- return persistedItem.kind === "commandExecution" ? deferCommandHistoryItem2(
10855
- persistedItem,
10856
- deferredDetails
10857
- ) : deferToolCallHistoryItem2(
10858
- persistedItem,
10859
- deferredDetails
10860
- );
10855
+ const sequencedItem = copyPersistedSequence(item, persistedItem);
10856
+ if (sequencedItem !== item) {
10857
+ changed = true;
10858
+ }
10859
+ if (persistedItem.kind === "commandExecution" || persistedItem.kind === "toolCall") {
10860
+ const existingText = item.detailText?.trim() || item.text.trim();
10861
+ const persistedText = persistedItem.detailText?.trim() || persistedItem.text.trim();
10862
+ if (persistedText.length > existingText.length) {
10863
+ changed = true;
10864
+ return persistedItem.kind === "commandExecution" ? deferCommandHistoryItem2(
10865
+ persistedItem,
10866
+ deferredDetails
10867
+ ) : deferToolCallHistoryItem2(
10868
+ persistedItem,
10869
+ deferredDetails
10870
+ );
10871
+ }
10872
+ }
10873
+ return sequencedItem;
10861
10874
  });
10862
10875
  const existingItemIds = new Set(nextItems.map((item) => item.id));
10863
10876
  const missingItems = [...persistedItemsById.values()].filter((item) => !existingItemIds.has(item.id)).map(
@@ -13587,10 +13600,22 @@ var ThreadService = class {
13587
13600
  if (!record) {
13588
13601
  return;
13589
13602
  }
13590
- this.recordTurnItemOrder(record.id, event.providerTurnId, event.itemId);
13603
+ const sequence = this.recordTurnItemOrder(
13604
+ record.id,
13605
+ event.providerTurnId,
13606
+ event.itemId
13607
+ );
13608
+ this.appendLiveAgentMessageDelta(
13609
+ record.id,
13610
+ event.providerTurnId,
13611
+ event.itemId,
13612
+ event.delta,
13613
+ sequence
13614
+ );
13591
13615
  this.emitThreadEvent("thread.output.delta", record.id, {
13592
13616
  turnId: event.providerTurnId,
13593
13617
  itemId: event.itemId,
13618
+ sequence,
13594
13619
  delta: event.delta
13595
13620
  });
13596
13621
  return;
@@ -13833,6 +13858,30 @@ var ThreadService = class {
13833
13858
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
13834
13859
  });
13835
13860
  }
13861
+ appendLiveAgentMessageDelta(localThreadId, turnId, itemId, delta, sequence) {
13862
+ const current = this.threadLiveItems.get(localThreadId);
13863
+ const currentItems = current?.turnId === turnId ? current.items : [];
13864
+ const existing = currentItems.find((entry) => entry.id === itemId);
13865
+ const nextItem = existing?.kind === "agentMessage" ? {
13866
+ ...existing,
13867
+ text: `${existing.text}${delta}`,
13868
+ sequence
13869
+ } : {
13870
+ id: itemId,
13871
+ kind: "agentMessage",
13872
+ text: delta,
13873
+ sequence
13874
+ };
13875
+ this.persistLiveHistoryItem(localThreadId, turnId, nextItem);
13876
+ this.setLiveItems(localThreadId, {
13877
+ turnId,
13878
+ items: sortHistoryItemsBySequence([
13879
+ ...currentItems.filter((entry) => entry.id !== itemId),
13880
+ nextItem
13881
+ ]),
13882
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
13883
+ });
13884
+ }
13836
13885
  async toThreadHooksDto(provider, workspacePath, entry, fallbackWarnings = []) {
13837
13886
  const { globalHooksPath, projectHooksPath } = this.codexManagement.hooksPaths(workspacePath);
13838
13887
  const officialHooks = (entry?.hooks ?? []).map((hook) => ({
@@ -13893,11 +13942,17 @@ var ThreadService = class {
13893
13942
  return null;
13894
13943
  }
13895
13944
  const matchingTurn = turns.find((turn) => turn.id === current.turnId);
13896
- const materializedItemIds = new Set(
13897
- matchingTurn?.items.map((item) => item.id) ?? []
13945
+ const materializedItemsById = new Map(
13946
+ matchingTurn?.items.map((item) => [item.id, item]) ?? []
13898
13947
  );
13899
13948
  const nextItems = current.items.filter(
13900
- (item) => !materializedItemIds.has(item.id)
13949
+ (item) => {
13950
+ const materializedItem = materializedItemsById.get(item.id);
13951
+ if (!materializedItem) {
13952
+ return true;
13953
+ }
13954
+ return typeof item.sequence === "number" && Number.isFinite(item.sequence) && materializedItem.sequence !== item.sequence;
13955
+ }
13901
13956
  );
13902
13957
  if (nextItems.length === current.items.length) {
13903
13958
  return current;
@@ -1 +1 @@
1
- import{r,R as x,L as d,j as f,A as p}from"./index-CrcX157r.js";var N=({code:i,language:e,raw:a,className:u,startLine:n,lineNumbers:g,...m})=>{let{shikiTheme:l}=r.useContext(x),s=d(),[h,t]=r.useState(a);return r.useEffect(()=>{if(!s){t(a);return}let o=s.highlight({code:i,language:e,themes:l},c=>{t(c)});o&&t(o)},[i,e,l,s,a]),f.jsx(p,{className:u,language:e,lineNumbers:g,result:h,startLine:n,...m})};export{N as HighlightedCodeBlockBody};
1
+ import{r,R as x,L as d,j as f,A as p}from"./index-Rd2EBQac.js";var N=({code:i,language:e,raw:a,className:u,startLine:n,lineNumbers:g,...m})=>{let{shikiTheme:l}=r.useContext(x),s=d(),[h,t]=r.useState(a);return r.useEffect(()=>{if(!s){t(a);return}let o=s.highlight({code:i,language:e,themes:l},c=>{t(c)});o&&t(o)},[i,e,l,s,a]),f.jsx(p,{className:u,language:e,lineNumbers:g,result:h,startLine:n,...m})};export{N as HighlightedCodeBlockBody};