@gkorepanov/ccodex 0.4.14 → 0.4.15

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "productVersion": "0.4.14",
3
+ "productVersion": "0.4.15",
4
4
  "node": ">=22.13 <27",
5
5
  "codexCli": "0.146.0",
6
6
  "codexGitRevision": "be449751a978f02e5bbba886999662956c7f38f5",
@@ -173,6 +173,8 @@ export declare class ClaudeSession implements ClaudeSessionHandle<ClaudeSessionC
173
173
  private providerCallbackContext;
174
174
  private providerInteractionOwner;
175
175
  private applyProviderMainStream;
176
+ private applyProviderToolInput;
177
+ private finishProviderToolInput;
176
178
  private canUseProviderTool;
177
179
  private askProviderUser;
178
180
  private handleProviderElicitation;
@@ -27,6 +27,7 @@ import { StaleClaudeRuntimeSettingsError, createProviderRuntime, providerPermiss
27
27
  import { isRetryableClaudeRuntimeStartupError, } from "./providerRuntime.js";
28
28
  import { assistantHasTools, backgroundOutputFile, backgroundTaskId, isNoQueryAcknowledgement, serverToolResult, toolResults, } from "./providerFacts.js";
29
29
  import { normalizeClaudeModelIdentifier } from "../modelSelection.js";
30
+ import { StreamingFileChangePreview } from "../streamingFilePreview.js";
30
31
  const nullSource = { providerEventId: null, providerEventType: null };
31
32
  const providerJournalMaxEvents = 20_000;
32
33
  const providerJournalMaxBytes = 256 * 1_024 * 1_024;
@@ -594,6 +595,7 @@ export class ClaudeSession {
594
595
  const projection = {
595
596
  context: new AsyncLocalStorage(),
596
597
  processEpoch: uuidv7(),
598
+ filePreviews: new Map(),
597
599
  providerSequence: 0,
598
600
  };
599
601
  try {
@@ -1762,6 +1764,37 @@ export class ClaudeSession {
1762
1764
  fact,
1763
1765
  });
1764
1766
  }
1767
+ async applyProviderToolInput(projection, runtimeGeneration, index, delta, ownerThreadId = this.threadId) {
1768
+ const projected = await this.applyProviderMainStream(projection, runtimeGeneration, {
1769
+ kind: "toolInput", index, delta,
1770
+ }, ownerThreadId);
1771
+ const tool = projected?.tool;
1772
+ if (tool?.name !== "Write" && tool?.name !== "Edit")
1773
+ return;
1774
+ const key = `${ownerThreadId}\0${index}`;
1775
+ let state = projection.filePreviews.get(key);
1776
+ if (!state) {
1777
+ state = { providerId: tool.providerId, preview: new StreamingFileChangePreview(tool.name, tool.cwd) };
1778
+ projection.filePreviews.set(key, state);
1779
+ }
1780
+ const change = await state.preview.push(delta);
1781
+ if (change)
1782
+ await this.applyProviderMainStream(projection, runtimeGeneration, {
1783
+ kind: "toolFiles", providerId: state.providerId, changes: [change],
1784
+ }, ownerThreadId);
1785
+ }
1786
+ async finishProviderToolInput(projection, runtimeGeneration, index, ownerThreadId = this.threadId) {
1787
+ const key = `${ownerThreadId}\0${index}`;
1788
+ const state = projection.filePreviews.get(key);
1789
+ if (!state)
1790
+ return;
1791
+ projection.filePreviews.delete(key);
1792
+ const change = await state.preview.finish();
1793
+ if (change)
1794
+ await this.applyProviderMainStream(projection, runtimeGeneration, {
1795
+ kind: "toolFiles", providerId: state.providerId, changes: [change],
1796
+ }, ownerThreadId);
1797
+ }
1765
1798
  async canUseProviderTool(projection, runtimeGeneration, name, input, options) {
1766
1799
  const context = await this.providerCallbackContext(runtimeGeneration);
1767
1800
  if (!context)
@@ -2183,15 +2216,12 @@ export class ClaudeSession {
2183
2216
  }, childThreadId);
2184
2217
  }
2185
2218
  else if (event.delta.type === "input_json_delta") {
2186
- await this.applyProviderMainStream(projection, runtimeGeneration, {
2187
- kind: "toolInput",
2188
- index: event.index,
2189
- delta: event.delta.partial_json,
2190
- }, childThreadId);
2219
+ await this.applyProviderToolInput(projection, runtimeGeneration, event.index, event.delta.partial_json, childThreadId);
2191
2220
  }
2192
2221
  return;
2193
2222
  }
2194
2223
  if (event.type === "content_block_stop") {
2224
+ await this.finishProviderToolInput(projection, runtimeGeneration, event.index, childThreadId);
2195
2225
  await this.applyProviderMainStream(projection, runtimeGeneration, { kind: "blockStop", index: event.index }, childThreadId);
2196
2226
  }
2197
2227
  }
@@ -2510,15 +2540,12 @@ export class ClaudeSession {
2510
2540
  });
2511
2541
  }
2512
2542
  else if (event.delta.type === "input_json_delta") {
2513
- await this.applyProviderMainStream(projection, runtimeGeneration, {
2514
- kind: "toolInput",
2515
- index: event.index,
2516
- delta: event.delta.partial_json,
2517
- });
2543
+ await this.applyProviderToolInput(projection, runtimeGeneration, event.index, event.delta.partial_json);
2518
2544
  }
2519
2545
  return;
2520
2546
  }
2521
2547
  if (event.type === "content_block_stop") {
2548
+ await this.finishProviderToolInput(projection, runtimeGeneration, event.index);
2522
2549
  await this.applyProviderMainStream(projection, runtimeGeneration, { kind: "blockStop", index: event.index });
2523
2550
  }
2524
2551
  }