@everme/codex 0.6.3 → 0.6.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everme/codex",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "type": "module",
5
5
  "description": "Native EverMe lifecycle hooks for Codex.",
6
6
  "license": "Apache-2.0",
@@ -40,7 +40,7 @@
40
40
  "registry": "https://registry.npmjs.org"
41
41
  },
42
42
  "dependencies": {
43
- "@everme/agent-sdk": "^0.6.3"
43
+ "@everme/agent-sdk": "^0.6.4"
44
44
  },
45
45
  "devDependencies": {
46
46
  "esbuild": "^0.28.1"
@@ -1,6 +1,7 @@
1
1
  import { readFile, readdir } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { readCanonicalTranscript, readLastTurn } from "./transcript.js";
4
+ import { turnOrdinals } from "@everme/agent-sdk";
4
5
 
5
6
  export async function readCodexStoreBatches(input, { checkpointStore } = {}) {
6
7
  if (!input?.sessionId || !input?.transcriptPath) return [];
@@ -31,16 +32,24 @@ async function transcriptBatch({ checkpointStore, conversationId, initialTailOnl
31
32
  const checkpoint = checkpointStore
32
33
  ? await checkpointStore.read(stateId)
33
34
  : { initialized: false, uploadedCount: 0 };
34
- let messages;
35
- if (checkpoint.initialized && checkpoint.uploadedCount <= canonical.length) {
36
- messages = canonical.slice(checkpoint.uploadedCount);
37
- } else {
38
- messages = initialTailOnly ? await readLastTurn(transcriptPath) : canonical;
39
- }
35
+ const continuation = checkpoint.initialized && checkpoint.uploadedCount <= canonical.length;
36
+ const messages = continuation
37
+ ? canonical.slice(checkpoint.uploadedCount)
38
+ : (initialTailOnly ? await readLastTurn(transcriptPath) : canonical);
40
39
  if (!messages.length) return null;
41
40
  return {
42
41
  conversationId,
43
42
  messages,
43
+ // Address by absolute turn only when everything before the slice is
44
+ // known to be covered: a checkpoint continuation, or the whole canonical
45
+ // transcript. A cold-start tail must not claim the turns it skipped, or
46
+ // the importer would trim the history it still has to bring in; left
47
+ // unaddressed, the gate appends it at the current watermark instead.
48
+ ...((continuation || messages.length === canonical.length) && messages.length <= canonical.length
49
+ ? { baseTurn: turnOrdinals(canonical)[canonical.length - messages.length] }
50
+ // A cold-start tail declares no completed turn either, so the gate
51
+ // neither positions nor appends it (see the claude-code adapter).
52
+ : { turns: 0 }),
44
53
  checkpoint: { stateId, uploadedCount: canonical.length },
45
54
  };
46
55
  }