@remnic/core 1.1.8 → 1.1.10

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 (267) hide show
  1. package/dist/access-cli.js +44 -41
  2. package/dist/access-cli.js.map +1 -1
  3. package/dist/access-http.d.ts +8 -7
  4. package/dist/access-http.js +20 -17
  5. package/dist/access-mcp.d.ts +8 -7
  6. package/dist/access-mcp.js +19 -16
  7. package/dist/{access-service-C0Rkioec.d.ts → access-service-BTTNyo1i.d.ts} +11 -9
  8. package/dist/access-service.d.ts +8 -7
  9. package/dist/access-service.js +18 -15
  10. package/dist/active-memory-bridge.d.ts +2 -1
  11. package/dist/active-recall.d.ts +3 -2
  12. package/dist/active-recall.js +2 -2
  13. package/dist/active-recall.js.map +1 -1
  14. package/dist/behavior-learner.d.ts +2 -1
  15. package/dist/behavior-signals.d.ts +2 -1
  16. package/dist/bootstrap.d.ts +7 -6
  17. package/dist/briefing.d.ts +3 -2
  18. package/dist/briefing.js +6 -6
  19. package/dist/buffer-surprise-report.d.ts +2 -1
  20. package/dist/buffer.d.ts +3 -2
  21. package/dist/calibration.d.ts +4 -1
  22. package/dist/calibration.js +10 -5
  23. package/dist/calibration.js.map +1 -1
  24. package/dist/causal-behavior.d.ts +2 -1
  25. package/dist/causal-consolidation.d.ts +5 -2
  26. package/dist/causal-consolidation.js +17 -11
  27. package/dist/causal-consolidation.js.map +1 -1
  28. package/dist/{chunk-AV2WSYZY.js → chunk-2YMTO4ZJ.js} +2 -2
  29. package/dist/{chunk-SYWJJTNL.js → chunk-363MWCD3.js} +42 -42
  30. package/dist/{chunk-65ZPH7QA.js → chunk-36CTNQY7.js} +7 -7
  31. package/dist/{chunk-GZCUW5IC.js → chunk-3IQ2TR4N.js} +5 -5
  32. package/dist/chunk-3IQ2TR4N.js.map +1 -0
  33. package/dist/{chunk-TUFG6VXY.js → chunk-4DWOBS2A.js} +2 -2
  34. package/dist/chunk-4DWOBS2A.js.map +1 -0
  35. package/dist/{chunk-SRIDOT64.js → chunk-4DXC6HQQ.js} +6 -4
  36. package/dist/chunk-4DXC6HQQ.js.map +1 -0
  37. package/dist/{chunk-L2IO2QPY.js → chunk-4IS4SXIQ.js} +17 -13
  38. package/dist/chunk-4IS4SXIQ.js.map +1 -0
  39. package/dist/{chunk-RJSVRPNU.js → chunk-57QNCUEZ.js} +19 -12
  40. package/dist/chunk-57QNCUEZ.js.map +1 -0
  41. package/dist/{chunk-GRDDGNYQ.js → chunk-5GCNE7CN.js} +105 -499
  42. package/dist/chunk-5GCNE7CN.js.map +1 -0
  43. package/dist/{chunk-LOBRX7VD.js → chunk-5UM2VJ6D.js} +12 -1
  44. package/dist/chunk-5UM2VJ6D.js.map +1 -0
  45. package/dist/{chunk-XVOIMCVW.js → chunk-6XA7UN4Z.js} +2 -2
  46. package/dist/{chunk-QJZ77K7F.js → chunk-6Z6UH6TK.js} +26 -12
  47. package/dist/chunk-6Z6UH6TK.js.map +1 -0
  48. package/dist/{chunk-ODWDQNRE.js → chunk-7SI52C65.js} +7 -3
  49. package/dist/chunk-7SI52C65.js.map +1 -0
  50. package/dist/{chunk-FIXIX6DE.js → chunk-C5HUWVH2.js} +33 -43
  51. package/dist/chunk-C5HUWVH2.js.map +1 -0
  52. package/dist/{chunk-NN3TS5BM.js → chunk-D54LZC5L.js} +4 -4
  53. package/dist/{chunk-KNQ5YJTO.js → chunk-ERUDW6DU.js} +209 -1
  54. package/dist/chunk-ERUDW6DU.js.map +1 -0
  55. package/dist/{chunk-E27HOXMX.js → chunk-EYNQTST2.js} +2 -2
  56. package/dist/chunk-FVQJYWH7.js +52 -0
  57. package/dist/chunk-FVQJYWH7.js.map +1 -0
  58. package/dist/{chunk-3FPTCC3Z.js → chunk-GVPWB7EY.js} +2 -2
  59. package/dist/chunk-HJYHRE4S.js +647 -0
  60. package/dist/chunk-HJYHRE4S.js.map +1 -0
  61. package/dist/{chunk-SWRJFKYW.js → chunk-I6BQZSML.js} +5 -5
  62. package/dist/chunk-IBX3VFOM.js +446 -0
  63. package/dist/chunk-IBX3VFOM.js.map +1 -0
  64. package/dist/{chunk-STB3GUYU.js → chunk-KBYWQWSB.js} +8 -8
  65. package/dist/chunk-KWBPHZUU.js +83 -0
  66. package/dist/chunk-KWBPHZUU.js.map +1 -0
  67. package/dist/{chunk-MYH2IBSP.js → chunk-LIO5X3CM.js} +3 -3
  68. package/dist/{chunk-XGX4TUF6.js → chunk-MCC6KDQF.js} +5 -5
  69. package/dist/{chunk-4KAN3GZ3.js → chunk-NN2DKE4T.js} +1 -1
  70. package/dist/chunk-NN2DKE4T.js.map +1 -0
  71. package/dist/{chunk-R2XRID2N.js → chunk-NN3LPQ5D.js} +5 -5
  72. package/dist/chunk-NN3LPQ5D.js.map +1 -0
  73. package/dist/{chunk-WXPPM426.js → chunk-O4XJUPSF.js} +2 -2
  74. package/dist/{chunk-WSZIHQBK.js → chunk-P77UEOU2.js} +4 -1
  75. package/dist/{chunk-WSZIHQBK.js.map → chunk-P77UEOU2.js.map} +1 -1
  76. package/dist/{chunk-RLV2F337.js → chunk-PB5KW5PL.js} +2 -2
  77. package/dist/{chunk-S5SQDIF5.js → chunk-PHNGXFQ6.js} +7 -5
  78. package/dist/chunk-PHNGXFQ6.js.map +1 -0
  79. package/dist/{chunk-FEMOX5AD.js → chunk-QR3C7BKQ.js} +7 -7
  80. package/dist/chunk-QR3C7BKQ.js.map +1 -0
  81. package/dist/{chunk-ETA2JXP5.js → chunk-RXTFCYQF.js} +2 -2
  82. package/dist/{chunk-Q7FJ5ZHM.js → chunk-S3IP6R6K.js} +8 -2
  83. package/dist/{chunk-Q7FJ5ZHM.js.map → chunk-S3IP6R6K.js.map} +1 -1
  84. package/dist/{chunk-3LCWFNVS.js → chunk-SKE7JYKA.js} +2 -2
  85. package/dist/{chunk-T65SHTJP.js → chunk-VQXK37XA.js} +1 -1
  86. package/dist/chunk-VQXK37XA.js.map +1 -0
  87. package/dist/{chunk-DWMXVUGO.js → chunk-VX2IUQFE.js} +98 -10
  88. package/dist/chunk-VX2IUQFE.js.map +1 -0
  89. package/dist/{chunk-KHJRMWO4.js → chunk-WGK4VHGP.js} +84 -22
  90. package/dist/chunk-WGK4VHGP.js.map +1 -0
  91. package/dist/{chunk-4IT6WL23.js → chunk-WTFWLUSX.js} +2 -2
  92. package/dist/{chunk-67YLUWLG.js → chunk-XJKFSSDW.js} +3 -3
  93. package/dist/chunk-XJKFSSDW.js.map +1 -0
  94. package/dist/{chunk-ASIQZXYO.js → chunk-XMVFHBHT.js} +2 -2
  95. package/dist/{chunk-Q5TJRAGE.js → chunk-Y5KDIOKF.js} +3 -3
  96. package/dist/{chunk-FCGWNWG4.js → chunk-Z5S5HNGY.js} +31 -29
  97. package/dist/chunk-Z5S5HNGY.js.map +1 -0
  98. package/dist/{chunk-OJMD2LIW.js → chunk-ZL4S7ARC.js} +3 -3
  99. package/dist/{cli-CIATRu8o.d.ts → cli-BrEwQTnW.d.ts} +4 -4
  100. package/dist/cli.d.ts +9 -8
  101. package/dist/cli.js +33 -31
  102. package/dist/codex-cli-fallback.d.ts +44 -0
  103. package/dist/codex-cli-fallback.js +12 -0
  104. package/dist/{codex-materialize-xVqbEmcm.d.ts → codex-materialize-CQlLTzke.d.ts} +1 -1
  105. package/dist/compression-optimizer.d.ts +2 -1
  106. package/dist/config.d.ts +2 -1
  107. package/dist/config.js +1 -1
  108. package/dist/consolidation-provenance-check.d.ts +3 -2
  109. package/dist/consolidation-undo.d.ts +3 -2
  110. package/dist/day-summary.d.ts +2 -1
  111. package/dist/day-summary.js +1 -1
  112. package/dist/delinearize.d.ts +2 -1
  113. package/dist/direct-answer-wiring.d.ts +2 -1
  114. package/dist/direct-answer.d.ts +2 -1
  115. package/dist/embedding-fallback.d.ts +2 -1
  116. package/dist/{engine-MEAYUA7A.js → engine-FOC3IJLA.js} +7 -7
  117. package/dist/entity-retrieval.d.ts +3 -2
  118. package/dist/entity-retrieval.js +6 -6
  119. package/dist/entity-schema.d.ts +2 -1
  120. package/dist/explicit-capture.d.ts +7 -6
  121. package/dist/explicit-capture.js +2 -2
  122. package/dist/explicit-cue-recall.js +1 -1
  123. package/dist/extraction-judge-telemetry.d.ts +2 -1
  124. package/dist/extraction-judge-training.d.ts +2 -1
  125. package/dist/extraction-judge.d.ts +2 -1
  126. package/dist/extraction.d.ts +2 -1
  127. package/dist/extraction.js +10 -8
  128. package/dist/fallback-llm.d.ts +8 -1
  129. package/dist/fallback-llm.js +5 -3
  130. package/dist/identity-continuity.d.ts +2 -1
  131. package/dist/importance.d.ts +2 -1
  132. package/dist/index-1qIcnbG1.d.ts +34 -0
  133. package/dist/index.d.ts +15 -13
  134. package/dist/index.js +175 -168
  135. package/dist/index.js.map +1 -1
  136. package/dist/intent.d.ts +2 -1
  137. package/dist/lifecycle.d.ts +2 -1
  138. package/dist/live-connectors-runner.d.ts +2 -1
  139. package/dist/live-connectors-runner.js +2 -2
  140. package/dist/local-llm.d.ts +2 -1
  141. package/dist/local-llm.js +1 -1
  142. package/dist/memory-action-policy.d.ts +2 -1
  143. package/dist/memory-cache.d.ts +2 -1
  144. package/dist/{memory-governance-G3XODEXW.js → memory-governance-F3QOJGEY.js} +7 -7
  145. package/dist/memory-lifecycle-ledger-utils.d.ts +2 -1
  146. package/dist/{memory-projection-store-lCzmu4JX.d.ts → memory-projection-store-CY8TU40w.d.ts} +1 -1
  147. package/dist/memory-projection-store.d.ts +3 -2
  148. package/dist/memory-projection-store.js +1 -1
  149. package/dist/memory-worth-outcomes.d.ts +3 -2
  150. package/dist/{migrate-from-identity-anchor-TTEDEJGX.js → migrate-from-identity-anchor-G27MCD6A.js} +2 -2
  151. package/dist/model-registry.js +1 -1
  152. package/dist/models-json.d.ts +2 -1
  153. package/dist/models-json.js +1 -1
  154. package/dist/native-knowledge.d.ts +2 -1
  155. package/dist/objective-state-writers.d.ts +23 -1
  156. package/dist/objective-state-writers.js +10 -306
  157. package/dist/objective-state-writers.js.map +1 -1
  158. package/dist/objective-state.d.ts +7 -1
  159. package/dist/objective-state.js +3 -1
  160. package/dist/operator-toolkit.d.ts +3 -2
  161. package/dist/operator-toolkit.js +11 -11
  162. package/dist/opik-exporter.js +2 -2
  163. package/dist/opik-exporter.js.map +1 -1
  164. package/dist/{orchestrator-CvUYwuaL.d.ts → orchestrator-6IvQ-Phj.d.ts} +6 -5
  165. package/dist/orchestrator.d.ts +7 -6
  166. package/dist/orchestrator.js +37 -35
  167. package/dist/patterns-cli.d.ts +2 -1
  168. package/dist/{peers-6OSQ3NK6.js → peers-HCVGHMAE.js} +3 -3
  169. package/dist/peers-HCVGHMAE.js.map +1 -0
  170. package/dist/policy-runtime.d.ts +2 -1
  171. package/dist/{port-BkWL7hqo.d.ts → port-B6VEDIkC.d.ts} +7 -1
  172. package/dist/qmd-recall-cache.d.ts +3 -2
  173. package/dist/qmd.d.ts +4 -2
  174. package/dist/qmd.js +1 -1
  175. package/dist/recall-disclosure-escalation.d.ts +2 -1
  176. package/dist/recall-explain-renderer.d.ts +2 -1
  177. package/dist/recall-explain-renderer.js +3 -3
  178. package/dist/recall-state.d.ts +2 -1
  179. package/dist/recall-tag-filter.d.ts +2 -1
  180. package/dist/recall-xray-cli.d.ts +2 -1
  181. package/dist/recall-xray-cli.js +4 -4
  182. package/dist/recall-xray-renderer.d.ts +2 -1
  183. package/dist/recall-xray-renderer.js +3 -3
  184. package/dist/recall-xray.d.ts +2 -1
  185. package/dist/recall-xray.js +2 -2
  186. package/dist/resolve-auth-token.d.ts +2 -1
  187. package/dist/resolve-provider-secret.d.ts +2 -1
  188. package/dist/resolve-provider-secret.js +3 -1
  189. package/dist/resume-bundles.js +4 -4
  190. package/dist/retrieval-agents.d.ts +3 -2
  191. package/dist/retrieval-tiers.d.ts +2 -1
  192. package/dist/sanitize.js +1 -1
  193. package/dist/schemas.d.ts +22 -22
  194. package/dist/{semantic-consolidation-CGiH52qa.d.ts → semantic-consolidation-ByBXb-sf.d.ts} +2 -2
  195. package/dist/semantic-consolidation.d.ts +4 -3
  196. package/dist/semantic-consolidation.js +6 -6
  197. package/dist/semantic-rule-promotion.js +6 -6
  198. package/dist/semantic-rule-verifier.d.ts +2 -1
  199. package/dist/semantic-rule-verifier.js +6 -6
  200. package/dist/session-observer-bands.d.ts +2 -1
  201. package/dist/session-observer-state.d.ts +2 -1
  202. package/dist/signal.d.ts +2 -1
  203. package/dist/source-attribution.d.ts +1 -1
  204. package/dist/source-attribution.js +1 -1
  205. package/dist/storage.d.ts +3 -2
  206. package/dist/storage.js +5 -5
  207. package/dist/summarizer.d.ts +2 -1
  208. package/dist/summarizer.js +8 -6
  209. package/dist/summary-snapshot.d.ts +2 -1
  210. package/dist/temporal-supersession.d.ts +3 -2
  211. package/dist/temporal-validity.d.ts +2 -1
  212. package/dist/threading.d.ts +2 -1
  213. package/dist/tier-migration.d.ts +4 -3
  214. package/dist/tier-routing.d.ts +2 -1
  215. package/dist/topics.d.ts +2 -1
  216. package/dist/transcript.d.ts +2 -1
  217. package/dist/types.d.ts +2693 -1
  218. package/dist/types.js +1 -1
  219. package/dist/utility-runtime.d.ts +2 -1
  220. package/dist/verified-recall.js +6 -6
  221. package/package.json +1 -1
  222. package/dist/chunk-4KAN3GZ3.js.map +0 -1
  223. package/dist/chunk-67YLUWLG.js.map +0 -1
  224. package/dist/chunk-DWMXVUGO.js.map +0 -1
  225. package/dist/chunk-FCGWNWG4.js.map +0 -1
  226. package/dist/chunk-FEMOX5AD.js.map +0 -1
  227. package/dist/chunk-FIXIX6DE.js.map +0 -1
  228. package/dist/chunk-GRDDGNYQ.js.map +0 -1
  229. package/dist/chunk-GZCUW5IC.js.map +0 -1
  230. package/dist/chunk-KHJRMWO4.js.map +0 -1
  231. package/dist/chunk-KNQ5YJTO.js.map +0 -1
  232. package/dist/chunk-L2IO2QPY.js.map +0 -1
  233. package/dist/chunk-LOBRX7VD.js.map +0 -1
  234. package/dist/chunk-M62O4P4T.js +0 -41
  235. package/dist/chunk-M62O4P4T.js.map +0 -1
  236. package/dist/chunk-ODWDQNRE.js.map +0 -1
  237. package/dist/chunk-QJZ77K7F.js.map +0 -1
  238. package/dist/chunk-R2XRID2N.js.map +0 -1
  239. package/dist/chunk-RJSVRPNU.js.map +0 -1
  240. package/dist/chunk-S5SQDIF5.js.map +0 -1
  241. package/dist/chunk-SRIDOT64.js.map +0 -1
  242. package/dist/chunk-T65SHTJP.js.map +0 -1
  243. package/dist/chunk-TUFG6VXY.js.map +0 -1
  244. package/dist/types-H85grL1f.d.ts +0 -2714
  245. /package/dist/{chunk-AV2WSYZY.js.map → chunk-2YMTO4ZJ.js.map} +0 -0
  246. /package/dist/{chunk-SYWJJTNL.js.map → chunk-363MWCD3.js.map} +0 -0
  247. /package/dist/{chunk-65ZPH7QA.js.map → chunk-36CTNQY7.js.map} +0 -0
  248. /package/dist/{chunk-XVOIMCVW.js.map → chunk-6XA7UN4Z.js.map} +0 -0
  249. /package/dist/{chunk-NN3TS5BM.js.map → chunk-D54LZC5L.js.map} +0 -0
  250. /package/dist/{chunk-E27HOXMX.js.map → chunk-EYNQTST2.js.map} +0 -0
  251. /package/dist/{chunk-3FPTCC3Z.js.map → chunk-GVPWB7EY.js.map} +0 -0
  252. /package/dist/{chunk-SWRJFKYW.js.map → chunk-I6BQZSML.js.map} +0 -0
  253. /package/dist/{chunk-STB3GUYU.js.map → chunk-KBYWQWSB.js.map} +0 -0
  254. /package/dist/{chunk-MYH2IBSP.js.map → chunk-LIO5X3CM.js.map} +0 -0
  255. /package/dist/{chunk-XGX4TUF6.js.map → chunk-MCC6KDQF.js.map} +0 -0
  256. /package/dist/{chunk-WXPPM426.js.map → chunk-O4XJUPSF.js.map} +0 -0
  257. /package/dist/{chunk-RLV2F337.js.map → chunk-PB5KW5PL.js.map} +0 -0
  258. /package/dist/{chunk-ETA2JXP5.js.map → chunk-RXTFCYQF.js.map} +0 -0
  259. /package/dist/{chunk-3LCWFNVS.js.map → chunk-SKE7JYKA.js.map} +0 -0
  260. /package/dist/{chunk-4IT6WL23.js.map → chunk-WTFWLUSX.js.map} +0 -0
  261. /package/dist/{chunk-ASIQZXYO.js.map → chunk-XMVFHBHT.js.map} +0 -0
  262. /package/dist/{chunk-Q5TJRAGE.js.map → chunk-Y5KDIOKF.js.map} +0 -0
  263. /package/dist/{chunk-OJMD2LIW.js.map → chunk-ZL4S7ARC.js.map} +0 -0
  264. /package/dist/{engine-MEAYUA7A.js.map → codex-cli-fallback.js.map} +0 -0
  265. /package/dist/{memory-governance-G3XODEXW.js.map → engine-FOC3IJLA.js.map} +0 -0
  266. /package/dist/{migrate-from-identity-anchor-TTEDEJGX.js.map → memory-governance-F3QOJGEY.js.map} +0 -0
  267. /package/dist/{peers-6OSQ3NK6.js.map → migrate-from-identity-anchor-G27MCD6A.js.map} +0 -0
@@ -0,0 +1,647 @@
1
+ import {
2
+ parseMessageParts
3
+ } from "./chunk-IBX3VFOM.js";
4
+ import {
5
+ recordObjectiveStateSnapshot
6
+ } from "./chunk-5UM2VJ6D.js";
7
+
8
+ // src/objective-state-writers.ts
9
+ import crypto from "crypto";
10
+ var rawProviderParts = /* @__PURE__ */ new WeakSet();
11
+ function markRawProviderParts(parts) {
12
+ for (const part of parts) {
13
+ rawProviderParts.add(part);
14
+ }
15
+ return parts;
16
+ }
17
+ function isRawProviderPart(part) {
18
+ return rawProviderParts.has(part);
19
+ }
20
+ function hashSha256(value) {
21
+ return crypto.createHash("sha256").update(value).digest("hex");
22
+ }
23
+ function isRecord(value) {
24
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25
+ }
26
+ function optionalString(value) {
27
+ if (typeof value !== "string") return void 0;
28
+ const trimmed = value.trim();
29
+ return trimmed.length > 0 ? trimmed : void 0;
30
+ }
31
+ function toolNameTokens(toolName) {
32
+ if (!toolName) return [];
33
+ return toolName.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter((token) => token.length > 0);
34
+ }
35
+ function normalizedToolName(toolName) {
36
+ return toolNameTokens(toolName).join("_");
37
+ }
38
+ function parseToolArguments(value) {
39
+ if (isRecord(value)) return value;
40
+ if (typeof value !== "string") return void 0;
41
+ try {
42
+ const parsed = JSON.parse(value);
43
+ return isRecord(parsed) ? parsed : void 0;
44
+ } catch {
45
+ return void 0;
46
+ }
47
+ }
48
+ function stableStringify(value) {
49
+ if (Array.isArray(value)) {
50
+ return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
51
+ }
52
+ if (isRecord(value)) {
53
+ return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
54
+ }
55
+ return JSON.stringify(value) ?? String(value);
56
+ }
57
+ function extractTextContent(value) {
58
+ if (typeof value === "string") return value.trim();
59
+ if (Array.isArray(value)) {
60
+ return value.map((block) => {
61
+ if (typeof block === "string") return block.trim();
62
+ if (isRecord(block) && block.type === "text" && typeof block.text === "string") {
63
+ return block.text.trim();
64
+ }
65
+ return "";
66
+ }).filter((item) => item.length > 0).join("\n");
67
+ }
68
+ if (isRecord(value)) {
69
+ return JSON.stringify(value);
70
+ }
71
+ return "";
72
+ }
73
+ function parseToolResultPayload(content) {
74
+ const text = extractTextContent(content);
75
+ if (text.length === 0) return void 0;
76
+ try {
77
+ return JSON.parse(text);
78
+ } catch {
79
+ return text;
80
+ }
81
+ }
82
+ function resultHash(value) {
83
+ if (value === void 0) return void 0;
84
+ const canonical = typeof value === "string" ? value : stableStringify(value);
85
+ if (!canonical || canonical.length === 0) return void 0;
86
+ return `sha256:${hashSha256(canonical)}`;
87
+ }
88
+ function getToolCallContexts(messages) {
89
+ const contexts = /* @__PURE__ */ new Map();
90
+ for (const message of messages) {
91
+ if (message.role !== "assistant") continue;
92
+ const toolCalls = message.tool_calls ?? message.toolCalls;
93
+ if (!Array.isArray(toolCalls)) continue;
94
+ for (const call of toolCalls) {
95
+ if (!isRecord(call)) continue;
96
+ const toolCallId = optionalString(call.id) ?? optionalString(call.toolCallId);
97
+ if (!toolCallId) continue;
98
+ const fn = isRecord(call.function) ? call.function : void 0;
99
+ const toolName = optionalString(fn?.name) ?? optionalString(call.name);
100
+ const args = parseToolArguments(fn?.arguments) ?? parseToolArguments(call.arguments) ?? parseToolArguments(call.args) ?? parseToolArguments(call.input);
101
+ contexts.set(toolCallId, { toolCallId, toolName, args });
102
+ }
103
+ }
104
+ return contexts;
105
+ }
106
+ function toolCallIdForMessage(message) {
107
+ return optionalString(message.tool_call_id) ?? optionalString(message.toolCallId) ?? optionalString(message.tool_use_id) ?? optionalString(message.toolUseId);
108
+ }
109
+ function toolNameForMessage(message, context) {
110
+ return optionalString(message.name) ?? optionalString(message.toolName) ?? optionalString(message.tool) ?? context?.toolName;
111
+ }
112
+ function pickString(args, keys) {
113
+ if (!args) return void 0;
114
+ for (const key of keys) {
115
+ const value = optionalString(args[key]);
116
+ if (value) return value;
117
+ }
118
+ return void 0;
119
+ }
120
+ function pickFirstStringArrayValue(args, key) {
121
+ const value = args?.[key];
122
+ if (!Array.isArray(value)) return void 0;
123
+ for (const item of value) {
124
+ const candidate = optionalString(item);
125
+ if (candidate) return candidate;
126
+ }
127
+ return void 0;
128
+ }
129
+ function fileScopeFromArgs(args) {
130
+ const destinationPath = pickString(args, ["destination", "dest", "targetPath", "target", "to"]) ?? pickString(args, ["path", "filePath", "workspacePath", "projectPath"]) ?? pickFirstStringArrayValue(args, "paths");
131
+ const sourcePath = pickString(args, ["source", "src", "from", "oldPath"]);
132
+ const scope = destinationPath ?? sourcePath;
133
+ return { scope, sourcePath, destinationPath };
134
+ }
135
+ function fileContentHash(args) {
136
+ const content = pickString(args, ["content", "patch", "diff", "text", "value"]) ?? args?.updates;
137
+ return resultHash(content);
138
+ }
139
+ function inferOutcome(message, parsedPayload) {
140
+ if (message.isError === true) return "failure";
141
+ if (isRecord(parsedPayload)) {
142
+ if (parsedPayload.partial === true || parsedPayload.status === "partial") return "partial";
143
+ if (parsedPayload.success === false || parsedPayload.ok === false) return "failure";
144
+ if (parsedPayload.success === true || parsedPayload.ok === true) return "success";
145
+ if (typeof parsedPayload.exitCode === "number") {
146
+ return parsedPayload.exitCode === 0 ? "success" : "failure";
147
+ }
148
+ if (optionalString(parsedPayload.error)) return "failure";
149
+ if (parsedPayload.status === "error" || parsedPayload.status === "failed") return "failure";
150
+ if (parsedPayload.status === "ok" || parsedPayload.status === "success") return "success";
151
+ const outputText = [
152
+ optionalString(parsedPayload.stdout),
153
+ optionalString(parsedPayload.stderr)
154
+ ].filter((entry) => entry !== void 0).join("\n");
155
+ if (outputText) {
156
+ const outputOutcome = inferOutcome({}, outputText);
157
+ if (outputOutcome !== "unknown") return outputOutcome;
158
+ }
159
+ }
160
+ if (typeof parsedPayload === "string") {
161
+ const lowered = parsedPayload.toLowerCase();
162
+ const loweredForFailure = lowered.replace(/\b(?:previously\s+)?failed tests?\s+now\s+pass(?:ed|es)?\b/g, "");
163
+ const hasZeroCountMarker = /\b(?:0|no)\s+(?:errors?|failures?|exceptions?|timeouts?)\b/.test(lowered);
164
+ const loweredForFailureCounts = loweredForFailure.replace(/\b(?:0|no)\s+errors?\b/g, "").replace(/\b(?:0|no)\s+failures?\b/g, "").replace(/\b(?:0|no)\s+exceptions?\b/g, "").replace(/\b(?:0|no)\s+timeouts?\b/g, "");
165
+ const hasNonZeroErrorCounts = /\b[1-9]\d*\s+errors?\b/.test(loweredForFailureCounts);
166
+ const hasNegatedSuccessMarkers = /\b(?:not|did not|didn't|doesn't|isn't|aren't|wasn't|weren't|won't|can't|couldn't|shouldn't|wouldn't)\s+(?:ok|pass|passed|passes|succeeded|success)\b/.test(loweredForFailure);
167
+ const hasSuccessMarkers = /\b(success|succeeded|pass|passes|passed|ok)\b/.test(lowered) || hasZeroCountMarker;
168
+ const hasFailureMarkers = hasNegatedSuccessMarkers || /\b(exceptions?|failed|failures?|fatal|timeouts?|timed out)\b/.test(loweredForFailureCounts) || hasNonZeroErrorCounts || /\berrors?\b/.test(loweredForFailureCounts) || /\b[a-z]+error\b/.test(loweredForFailureCounts) || /\b[a-z]+exception\b/.test(loweredForFailureCounts);
169
+ if (hasFailureMarkers) return "failure";
170
+ if (hasSuccessMarkers) return "success";
171
+ }
172
+ return "unknown";
173
+ }
174
+ function isProcessTool(toolName, args) {
175
+ const tokens = toolNameTokens(toolName);
176
+ const normalizedName = normalizedToolName(toolName);
177
+ if (pickString(args, ["cmd", "command", "script"])) return true;
178
+ return ["exec", "shell", "bash", "terminal", "run_command", "exec_command"].some(
179
+ (token) => token.includes("_") ? normalizedName === token : tokens.includes(token)
180
+ );
181
+ }
182
+ function isFileTool(toolName, args) {
183
+ const tokens = toolNameTokens(toolName);
184
+ const fileScope = fileScopeFromArgs(args);
185
+ if (fileScope.scope) return true;
186
+ return ["file", "path", "patch", "directory", "mkdir", "rename", "move"].some(
187
+ (token) => tokens.includes(token)
188
+ );
189
+ }
190
+ function inferFileChangeKind(toolName, outcome) {
191
+ if (outcome === "failure") return "failed";
192
+ const tokens = toolNameTokens(toolName);
193
+ if (["delete", "remove", "unlink"].some((token) => tokens.includes(token))) return "deleted";
194
+ if (["create", "mkdir", "new"].some((token) => tokens.includes(token))) return "created";
195
+ if (["write", "edit", "patch", "update", "append", "move", "rename"].some((token) => tokens.includes(token))) {
196
+ return "updated";
197
+ }
198
+ return "observed";
199
+ }
200
+ function buildFileValueRefs(args, changeKind) {
201
+ const { sourcePath, destinationPath, scope } = fileScopeFromArgs(args);
202
+ const contentHash = fileContentHash(args);
203
+ if (changeKind === "failed") {
204
+ if (sourcePath && destinationPath && sourcePath !== destinationPath) {
205
+ return {
206
+ before: { ref: sourcePath },
207
+ after: { ref: destinationPath }
208
+ };
209
+ }
210
+ return {
211
+ before: sourcePath ? { ref: sourcePath } : void 0,
212
+ after: scope ? { ref: scope } : void 0
213
+ };
214
+ }
215
+ if (changeKind === "deleted") {
216
+ return {
217
+ before: scope ? { exists: true, ref: scope } : void 0,
218
+ after: { exists: false }
219
+ };
220
+ }
221
+ if (changeKind === "created") {
222
+ return {
223
+ after: {
224
+ exists: true,
225
+ ref: scope,
226
+ valueHash: contentHash
227
+ }
228
+ };
229
+ }
230
+ if (sourcePath && destinationPath && sourcePath !== destinationPath) {
231
+ return {
232
+ before: { exists: true, ref: sourcePath },
233
+ after: {
234
+ exists: true,
235
+ ref: destinationPath
236
+ }
237
+ };
238
+ }
239
+ return {
240
+ after: {
241
+ exists: true,
242
+ ref: scope,
243
+ valueHash: contentHash
244
+ }
245
+ };
246
+ }
247
+ function summarizeSnapshot(kind, changeKind, toolName, scope) {
248
+ const action = changeKind === "executed" ? "Executed" : changeKind === "failed" ? "Failed" : changeKind === "created" ? "Created" : changeKind === "deleted" ? "Deleted" : changeKind === "updated" ? "Updated" : "Observed";
249
+ if (kind === "process") return `${action} process via ${toolName}: ${scope}`;
250
+ if (kind === "file") return `${action} file via ${toolName}: ${scope}`;
251
+ return `${action} tool result from ${toolName}: ${scope}`;
252
+ }
253
+ function buildGenericToolAfterRef(outcome, parsedPayload) {
254
+ const valueHash = resultHash(parsedPayload);
255
+ return valueHash ? { valueHash } : { exists: outcome !== "failure" };
256
+ }
257
+ function snapshotIdFor(sessionKey, recordedAt, index, toolName, scope, stableKey) {
258
+ const digest = crypto.createHash("sha256").update(
259
+ stableKey ? `${sessionKey}|${recordedAt}|${index}|${toolName}|${scope}|stable|${stableKey}` : `${sessionKey}|${recordedAt}|${index}|${toolName}|${scope}`
260
+ ).digest("hex").slice(0, 12);
261
+ return `obj-${digest}`;
262
+ }
263
+ function objectiveStatePartsForObservedMessage(message) {
264
+ if (message.role === "user") {
265
+ const explicitParts2 = Array.isArray(message.parts) && message.parts.length > 0 ? sanitizeUserRoleToolResultParts(message.parts) : [];
266
+ if (Array.isArray(message.parts) && message.parts.length > 0) {
267
+ const rawParts2 = userRawToolResultParts(message);
268
+ return mergeObservedEvidenceParts(explicitParts2, rawParts2);
269
+ }
270
+ return userRawToolResultParts(message);
271
+ }
272
+ if (message.role !== "assistant") {
273
+ return [];
274
+ }
275
+ const explicitParts = Array.isArray(message.parts) && message.parts.length > 0 ? message.parts : [];
276
+ const rawParts = assistantRawObjectiveStateParts(message);
277
+ return mergeObservedEvidenceParts(explicitParts, rawParts);
278
+ }
279
+ function userRawToolResultParts(message) {
280
+ const rawContent = message.rawContent ?? message.content;
281
+ if (!containsProviderToolResultBlock(rawContent)) {
282
+ return [];
283
+ }
284
+ return markRawProviderParts(
285
+ sanitizeUserRoleToolResultParts(parseMessageParts(rawContent, {
286
+ sourceFormat: message.sourceFormat,
287
+ allowRenderedFallback: false
288
+ }))
289
+ );
290
+ }
291
+ function assistantRawObjectiveStateParts(message) {
292
+ if (message.rawContent === void 0 || message.rawContent === null) {
293
+ return [];
294
+ }
295
+ return markRawProviderParts(parseMessageParts(message.rawContent, {
296
+ sourceFormat: message.sourceFormat,
297
+ allowRenderedFallback: false
298
+ }));
299
+ }
300
+ function mergeObservedEvidenceParts(explicitParts, rawParts) {
301
+ if (explicitParts.length === 0) return rawParts;
302
+ if (rawParts.length === 0) return explicitParts;
303
+ const merged = [...explicitParts];
304
+ const seen = new Set(
305
+ explicitParts.filter(isObjectiveStateEvidencePart).map(objectiveStateEvidencePartKey)
306
+ );
307
+ for (const part of rawParts) {
308
+ if (!isObjectiveStateEvidencePart(part)) continue;
309
+ const key = objectiveStateEvidencePartKey(part);
310
+ if (seen.has(key)) continue;
311
+ seen.add(key);
312
+ merged.push(part);
313
+ }
314
+ return merged;
315
+ }
316
+ function isObjectiveStateEvidencePart(part) {
317
+ return part.kind === "tool_call" || part.kind === "tool_result" || part.kind === "file_write" || part.kind === "patch";
318
+ }
319
+ function objectiveStateEvidencePartKey(part) {
320
+ const id = partToolCallId(part);
321
+ if (id) return `${part.kind}:id:${id}`;
322
+ const toolName = partToolName(part) ?? "";
323
+ const filePath = partFilePath(part) ?? "";
324
+ return `${part.kind}:shape:${toolName}:${filePath}:${stableStringify(partPayload(part))}`;
325
+ }
326
+ function flattenObservedParts(messages) {
327
+ const entries = [];
328
+ messages.forEach((message, messageIndex) => {
329
+ const parts = objectiveStatePartsForObservedMessage(message);
330
+ parts.forEach((part, partIndex) => {
331
+ entries.push({ messageIndex, partIndex, part });
332
+ });
333
+ });
334
+ return entries.sort((a, b) => {
335
+ if (a.messageIndex !== b.messageIndex) return a.messageIndex - b.messageIndex;
336
+ const aOrdinal = typeof a.part.ordinal === "number" ? a.part.ordinal : a.partIndex;
337
+ const bOrdinal = typeof b.part.ordinal === "number" ? b.part.ordinal : b.partIndex;
338
+ if (aOrdinal !== bOrdinal) return aOrdinal - bOrdinal;
339
+ return a.partIndex - b.partIndex;
340
+ });
341
+ }
342
+ function sanitizeUserRoleToolResultParts(parts) {
343
+ return parts.filter((part) => part.kind === "tool_result").map((part) => {
344
+ const payload = { ...partPayload(part) };
345
+ delete payload.name;
346
+ delete payload.tool;
347
+ delete payload.toolName;
348
+ delete payload.tool_name;
349
+ return {
350
+ ...part,
351
+ toolName: null,
352
+ tool_name: null,
353
+ payload
354
+ };
355
+ });
356
+ }
357
+ function containsProviderToolResultBlock(value) {
358
+ if (Array.isArray(value)) {
359
+ return value.some(containsProviderToolResultBlock);
360
+ }
361
+ if (!isRecord(value)) return false;
362
+ const type = optionalString(value.type ?? value.kind);
363
+ if (type === "tool_result" || type === "function_call_output") {
364
+ return true;
365
+ }
366
+ return containsProviderToolResultBlock(value.content) || containsProviderToolResultBlock(value.output) || containsProviderToolResultBlock(value.items);
367
+ }
368
+ function partPayload(part) {
369
+ return isRecord(part.payload) ? part.payload : {};
370
+ }
371
+ function partToolCallId(part) {
372
+ const payload = partPayload(part);
373
+ return optionalString(payload.call_id) ?? optionalString(payload.callId) ?? optionalString(payload.id) ?? optionalString(payload.tool_call_id) ?? optionalString(payload.toolCallId) ?? optionalString(payload.tool_use_id) ?? optionalString(payload.toolUseId);
374
+ }
375
+ function partToolName(part) {
376
+ const payload = partPayload(part);
377
+ return optionalString(part.toolName) ?? optionalString(part.tool_name) ?? optionalString(payload.name) ?? optionalString(payload.toolName) ?? optionalString(payload.tool_name) ?? (part.kind === "patch" ? "apply_patch" : void 0) ?? (part.kind === "file_write" ? "file_write" : void 0);
378
+ }
379
+ function partFilePath(part) {
380
+ const payload = partPayload(part);
381
+ return optionalString(part.filePath) ?? optionalString(part.file_path) ?? optionalString(payload.path) ?? optionalString(payload.filePath) ?? optionalString(payload.file_path);
382
+ }
383
+ function syntheticPartId(options) {
384
+ const digest = hashSha256(
385
+ [
386
+ options.sessionKey,
387
+ String(options.messageIndex),
388
+ String(options.part.ordinal ?? options.partIndex),
389
+ options.part.kind,
390
+ optionalString(options.part.toolName) ?? "",
391
+ optionalString(options.part.tool_name) ?? "",
392
+ optionalString(options.part.filePath) ?? "",
393
+ optionalString(options.part.file_path) ?? "",
394
+ stableStringify(options.part.payload)
395
+ ].join("|")
396
+ ).slice(0, 12);
397
+ return `part-${digest}`;
398
+ }
399
+ function toolArgumentsFromPart(part) {
400
+ const payload = partPayload(part);
401
+ const parsedArgs = parseToolArguments(payload.arguments) ?? parseToolArguments(payload.input) ?? parseToolArguments(payload.args) ?? parseToolArguments(payload.params) ?? payload;
402
+ const args = { ...parsedArgs };
403
+ const filePath = partFilePath(part);
404
+ if (filePath && !pickString(args, ["path", "filePath", "file_path"])) {
405
+ args.path = filePath;
406
+ }
407
+ if (part.kind === "patch" && !pickString(args, ["patch", "diff", "text"])) {
408
+ const text = optionalString(payload.text) ?? optionalString(payload.patch);
409
+ if (text) args.patch = text;
410
+ }
411
+ return args;
412
+ }
413
+ function toolResultContentFromPart(part) {
414
+ const payload = partPayload(part);
415
+ if ("output" in payload) return payload.output;
416
+ if ("content" in payload) return payload.content;
417
+ if ("result" in payload) return payload.result;
418
+ if ("value" in payload) return payload.value;
419
+ return payload;
420
+ }
421
+ function inlineToolResultContentFromPart(part) {
422
+ const payload = partPayload(part);
423
+ if (hasDefinedPayloadKey(payload, "output")) return payload.output;
424
+ if (hasDefinedPayloadKey(payload, "result")) return payload.result;
425
+ if (part.kind === "tool_result" && hasDefinedPayloadKey(payload, "value")) {
426
+ return payload.value;
427
+ }
428
+ const statusPayload = {};
429
+ for (const key of ["exitCode", "ok", "success", "error", "stdout", "stderr"]) {
430
+ if (hasDefinedPayloadKey(payload, key)) {
431
+ statusPayload[key] = payload[key];
432
+ }
433
+ }
434
+ return Object.keys(statusPayload).length > 0 ? statusPayload : payload;
435
+ }
436
+ function hasDefinedPayloadKey(payload, key) {
437
+ return Object.prototype.hasOwnProperty.call(payload, key) && payload[key] !== void 0;
438
+ }
439
+ function partHasInlineToolResult(part) {
440
+ const payload = partPayload(part);
441
+ return hasDefinedPayloadKey(payload, "output") || hasDefinedPayloadKey(payload, "result") || part.kind === "tool_result" && hasDefinedPayloadKey(payload, "value") || hasDefinedPayloadKey(payload, "exitCode") || hasDefinedPayloadKey(payload, "ok") || hasDefinedPayloadKey(payload, "success") || hasDefinedPayloadKey(payload, "error") || hasDefinedPayloadKey(payload, "stdout") || hasDefinedPayloadKey(payload, "stderr");
442
+ }
443
+ function toolResultIsError(part) {
444
+ const payload = partPayload(part);
445
+ return payload.isError === true || payload.is_error === true || payload.ok === false || payload.success === false || optionalString(payload.error) !== void 0;
446
+ }
447
+ function buildSyntheticAssistantToolCall(id, toolName, args) {
448
+ return {
449
+ role: "assistant",
450
+ tool_calls: [
451
+ {
452
+ id,
453
+ function: {
454
+ name: toolName,
455
+ arguments: JSON.stringify(args)
456
+ }
457
+ }
458
+ ]
459
+ };
460
+ }
461
+ function observedPartsToAgentMessages(options) {
462
+ const entries = flattenObservedParts(options.messages);
463
+ const resultIds = new Set(
464
+ entries.filter((entry) => entry.part.kind === "tool_result").map((entry) => partToolCallId(entry.part)).filter((id) => id !== void 0)
465
+ );
466
+ const synthetic = [];
467
+ let pendingIdlessToolCallId;
468
+ for (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {
469
+ const entry = entries[entryIndex];
470
+ const { part } = entry;
471
+ if (part.kind === "tool_call" || part.kind === "file_write" || part.kind === "patch") {
472
+ const toolName = partToolName(part);
473
+ if (!toolName) continue;
474
+ const observedToolCallId = partToolCallId(part);
475
+ const id = observedToolCallId ?? syntheticPartId({
476
+ sessionKey: options.sessionKey,
477
+ messageIndex: entry.messageIndex,
478
+ partIndex: entry.partIndex,
479
+ part
480
+ });
481
+ const args = toolArgumentsFromPart(part);
482
+ synthetic.push(buildSyntheticAssistantToolCall(id, toolName, args));
483
+ const nextEntry = entries[entryIndex + 1];
484
+ const nextIsIdlessToolResult = nextEntry?.part.kind === "tool_result" && partToolCallId(nextEntry.part) === void 0;
485
+ pendingIdlessToolCallId = nextIsIdlessToolResult ? id : void 0;
486
+ const hasSeparateToolResult = resultIds.has(id) || nextIsIdlessToolResult;
487
+ if (partHasInlineToolResult(part) && !hasSeparateToolResult) {
488
+ synthetic.push({
489
+ role: "tool",
490
+ tool_call_id: id,
491
+ name: toolName,
492
+ content: inlineToolResultContentFromPart(part),
493
+ ...toolResultIsError(part) ? { isError: true } : {}
494
+ });
495
+ pendingIdlessToolCallId = void 0;
496
+ continue;
497
+ }
498
+ if ((part.kind === "file_write" || part.kind === "patch") && !nextIsIdlessToolResult && !resultIds.has(id) && !isRawProviderPart(part)) {
499
+ synthetic.push({
500
+ role: "tool",
501
+ tool_call_id: id,
502
+ name: toolName,
503
+ content: { ok: true, source: "message_part" }
504
+ });
505
+ pendingIdlessToolCallId = void 0;
506
+ }
507
+ continue;
508
+ }
509
+ if (part.kind === "tool_result") {
510
+ const id = partToolCallId(part) ?? pendingIdlessToolCallId;
511
+ const toolName = partToolName(part);
512
+ synthetic.push({
513
+ role: "tool",
514
+ ...id ? { tool_call_id: id } : {},
515
+ ...toolName ? { name: toolName } : {},
516
+ content: toolResultContentFromPart(part),
517
+ ...toolResultIsError(part) ? { isError: true } : {}
518
+ });
519
+ pendingIdlessToolCallId = void 0;
520
+ }
521
+ }
522
+ return synthetic;
523
+ }
524
+ function deriveObjectiveStateSnapshotsFromAgentMessages(options) {
525
+ const toolCallsById = getToolCallContexts(options.messages);
526
+ const snapshots = [];
527
+ for (const message of options.messages) {
528
+ if (message.role !== "tool") continue;
529
+ const toolCallId = toolCallIdForMessage(message);
530
+ const context = toolCallId ? toolCallsById.get(toolCallId) : void 0;
531
+ const toolName = toolNameForMessage(message, context);
532
+ if (!toolName) continue;
533
+ const parsedPayload = parseToolResultPayload(message.content);
534
+ const outcome = inferOutcome(message, parsedPayload);
535
+ const args = context?.args;
536
+ const command = pickString(args, ["cmd", "command", "script"]);
537
+ let kind = "tool";
538
+ let changeKind = outcome === "failure" ? "failed" : "observed";
539
+ let scope = toolName;
540
+ let before;
541
+ let after;
542
+ if (isProcessTool(toolName, args)) {
543
+ kind = "process";
544
+ changeKind = outcome === "failure" ? "failed" : "executed";
545
+ scope = command ?? toolName;
546
+ after = { exists: outcome !== "failure", valueHash: resultHash(parsedPayload) };
547
+ } else if (isFileTool(toolName, args)) {
548
+ kind = "file";
549
+ changeKind = inferFileChangeKind(toolName, outcome);
550
+ const fileScope = fileScopeFromArgs(args);
551
+ scope = fileScope.scope ?? toolName;
552
+ const refs = buildFileValueRefs(args, changeKind);
553
+ before = refs.before;
554
+ after = refs.after;
555
+ } else {
556
+ after = buildGenericToolAfterRef(outcome, parsedPayload);
557
+ }
558
+ snapshots.push({
559
+ schemaVersion: 1,
560
+ snapshotId: snapshotIdFor(
561
+ options.sessionKey,
562
+ options.recordedAt,
563
+ snapshots.length,
564
+ toolName,
565
+ scope,
566
+ toolCallId
567
+ ),
568
+ recordedAt: options.recordedAt,
569
+ sessionKey: options.sessionKey,
570
+ source: "tool_result",
571
+ kind,
572
+ changeKind,
573
+ scope,
574
+ summary: summarizeSnapshot(kind, changeKind, toolName, scope),
575
+ toolName,
576
+ command,
577
+ outcome,
578
+ before,
579
+ after,
580
+ tags: ["agent-end", `tool:${toolName}`],
581
+ metadata: toolCallId ? { toolCallId } : void 0
582
+ });
583
+ }
584
+ return snapshots;
585
+ }
586
+ function deriveObjectiveStateSnapshotsFromObservedMessages(options) {
587
+ const syntheticMessages = observedPartsToAgentMessages({
588
+ sessionKey: options.sessionKey,
589
+ messages: options.messages
590
+ });
591
+ if (syntheticMessages.length === 0) return [];
592
+ return deriveObjectiveStateSnapshotsFromAgentMessages({
593
+ sessionKey: options.sessionKey,
594
+ recordedAt: options.recordedAt,
595
+ messages: syntheticMessages
596
+ });
597
+ }
598
+ async function recordObjectiveStateSnapshotsFromAgentMessages(options) {
599
+ if (!options.objectiveStateMemoryEnabled || !options.objectiveStateSnapshotWritesEnabled) {
600
+ return { snapshots: [], filePaths: [] };
601
+ }
602
+ const snapshots = deriveObjectiveStateSnapshotsFromAgentMessages({
603
+ sessionKey: options.sessionKey,
604
+ recordedAt: options.recordedAt,
605
+ messages: options.messages
606
+ });
607
+ const filePaths = [];
608
+ for (const snapshot of snapshots) {
609
+ filePaths.push(
610
+ await recordObjectiveStateSnapshot({
611
+ memoryDir: options.memoryDir,
612
+ objectiveStateStoreDir: options.objectiveStateStoreDir,
613
+ snapshot
614
+ })
615
+ );
616
+ }
617
+ return { snapshots, filePaths };
618
+ }
619
+ async function recordObjectiveStateSnapshotsFromObservedMessages(options) {
620
+ if (!options.objectiveStateMemoryEnabled || !options.objectiveStateSnapshotWritesEnabled) {
621
+ return { snapshots: [], filePaths: [] };
622
+ }
623
+ const snapshots = deriveObjectiveStateSnapshotsFromObservedMessages({
624
+ sessionKey: options.sessionKey,
625
+ recordedAt: options.recordedAt,
626
+ messages: options.messages
627
+ });
628
+ const filePaths = [];
629
+ for (const snapshot of snapshots) {
630
+ filePaths.push(
631
+ await recordObjectiveStateSnapshot({
632
+ memoryDir: options.memoryDir,
633
+ objectiveStateStoreDir: options.objectiveStateStoreDir,
634
+ snapshot
635
+ })
636
+ );
637
+ }
638
+ return { snapshots, filePaths };
639
+ }
640
+
641
+ export {
642
+ deriveObjectiveStateSnapshotsFromAgentMessages,
643
+ deriveObjectiveStateSnapshotsFromObservedMessages,
644
+ recordObjectiveStateSnapshotsFromAgentMessages,
645
+ recordObjectiveStateSnapshotsFromObservedMessages
646
+ };
647
+ //# sourceMappingURL=chunk-HJYHRE4S.js.map