@kody-ade/kody-engine 0.4.423 → 0.4.425

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 +27 -7
  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.423",
18
+ version: "0.4.425",
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",
@@ -2329,6 +2329,14 @@ var init_kody_api_client = __esm({
2329
2329
 
2330
2330
  // src/state-backend.ts
2331
2331
  import { anyApi } from "convex/server";
2332
+ function serializeAgencyDispatchDecision(decision) {
2333
+ return {
2334
+ kind: decision.kind,
2335
+ reason: decision.reason,
2336
+ ...decision.scheduledAt ? { scheduledAt: decision.scheduledAt } : {},
2337
+ ...decision.nextEligibleAt ? { nextEligibleAt: decision.nextEligibleAt } : {}
2338
+ };
2339
+ }
2332
2340
  function requireTenant(tenantId2) {
2333
2341
  const value = tenantId2.trim();
2334
2342
  if (!/^[^/\s]+\/[^/\s]+$/.test(value)) throw new Error("tenantId must be an owner/repository pair");
@@ -2447,17 +2455,17 @@ function createStateBackendFromEnv(env = process.env, client) {
2447
2455
  });
2448
2456
  return Array.isArray(result) ? result : [];
2449
2457
  },
2450
- async getAgencyState(tenantId2, definitionId) {
2458
+ async getAgencyState(tenantId2, definitionId2) {
2451
2459
  const result = await transport.query(anyApi.agencyModel.getState, {
2452
2460
  tenantId: requireTenant(tenantId2),
2453
- definitionId: requireNonEmpty(definitionId, "definitionId")
2461
+ definitionId: requireNonEmpty(definitionId2, "definitionId")
2454
2462
  });
2455
2463
  return result ?? null;
2456
2464
  },
2457
- async putAgencyState(tenantId2, definitionId, kind, schemaVersion, data, updatedAt) {
2465
+ async putAgencyState(tenantId2, definitionId2, kind, schemaVersion, data, updatedAt) {
2458
2466
  await transport.mutation(anyApi.agencyModel.putState, {
2459
2467
  tenantId: requireTenant(tenantId2),
2460
- definitionId: requireNonEmpty(definitionId, "definitionId"),
2468
+ definitionId: requireNonEmpty(definitionId2, "definitionId"),
2461
2469
  kind,
2462
2470
  schemaVersion,
2463
2471
  data,
@@ -2485,6 +2493,7 @@ function createStateBackendFromEnv(env = process.env, client) {
2485
2493
  const result = await transport.mutation(anyApi.agencyModel.reserveDispatch, {
2486
2494
  tenantId: requireTenant(tenantId2),
2487
2495
  ...reservation,
2496
+ decision: serializeAgencyDispatchDecision(reservation.decision),
2488
2497
  idempotencyKey: requireNonEmpty(reservation.idempotencyKey, "idempotencyKey"),
2489
2498
  loopId: requireNonEmpty(reservation.loopId, "loopId"),
2490
2499
  reservationId: requireNonEmpty(reservation.reservationId, "reservationId"),
@@ -2498,7 +2507,7 @@ function createStateBackendFromEnv(env = process.env, client) {
2498
2507
  tenantId: requireTenant(tenantId2),
2499
2508
  idempotencyKey: requireNonEmpty(idempotencyKey, "idempotencyKey"),
2500
2509
  loopId: requireNonEmpty(loopId, "loopId"),
2501
- decision,
2510
+ decision: serializeAgencyDispatchDecision(decision),
2502
2511
  now
2503
2512
  });
2504
2513
  },
@@ -13018,6 +13027,13 @@ function goalProgressFromOutputs(definition, outputs) {
13018
13027
  );
13019
13028
  return required2.filter((key) => satisfied.has(key)).length / required2.length;
13020
13029
  }
13030
+ function definitionId(document) {
13031
+ const data = document.data;
13032
+ if (typeof data.id !== "string" || !data.id.trim()) {
13033
+ throw new Error(`Agency Definition is missing id: ${document.recordId}`);
13034
+ }
13035
+ return data.id;
13036
+ }
13021
13037
  function parseState(document, definition, kind) {
13022
13038
  if (!document) return null;
13023
13039
  if (document.schemaVersion !== 1) throw new Error(`Unsupported Agency State schema: ${document.schemaVersion}`);
@@ -13111,7 +13127,11 @@ var init_agencyModelRepository = __esm({
13111
13127
  const ordered = [...documents].sort(
13112
13128
  (left, right) => left.createdAt.localeCompare(right.createdAt) || left.recordId.localeCompare(right.recordId)
13113
13129
  );
13114
- for (const document of ordered) addDefinition(catalog, document);
13130
+ const latest = /* @__PURE__ */ new Map();
13131
+ for (const document of ordered) {
13132
+ latest.set(`${document.kind}:${definitionId(document)}`, document);
13133
+ }
13134
+ for (const document of latest.values()) addDefinition(catalog, document);
13115
13135
  validateRelationships(catalog);
13116
13136
  return catalog;
13117
13137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.423",
3
+ "version": "0.4.425",
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",