@theokit/sdk 4.39.2 → 4.39.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/{agent-TOWHPM7B.cjs → agent-DB245YMC.cjs} +9 -9
  3. package/dist/{agent-TOWHPM7B.cjs.map → agent-DB245YMC.cjs.map} +1 -1
  4. package/dist/{agent-KGKKAGXY.js → agent-UNWZCXBS.js} +8 -8
  5. package/dist/{agent-KGKKAGXY.js.map → agent-UNWZCXBS.js.map} +1 -1
  6. package/dist/{chunk-AFJAQ5JV.js → chunk-23HI77BZ.js} +8 -3
  7. package/dist/chunk-23HI77BZ.js.map +1 -0
  8. package/dist/{chunk-RTDT2UMT.js → chunk-5VKUZ26Q.js} +22 -7
  9. package/dist/chunk-5VKUZ26Q.js.map +1 -0
  10. package/dist/{chunk-TZ47DTM2.cjs → chunk-KV3HR7KL.cjs} +5 -5
  11. package/dist/{chunk-TZ47DTM2.cjs.map → chunk-KV3HR7KL.cjs.map} +1 -1
  12. package/dist/{chunk-Z5DYGBPV.cjs → chunk-N4JNY5DT.cjs} +3 -3
  13. package/dist/{chunk-Z5DYGBPV.cjs.map → chunk-N4JNY5DT.cjs.map} +1 -1
  14. package/dist/{chunk-7HP6N5X3.js → chunk-ONVIALVV.js} +3 -3
  15. package/dist/{chunk-7HP6N5X3.js.map → chunk-ONVIALVV.js.map} +1 -1
  16. package/dist/{chunk-MDN44YMZ.js → chunk-P3ZVI46Y.js} +3 -3
  17. package/dist/{chunk-MDN44YMZ.js.map → chunk-P3ZVI46Y.js.map} +1 -1
  18. package/dist/{chunk-LR3VKB7A.cjs → chunk-SEWAPWAF.cjs} +20 -20
  19. package/dist/{chunk-LR3VKB7A.cjs.map → chunk-SEWAPWAF.cjs.map} +1 -1
  20. package/dist/{chunk-ERBH54V3.js → chunk-SGGH3B2W.js} +10 -10
  21. package/dist/{chunk-ERBH54V3.js.map → chunk-SGGH3B2W.js.map} +1 -1
  22. package/dist/{chunk-AYDSWY35.cjs → chunk-SHQEZ6Q2.cjs} +55 -55
  23. package/dist/{chunk-AYDSWY35.cjs.map → chunk-SHQEZ6Q2.cjs.map} +1 -1
  24. package/dist/{chunk-UDSGSPUY.cjs → chunk-T6KFGMNY.cjs} +9 -4
  25. package/dist/chunk-T6KFGMNY.cjs.map +1 -0
  26. package/dist/{chunk-MWVLE5RY.cjs → chunk-WMWZAJMJ.cjs} +5 -5
  27. package/dist/{chunk-MWVLE5RY.cjs.map → chunk-WMWZAJMJ.cjs.map} +1 -1
  28. package/dist/{chunk-RMO7HAIF.js → chunk-X627TO3A.js} +3 -3
  29. package/dist/{chunk-RMO7HAIF.js.map → chunk-X627TO3A.js.map} +1 -1
  30. package/dist/{chunk-7WXT5M6P.js → chunk-XRKFWV7K.js} +3 -3
  31. package/dist/{chunk-7WXT5M6P.js.map → chunk-XRKFWV7K.js.map} +1 -1
  32. package/dist/{chunk-JERO4TP6.cjs → chunk-ZVQJHY4Y.cjs} +22 -7
  33. package/dist/chunk-ZVQJHY4Y.cjs.map +1 -0
  34. package/dist/{compact-session-KPYRNTQN.js → compact-session-AZU2LEAE.js} +4 -4
  35. package/dist/{compact-session-KPYRNTQN.js.map → compact-session-AZU2LEAE.js.map} +1 -1
  36. package/dist/{compact-session-FCEFK2CG.cjs → compact-session-TRCEYCPG.cjs} +12 -12
  37. package/dist/{compact-session-FCEFK2CG.cjs.map → compact-session-TRCEYCPG.cjs.map} +1 -1
  38. package/dist/cron.cjs +8 -8
  39. package/dist/cron.js +7 -7
  40. package/dist/eval.cjs +11 -11
  41. package/dist/eval.js +7 -7
  42. package/dist/fs-session-store-I6GUIFRO.js +10 -0
  43. package/dist/{fs-session-store-YPZIOLJM.js.map → fs-session-store-I6GUIFRO.js.map} +1 -1
  44. package/dist/{fs-session-store-V32XJ63Z.cjs → fs-session-store-KRZZIG3O.cjs} +5 -5
  45. package/dist/{fs-session-store-V32XJ63Z.cjs.map → fs-session-store-KRZZIG3O.cjs.map} +1 -1
  46. package/dist/index.cjs +38 -38
  47. package/dist/index.js +9 -9
  48. package/dist/{inject-session-BIVVFWGL.cjs → inject-session-BVSERZCI.cjs} +4 -4
  49. package/dist/{inject-session-BIVVFWGL.cjs.map → inject-session-BVSERZCI.cjs.map} +1 -1
  50. package/dist/{inject-session-OLWZ2NJN.js → inject-session-E75EP3LL.js} +3 -3
  51. package/dist/{inject-session-OLWZ2NJN.js.map → inject-session-E75EP3LL.js.map} +1 -1
  52. package/dist/internal/persistence/index.cjs +6 -6
  53. package/dist/internal/persistence/index.js +1 -1
  54. package/dist/models.cjs +9 -9
  55. package/dist/models.js +1 -1
  56. package/dist/persistence.cjs +6 -6
  57. package/dist/persistence.js +1 -1
  58. package/package.json +1 -1
  59. package/dist/chunk-AFJAQ5JV.js.map +0 -1
  60. package/dist/chunk-JERO4TP6.cjs.map +0 -1
  61. package/dist/chunk-RTDT2UMT.js.map +0 -1
  62. package/dist/chunk-UDSGSPUY.cjs.map +0 -1
  63. package/dist/fs-session-store-YPZIOLJM.js +0 -10
@@ -1,6 +1,6 @@
1
1
  import { acquireSessionWriter } from './chunk-LWVKI75U.js';
2
2
  import { readTranscript, transcriptPath } from './chunk-EYUZZXHZ.js';
3
- import { withFileLock, appendJsonl } from './chunk-RTDT2UMT.js';
3
+ import { withFileLock, appendJsonl } from './chunk-5VKUZ26Q.js';
4
4
  import { mkdir } from 'fs/promises';
5
5
  import { dirname } from 'path';
6
6
 
@@ -106,5 +106,5 @@ var FsSessionStore = class {
106
106
  };
107
107
 
108
108
  export { FsSessionStore };
109
- //# sourceMappingURL=chunk-7WXT5M6P.js.map
110
- //# sourceMappingURL=chunk-7WXT5M6P.js.map
109
+ //# sourceMappingURL=chunk-XRKFWV7K.js.map
110
+ //# sourceMappingURL=chunk-XRKFWV7K.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/persistence/fs-session-store.ts"],"names":[],"mappings":";;;;;;AA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A;AAAA;AAAA,EASA,MAAM,QAAQ,OAAA,EAAgC;AAC5C,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,OAAO,CAAA;AACtC,IAAA,IAAI,UAAU,MAAA,EAAW;AACzB,IAAA,IAAA,CAAK,OAAA,CAAQ,OAAO,OAAO,CAAA;AAC3B,IAAA,MAAM,MAAM,OAAA,EAAQ;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,OAAA,GAAyB;AAC7B,IAAA,MAAM,SAAS,CAAC,GAAG,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACxC,IAAA,IAAA,CAAK,QAAQ,KAAA,EAAM;AACnB,IAAA,KAAA,MAAW,KAAA,IAAS,MAAA,EAAQ,MAAM,KAAA,CAAM,OAAA,EAAQ;AAAA,EAClD;AACF","file":"chunk-7WXT5M6P.js","sourcesContent":["/**\n * SE41 — `FsSessionStore`, the DEFAULT reference implementation of the pluggable\n * {@link SessionStore} seam. It reads and append-writes the native Claude-shaped\n * `.jsonl` transcript at `<baseDir>/projects/<encoded-cwd>/<agentId>.jsonl` — the\n * exact on-disk format SE40 introduced (the file the Claude Code CLI can\n * `--continue`). Omitting `local.sessionStore` resolves to this store, so the\n * default persistence path is byte-identical to SE40 behavior.\n *\n * `readRecords` is `readTranscript(transcriptPath(...))` (a missing session →\n * `[]`, not an error — a fresh agent has no history). `appendRecords` is a TRUE\n * append: it reads the prior records, concatenates the new-turn delta, and\n * rewrites the whole line set atomically under the SE40 cross-process file lock\n * (`writeTranscript` never shrinks — the native format is an append-only\n * `parentUuid` DAG). The parent dir is created BEFORE acquiring the lock because\n * the lock's companion `<path>.lock` file needs an existing parent dir (the SE40\n * `mkdir(dirname)`-before-lock fix).\n *\n * @internal\n */\n\nimport { mkdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { withFileLock } from \"./file-lock.js\";\nimport { appendJsonl } from \"./jsonl.js\";\nimport { readTranscript, type SessionRecord, transcriptPath } from \"./session-transcript.js\";\nimport { acquireSessionWriter, type SessionWriterLease } from \"./session-writer.js\";\n\n/** Options identifying the on-disk transcript location for the FS default store. */\nexport interface FsSessionStoreOptions {\n /** Transcript base dir (`~/.theokit` default, `~/.claude` for CLI interop) — already `~`-expanded. */\n baseDir: string;\n /** The workspace cwd whose encoded form is the transcript project dir. */\n cwd: string;\n}\n\n/**\n * The default `SessionStore` — reads/append-writes the native `.jsonl` transcript.\n *\n * @internal\n */\n/**\n * Reference-counted leases, shared per path.\n *\n * `acquireSessionWriter` is STRICT on purpose: two concurrent acquisitions of the same path, and\n * exactly one wins — \"a lease that let both through would be decorative\" (the M81 test says exactly\n * that, and it is right). That is the primitive's contract, and it does not change.\n *\n * But within ONE process it is normal to have more than one store over the same session: the golden\n * compaction tests and the concurrent-send tests do exactly that, and they record real runtime\n * behavior. Applying the raw primitive there would turn a legitimate pattern into a\n * `SessionBusyError`.\n *\n * The reconciliation belongs here, in the primitive's consumer: the process takes ONE lease per path\n * and counts how many stores use it. The last to release actually frees it. Cross-process stays\n * strict — which is the problem M81 states (\"`exec resume --last` can write into the TUI's live\n * session\").\n */\nconst sharedLeases = new Map<string, { lease: SessionWriterLease; refs: number }>();\n\nasync function acquireShared(path: string): Promise<SessionWriterLease> {\n const existing = sharedLeases.get(path);\n if (existing !== undefined) {\n existing.refs++;\n return createProxy(path);\n }\n const lease = await acquireSessionWriter(path);\n sharedLeases.set(path, { lease, refs: 1 });\n return createProxy(path);\n}\n\n/** A handle that decrements the count; the last to release frees the real lease. */\nfunction createProxy(path: string): SessionWriterLease {\n let released = false;\n return {\n sessionPath: path,\n // The proxy forwards the renewal to the ONE real lease this path shares. Renewing through any\n // holder is correct and is the point: the record must say \"someone in this process is still\n // writing\", and the refcount already guarantees they are all the same owner.\n renew: (): void => {\n if (released) return;\n sharedLeases.get(path)?.lease.renew();\n },\n release: async (): Promise<void> => {\n if (released) return;\n released = true;\n const entry = sharedLeases.get(path);\n if (entry === undefined) return;\n entry.refs--;\n if (entry.refs > 0) return;\n sharedLeases.delete(path);\n await entry.lease.release();\n },\n };\n}\n\nexport class FsSessionStore implements SessionStore {\n readonly #baseDir: string;\n readonly #cwd: string;\n /** One lease per `agentId` — a store serves more than one session over the process lifetime. */\n readonly #leases = new Map<string, SessionWriterLease>();\n\n constructor(options: FsSessionStoreOptions) {\n this.#baseDir = options.baseDir;\n this.#cwd = options.cwd;\n }\n\n async readRecords(agentId: string): Promise<SessionRecord[]> {\n return readTranscript(transcriptPath(this.#baseDir, this.#cwd, agentId));\n }\n\n async appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void> {\n // Empty delta → nothing to persist (avoids an unnecessary lock + rewrite).\n if (records.length === 0) return;\n const path = transcriptPath(this.#baseDir, this.#cwd, agentId);\n // mkdir BEFORE the lock: withFileLock's companion `<path>.lock` needs the parent dir.\n await mkdir(dirname(path), { recursive: true });\n\n await withFileLock(path, async () => {\n // M93 — appends the DELTA instead of rewriting the whole file.\n //\n // Before: `readTranscript` + `writeTranscript` of everything, per turn. O(n) of I/O **and** of\n // parsing on every turn, O(n^2) per session — the consumer note in\n // `agents/lib/session/backtrack.ts` records 1.4 MB / 3000 lines over 200 turns.\n //\n // Correct because the format **is already append-only**: the `parentUuid` DAG does not depend\n // on line order, and every record carries its own parent. `appendJsonl` **already existed in\n // the package** and had a single caller (`eval/runner.ts`) — the primitive was there, it was\n // the store that ignored it (rung 4).\n //\n // `withFileLock` stays — but the earlier claim that \"it is what serializes two concurrent\n // `appendRecords`\" was too strong, and M93's adversarial review measured it: removing it fails\n // no test. The reason is the paragraph above — the `parentUuid` DAG does not depend on line\n // order, so two interleaved batches reconstruct identically. The work the lock was doing\n // (protecting a read-modify-write) disappeared along with the rewrite.\n //\n // What it still covers is the TOCTOU window in `needsLineBreakBefore` (read the last byte,\n // then write): without it, two processes can both conclude \"a \\n is missing\" and produce a\n // blank line — which the reader discards, i.e. benign. It stays as a **declared, not\n // mechanized** defense (the discipline in `error-handling.md` § 4: enumerate the residue\n // rather than let a missing test pass for coverage).\n //\n // `writeTranscript` still exists for **compaction**, the one operation that legitimately\n // rewrites the file.\n for (const record of records) appendJsonl(path, record);\n });\n }\n\n /**\n * Takes the session's writer lease. Throws `SessionBusyError` when another process holds it.\n *\n * **Explicit, and NOT inside `appendRecords`** — M95's adversarial review measured why that\n * matters: the `SessionStore` contract states that \"an `appendRecords` rejection is logged to\n * stderr, NOT thrown to the caller (best-effort write)\". Acquiring there made the\n * `SessionBusyError` get **swallowed**, and the result was worse than the original problem:\n * instead of two writers interleaving lines, the loser **lost the turn silently** — nothing on\n * disk, a stderr warning invisible under the TUI, and no way for the caller to react.\n *\n * At init the error reaches someone who can act: `exec` forks to a new id, which is exactly what\n * the error message itself prescribes. It is the difference between failing where a decision is\n * possible and failing where only loss is.\n */\n async acquire(agentId: string): Promise<void> {\n if (this.#leases.has(agentId)) return;\n const path = transcriptPath(this.#baseDir, this.#cwd, agentId);\n await mkdir(dirname(path), { recursive: true });\n this.#leases.set(agentId, await acquireShared(path));\n }\n\n /**\n * Releases ONE agent's lease.\n *\n * It exists because `dispose()` releases **every** lease the store holds, and a store injected by\n * the consumer may serve several agents: an init that fails for agent B must not free agent A's\n * lease, which is still live and writing.\n */\n async release(agentId: string): Promise<void> {\n const lease = this.#leases.get(agentId);\n if (lease === undefined) return;\n this.#leases.delete(agentId);\n await lease.release();\n }\n\n /**\n * Releases every lease this store holds.\n *\n * Without it the `.writer.lock` outlives the process and the next open would have to wait out the\n * heartbeat window — recoverable, but 30 s of waiting after a CLEAN shutdown would be an avoidable\n * defect. Idempotent: calling it twice is not an error.\n */\n async dispose(): Promise<void> {\n const leases = [...this.#leases.values()];\n this.#leases.clear();\n for (const lease of leases) await lease.release();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/persistence/fs-session-store.ts"],"names":[],"mappings":";;;;;;AA0DA,IAAM,YAAA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ASA,MAAM,QAAQ,OAAA,EAAgC;AAC5C,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,OAAO,CAAA;AACtC,IAAA,IAAI,UAAU,MAAA,EAAW;AACzB,IAAA,IAAA,CAAK,OAAA,CAAQ,OAAO,OAAO,CAAA;AAC3B,IAAA,MAAM,MAAM,OAAA,EAAQ;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,OAAA,GAAyB;AAC7B,IAAA,MAAM,SAAS,CAAC,GAAG,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACxC,IAAA,IAAA,CAAK,QAAQ,KAAA,EAAM;AACnB,IAAA,KAAA,MAAW,KAAA,IAAS,MAAA,EAAQ,MAAM,KAAA,CAAM,OAAA,EAAQ;AAAA,EAClD;AACF","file":"chunk-XRKFWV7K.js","sourcesContent":["/**\n * SE41 — `FsSessionStore`, the DEFAULT reference implementation of the pluggable\n * {@link SessionStore} seam. It reads and append-writes the native Claude-shaped\n * `.jsonl` transcript at `<baseDir>/projects/<encoded-cwd>/<agentId>.jsonl` — the\n * exact on-disk format SE40 introduced (the file the Claude Code CLI can\n * `--continue`). Omitting `local.sessionStore` resolves to this store, so the\n * default persistence path is byte-identical to SE40 behavior.\n *\n * `readRecords` is `readTranscript(transcriptPath(...))` (a missing session →\n * `[]`, not an error — a fresh agent has no history). `appendRecords` is a TRUE\n * append: it reads the prior records, concatenates the new-turn delta, and\n * rewrites the whole line set atomically under the SE40 cross-process file lock\n * (`writeTranscript` never shrinks — the native format is an append-only\n * `parentUuid` DAG). The parent dir is created BEFORE acquiring the lock because\n * the lock's companion `<path>.lock` file needs an existing parent dir (the SE40\n * `mkdir(dirname)`-before-lock fix).\n *\n * @internal\n */\n\nimport { mkdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { withFileLock } from \"./file-lock.js\";\nimport { appendJsonl } from \"./jsonl.js\";\nimport { readTranscript, type SessionRecord, transcriptPath } from \"./session-transcript.js\";\nimport { acquireSessionWriter, type SessionWriterLease } from \"./session-writer.js\";\n\n/** Options identifying the on-disk transcript location for the FS default store. */\nexport interface FsSessionStoreOptions {\n /** Transcript base dir (`~/.theokit` default, `~/.claude` for CLI interop) — already `~`-expanded. */\n baseDir: string;\n /** The workspace cwd whose encoded form is the transcript project dir. */\n cwd: string;\n}\n\n/**\n * The default `SessionStore` — reads/append-writes the native `.jsonl` transcript.\n *\n * @internal\n */\n/**\n * Reference-counted leases, shared per path.\n *\n * `acquireSessionWriter` is STRICT on purpose: two concurrent acquisitions of the same path, and\n * exactly one wins — \"a lease that let both through would be decorative\" (the M81 test says exactly\n * that, and it is right). That is the primitive's contract, and it does not change.\n *\n * But within ONE process it is normal to have more than one store over the same session: the golden\n * compaction tests and the concurrent-send tests do exactly that, and they record real runtime\n * behavior. Applying the raw primitive there would turn a legitimate pattern into a\n * `SessionBusyError`.\n *\n * The reconciliation belongs here, in the primitive's consumer: the process takes ONE lease per path\n * and counts how many stores use it. The last to release actually frees it. Cross-process stays\n * strict — which is the problem M81 states (\"`exec resume --last` can write into the TUI's live\n * session\").\n */\nconst sharedLeases = new Map<string, { lease: SessionWriterLease; refs: number }>();\n\nasync function acquireShared(path: string): Promise<SessionWriterLease> {\n const existing = sharedLeases.get(path);\n if (existing !== undefined) {\n existing.refs++;\n return createProxy(path);\n }\n const lease = await acquireSessionWriter(path);\n sharedLeases.set(path, { lease, refs: 1 });\n return createProxy(path);\n}\n\n/** A handle that decrements the count; the last to release frees the real lease. */\nfunction createProxy(path: string): SessionWriterLease {\n let released = false;\n return {\n sessionPath: path,\n // The proxy forwards the renewal to the ONE real lease this path shares. Renewing through any\n // holder is correct and is the point: the record must say \"someone in this process is still\n // writing\", and the refcount already guarantees they are all the same owner.\n renew: (): void => {\n if (released) return;\n sharedLeases.get(path)?.lease.renew();\n },\n release: async (): Promise<void> => {\n if (released) return;\n released = true;\n const entry = sharedLeases.get(path);\n if (entry === undefined) return;\n entry.refs--;\n if (entry.refs > 0) return;\n sharedLeases.delete(path);\n await entry.lease.release();\n },\n };\n}\n\nexport class FsSessionStore implements SessionStore {\n readonly #baseDir: string;\n readonly #cwd: string;\n /** One lease per `agentId` — a store serves more than one session over the process lifetime. */\n readonly #leases = new Map<string, SessionWriterLease>();\n\n constructor(options: FsSessionStoreOptions) {\n this.#baseDir = options.baseDir;\n this.#cwd = options.cwd;\n }\n\n async readRecords(agentId: string): Promise<SessionRecord[]> {\n return readTranscript(transcriptPath(this.#baseDir, this.#cwd, agentId));\n }\n\n async appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void> {\n // Empty delta → nothing to persist (avoids an unnecessary lock + rewrite).\n if (records.length === 0) return;\n const path = transcriptPath(this.#baseDir, this.#cwd, agentId);\n // mkdir BEFORE the lock: withFileLock's companion `<path>.lock` needs the parent dir.\n await mkdir(dirname(path), { recursive: true });\n\n await withFileLock(path, async () => {\n // M93 — appends the DELTA instead of rewriting the whole file.\n //\n // Before: `readTranscript` + `writeTranscript` of everything, per turn. O(n) of I/O **and** of\n // parsing on every turn, O(n^2) per session — the consumer note in\n // `agents/lib/session/backtrack.ts` records 1.4 MB / 3000 lines over 200 turns.\n //\n // Correct because the format **is already append-only**: the `parentUuid` DAG does not depend\n // on line order, and every record carries its own parent. `appendJsonl` **already existed in\n // the package** and had a single caller (`eval/runner.ts`) — the primitive was there, it was\n // the store that ignored it (rung 4).\n //\n // `withFileLock` stays — but the earlier claim that \"it is what serializes two concurrent\n // `appendRecords`\" was too strong, and M93's adversarial review measured it: removing it fails\n // no test. The reason is the paragraph above — the `parentUuid` DAG does not depend on line\n // order, so two interleaved batches reconstruct identically. The work the lock was doing\n // (protecting a read-modify-write) disappeared along with the rewrite.\n //\n // What it still covers is the TOCTOU window in `needsLineBreakBefore` (read the last byte,\n // then write): without it, two processes can both conclude \"a \\n is missing\" and produce a\n // blank line — which the reader discards, i.e. benign. It stays as a **declared, not\n // mechanized** defense (the discipline in `error-handling.md` § 4: enumerate the residue\n // rather than let a missing test pass for coverage).\n //\n // `writeTranscript` still exists for **compaction**, the one operation that legitimately\n // rewrites the file.\n for (const record of records) appendJsonl(path, record);\n });\n }\n\n /**\n * Takes the session's writer lease. Throws `SessionBusyError` when another process holds it.\n *\n * **Explicit, and NOT inside `appendRecords`** — M95's adversarial review measured why that\n * matters: the `SessionStore` contract states that \"an `appendRecords` rejection is logged to\n * stderr, NOT thrown to the caller (best-effort write)\". Acquiring there made the\n * `SessionBusyError` get **swallowed**, and the result was worse than the original problem:\n * instead of two writers interleaving lines, the loser **lost the turn silently** — nothing on\n * disk, a stderr warning invisible under the TUI, and no way for the caller to react.\n *\n * At init the error reaches someone who can act: `exec` forks to a new id, which is exactly what\n * the error message itself prescribes. It is the difference between failing where a decision is\n * possible and failing where only loss is.\n */\n async acquire(agentId: string): Promise<void> {\n if (this.#leases.has(agentId)) return;\n const path = transcriptPath(this.#baseDir, this.#cwd, agentId);\n await mkdir(dirname(path), { recursive: true });\n this.#leases.set(agentId, await acquireShared(path));\n }\n\n /**\n * Releases ONE agent's lease.\n *\n * It exists because `dispose()` releases **every** lease the store holds, and a store injected by\n * the consumer may serve several agents: an init that fails for agent B must not free agent A's\n * lease, which is still live and writing.\n */\n async release(agentId: string): Promise<void> {\n const lease = this.#leases.get(agentId);\n if (lease === undefined) return;\n this.#leases.delete(agentId);\n await lease.release();\n }\n\n /**\n * Releases every lease this store holds.\n *\n * Without it the `.writer.lock` outlives the process and the next open would have to wait out the\n * heartbeat window — recoverable, but 30 s of waiting after a CLEAN shutdown would be an avoidable\n * defect. Idempotent: calling it twice is not an error.\n */\n async dispose(): Promise<void> {\n const leases = [...this.#leases.values()];\n this.#leases.clear();\n for (const lease of leases) await lease.release();\n }\n}\n"]}
@@ -9,6 +9,22 @@ var path = require('path');
9
9
  var cached;
10
10
  var warnedMissing = false;
11
11
  var warnedStructural = false;
12
+ var loadFailure;
13
+ function isModuleAbsent(err) {
14
+ const code = err?.code;
15
+ return code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND";
16
+ }
17
+ function describeLockLoadFailure(err) {
18
+ const consequence = "cross-process file lock unavailable \u2014 concurrent processes over the same file are NOT serialized.";
19
+ if (isModuleAbsent(err)) {
20
+ return `[theokit-sdk] proper-lockfile not installed; ${consequence} Install with: pnpm add proper-lockfile
21
+ `;
22
+ }
23
+ const code = err?.code;
24
+ const detail = err instanceof Error ? err.message : String(err);
25
+ return `[theokit-sdk] proper-lockfile could not be loaded${code !== void 0 ? ` (${String(code)})` : ""}: ${detail}. ${consequence} The package resolves for the SDK but failed to load \u2014 check bundling and module-format interop before re-checking the install.
26
+ `;
27
+ }
12
28
  async function getProperLockfile() {
13
29
  if (cached !== void 0) return cached;
14
30
  try {
@@ -24,7 +40,8 @@ async function getProperLockfile() {
24
40
  return cached;
25
41
  }
26
42
  cached = mod;
27
- } catch {
43
+ } catch (err) {
44
+ loadFailure = err;
28
45
  cached = null;
29
46
  }
30
47
  return cached;
@@ -37,11 +54,9 @@ function validateLockModule(mod) {
37
54
  async function withFileLock(path, fn, options) {
38
55
  const lib = await getProperLockfile();
39
56
  if (lib === null) {
40
- if (!warnedMissing) {
57
+ if (!warnedMissing && !warnedStructural) {
41
58
  warnedMissing = true;
42
- chunkA76OFN2B_cjs.diag(
43
- "[theokit-sdk] proper-lockfile not installed; cross-process file lock unavailable. Install with: pnpm add proper-lockfile\n"
44
- );
59
+ chunkA76OFN2B_cjs.diag(describeLockLoadFailure(loadFailure));
45
60
  }
46
61
  return chunkYLQQX5W2_cjs.withCwdMutex(`file-lock:${path}`, fn);
47
62
  }
@@ -166,5 +181,5 @@ exports.appendJsonl = appendJsonl;
166
181
  exports.loadJsonl = loadJsonl;
167
182
  exports.readJsonlIds = readJsonlIds;
168
183
  exports.withFileLock = withFileLock;
169
- //# sourceMappingURL=chunk-JERO4TP6.cjs.map
170
- //# sourceMappingURL=chunk-JERO4TP6.cjs.map
184
+ //# sourceMappingURL=chunk-ZVQJHY4Y.cjs.map
185
+ //# sourceMappingURL=chunk-ZVQJHY4Y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/persistence/file-lock.ts","../src/internal/persistence/jsonl.ts"],"names":["diag","withCwdMutex","readFileSync","path","mkdirSync","dirname","openSync","writeSync","closeSync","fstatSync","readSync"],"mappings":";;;;;;;;AAiCA,IAAI,MAAA;AACJ,IAAI,aAAA,GAAgB,KAAA;AACpB,IAAI,gBAAA,GAAmB,KAAA;AAEvB,IAAI,WAAA;AAGJ,SAAS,eAAe,GAAA,EAAuB;AAC7C,EAAA,MAAM,OAAQ,GAAA,EAA+C,IAAA;AAC7D,EAAA,OAAO,IAAA,KAAS,0BAA0B,IAAA,KAAS,kBAAA;AACrD;AAgBA,SAAS,wBAAwB,GAAA,EAAsB;AACrD,EAAA,MAAM,WAAA,GACJ,wGAAA;AACF,EAAA,IAAI,cAAA,CAAe,GAAG,CAAA,EAAG;AACvB,IAAA,OAAO,gDAAgD,WAAW,CAAA;AAAA,CAAA;AAAA,EACpE;AACA,EAAA,MAAM,OAAQ,GAAA,EAA+C,IAAA;AAC7D,EAAA,MAAM,SAAS,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,OAAO,GAAG,CAAA;AAC9D,EAAA,OACE,CAAA,iDAAA,EAAoD,IAAA,KAAS,MAAA,GAAY,CAAA,EAAA,EAAK,MAAA,CAAO,IAAI,CAAC,CAAA,CAAA,CAAA,GAAM,EAAE,CAAA,EAAA,EAC/F,MAAM,CAAA,EAAA,EAAK,WAAW,CAAA;AAAA,CAAA;AAG7B;AAOA,eAAe,iBAAA,GAA0D;AACvE,EAAA,IAAI,MAAA,KAAW,QAAW,OAAO,MAAA;AACjC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,OAAO,iBAAiB,CAAA;AAM1C,IAAA,IAAI,CAAC,kBAAA,CAAmB,GAAG,C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M,CAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,KAAA,MAAW,OAAA,IAAW,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA,EAAG;AAEtC,IAAA,MAAM,MAAA,GAAS,kBAAA,CAAmB,OAAA,CAAQ,IAAA,EAAM,CAAA;AAChD,IAAA,IAAI,WAAW,MAAA,EAAW;AAC1B,IAAA,MAAM,GAAA,GAAM,MAAM,MAAM,CAAA;AACxB,IAAA,IAAI,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,SAAS,CAAA,EAAG,IAAA,CAAK,IAAI,GAAG,CAAA;AAAA,EAC7D;AACA,EAAA,OAAO,IAAA;AACT","file":"chunk-ZVQJHY4Y.cjs","sourcesContent":["/**\n * Cross-process file lock helper (ADR D61).\n *\n * Uses `proper-lockfile` (optional peer dep) for cross-process locks. When\n * the peer dep is absent, falls back to `withCwdMutex` (in-process only)\n * with a one-shot stderr warning.\n *\n * EC-1 fix: uses a companion `<path>.lock` file with `realpath: false` so\n * `withFileLock` works even when the target `path` does not exist yet.\n * Without this, fresh installs that lock-then-create would crash with ENOENT.\n *\n * @internal\n */\n\nimport { diag } from \"../diagnostics.js\";\nimport { withCwdMutex } from \"./cwd-mutex.js\";\n\ninterface ProperLockfileModule {\n lock: (file: string, options: ProperLockfileOptions) => Promise<() => Promise<void>>;\n}\n\ninterface ProperLockfileOptions {\n lockfilePath?: string;\n realpath?: boolean;\n stale?: number;\n retries?: {\n retries: number;\n factor?: number;\n minTimeout?: number;\n maxTimeout?: number;\n };\n}\n\nlet cached: ProperLockfileModule | null | undefined;\nlet warnedMissing = false;\nlet warnedStructural = false;\n/** Why the import failed, kept so the warning can report the observation instead of a guess (#174). */\nlet loadFailure: unknown;\n\n/** Node reports a missing module as `ERR_MODULE_NOT_FOUND` (ESM loader) or `MODULE_NOT_FOUND` (CJS). */\nfunction isModuleAbsent(err: unknown): boolean {\n const code = (err as { code?: unknown } | null | undefined)?.code;\n return code === \"ERR_MODULE_NOT_FOUND\" || code === \"MODULE_NOT_FOUND\";\n}\n\n/**\n * #174 — build the fallback warning from what actually happened.\n *\n * This used to always read \"proper-lockfile not installed\", because the import was wrapped in a\n * bare `catch` that discarded the error (Unbreakable Rule 8: a swallowed error is the dangerous\n * kind). A consumer whose package WAS installed, declared and resolvable spent a debugging session\n * re-verifying the install, because the message named a cause the code had never checked.\n *\n * Absence is now the only case that claims absence. Every other failure — a broken install, an\n * interop problem, a bundler that rewrote the specifier — reports its own code and message, which\n * is what points at the real cause.\n *\n * @internal\n */\nfunction describeLockLoadFailure(err: unknown): string {\n const consequence =\n \"cross-process file lock unavailable — concurrent processes over the same file are NOT serialized.\";\n if (isModuleAbsent(err)) {\n return `[theokit-sdk] proper-lockfile not installed; ${consequence} Install with: pnpm add proper-lockfile\\n`;\n }\n const code = (err as { code?: unknown } | null | undefined)?.code;\n const detail = err instanceof Error ? err.message : String(err);\n return (\n `[theokit-sdk] proper-lockfile could not be loaded${code !== undefined ? ` (${String(code)})` : \"\"}: ` +\n `${detail}. ${consequence} The package resolves for the SDK but failed to load — check bundling ` +\n \"and module-format interop before re-checking the install.\\n\"\n );\n}\n\n/** Test seam for the message builder — NOT in the public barrel. @internal */\nexport function __TESTING__describeLockLoadFailure(err: unknown): string {\n return describeLockLoadFailure(err);\n}\n\nasync function getProperLockfile(): Promise<ProperLockfileModule | null> {\n if (cached !== undefined) return cached;\n try {\n const mod = await import(\"proper-lockfile\");\n // T5.9 — supply-chain hardening: validate the imported module\n // exposes the API surface we depend on BEFORE caching it. A\n // tampered or incompatible version that lacks `lock`/`unlock`\n // functions gets treated as \"not installed\" with an advisory\n // warning — never silently used.\n if (!validateLockModule(mod)) {\n if (!warnedStructural) {\n warnedStructural = true;\n diag(\n \"[theokit-sdk] proper-lockfile: imported module does NOT expose \" +\n \"the expected `lock`/`unlock` API surface. This may indicate a \" +\n \"supply-chain compromise or an incompatible major version. \" +\n \"Falling back to in-process mutex (no cross-process safety). \" +\n \"Reinstall with: pnpm add proper-lockfile@^11\\n\",\n );\n }\n cached = null;\n return cached;\n }\n cached = mod as ProperLockfileModule;\n } catch (err) {\n // #174 — keep WHY. Discarding it here is what made the fallback warning assert a cause it had\n // never observed, and sent a consumer to re-check an install that was already correct.\n loadFailure = err;\n cached = null;\n }\n return cached;\n}\n\n/**\n * T5.9 — Structural validation of the dynamically-imported\n * `proper-lockfile` module. Verifies the API surface we depend on\n * (`lock` and `unlock` as functions) is present. Pure function —\n * never throws, never mutates, never performs I/O.\n *\n * Exported via `__TESTING__validateLockModule` seam so unit tests\n * can drive the check without spinning up the dynamic import.\n *\n * @internal\n */\nfunction validateLockModule(mod: unknown): boolean {\n if (mod === null || mod === undefined || typeof mod !== \"object\") return false;\n const m = mod as Record<string, unknown>;\n return typeof m.lock === \"function\" && typeof m.unlock === \"function\";\n}\n\n/**\n * T5.9 — Test seam: expose the structural validator for unit tests.\n * NOT included in the public barrel.\n *\n * @internal\n */\nexport function __TESTING__validateLockModule(mod: unknown): boolean {\n return validateLockModule(mod);\n}\n\n/**\n * T5.9 — Test seam: reset the module cache + warning flags between\n * tests so each test starts fresh. NOT included in the public barrel.\n *\n * @internal\n */\nexport function __TESTING__resetFileLockCache(): void {\n cached = undefined;\n warnedMissing = false;\n warnedStructural = false;\n loadFailure = undefined;\n}\n\n/**\n * Options for `withFileLock`.\n *\n * @internal\n */\nexport interface FileLockOptions {\n /** Stale lock timeout in ms. Default 30_000 (30s). */\n stale?: number;\n /** Max retries on busy lock. Default 5. */\n retries?: number;\n /** Backoff factor between retries. Default 1.5. */\n retryFactor?: number;\n}\n\n/**\n * Run `fn` while holding an OS-level cross-process lock on `path`.\n *\n * If `proper-lockfile` is installed, uses it with a companion `<path>.lock`\n * file (`realpath: false`, so target file does NOT need to exist yet).\n * Otherwise falls back to in-process `withCwdMutex` and prints a one-shot\n * stderr warning telling the user to install `proper-lockfile` for\n * cross-process safety.\n *\n * The lock is released even when `fn` throws.\n *\n * @internal\n */\nexport async function withFileLock<T>(\n path: string,\n fn: () => Promise<T>,\n options?: FileLockOptions,\n): Promise<T> {\n const lib = await getProperLockfile();\n\n if (lib === null) {\n // #174 — stay silent when the structural check already explained itself. Emitting \"not\n // installed\" on top of \"does not expose lock/unlock\" would be two contradictory diagnoses of\n // one failure, and the reader has no way to tell which is true.\n if (!warnedMissing && !warnedStructural) {\n warnedMissing = true;\n diag(describeLockLoadFailure(loadFailure));\n }\n return withCwdMutex(`file-lock:${path}`, fn);\n }\n\n // proper-lockfile errors immediately on same-process concurrent acquire\n // (\"Lock file is already being held\"). Wrap with cwd-mutex first so\n // in-process callers queue and only ONE thread at a time enters the\n // cross-process acquire path. Combined: full in-process + cross-process\n // serialization.\n return withCwdMutex(`file-lock:${path}`, async () => {\n const release = await lib.lock(path, {\n // EC-1: companion lockfile, target path may not exist yet.\n lockfilePath: `${path}.lock`,\n realpath: false,\n stale: options?.stale ?? 30_000,\n retries: {\n retries: options?.retries ?? 5,\n factor: options?.retryFactor ?? 1.5,\n minTimeout: 100,\n maxTimeout: 5_000,\n },\n });\n\n try {\n return await fn();\n } finally {\n await release();\n }\n });\n}\n\n/**\n * Test helper — resets the cached proper-lockfile module + warning flag.\n * Allows tests to simulate \"module absent\" by clearing cache then\n * monkey-patching the dynamic import resolution.\n *\n * @internal\n */\nexport function _resetFileLockCacheForTesting(): void {\n cached = undefined;\n warnedMissing = false;\n}\n","/**\n * Durable JSONL primitives shared by the eval harness (M6).\n *\n * - `loadJsonl` — generic dataset reader (split/trim/skip-blank/parse) with a\n * line-numbered {@link JsonlParseError}. The dataset SCHEMA is the caller's\n * concern via `map` (M6 ADR D3) — this module owns only the parse.\n * - `appendJsonl` / `readJsonlIds` — crash-durable, resumable batch persistence\n * (M6 ADR D1): each record is appended as one whole `\\n`-terminated line the\n * instant it is produced, and a re-run resumes by skipping already-keyed rows.\n *\n * referencia: knowledge-base/references/theocode-eval/lib/swebench-dataset.ts:82\n * (parseJsonl + line-N error) and swebench-batch.ts:113,205 (resume + per-line\n * flush).\n *\n * @internal\n */\nimport {\n closeSync,\n fstatSync,\n mkdirSync,\n openSync,\n readFileSync,\n readSync,\n writeSync,\n} from \"node:fs\";\nimport { dirname } from \"node:path\";\n\n/** Raised when a JSONL line is not valid JSON or is not a JSON object. Carries the 1-based line number. */\nexport class JsonlParseError extends Error {\n constructor(\n message: string,\n readonly line: number,\n ) {\n super(message);\n this.name = \"JsonlParseError\";\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Parse a single trimmed line to a plain object, or `undefined` if blank / invalid / non-object. */\nfunction tryParseObjectLine(line: string): Record<string, unknown> | undefined {\n if (line.length === 0) return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n return undefined;\n }\n return isPlainObject(parsed) ? parsed : undefined;\n}\n\n/**\n * Parse a JSONL file into rows. Blank lines are skipped. A malformed or\n * non-object line throws {@link JsonlParseError} naming the 1-based line. When\n * `map` is provided, each raw object is mapped to the typed row (the SWE-bench\n * schema lives in the caller's `map`, per M6 ADR D3).\n */\nexport function loadJsonl<T = Record<string, unknown>>(\n path: string,\n opts: {\n map?: (raw: Record<string, unknown>, lineNumber: number) => T;\n /**\n * M81 — tolerate a truncated LAST line (a crash artifact: the process died mid-write).\n *\n * Opt-in on purpose. As a default it would also swallow corruption in the MIDDLE of the file,\n * turning loud data loss into silent data loss — the wrong trade for a session store.\n */\n tolerateTrailingPartialLine?: boolean;\n } = {},\n): T[] {\n const lines = readFileSync(path, \"utf8\").split(\"\\n\");\n const out: T[] = [];\n for (let i = 0; i < lines.length; i += 1) {\n const lineNumber = i + 1;\n const line = (lines[i] ?? \"\").trim();\n if (line.length === 0) continue;\n // M81 — `undefined` = a tolerated invalid line (the last one, truncated by a crash). Any other\n // invalid line has already thrown inside `parseLine`.\n const parsed = parseLine(\n line,\n lineNumber,\n opts.tolerateTrailingPartialLine === true && lineNumber === lines.length,\n );\n if (parsed === undefined) break;\n out.push(opts.map ? opts.map(parsed, lineNumber) : (parsed as unknown as T));\n }\n return out;\n}\n\n/**\n * Parses ONE line, returning `undefined` when it is a tolerated truncated last line.\n *\n * Extracted because `loadJsonl` went over the cognitive-complexity ceiling once it gained the\n * tolerance — and because parsing a line and iterating a file are two responsibilities that were\n * only together out of habit.\n */\nfunction parseLine(\n line: string,\n lineNumber: number,\n tolerate: boolean,\n): Record<string, unknown> | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n if (tolerate) return undefined;\n throw new JsonlParseError(`line ${lineNumber}: invalid JSON`, lineNumber);\n }\n if (!isPlainObject(parsed)) {\n throw new JsonlParseError(`line ${lineNumber}: not a JSON object`, lineNumber);\n }\n return parsed;\n}\n\n/**\n * Append one record as a whole `\\n`-terminated JSON line. Creates the parent dir\n * if missing. `appendFileSync` is synchronous, so within a single Node process\n * the event loop serializes writes and each call writes its line atomically —\n * interleave-safe for the bounded-concurrency batch runner.\n *\n * referencia: swebench-batch.ts:192 (mkdir-before-append), :205 (per-line flush).\n */\nexport function appendJsonl(path: string, record: unknown): void {\n mkdirSync(dirname(path), { recursive: true });\n const prefix = needsLineBreakBefore(path) ? \"\\n\" : \"\";\n // M93 (adversarial review, H1) — `0o600`. `appendFileSync` takes no `mode`, so the permission came\n // from the umask: under `umask 022` the transcript was born `0664`, world-readable. The previous\n // path (`replaceFileAtomic`) pinned `0o600` on purpose — \"holds the FULL in-flight content\n // (credential snapshots, OAuth tokens)\" (`atomic-write.ts:107`) — and switching to append lost\n // that silently. The same class had already been caught in the consumer (`atomic-sync.ts`, M88\n // HIGH-1).\n //\n // `mode` only applies on CREATION; a pre-existing file keeps whatever permission it already has.\n const fd = openSync(path, \"a\", 0o600);\n try {\n writeSync(fd, `${prefix}${JSON.stringify(record)}\\n`);\n } finally {\n closeSync(fd);\n }\n}\n\n/**\n * Does the file end without a `\\n`? Then the last line is truncated — a crash mid-append.\n *\n * Without this check the next append **glues** itself onto the middle of the broken line, producing\n * an invalid line the reader discards: the NEW record disappears along with the partial one. The\n * previous path (read-modify-write) self-healed from this because it rewrote the whole file.\n * Measured in M93's adversarial review (H2): after an append over a truncated file, the\n * just-written record was no longer readable.\n *\n * Reads **one byte**, not the file.\n */\nfunction needsLineBreakBefore(path: string): boolean {\n let fd: number;\n try {\n fd = openSync(path, \"r\");\n } catch {\n return false; // the file does not exist yet: nothing to splice onto\n }\n try {\n const size = fstatSync(fd).size;\n if (size === 0) return false;\n const buf = Buffer.alloc(1);\n readSync(fd, buf, 0, 1, size - 1);\n return buf[0] !== 0x0a;\n } finally {\n closeSync(fd);\n }\n}\n\n/**\n * Read the set of keys from an existing JSONL file for which `keyFn(parsed)`\n * returns a non-empty string. Used to resume a crashed batch by skipping rows\n * already persisted with a successful result. A trailing partial line from an\n * interrupted append is tolerated (skipped, not thrown), and a missing file\n * yields an empty set.\n *\n * referencia: swebench-batch.ts:113 (readDoneIds), :129 (success-only),\n * :131 (tolerate partial line).\n */\nexport function readJsonlIds(\n path: string,\n keyFn: (parsed: Record<string, unknown>) => string | undefined,\n): Set<string> {\n const done = new Set<string>();\n let text: string;\n try {\n text = readFileSync(path, \"utf8\");\n } catch {\n return done; // no file yet → nothing done\n }\n for (const rawLine of text.split(\"\\n\")) {\n // A trailing partial line from an interrupted run parses to undefined → skipped.\n const parsed = tryParseObjectLine(rawLine.trim());\n if (parsed === undefined) continue;\n const key = keyFn(parsed);\n if (typeof key === \"string\" && key.length > 0) done.add(key);\n }\n return done;\n}\n"]}
@@ -1,4 +1,4 @@
1
- export { COMPACT_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, autoCompactIfNeeded, buildDefaultSummarizer, compactSessionTranscript, isCompactSummary, resolveSummarizerRoute, shouldAutoCompact } from './chunk-RMO7HAIF.js';
1
+ export { COMPACT_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, autoCompactIfNeeded, buildDefaultSummarizer, compactSessionTranscript, isCompactSummary, resolveSummarizerRoute, shouldAutoCompact } from './chunk-X627TO3A.js';
2
2
  import './chunk-MI3OKONE.js';
3
3
  import './chunk-5KOW3GLE.js';
4
4
  import './chunk-FUP3ZA5T.js';
@@ -8,11 +8,11 @@ import './chunk-EYUZZXHZ.js';
8
8
  import './chunk-2XLKLVVR.js';
9
9
  import './chunk-5XPKYDK7.js';
10
10
  import './chunk-XZ7PO2FM.js';
11
- import './chunk-AFJAQ5JV.js';
11
+ import './chunk-23HI77BZ.js';
12
12
  import './chunk-AKMPQJPX.js';
13
13
  import './chunk-5NBUH3NO.js';
14
14
  import './chunk-IEKSEAIV.js';
15
15
  import './chunk-VQ33XLC6.js';
16
16
  import './chunk-RNCN2TTP.js';
17
- //# sourceMappingURL=compact-session-KPYRNTQN.js.map
18
- //# sourceMappingURL=compact-session-KPYRNTQN.js.map
17
+ //# sourceMappingURL=compact-session-AZU2LEAE.js.map
18
+ //# sourceMappingURL=compact-session-AZU2LEAE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"compact-session-KPYRNTQN.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"compact-session-AZU2LEAE.js"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkLR3VKB7A_cjs = require('./chunk-LR3VKB7A.cjs');
3
+ var chunkSEWAPWAF_cjs = require('./chunk-SEWAPWAF.cjs');
4
4
  require('./chunk-ELYGL52R.cjs');
5
5
  require('./chunk-BURYFNOM.cjs');
6
6
  require('./chunk-U53AYSHS.cjs');
@@ -10,7 +10,7 @@ require('./chunk-NJVV5OAV.cjs');
10
10
  require('./chunk-YLQQX5W2.cjs');
11
11
  require('./chunk-33B2BSME.cjs');
12
12
  require('./chunk-OVGNXGCK.cjs');
13
- require('./chunk-UDSGSPUY.cjs');
13
+ require('./chunk-T6KFGMNY.cjs');
14
14
  require('./chunk-V7CA3CX5.cjs');
15
15
  require('./chunk-C6Y6CWYD.cjs');
16
16
  require('./chunk-ZAKTZ5B4.cjs');
@@ -21,35 +21,35 @@ require('./chunk-A76OFN2B.cjs');
21
21
 
22
22
  Object.defineProperty(exports, "COMPACT_SUMMARY_MARKER", {
23
23
  enumerable: true,
24
- get: function () { return chunkLR3VKB7A_cjs.COMPACT_SUMMARY_MARKER; }
24
+ get: function () { return chunkSEWAPWAF_cjs.COMPACT_SUMMARY_MARKER; }
25
25
  });
26
26
  Object.defineProperty(exports, "COMPACT_USER_MESSAGE_MAX_TOKENS", {
27
27
  enumerable: true,
28
- get: function () { return chunkLR3VKB7A_cjs.COMPACT_USER_MESSAGE_MAX_TOKENS; }
28
+ get: function () { return chunkSEWAPWAF_cjs.COMPACT_USER_MESSAGE_MAX_TOKENS; }
29
29
  });
30
30
  Object.defineProperty(exports, "autoCompactIfNeeded", {
31
31
  enumerable: true,
32
- get: function () { return chunkLR3VKB7A_cjs.autoCompactIfNeeded; }
32
+ get: function () { return chunkSEWAPWAF_cjs.autoCompactIfNeeded; }
33
33
  });
34
34
  Object.defineProperty(exports, "buildDefaultSummarizer", {
35
35
  enumerable: true,
36
- get: function () { return chunkLR3VKB7A_cjs.buildDefaultSummarizer; }
36
+ get: function () { return chunkSEWAPWAF_cjs.buildDefaultSummarizer; }
37
37
  });
38
38
  Object.defineProperty(exports, "compactSessionTranscript", {
39
39
  enumerable: true,
40
- get: function () { return chunkLR3VKB7A_cjs.compactSessionTranscript; }
40
+ get: function () { return chunkSEWAPWAF_cjs.compactSessionTranscript; }
41
41
  });
42
42
  Object.defineProperty(exports, "isCompactSummary", {
43
43
  enumerable: true,
44
- get: function () { return chunkLR3VKB7A_cjs.isCompactSummary; }
44
+ get: function () { return chunkSEWAPWAF_cjs.isCompactSummary; }
45
45
  });
46
46
  Object.defineProperty(exports, "resolveSummarizerRoute", {
47
47
  enumerable: true,
48
- get: function () { return chunkLR3VKB7A_cjs.resolveSummarizerRoute; }
48
+ get: function () { return chunkSEWAPWAF_cjs.resolveSummarizerRoute; }
49
49
  });
50
50
  Object.defineProperty(exports, "shouldAutoCompact", {
51
51
  enumerable: true,
52
- get: function () { return chunkLR3VKB7A_cjs.shouldAutoCompact; }
52
+ get: function () { return chunkSEWAPWAF_cjs.shouldAutoCompact; }
53
53
  });
54
- //# sourceMappingURL=compact-session-FCEFK2CG.cjs.map
55
- //# sourceMappingURL=compact-session-FCEFK2CG.cjs.map
54
+ //# sourceMappingURL=compact-session-TRCEYCPG.cjs.map
55
+ //# sourceMappingURL=compact-session-TRCEYCPG.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"compact-session-FCEFK2CG.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"compact-session-TRCEYCPG.cjs"}
package/dist/cron.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkTZ47DTM2_cjs = require('./chunk-TZ47DTM2.cjs');
4
- require('./chunk-AYDSWY35.cjs');
3
+ var chunkKV3HR7KL_cjs = require('./chunk-KV3HR7KL.cjs');
4
+ require('./chunk-SHQEZ6Q2.cjs');
5
5
  require('./chunk-BV2MWEMV.cjs');
6
6
  require('./chunk-QMIG7TKG.cjs');
7
7
  require('./chunk-BUUUWQMB.cjs');
8
- require('./chunk-Z5DYGBPV.cjs');
9
- require('./chunk-MWVLE5RY.cjs');
10
- require('./chunk-LR3VKB7A.cjs');
8
+ require('./chunk-N4JNY5DT.cjs');
9
+ require('./chunk-WMWZAJMJ.cjs');
10
+ require('./chunk-SEWAPWAF.cjs');
11
11
  require('./chunk-ELYGL52R.cjs');
12
12
  require('./chunk-BURYFNOM.cjs');
13
13
  require('./chunk-3LK3ZDL5.cjs');
@@ -28,7 +28,7 @@ require('./chunk-RHQJX3EI.cjs');
28
28
  require('./chunk-PDOLUFGY.cjs');
29
29
  require('./chunk-4E3HLSYE.cjs');
30
30
  require('./chunk-NJVV5OAV.cjs');
31
- require('./chunk-JERO4TP6.cjs');
31
+ require('./chunk-ZVQJHY4Y.cjs');
32
32
  require('./chunk-4H2QARXM.cjs');
33
33
  require('./chunk-YLQQX5W2.cjs');
34
34
  require('./chunk-H2V6CXM7.cjs');
@@ -37,7 +37,7 @@ require('./chunk-33B2BSME.cjs');
37
37
  require('./chunk-LOTWA65Z.cjs');
38
38
  require('./chunk-OVGNXGCK.cjs');
39
39
  require('./chunk-VYHJZVL5.cjs');
40
- require('./chunk-UDSGSPUY.cjs');
40
+ require('./chunk-T6KFGMNY.cjs');
41
41
  require('./chunk-V7CA3CX5.cjs');
42
42
  require('./chunk-C6Y6CWYD.cjs');
43
43
  require('./chunk-CJHBSSAF.cjs');
@@ -50,7 +50,7 @@ require('./chunk-A76OFN2B.cjs');
50
50
 
51
51
  Object.defineProperty(exports, "Cron", {
52
52
  enumerable: true,
53
- get: function () { return chunkTZ47DTM2_cjs.Cron; }
53
+ get: function () { return chunkKV3HR7KL_cjs.Cron; }
54
54
  });
55
55
  //# sourceMappingURL=cron.cjs.map
56
56
  //# sourceMappingURL=cron.cjs.map
package/dist/cron.js CHANGED
@@ -1,11 +1,11 @@
1
- export { Cron } from './chunk-MDN44YMZ.js';
2
- import './chunk-ERBH54V3.js';
1
+ export { Cron } from './chunk-P3ZVI46Y.js';
2
+ import './chunk-SGGH3B2W.js';
3
3
  import './chunk-2SFBB54R.js';
4
4
  import './chunk-UIPTINIF.js';
5
5
  import './chunk-K2BQQ445.js';
6
- import './chunk-7HP6N5X3.js';
7
- import './chunk-7WXT5M6P.js';
8
- import './chunk-RMO7HAIF.js';
6
+ import './chunk-ONVIALVV.js';
7
+ import './chunk-XRKFWV7K.js';
8
+ import './chunk-X627TO3A.js';
9
9
  import './chunk-MI3OKONE.js';
10
10
  import './chunk-5KOW3GLE.js';
11
11
  import './chunk-7PBAJ2WA.js';
@@ -26,7 +26,7 @@ import './chunk-XKGOIGTJ.js';
26
26
  import './chunk-F4SQTWVR.js';
27
27
  import './chunk-LWVKI75U.js';
28
28
  import './chunk-EYUZZXHZ.js';
29
- import './chunk-RTDT2UMT.js';
29
+ import './chunk-5VKUZ26Q.js';
30
30
  import './chunk-VTDQRUAJ.js';
31
31
  import './chunk-2XLKLVVR.js';
32
32
  import './chunk-BM7VYZED.js';
@@ -35,7 +35,7 @@ import './chunk-5XPKYDK7.js';
35
35
  import './chunk-BBMN4O6E.js';
36
36
  import './chunk-XZ7PO2FM.js';
37
37
  import './chunk-X2FR4OIT.js';
38
- import './chunk-AFJAQ5JV.js';
38
+ import './chunk-23HI77BZ.js';
39
39
  import './chunk-AKMPQJPX.js';
40
40
  import './chunk-5NBUH3NO.js';
41
41
  import './chunk-LYD3ALDT.js';
package/dist/eval.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkS7OEXQMI_cjs = require('./chunk-S7OEXQMI.cjs');
4
- var chunkAYDSWY35_cjs = require('./chunk-AYDSWY35.cjs');
4
+ var chunkSHQEZ6Q2_cjs = require('./chunk-SHQEZ6Q2.cjs');
5
5
  require('./chunk-BV2MWEMV.cjs');
6
6
  require('./chunk-QMIG7TKG.cjs');
7
7
  var chunkBUUUWQMB_cjs = require('./chunk-BUUUWQMB.cjs');
8
- require('./chunk-Z5DYGBPV.cjs');
9
- require('./chunk-MWVLE5RY.cjs');
10
- require('./chunk-LR3VKB7A.cjs');
8
+ require('./chunk-N4JNY5DT.cjs');
9
+ require('./chunk-WMWZAJMJ.cjs');
10
+ require('./chunk-SEWAPWAF.cjs');
11
11
  require('./chunk-ELYGL52R.cjs');
12
12
  require('./chunk-BURYFNOM.cjs');
13
13
  require('./chunk-3LK3ZDL5.cjs');
@@ -28,7 +28,7 @@ require('./chunk-RHQJX3EI.cjs');
28
28
  require('./chunk-PDOLUFGY.cjs');
29
29
  require('./chunk-4E3HLSYE.cjs');
30
30
  require('./chunk-NJVV5OAV.cjs');
31
- var chunkJERO4TP6_cjs = require('./chunk-JERO4TP6.cjs');
31
+ var chunkZVQJHY4Y_cjs = require('./chunk-ZVQJHY4Y.cjs');
32
32
  require('./chunk-4H2QARXM.cjs');
33
33
  require('./chunk-YLQQX5W2.cjs');
34
34
  require('./chunk-H2V6CXM7.cjs');
@@ -37,7 +37,7 @@ require('./chunk-33B2BSME.cjs');
37
37
  require('./chunk-LOTWA65Z.cjs');
38
38
  require('./chunk-OVGNXGCK.cjs');
39
39
  require('./chunk-VYHJZVL5.cjs');
40
- require('./chunk-UDSGSPUY.cjs');
40
+ require('./chunk-T6KFGMNY.cjs');
41
41
  require('./chunk-V7CA3CX5.cjs');
42
42
  require('./chunk-C6Y6CWYD.cjs');
43
43
  require('./chunk-CJHBSSAF.cjs');
@@ -330,14 +330,14 @@ function probeRow(entry, index) {
330
330
  }
331
331
  function computeDoneKeys(persist) {
332
332
  if (persist.resume !== true) return /* @__PURE__ */ new Set();
333
- return chunkJERO4TP6_cjs.readJsonlIds(
333
+ return chunkZVQJHY4Y_cjs.readJsonlIds(
334
334
  persist.path,
335
335
  (parsed) => parsed.error === void 0 ? persist.key(parsed) : void 0
336
336
  );
337
337
  }
338
338
  function appendRowSafely(path, row) {
339
339
  try {
340
- chunkJERO4TP6_cjs.appendJsonl(path, row);
340
+ chunkZVQJHY4Y_cjs.appendJsonl(path, row);
341
341
  } catch (err) {
342
342
  chunkA76OFN2B_cjs.diag(
343
343
  `[eval] persist append failed (ignored): ${err instanceof Error ? err.message : String(err)}
@@ -773,7 +773,7 @@ function makeDefaultEmbedder(opts) {
773
773
  let runtime;
774
774
  return (texts) => {
775
775
  if (runtime === void 0) {
776
- runtime = chunkAYDSWY35_cjs.openRouterMemoryEmbeddingProviderAdapter.create(embedderCreateOptions(opts));
776
+ runtime = chunkSHQEZ6Q2_cjs.openRouterMemoryEmbeddingProviderAdapter.create(embedderCreateOptions(opts));
777
777
  }
778
778
  return runtime.then((rt) => rt.embed(texts));
779
779
  };
@@ -1017,11 +1017,11 @@ var Eval = class _Eval {
1017
1017
 
1018
1018
  Object.defineProperty(exports, "JsonlParseError", {
1019
1019
  enumerable: true,
1020
- get: function () { return chunkJERO4TP6_cjs.JsonlParseError; }
1020
+ get: function () { return chunkZVQJHY4Y_cjs.JsonlParseError; }
1021
1021
  });
1022
1022
  Object.defineProperty(exports, "loadJsonl", {
1023
1023
  enumerable: true,
1024
- get: function () { return chunkJERO4TP6_cjs.loadJsonl; }
1024
+ get: function () { return chunkZVQJHY4Y_cjs.loadJsonl; }
1025
1025
  });
1026
1026
  exports.Eval = Eval;
1027
1027
  exports.EvalAlreadyRunningError = EvalAlreadyRunningError;
package/dist/eval.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { shellEscapePosix, LocalSandbox } from './chunk-SKWVAQAY.js';
2
- import { openRouterMemoryEmbeddingProviderAdapter } from './chunk-ERBH54V3.js';
2
+ import { openRouterMemoryEmbeddingProviderAdapter } from './chunk-SGGH3B2W.js';
3
3
  import './chunk-2SFBB54R.js';
4
4
  import './chunk-UIPTINIF.js';
5
5
  import { getTracer } from './chunk-K2BQQ445.js';
6
- import './chunk-7HP6N5X3.js';
7
- import './chunk-7WXT5M6P.js';
8
- import './chunk-RMO7HAIF.js';
6
+ import './chunk-ONVIALVV.js';
7
+ import './chunk-XRKFWV7K.js';
8
+ import './chunk-X627TO3A.js';
9
9
  import './chunk-MI3OKONE.js';
10
10
  import './chunk-5KOW3GLE.js';
11
11
  import './chunk-7PBAJ2WA.js';
@@ -26,8 +26,8 @@ import './chunk-XKGOIGTJ.js';
26
26
  import './chunk-F4SQTWVR.js';
27
27
  import './chunk-LWVKI75U.js';
28
28
  import './chunk-EYUZZXHZ.js';
29
- import { readJsonlIds, appendJsonl } from './chunk-RTDT2UMT.js';
30
- export { JsonlParseError, loadJsonl } from './chunk-RTDT2UMT.js';
29
+ import { readJsonlIds, appendJsonl } from './chunk-5VKUZ26Q.js';
30
+ export { JsonlParseError, loadJsonl } from './chunk-5VKUZ26Q.js';
31
31
  import './chunk-VTDQRUAJ.js';
32
32
  import './chunk-2XLKLVVR.js';
33
33
  import './chunk-BM7VYZED.js';
@@ -36,7 +36,7 @@ import './chunk-5XPKYDK7.js';
36
36
  import './chunk-BBMN4O6E.js';
37
37
  import './chunk-XZ7PO2FM.js';
38
38
  import './chunk-X2FR4OIT.js';
39
- import './chunk-AFJAQ5JV.js';
39
+ import './chunk-23HI77BZ.js';
40
40
  import './chunk-AKMPQJPX.js';
41
41
  import './chunk-5NBUH3NO.js';
42
42
  import './chunk-LYD3ALDT.js';
@@ -0,0 +1,10 @@
1
+ export { FsSessionStore } from './chunk-XRKFWV7K.js';
2
+ import './chunk-LWVKI75U.js';
3
+ import './chunk-EYUZZXHZ.js';
4
+ import './chunk-5VKUZ26Q.js';
5
+ import './chunk-2XLKLVVR.js';
6
+ import './chunk-5XPKYDK7.js';
7
+ import './chunk-VQ33XLC6.js';
8
+ import './chunk-RNCN2TTP.js';
9
+ //# sourceMappingURL=fs-session-store-I6GUIFRO.js.map
10
+ //# sourceMappingURL=fs-session-store-I6GUIFRO.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"fs-session-store-YPZIOLJM.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"fs-session-store-I6GUIFRO.js"}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkMWVLE5RY_cjs = require('./chunk-MWVLE5RY.cjs');
3
+ var chunkWMWZAJMJ_cjs = require('./chunk-WMWZAJMJ.cjs');
4
4
  require('./chunk-4E3HLSYE.cjs');
5
5
  require('./chunk-NJVV5OAV.cjs');
6
- require('./chunk-JERO4TP6.cjs');
6
+ require('./chunk-ZVQJHY4Y.cjs');
7
7
  require('./chunk-YLQQX5W2.cjs');
8
8
  require('./chunk-33B2BSME.cjs');
9
9
  require('./chunk-E7WWIX34.cjs');
@@ -13,7 +13,7 @@ require('./chunk-A76OFN2B.cjs');
13
13
 
14
14
  Object.defineProperty(exports, "FsSessionStore", {
15
15
  enumerable: true,
16
- get: function () { return chunkMWVLE5RY_cjs.FsSessionStore; }
16
+ get: function () { return chunkWMWZAJMJ_cjs.FsSessionStore; }
17
17
  });
18
- //# sourceMappingURL=fs-session-store-V32XJ63Z.cjs.map
19
- //# sourceMappingURL=fs-session-store-V32XJ63Z.cjs.map
18
+ //# sourceMappingURL=fs-session-store-KRZZIG3O.cjs.map
19
+ //# sourceMappingURL=fs-session-store-KRZZIG3O.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"fs-session-store-V32XJ63Z.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"fs-session-store-KRZZIG3O.cjs"}