@kody-ade/kody-engine 0.4.380 → 0.4.381

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 (2) hide show
  1. package/dist/bin/kody.js +39 -23
  2. package/package.json +1 -1
package/dist/bin/kody.js CHANGED
@@ -15,7 +15,7 @@ var init_package = __esm({
15
15
  "package.json"() {
16
16
  package_default = {
17
17
  name: "@kody-ade/kody-engine",
18
- version: "0.4.380",
18
+ version: "0.4.381",
19
19
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
20
20
  license: "MIT",
21
21
  type: "module",
@@ -22625,37 +22625,53 @@ function createJsonlStore(sessionFile) {
22625
22625
  }
22626
22626
  };
22627
22627
  }
22628
+ function normalizeTurn(turn) {
22629
+ return {
22630
+ role: turn.role,
22631
+ content: turn.content,
22632
+ timestamp: turn.timestamp,
22633
+ toolCalls: turn.toolCalls ?? []
22634
+ };
22635
+ }
22628
22636
  function createConvexStore(args) {
22629
22637
  const { client, tenantId, sessionId, sessionFile, logger } = args;
22630
22638
  let sessionUpserted = false;
22639
+ const appendToConvex = async (turn) => {
22640
+ if (!sessionUpserted) {
22641
+ try {
22642
+ const meta = readMeta(sessionFile) ?? { type: "meta", mode: "one-shot" };
22643
+ await client.mutation(anyApi.chatSessions.upsert, {
22644
+ tenantId,
22645
+ sessionId,
22646
+ meta,
22647
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
22648
+ });
22649
+ sessionUpserted = true;
22650
+ } catch (err) {
22651
+ logger.warn(`session ${sessionId}: chatSessions.upsert failed: ${err instanceof Error ? err.message : String(err)}`);
22652
+ }
22653
+ }
22654
+ await client.mutation(anyApi.chatTurns.append, { tenantId, sessionId, turn });
22655
+ };
22631
22656
  return {
22632
22657
  backend: "convex",
22633
22658
  readTurns: async () => {
22634
22659
  const docs = await client.query(anyApi.chatTurns.list, { tenantId, sessionId });
22635
- return [...docs].sort((a, b) => a.seq - b.seq).map((doc) => doc.turn).filter(isChatTurn);
22660
+ const convexTurns = [...docs].sort((a, b) => a.seq - b.seq).map((doc) => doc.turn).filter(isChatTurn);
22661
+ const localTurns = readSession(sessionFile);
22662
+ if (localTurns.length <= convexTurns.length) return convexTurns;
22663
+ const tail = localTurns.slice(convexTurns.length).map(normalizeTurn);
22664
+ logger.info(
22665
+ `session ${sessionId}: backfilling ${tail.length} local JSONL turn(s) into Convex (convex=${convexTurns.length}, local=${localTurns.length})`
22666
+ );
22667
+ for (const turn of tail) {
22668
+ await appendToConvex(turn);
22669
+ }
22670
+ return [...convexTurns, ...tail];
22636
22671
  },
22637
22672
  appendTurn: async (turn) => {
22638
- const normalized = {
22639
- role: turn.role,
22640
- content: turn.content,
22641
- timestamp: turn.timestamp,
22642
- toolCalls: turn.toolCalls ?? []
22643
- };
22644
- if (!sessionUpserted) {
22645
- try {
22646
- const meta = readMeta(sessionFile) ?? { type: "meta", mode: "one-shot" };
22647
- await client.mutation(anyApi.chatSessions.upsert, {
22648
- tenantId,
22649
- sessionId,
22650
- meta,
22651
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
22652
- });
22653
- sessionUpserted = true;
22654
- } catch (err) {
22655
- logger.warn(`session ${sessionId}: chatSessions.upsert failed: ${err instanceof Error ? err.message : String(err)}`);
22656
- }
22657
- }
22658
- await client.mutation(anyApi.chatTurns.append, { tenantId, sessionId, turn: normalized });
22673
+ const normalized = normalizeTurn(turn);
22674
+ await appendToConvex(normalized);
22659
22675
  try {
22660
22676
  appendTurn(sessionFile, normalized);
22661
22677
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.380",
3
+ "version": "0.4.381",
4
4
  "description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
5
5
  "license": "MIT",
6
6
  "type": "module",