@jun133/kitty 0.0.15 → 0.0.16

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.
@@ -735,10 +735,26 @@ function truncate2(value, maxChars) {
735
735
  return value.length <= maxChars ? value : `${value.slice(0, maxChars)}...`;
736
736
  }
737
737
 
738
- // src/agent/runtimeTransition/shared.ts
739
- var MAX_REASON_ITEMS = 6;
740
- var MAX_REASON_TEXT_CHARS = 220;
741
- function takeLastUnique2(values) {
738
+ // src/session/checkpoint/shared.ts
739
+ import crypto from "crypto";
740
+ import path2 from "path";
741
+ var MAX_COMPLETED_STEPS = 8;
742
+ var MAX_BATCH_TOOLS = 6;
743
+ var MAX_BATCH_PATHS = 6;
744
+ var MAX_SUMMARY_CHARS = 220;
745
+ function fingerprintFocus(focus) {
746
+ return crypto.createHash("sha1").update(focus.trim().toLowerCase()).digest("hex");
747
+ }
748
+ function normalizeText2(value) {
749
+ return String(value ?? "").replace(/\s+/g, " ").trim();
750
+ }
751
+ function truncate3(value, maxChars) {
752
+ if (!value) {
753
+ return void 0;
754
+ }
755
+ return value.length <= maxChars ? value : `${value.slice(0, maxChars)}...`;
756
+ }
757
+ function takeLastUnique2(values, limit) {
742
758
  const seen = /* @__PURE__ */ new Set();
743
759
  const result = [];
744
760
  for (let index = values.length - 1; index >= 0; index -= 1) {
@@ -748,92 +764,169 @@ function takeLastUnique2(values) {
748
764
  }
749
765
  seen.add(normalized);
750
766
  result.unshift(normalized);
751
- if (result.length >= MAX_REASON_ITEMS) {
767
+ if (result.length >= limit) {
752
768
  break;
753
769
  }
754
770
  }
755
771
  return result;
756
772
  }
757
- function truncate3(value) {
758
- return value.length <= MAX_REASON_TEXT_CHARS ? value : `${value.slice(0, MAX_REASON_TEXT_CHARS)}...`;
773
+ function safeParseObject2(raw) {
774
+ if (typeof raw !== "string" || raw.trim().length === 0) {
775
+ return null;
776
+ }
777
+ try {
778
+ const parsed = JSON.parse(raw);
779
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
780
+ return null;
781
+ }
782
+ return parsed;
783
+ } catch {
784
+ return null;
785
+ }
759
786
  }
760
- function normalizeText2(value) {
761
- return String(value ?? "").replace(/\s+/g, " ").trim();
787
+ function readString(value) {
788
+ const normalized = normalizeText2(value);
789
+ return normalized || void 0;
762
790
  }
763
- function clampWholeNumber(value, min, max, fallback) {
764
- if (typeof value !== "number" || !Number.isFinite(value)) {
765
- return fallback;
791
+ function normalizeToolBatch(toolBatch) {
792
+ if (!toolBatch) {
793
+ return void 0;
794
+ }
795
+ const tools = takeLastUnique2(toolBatch.tools ?? [], MAX_BATCH_TOOLS);
796
+ if (tools.length === 0) {
797
+ return void 0;
766
798
  }
767
- return Math.max(min, Math.min(max, Math.trunc(value)));
768
- }
769
-
770
- // src/agent/runtimeTransition/builders.ts
771
- function createToolBatchTransition(input, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
772
799
  return {
773
- action: "continue",
774
- reason: {
775
- code: "continue.after_tool_batch",
776
- toolNames: takeLastUnique2(input.toolNames),
777
- changedPaths: takeLastUnique2(input.changedPaths ?? [])
778
- },
779
- timestamp
800
+ tools,
801
+ summary: truncate3(normalizeText2(toolBatch.summary) || `Ran ${tools.join(", ")}`, MAX_SUMMARY_CHARS),
802
+ changedPaths: takeLastUnique2(toolBatch.changedPaths ?? [], MAX_BATCH_PATHS),
803
+ recordedAt: normalizeTimestamp(toolBatch.recordedAt, (/* @__PURE__ */ new Date()).toISOString())
780
804
  };
781
805
  }
782
- function createEmptyAssistantResponseTransition(timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
783
- return {
784
- action: "continue",
785
- reason: {
786
- code: "continue.empty_assistant_response"
787
- },
788
- timestamp
789
- };
806
+
807
+ // src/session/checkpoint/derivation.ts
808
+ function deriveCompletedSteps(session) {
809
+ const completedActions = session.taskState?.completedActions ?? [];
810
+ return takeLastUnique2(completedActions, MAX_COMPLETED_STEPS);
790
811
  }
791
- function createProviderRecoveryTransition(input, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
792
- return {
793
- action: "recover",
794
- reason: {
795
- code: "recover.provider_request_retry",
796
- consecutiveFailures: Math.max(1, Math.trunc(input.consecutiveFailures)),
797
- error: truncate3(normalizeText2(input.error?.message ?? input.error) || "request failed"),
798
- configuredModel: normalizeText2(input.configuredModel) || "unknown_model",
799
- requestModel: normalizeText2(input.requestModel) || "unknown_model",
800
- contextWindowMessages: Math.max(1, Math.trunc(input.requestConfig.contextWindowMessages)),
801
- maxContextChars: Math.max(1, Math.trunc(input.requestConfig.maxContextChars)),
802
- contextSummaryChars: Math.max(1, Math.trunc(input.requestConfig.contextSummaryChars)),
803
- delayMs: Math.max(0, Math.trunc(input.delayMs))
804
- },
812
+ function deriveRecentToolBatchFromMessages(messages, timestamp) {
813
+ let lastToolIndex = messages.length - 1;
814
+ while (lastToolIndex >= 0 && messages[lastToolIndex]?.role !== "tool") {
815
+ lastToolIndex -= 1;
816
+ }
817
+ if (lastToolIndex < 0) {
818
+ return void 0;
819
+ }
820
+ let startIndex = lastToolIndex;
821
+ while (startIndex >= 0 && messages[startIndex]?.role === "tool") {
822
+ startIndex -= 1;
823
+ }
824
+ const toolMessages = messages.slice(startIndex + 1, lastToolIndex + 1).filter((message) => message.role === "tool");
825
+ const toolNames = toolMessages.map((message) => normalizeText2(message.name)).filter(Boolean);
826
+ return buildToolBatch(toolNames, toolMessages, void 0, timestamp);
827
+ }
828
+ function buildToolBatch(toolNames, toolMessages, changedPaths, timestamp) {
829
+ const tools = takeLastUnique2(toolNames, MAX_BATCH_TOOLS);
830
+ if (tools.length === 0) {
831
+ return void 0;
832
+ }
833
+ const batchChangedPaths = takeLastUnique2(
834
+ [
835
+ ...changedPaths ?? [],
836
+ ...toolMessages.map((message) => readPathFromMessage(message)).filter(Boolean)
837
+ ],
838
+ MAX_BATCH_PATHS
839
+ );
840
+ const recordedAt = normalizeTimestamp(
841
+ toolMessages[toolMessages.length - 1]?.createdAt,
805
842
  timestamp
843
+ );
844
+ return {
845
+ tools,
846
+ summary: buildToolBatchSummary(tools, batchChangedPaths),
847
+ changedPaths: batchChangedPaths,
848
+ recordedAt
806
849
  };
807
850
  }
808
- function createFinalizeTransition(input, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
851
+ function readPathFromMessage(message) {
852
+ const payload = safeParseObject2(message.content);
853
+ return readString(payload?.path) ?? readString(payload?.requestedPath);
854
+ }
855
+ function buildToolBatchSummary(toolNames, changedPaths) {
856
+ const fragments = [`Ran ${toolNames.join(", ")}`];
857
+ if (changedPaths.length > 0) {
858
+ fragments.push(`changed ${changedPaths.join(" | ")}`);
859
+ }
860
+ return truncate3(fragments.join("; "), MAX_SUMMARY_CHARS);
861
+ }
862
+
863
+ // src/session/checkpoint/base.ts
864
+ function createEmptyCheckpoint(timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
809
865
  return {
810
- action: "finalize",
811
- reason: {
812
- code: "finalize.completed",
813
- changedPaths: takeLastUnique2([...input.changedPaths])
866
+ version: 1,
867
+ status: "active",
868
+ completedSteps: [],
869
+ flow: {
870
+ phase: "active",
871
+ runState: {
872
+ status: "idle",
873
+ source: "checkpoint",
874
+ pendingToolCallCount: 0,
875
+ updatedAt: timestamp
876
+ },
877
+ updatedAt: timestamp
814
878
  },
815
- timestamp
879
+ updatedAt: timestamp
816
880
  };
817
881
  }
818
- function createExecutionWaitYieldTransition(input, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
882
+ function createCheckpointForFocus(focus, timestamp) {
819
883
  return {
820
- action: "yield",
821
- reason: {
822
- code: "yield.execution_wait",
823
- executionIds: takeLastUnique2([...input.executionIds]),
824
- toolNames: takeLastUnique2([...input.toolNames])
825
- },
826
- timestamp
884
+ ...createEmptyCheckpoint(timestamp),
885
+ focus,
886
+ focusFingerprint: focus ? fingerprintFocus(focus) : void 0
827
887
  };
828
888
  }
829
- function buildRunTurnResult(input) {
889
+ function deriveCheckpointFromSession(session, timestamp) {
890
+ const recentToolBatch = deriveRecentToolBatchFromMessages(session.messages, timestamp);
830
891
  return {
831
- session: input.session,
832
- changedPaths: [...input.changedPaths],
833
- transition: input.transition
892
+ ...createCheckpointForFocus(normalizeText2(session.taskState?.focus) || void 0, timestamp),
893
+ completedSteps: deriveCompletedSteps(session),
894
+ recentToolBatch
834
895
  };
835
896
  }
836
897
 
898
+ // src/agent/runtimeTransition/shared.ts
899
+ var MAX_REASON_ITEMS = 6;
900
+ var MAX_REASON_TEXT_CHARS = 220;
901
+ function takeLastUnique3(values) {
902
+ const seen = /* @__PURE__ */ new Set();
903
+ const result = [];
904
+ for (let index = values.length - 1; index >= 0; index -= 1) {
905
+ const normalized = normalizeText3(values[index]);
906
+ if (!normalized || seen.has(normalized)) {
907
+ continue;
908
+ }
909
+ seen.add(normalized);
910
+ result.unshift(normalized);
911
+ if (result.length >= MAX_REASON_ITEMS) {
912
+ break;
913
+ }
914
+ }
915
+ return result;
916
+ }
917
+ function truncate4(value) {
918
+ return value.length <= MAX_REASON_TEXT_CHARS ? value : `${value.slice(0, MAX_REASON_TEXT_CHARS)}...`;
919
+ }
920
+ function normalizeText3(value) {
921
+ return String(value ?? "").replace(/\s+/g, " ").trim();
922
+ }
923
+ function clampWholeNumber(value, min, max, fallback) {
924
+ if (typeof value !== "number" || !Number.isFinite(value)) {
925
+ return fallback;
926
+ }
927
+ return Math.max(min, Math.min(max, Math.trunc(value)));
928
+ }
929
+
837
930
  // src/agent/runtimeTransition/normalize.ts
838
931
  function normalizeRuntimeTransition(transition, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
839
932
  if (!transition || typeof transition !== "object") {
@@ -861,7 +954,7 @@ function normalizeRuntimeTransition(transition, timestamp = (/* @__PURE__ */ new
861
954
  function normalizeContinueTransition(reason, timestamp) {
862
955
  switch (reason.code) {
863
956
  case "continue.after_tool_batch": {
864
- const toolNames = takeLastUnique2(reason.toolNames);
957
+ const toolNames = takeLastUnique3(reason.toolNames);
865
958
  if (toolNames.length === 0) {
866
959
  return void 0;
867
960
  }
@@ -870,7 +963,7 @@ function normalizeContinueTransition(reason, timestamp) {
870
963
  reason: {
871
964
  code: reason.code,
872
965
  toolNames,
873
- changedPaths: takeLastUnique2(reason.changedPaths ?? [])
966
+ changedPaths: takeLastUnique3(reason.changedPaths ?? [])
874
967
  },
875
968
  timestamp
876
969
  };
@@ -896,9 +989,9 @@ function normalizeRecoverTransition(reason, timestamp) {
896
989
  reason: {
897
990
  code: reason.code,
898
991
  consecutiveFailures: clampWholeNumber(reason.consecutiveFailures, 1, 50, 1) ?? 1,
899
- error: truncate3(normalizeText2(reason.error) || "request failed"),
900
- configuredModel: normalizeText2(reason.configuredModel) || "unknown_model",
901
- requestModel: normalizeText2(reason.requestModel) || "unknown_model",
992
+ error: truncate4(normalizeText3(reason.error) || "request failed"),
993
+ configuredModel: normalizeText3(reason.configuredModel) || "unknown_model",
994
+ requestModel: normalizeText3(reason.requestModel) || "unknown_model",
902
995
  contextWindowMessages: clampWholeNumber(reason.contextWindowMessages, 1, 999, 1) ?? 1,
903
996
  maxContextChars: clampWholeNumber(reason.maxContextChars, 1, 1e6, 1) ?? 1,
904
997
  contextSummaryChars: clampWholeNumber(reason.contextSummaryChars, 1, 1e6, 1) ?? 1,
@@ -915,7 +1008,7 @@ function normalizeFinalizeTransition(reason, timestamp) {
915
1008
  action: "finalize",
916
1009
  reason: {
917
1010
  code: reason.code,
918
- changedPaths: takeLastUnique2(reason.changedPaths ?? [])
1011
+ changedPaths: takeLastUnique3(reason.changedPaths ?? [])
919
1012
  },
920
1013
  timestamp
921
1014
  };
@@ -924,7 +1017,7 @@ function normalizeYieldTransition(reason, timestamp) {
924
1017
  if (reason.code !== "yield.execution_wait") {
925
1018
  return void 0;
926
1019
  }
927
- const executionIds = takeLastUnique2(reason.executionIds ?? []);
1020
+ const executionIds = takeLastUnique3(reason.executionIds ?? []);
928
1021
  if (executionIds.length === 0) {
929
1022
  return void 0;
930
1023
  }
@@ -933,7 +1026,7 @@ function normalizeYieldTransition(reason, timestamp) {
933
1026
  reason: {
934
1027
  code: reason.code,
935
1028
  executionIds,
936
- toolNames: takeLastUnique2(reason.toolNames ?? [])
1029
+ toolNames: takeLastUnique3(reason.toolNames ?? [])
937
1030
  },
938
1031
  timestamp
939
1032
  };
@@ -953,7 +1046,7 @@ function normalizeCheckpointFlow(flow, status, timestamp = (/* @__PURE__ */ new
953
1046
  });
954
1047
  return {
955
1048
  phase,
956
- reason: lastTransition ? formatRuntimeTransitionReason(lastTransition) : normalizeText2(flow?.reason) || void 0,
1049
+ reason: lastTransition ? formatRuntimeTransitionReason(lastTransition) : normalizeText3(flow?.reason) || void 0,
957
1050
  recoveryFailures: lastTransition?.action === "recover" ? lastTransition.reason.consecutiveFailures : phase === "recovery" ? clampWholeNumber(flow?.recoveryFailures, 1, 50, void 0) : void 0,
958
1051
  runState,
959
1052
  lastTransition,
@@ -1023,163 +1116,70 @@ function normalizeRunStateSource(source, status) {
1023
1116
  return "checkpoint";
1024
1117
  }
1025
1118
 
1026
- // src/session/checkpoint/shared.ts
1027
- import crypto from "crypto";
1028
- import path2 from "path";
1029
- var MAX_COMPLETED_STEPS = 8;
1030
- var MAX_BATCH_TOOLS = 6;
1031
- var MAX_BATCH_PATHS = 6;
1032
- var MAX_SUMMARY_CHARS = 220;
1033
- function fingerprintFocus(focus) {
1034
- return crypto.createHash("sha1").update(focus.trim().toLowerCase()).digest("hex");
1035
- }
1036
- function normalizeText3(value) {
1037
- return String(value ?? "").replace(/\s+/g, " ").trim();
1038
- }
1039
- function truncate4(value, maxChars) {
1040
- if (!value) {
1041
- return void 0;
1042
- }
1043
- return value.length <= maxChars ? value : `${value.slice(0, maxChars)}...`;
1044
- }
1045
- function takeLastUnique3(values, limit) {
1046
- const seen = /* @__PURE__ */ new Set();
1047
- const result = [];
1048
- for (let index = values.length - 1; index >= 0; index -= 1) {
1049
- const normalized = normalizeText3(values[index]);
1050
- if (!normalized || seen.has(normalized)) {
1051
- continue;
1052
- }
1053
- seen.add(normalized);
1054
- result.unshift(normalized);
1055
- if (result.length >= limit) {
1056
- break;
1057
- }
1058
- }
1059
- return result;
1060
- }
1061
- function safeParseObject2(raw) {
1062
- if (typeof raw !== "string" || raw.trim().length === 0) {
1063
- return null;
1064
- }
1065
- try {
1066
- const parsed = JSON.parse(raw);
1067
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1068
- return null;
1069
- }
1070
- return parsed;
1071
- } catch {
1072
- return null;
1073
- }
1074
- }
1075
- function readString(value) {
1076
- const normalized = normalizeText3(value);
1077
- return normalized || void 0;
1078
- }
1079
- function normalizeToolBatch(toolBatch) {
1080
- if (!toolBatch) {
1081
- return void 0;
1082
- }
1083
- const tools = takeLastUnique3(toolBatch.tools ?? [], MAX_BATCH_TOOLS);
1084
- if (tools.length === 0) {
1085
- return void 0;
1086
- }
1119
+ // src/agent/runtimeTransition/builders.ts
1120
+ function createToolBatchTransition(input, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
1087
1121
  return {
1088
- tools,
1089
- summary: truncate4(normalizeText3(toolBatch.summary) || `Ran ${tools.join(", ")}`, MAX_SUMMARY_CHARS),
1090
- changedPaths: takeLastUnique3(toolBatch.changedPaths ?? [], MAX_BATCH_PATHS),
1091
- recordedAt: normalizeTimestamp(toolBatch.recordedAt, (/* @__PURE__ */ new Date()).toISOString())
1122
+ action: "continue",
1123
+ reason: {
1124
+ code: "continue.after_tool_batch",
1125
+ toolNames: takeLastUnique3(input.toolNames),
1126
+ changedPaths: takeLastUnique3(input.changedPaths ?? [])
1127
+ },
1128
+ timestamp
1092
1129
  };
1093
1130
  }
1094
-
1095
- // src/session/checkpoint/derivation.ts
1096
- function deriveCompletedSteps(session) {
1097
- const completedActions = session.taskState?.completedActions ?? [];
1098
- return takeLastUnique3(completedActions, MAX_COMPLETED_STEPS);
1099
- }
1100
- function deriveRecentToolBatchFromMessages(messages, timestamp) {
1101
- let lastToolIndex = messages.length - 1;
1102
- while (lastToolIndex >= 0 && messages[lastToolIndex]?.role !== "tool") {
1103
- lastToolIndex -= 1;
1104
- }
1105
- if (lastToolIndex < 0) {
1106
- return void 0;
1107
- }
1108
- let startIndex = lastToolIndex;
1109
- while (startIndex >= 0 && messages[startIndex]?.role === "tool") {
1110
- startIndex -= 1;
1111
- }
1112
- const toolMessages = messages.slice(startIndex + 1, lastToolIndex + 1).filter((message) => message.role === "tool");
1113
- const toolNames = toolMessages.map((message) => normalizeText3(message.name)).filter(Boolean);
1114
- return buildToolBatch(toolNames, toolMessages, void 0, timestamp);
1115
- }
1116
- function buildToolBatch(toolNames, toolMessages, changedPaths, timestamp) {
1117
- const tools = takeLastUnique3(toolNames, MAX_BATCH_TOOLS);
1118
- if (tools.length === 0) {
1119
- return void 0;
1120
- }
1121
- const batchChangedPaths = takeLastUnique3(
1122
- [
1123
- ...changedPaths ?? [],
1124
- ...toolMessages.map((message) => readPathFromMessage(message)).filter(Boolean)
1125
- ],
1126
- MAX_BATCH_PATHS
1127
- );
1128
- const recordedAt = normalizeTimestamp(
1129
- toolMessages[toolMessages.length - 1]?.createdAt,
1130
- timestamp
1131
- );
1131
+ function createEmptyAssistantResponseTransition(timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
1132
1132
  return {
1133
- tools,
1134
- summary: buildToolBatchSummary(tools, batchChangedPaths),
1135
- changedPaths: batchChangedPaths,
1136
- recordedAt
1133
+ action: "continue",
1134
+ reason: {
1135
+ code: "continue.empty_assistant_response"
1136
+ },
1137
+ timestamp
1137
1138
  };
1138
1139
  }
1139
- function readPathFromMessage(message) {
1140
- const payload = safeParseObject2(message.content);
1141
- return readString(payload?.path) ?? readString(payload?.requestedPath);
1142
- }
1143
- function buildToolBatchSummary(toolNames, changedPaths) {
1144
- const fragments = [`Ran ${toolNames.join(", ")}`];
1145
- if (changedPaths.length > 0) {
1146
- fragments.push(`changed ${changedPaths.join(" | ")}`);
1147
- }
1148
- return truncate4(fragments.join("; "), MAX_SUMMARY_CHARS);
1140
+ function createProviderRecoveryTransition(input, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
1141
+ return {
1142
+ action: "recover",
1143
+ reason: {
1144
+ code: "recover.provider_request_retry",
1145
+ consecutiveFailures: Math.max(1, Math.trunc(input.consecutiveFailures)),
1146
+ error: truncate4(normalizeText3(input.error?.message ?? input.error) || "request failed"),
1147
+ configuredModel: normalizeText3(input.configuredModel) || "unknown_model",
1148
+ requestModel: normalizeText3(input.requestModel) || "unknown_model",
1149
+ contextWindowMessages: Math.max(1, Math.trunc(input.requestConfig.contextWindowMessages)),
1150
+ maxContextChars: Math.max(1, Math.trunc(input.requestConfig.maxContextChars)),
1151
+ contextSummaryChars: Math.max(1, Math.trunc(input.requestConfig.contextSummaryChars)),
1152
+ delayMs: Math.max(0, Math.trunc(input.delayMs))
1153
+ },
1154
+ timestamp
1155
+ };
1149
1156
  }
1150
-
1151
- // src/session/checkpoint/base.ts
1152
- function createEmptyCheckpoint(timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
1157
+ function createFinalizeTransition(input, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
1153
1158
  return {
1154
- version: 1,
1155
- status: "active",
1156
- completedSteps: [],
1157
- flow: {
1158
- phase: "active",
1159
- runState: {
1160
- status: "idle",
1161
- source: "checkpoint",
1162
- pendingToolCallCount: 0,
1163
- updatedAt: timestamp
1164
- },
1165
- updatedAt: timestamp
1159
+ action: "finalize",
1160
+ reason: {
1161
+ code: "finalize.completed",
1162
+ changedPaths: takeLastUnique3([...input.changedPaths])
1166
1163
  },
1167
- updatedAt: timestamp
1164
+ timestamp
1168
1165
  };
1169
1166
  }
1170
- function createCheckpointForFocus(focus, timestamp) {
1167
+ function createExecutionWaitYieldTransition(input, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
1171
1168
  return {
1172
- ...createEmptyCheckpoint(timestamp),
1173
- focus,
1174
- focusFingerprint: focus ? fingerprintFocus(focus) : void 0
1169
+ action: "yield",
1170
+ reason: {
1171
+ code: "yield.execution_wait",
1172
+ executionIds: takeLastUnique3([...input.executionIds]),
1173
+ toolNames: takeLastUnique3([...input.toolNames])
1174
+ },
1175
+ timestamp
1175
1176
  };
1176
1177
  }
1177
- function deriveCheckpointFromSession(session, timestamp) {
1178
- const recentToolBatch = deriveRecentToolBatchFromMessages(session.messages, timestamp);
1178
+ function buildRunTurnResult(input) {
1179
1179
  return {
1180
- ...createCheckpointForFocus(normalizeText3(session.taskState?.focus) || void 0, timestamp),
1181
- completedSteps: deriveCompletedSteps(session),
1182
- recentToolBatch
1180
+ session: input.session,
1181
+ changedPaths: [...input.changedPaths],
1182
+ transition: input.transition
1183
1183
  };
1184
1184
  }
1185
1185
 
@@ -1188,14 +1188,14 @@ function normalizeCheckpoint(checkpoint, timestamp = (/* @__PURE__ */ new Date()
1188
1188
  if (!checkpoint) {
1189
1189
  return void 0;
1190
1190
  }
1191
- const focus = normalizeText3(checkpoint.focus) || void 0;
1191
+ const focus = normalizeText2(checkpoint.focus) || void 0;
1192
1192
  const status = checkpoint.status === "completed" ? "completed" : "active";
1193
1193
  return {
1194
1194
  version: 1,
1195
1195
  focus,
1196
- focusFingerprint: normalizeText3(checkpoint.focusFingerprint) || (focus ? fingerprintFocus(focus) : void 0),
1196
+ focusFingerprint: normalizeText2(checkpoint.focusFingerprint) || (focus ? fingerprintFocus(focus) : void 0),
1197
1197
  status,
1198
- completedSteps: takeLastUnique3(checkpoint.completedSteps ?? [], 8),
1198
+ completedSteps: takeLastUnique2(checkpoint.completedSteps ?? [], 8),
1199
1199
  recentToolBatch: normalizeToolBatch(checkpoint.recentToolBatch),
1200
1200
  flow: normalizeCheckpointFlow(checkpoint.flow, status, timestamp),
1201
1201
  updatedAt: normalizeTimestamp(checkpoint.updatedAt, timestamp)
@@ -1241,7 +1241,7 @@ function noteCheckpointTurnInput(session, input, timestamp = (/* @__PURE__ */ ne
1241
1241
  };
1242
1242
  }
1243
1243
  function resolveCurrentFocusCheckpoint(session, timestamp = (/* @__PURE__ */ new Date()).toISOString()) {
1244
- const focus = normalizeText3(session.taskState?.focus) || void 0;
1244
+ const focus = normalizeText2(session.taskState?.focus) || void 0;
1245
1245
  const fingerprint = focus ? fingerprintFocus(focus) : void 0;
1246
1246
  const checkpoint = normalizeCheckpoint(session.checkpoint, timestamp) ?? createEmptyCheckpoint(timestamp);
1247
1247
  if (!focus) {
@@ -1666,8 +1666,8 @@ export {
1666
1666
  createExecutionWaitYieldTransition,
1667
1667
  buildRunTurnResult,
1668
1668
  fingerprintFocus,
1669
- normalizeText3 as normalizeText,
1670
- takeLastUnique3 as takeLastUnique,
1669
+ normalizeText2 as normalizeText,
1670
+ takeLastUnique2 as takeLastUnique,
1671
1671
  createEmptyCheckpoint,
1672
1672
  normalizeCheckpoint,
1673
1673
  normalizeSessionCheckpoint,
@@ -11,7 +11,7 @@ import {
11
11
  normalizeSessionTodos,
12
12
  normalizeSessionWorkset,
13
13
  normalizeTodoItems
14
- } from "./chunk-S4QTRPZ7.mjs";
14
+ } from "./chunk-C3MFBHV3.mjs";
15
15
 
16
16
  // src/session/store.ts
17
17
  import crypto from "crypto";