@sixb/core 0.1.2 → 0.1.3

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 (264) hide show
  1. package/dist/actions/index.js +16 -13
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/agents/adapters.d.ts +11 -1
  4. package/dist/agents/adapters.d.ts.map +1 -1
  5. package/dist/agents/context.js +1 -1
  6. package/dist/agents/errors.d.ts +1 -1
  7. package/dist/agents/errors.d.ts.map +1 -1
  8. package/dist/agents/execution.d.ts +3 -0
  9. package/dist/agents/execution.d.ts.map +1 -1
  10. package/dist/agents/index.d.ts +6 -3
  11. package/dist/agents/index.d.ts.map +1 -1
  12. package/dist/agents/index.js +33 -22
  13. package/dist/agents/index.js.map +1 -1
  14. package/dist/agents/prompt.d.ts +8 -2
  15. package/dist/agents/prompt.d.ts.map +1 -1
  16. package/dist/agents/request.d.ts.map +1 -1
  17. package/dist/agents/streams.js +2 -2
  18. package/dist/agents/thread-context-projection.d.ts +19 -0
  19. package/dist/agents/thread-context-projection.d.ts.map +1 -0
  20. package/dist/agents/tool-definition.d.ts.map +1 -1
  21. package/dist/agents/tool-result.d.ts +6 -0
  22. package/dist/agents/tool-result.d.ts.map +1 -0
  23. package/dist/agents/types.d.ts +37 -1
  24. package/dist/agents/types.d.ts.map +1 -1
  25. package/dist/agents/validation.d.ts +1 -1
  26. package/dist/agents/validation.d.ts.map +1 -1
  27. package/dist/auth/index.js +7 -5
  28. package/dist/auth/index.js.map +1 -1
  29. package/dist/authorization/index.js +1 -1
  30. package/dist/bootstrap/index.js +27 -24
  31. package/dist/bootstrap/index.js.map +1 -1
  32. package/dist/{chunk-0mbx247x.js → chunk-177ed2mp.js} +241 -45
  33. package/dist/chunk-177ed2mp.js.map +46 -0
  34. package/dist/{chunk-sa4340y1.js → chunk-1ywq4hzk.js} +7 -7
  35. package/dist/{chunk-zg9yryhz.js → chunk-261ag4t4.js} +3 -3
  36. package/dist/{chunk-k9pts48t.js → chunk-3rsf30p4.js} +5 -5
  37. package/dist/{chunk-8ryen3p3.js → chunk-4aw0jwk0.js} +1 -1
  38. package/dist/{chunk-bh6k3nc6.js → chunk-4p9rh7jj.js} +1 -1
  39. package/dist/{chunk-34bqh420.js → chunk-4z3n1dzt.js} +59 -21
  40. package/dist/{chunk-34bqh420.js.map → chunk-4z3n1dzt.js.map} +4 -4
  41. package/dist/chunk-96swp2wd.js +47 -0
  42. package/dist/chunk-96swp2wd.js.map +10 -0
  43. package/dist/{chunk-n8herkry.js → chunk-bv41fmjn.js} +11 -11
  44. package/dist/{chunk-7pc8b818.js → chunk-c6cfqydk.js} +1 -1
  45. package/dist/{chunk-0k4avqr2.js → chunk-c8bw2b6c.js} +2 -2
  46. package/dist/{chunk-jaj13078.js → chunk-d2adj15j.js} +3 -33
  47. package/dist/{chunk-jaj13078.js.map → chunk-d2adj15j.js.map} +3 -4
  48. package/dist/{chunk-c6qd89g5.js → chunk-d6y2wsfg.js} +3 -3
  49. package/dist/chunk-dysw7nsm.js.map +1 -1
  50. package/dist/{chunk-st4xgxey.js → chunk-ettb0cy4.js} +150 -23
  51. package/dist/chunk-ettb0cy4.js.map +45 -0
  52. package/dist/{chunk-nnyp53zt.js → chunk-f1cyvnrk.js} +1 -1
  53. package/dist/chunk-fmx1sz2h.js.map +2 -2
  54. package/dist/{chunk-bct7hmfc.js → chunk-km4rkj4t.js} +3 -3
  55. package/dist/chunk-kqxgf6kv.js +898 -0
  56. package/dist/chunk-kqxgf6kv.js.map +15 -0
  57. package/dist/{chunk-qvybnnpe.js → chunk-n5x5y80a.js} +2 -2
  58. package/dist/{chunk-4x43bkbp.js → chunk-pxtrxm3p.js} +1 -1
  59. package/dist/chunk-qer6am8w.js +133 -0
  60. package/dist/chunk-qer6am8w.js.map +11 -0
  61. package/dist/{chunk-85j5ybfj.js → chunk-rdeagz6b.js} +2 -2
  62. package/dist/{chunk-85j5ybfj.js.map → chunk-rdeagz6b.js.map} +3 -3
  63. package/dist/chunk-rhrbz7d4.js +36 -0
  64. package/dist/chunk-rhrbz7d4.js.map +10 -0
  65. package/dist/{chunk-663csy96.js → chunk-t0jjkep3.js} +2 -1
  66. package/dist/chunk-t0jjkep3.js.map +10 -0
  67. package/dist/{chunk-5egfka8j.js → chunk-ttba8x6z.js} +2 -2
  68. package/dist/{chunk-nten49ta.js → chunk-wb4051cx.js} +3 -3
  69. package/dist/{chunk-nten49ta.js.map → chunk-wb4051cx.js.map} +1 -1
  70. package/dist/{chunk-57r1cpxx.js → chunk-xc7hq65b.js} +3 -2
  71. package/dist/{chunk-57r1cpxx.js.map → chunk-xc7hq65b.js.map} +3 -3
  72. package/dist/{chunk-ys1nse2v.js → chunk-xmggaxg4.js} +256 -231
  73. package/dist/{chunk-ys1nse2v.js.map → chunk-xmggaxg4.js.map} +8 -10
  74. package/dist/{chunk-g9t3kdtx.js → chunk-z8j83gzd.js} +1 -1
  75. package/dist/{chunk-57zpb99z.js → chunk-zpw39qhj.js} +1 -1
  76. package/dist/execution/agent.js +23 -20
  77. package/dist/execution/agent.js.map +1 -1
  78. package/dist/execution/primitive.js +23 -20
  79. package/dist/execution/primitive.js.map +2 -2
  80. package/dist/execution/request.js +24 -21
  81. package/dist/execution/request.js.map +2 -2
  82. package/dist/index.d.ts +3 -3
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +32 -29
  85. package/dist/index.js.map +1 -1
  86. package/dist/materialization/model.d.ts +4 -0
  87. package/dist/materialization/model.d.ts.map +1 -1
  88. package/dist/materializer/edits/apply.d.ts +6 -1
  89. package/dist/materializer/edits/apply.d.ts.map +1 -1
  90. package/dist/materializer/edits/working-state.d.ts +2 -0
  91. package/dist/materializer/edits/working-state.d.ts.map +1 -1
  92. package/dist/materializer/effective/resolve.d.ts +3 -1
  93. package/dist/materializer/effective/resolve.d.ts.map +1 -1
  94. package/dist/materializer/execution/work-records.d.ts.map +1 -1
  95. package/dist/materializer/index.js +14 -11
  96. package/dist/materializer/index.js.map +1 -1
  97. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  98. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  99. package/dist/objects/index.js +17 -14
  100. package/dist/objects/index.js.map +1 -1
  101. package/dist/objects/query/index.js +2 -2
  102. package/dist/pipelines/index.js +14 -12
  103. package/dist/pipelines/index.js.map +1 -1
  104. package/dist/projections/builders.d.ts +19 -6
  105. package/dist/projections/builders.d.ts.map +1 -1
  106. package/dist/projections/index.d.ts +2 -1
  107. package/dist/projections/index.d.ts.map +1 -1
  108. package/dist/projections/internal.d.ts +4 -1
  109. package/dist/projections/internal.d.ts.map +1 -1
  110. package/dist/projections/internal.js +17 -11
  111. package/dist/projections/internal.js.map +1 -1
  112. package/dist/projections/timestamp.d.ts +3 -0
  113. package/dist/projections/timestamp.d.ts.map +1 -0
  114. package/dist/projections/types.d.ts +9 -0
  115. package/dist/projections/types.d.ts.map +1 -1
  116. package/dist/projections/validation.d.ts.map +1 -1
  117. package/dist/queues/index.d.ts +1 -1
  118. package/dist/queues/index.d.ts.map +1 -1
  119. package/dist/queues/types.d.ts +7 -0
  120. package/dist/queues/types.d.ts.map +1 -1
  121. package/dist/runtime/ai-cost.d.ts +8 -0
  122. package/dist/runtime/ai-cost.d.ts.map +1 -0
  123. package/dist/storage/agents/in-memory.d.ts +18 -4
  124. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  125. package/dist/storage/agents/index.d.ts +1 -1
  126. package/dist/storage/agents/index.d.ts.map +1 -1
  127. package/dist/storage/agents/provider.d.ts +31 -0
  128. package/dist/storage/agents/provider.d.ts.map +1 -1
  129. package/dist/storage/agents/provider.js +18 -7
  130. package/dist/storage/agents/provider.js.map +1 -1
  131. package/dist/storage/agents/types.d.ts +70 -4
  132. package/dist/storage/agents/types.d.ts.map +1 -1
  133. package/dist/storage/ai-cost/analytics.d.ts +61 -0
  134. package/dist/storage/ai-cost/analytics.d.ts.map +1 -0
  135. package/dist/storage/ai-cost/codec.d.ts +14 -0
  136. package/dist/storage/ai-cost/codec.d.ts.map +1 -0
  137. package/dist/storage/ai-cost/errors.d.ts +7 -0
  138. package/dist/storage/ai-cost/errors.d.ts.map +1 -0
  139. package/dist/storage/ai-cost/in-memory.d.ts +32 -0
  140. package/dist/storage/ai-cost/in-memory.d.ts.map +1 -0
  141. package/dist/storage/ai-cost/index.d.ts +6 -0
  142. package/dist/storage/ai-cost/index.d.ts.map +1 -0
  143. package/dist/storage/ai-cost/provider.d.ts +7 -0
  144. package/dist/storage/ai-cost/provider.d.ts.map +1 -0
  145. package/dist/storage/ai-cost/provider.js +132 -0
  146. package/dist/storage/ai-cost/provider.js.map +10 -0
  147. package/dist/storage/ai-cost/types.d.ts +154 -0
  148. package/dist/storage/ai-cost/types.d.ts.map +1 -0
  149. package/dist/storage/ai-cost/validation.d.ts +7 -0
  150. package/dist/storage/ai-cost/validation.d.ts.map +1 -0
  151. package/dist/storage/in-memory/index.d.ts +5 -0
  152. package/dist/storage/in-memory/index.d.ts.map +1 -1
  153. package/dist/storage/index.d.ts +3 -1
  154. package/dist/storage/index.d.ts.map +1 -1
  155. package/dist/storage/index.js +22 -15
  156. package/dist/storage/index.js.map +1 -1
  157. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  158. package/dist/storage/ontology/materializations.d.ts +3 -0
  159. package/dist/storage/ontology/materializations.d.ts.map +1 -1
  160. package/dist/storage/operation-scope.d.ts.map +1 -1
  161. package/dist/storage/operation-scope.js +1 -1
  162. package/dist/storage/types.d.ts +2 -0
  163. package/dist/storage/types.d.ts.map +1 -1
  164. package/dist/storage/workflow-runs/provider.js +6 -5
  165. package/dist/storage/workflow-runs/provider.js.map +1 -1
  166. package/dist/syncs/index.js +14 -12
  167. package/dist/syncs/index.js.map +1 -1
  168. package/dist/testing/agent-storage-contract.d.ts +3 -2
  169. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  170. package/dist/testing/ai-cost-storage-contract.d.ts +12 -0
  171. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -0
  172. package/dist/testing/index.d.ts +1 -0
  173. package/dist/testing/index.d.ts.map +1 -1
  174. package/dist/testing/index.js +2098 -1468
  175. package/dist/testing/index.js.map +6 -5
  176. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  177. package/dist/webhooks/internal.js +12 -10
  178. package/dist/webhooks/internal.js.map +2 -2
  179. package/dist/workers/index.js +12 -2
  180. package/dist/workers/index.js.map +3 -3
  181. package/dist/workers/queue-worker.d.ts +2 -0
  182. package/dist/workers/queue-worker.d.ts.map +1 -1
  183. package/dist/workflows/execution.d.ts +3 -0
  184. package/dist/workflows/execution.d.ts.map +1 -1
  185. package/dist/workflows/index.js +24 -21
  186. package/dist/workflows/index.js.map +1 -1
  187. package/package.json +7 -1
  188. package/src/agents/adapters.ts +64 -23
  189. package/src/agents/errors.ts +2 -2
  190. package/src/agents/execution.ts +14 -2
  191. package/src/agents/index.ts +18 -1
  192. package/src/agents/prompt.ts +33 -5
  193. package/src/agents/request.ts +5 -0
  194. package/src/agents/thread-context-projection.ts +93 -0
  195. package/src/agents/tool-definition.ts +17 -2
  196. package/src/agents/tool-result.ts +61 -0
  197. package/src/agents/types.ts +47 -1
  198. package/src/agents/validation.ts +1 -1
  199. package/src/index.ts +13 -0
  200. package/src/materialization/model.ts +4 -0
  201. package/src/materializer/edits/apply.ts +55 -2
  202. package/src/materializer/edits/operations.ts +8 -1
  203. package/src/materializer/edits/working-state.ts +7 -0
  204. package/src/materializer/effective/resolve.ts +78 -9
  205. package/src/materializer/execution/work-records.ts +3 -1
  206. package/src/materializer/projections/entry-validator.ts +23 -1
  207. package/src/materializer/projections/replacement-plan.ts +2 -0
  208. package/src/materializer/shared/normalize.ts +16 -0
  209. package/src/projections/builders.ts +100 -35
  210. package/src/projections/index.ts +6 -0
  211. package/src/projections/internal.ts +4 -1
  212. package/src/projections/registry.ts +7 -0
  213. package/src/projections/revision.ts +4 -0
  214. package/src/projections/timestamp.ts +66 -0
  215. package/src/projections/types.ts +7 -0
  216. package/src/projections/validation.ts +24 -0
  217. package/src/queues/index.ts +1 -0
  218. package/src/queues/types.ts +8 -0
  219. package/src/runtime/ai-cost.ts +15 -0
  220. package/src/storage/agents/in-memory.ts +171 -4
  221. package/src/storage/agents/index.ts +5 -0
  222. package/src/storage/agents/provider.ts +225 -0
  223. package/src/storage/agents/types.ts +77 -3
  224. package/src/storage/ai-cost/analytics.ts +602 -0
  225. package/src/storage/ai-cost/codec.ts +136 -0
  226. package/src/storage/ai-cost/errors.ts +12 -0
  227. package/src/storage/ai-cost/in-memory.ts +164 -0
  228. package/src/storage/ai-cost/index.ts +35 -0
  229. package/src/storage/ai-cost/provider.ts +20 -0
  230. package/src/storage/ai-cost/types.ts +193 -0
  231. package/src/storage/ai-cost/validation.ts +337 -0
  232. package/src/storage/in-memory/index.ts +50 -0
  233. package/src/storage/index.ts +37 -0
  234. package/src/storage/ontology/in-memory/materializations.ts +1 -0
  235. package/src/storage/ontology/materializations.ts +3 -0
  236. package/src/storage/operation-scope.ts +1 -0
  237. package/src/storage/types.ts +2 -0
  238. package/src/testing/agent-storage-contract.ts +341 -2
  239. package/src/testing/ai-cost-storage-contract.ts +320 -0
  240. package/src/testing/index.ts +5 -0
  241. package/src/testing/materializer-storage-contract.ts +120 -2
  242. package/src/workers/queue-worker.ts +14 -1
  243. package/src/workflows/execution.ts +31 -10
  244. package/dist/chunk-0mbx247x.js.map +0 -43
  245. package/dist/chunk-663csy96.js.map +0 -10
  246. package/dist/chunk-st4xgxey.js.map +0 -45
  247. package/dist/chunk-vp1vc6ee.js +0 -35
  248. package/dist/chunk-vp1vc6ee.js.map +0 -11
  249. /package/dist/{chunk-sa4340y1.js.map → chunk-1ywq4hzk.js.map} +0 -0
  250. /package/dist/{chunk-zg9yryhz.js.map → chunk-261ag4t4.js.map} +0 -0
  251. /package/dist/{chunk-k9pts48t.js.map → chunk-3rsf30p4.js.map} +0 -0
  252. /package/dist/{chunk-8ryen3p3.js.map → chunk-4aw0jwk0.js.map} +0 -0
  253. /package/dist/{chunk-bh6k3nc6.js.map → chunk-4p9rh7jj.js.map} +0 -0
  254. /package/dist/{chunk-n8herkry.js.map → chunk-bv41fmjn.js.map} +0 -0
  255. /package/dist/{chunk-7pc8b818.js.map → chunk-c6cfqydk.js.map} +0 -0
  256. /package/dist/{chunk-0k4avqr2.js.map → chunk-c8bw2b6c.js.map} +0 -0
  257. /package/dist/{chunk-c6qd89g5.js.map → chunk-d6y2wsfg.js.map} +0 -0
  258. /package/dist/{chunk-nnyp53zt.js.map → chunk-f1cyvnrk.js.map} +0 -0
  259. /package/dist/{chunk-bct7hmfc.js.map → chunk-km4rkj4t.js.map} +0 -0
  260. /package/dist/{chunk-qvybnnpe.js.map → chunk-n5x5y80a.js.map} +0 -0
  261. /package/dist/{chunk-4x43bkbp.js.map → chunk-pxtrxm3p.js.map} +0 -0
  262. /package/dist/{chunk-5egfka8j.js.map → chunk-ttba8x6z.js.map} +0 -0
  263. /package/dist/{chunk-g9t3kdtx.js.map → chunk-z8j83gzd.js.map} +0 -0
  264. /package/dist/{chunk-57zpb99z.js.map → chunk-zpw39qhj.js.map} +0 -0
@@ -35,7 +35,7 @@ import {
35
35
  createOperationScopedFacade,
36
36
  createStorageOperationScope,
37
37
  createWorkflowRunOperationScope
38
- } from "./chunk-57r1cpxx.js";
38
+ } from "./chunk-xc7hq65b.js";
39
39
  import {
40
40
  PipelineRunError,
41
41
  assertPipelineRunExecution
@@ -79,7 +79,7 @@ import {
79
79
  WorkflowRunError,
80
80
  assertWorkflowAgentNodeRunExecution,
81
81
  assertWorkflowRunExecution
82
- } from "./chunk-4x43bkbp.js";
82
+ } from "./chunk-pxtrxm3p.js";
83
83
  import {
84
84
  parseActionRunFailure
85
85
  } from "./chunk-htq0qh7z.js";
@@ -89,8 +89,20 @@ import {
89
89
  } from "./chunk-xkthy56g.js";
90
90
  import {
91
91
  AgentStorageError,
92
- assertAgentRunExecution
93
- } from "./chunk-vp1vc6ee.js";
92
+ agentContextCheckpointMatchesCreateInput,
93
+ assertAgentContextCheckpointAnchors,
94
+ assertAgentContextCheckpointAuthority,
95
+ assertAgentContextCheckpointReplayState,
96
+ assertAgentRunExecution,
97
+ assertCreateAgentContextCheckpointInput
98
+ } from "./chunk-qer6am8w.js";
99
+ import {
100
+ InMemoryAiUsageStorage,
101
+ aiModelCallCostMatchesUsage,
102
+ buildAiAccountingOverview,
103
+ buildAiModelCallAccountingList,
104
+ normalizeAiModelCallCostRecord
105
+ } from "./chunk-kqxgf6kv.js";
94
106
  import {
95
107
  CONNECTOR_CONNECTION_RUN_FAILURE_CODES,
96
108
  ConnectorConnectionStorageError
@@ -125,22 +137,22 @@ import {
125
137
  } from "./chunk-6wetht33.js";
126
138
  import {
127
139
  AGENT_RUN_FAILURE_CODES
128
- } from "./chunk-663csy96.js";
140
+ } from "./chunk-t0jjkep3.js";
129
141
  import {
130
142
  InMemoryAuthStorage,
131
- normalizeRequesterGroupIds,
132
143
  paginate,
133
144
  principalsEqual
134
- } from "./chunk-jaj13078.js";
145
+ } from "./chunk-d2adj15j.js";
146
+ import {
147
+ normalizeRequesterGroupIds
148
+ } from "./chunk-rhrbz7d4.js";
135
149
  import {
136
150
  createSixbError,
137
151
  parseSixbFailure,
138
152
  toSixbFailure
139
153
  } from "./chunk-0172wgm9.js";
140
154
  import {
141
- assertJsonValue,
142
155
  cloneJsonValue,
143
- isPlainRecord,
144
156
  stableJsonStringify
145
157
  } from "./chunk-t8t39h7v.js";
146
158
  // src/storage/action-runs/idempotency.ts
@@ -729,6 +741,30 @@ class InMemoryAgentMessageStore {
729
741
  }));
730
742
  return clone(message);
731
743
  }
744
+ async deleteByRunId(input) {
745
+ const threadKey = key(input.projectId, input.threadId);
746
+ const thread = this.state.threads.get(threadKey);
747
+ if (!thread) {
748
+ throw new AgentStorageError("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found for project '${input.projectId}'.`);
749
+ }
750
+ const messages = [...this.state.messages.entries()].filter(([, message]) => message.projectId === input.projectId && message.threadId === input.threadId && message.runId === input.runId);
751
+ if (messages.length === 0) {
752
+ return 0;
753
+ }
754
+ for (const [messageKey] of messages) {
755
+ this.state.messages.delete(messageKey);
756
+ }
757
+ const remainingMessages = [...this.state.messages.values()].filter((message) => message.projectId === input.projectId && message.threadId === input.threadId).sort((left, right) => right.seq - left.seq);
758
+ const latestMessage = remainingMessages[0];
759
+ const updatedAt = new Date;
760
+ this.state.threads.set(threadKey, clone({
761
+ ...thread,
762
+ messageCount: remainingMessages.length,
763
+ lastMessageAt: latestMessage?.createdAt,
764
+ updatedAt
765
+ }));
766
+ return messages.length;
767
+ }
732
768
  async getById(params) {
733
769
  const record = this.state.messages.get(key(params.projectId, params.id));
734
770
  return record ? clone(record) : null;
@@ -736,7 +772,7 @@ class InMemoryAgentMessageStore {
736
772
  async list(input) {
737
773
  const order = input.order ?? "asc";
738
774
  const roles = input.roles ? new Set(input.roles) : null;
739
- const filtered = [...this.state.messages.values()].filter((message) => message.projectId === input.projectId).filter((message) => message.threadId === input.threadId).filter((message) => roles ? roles.has(message.role) : true).sort((a, b) => order === "asc" ? a.seq - b.seq : b.seq - a.seq);
775
+ const filtered = [...this.state.messages.values()].filter((message) => message.projectId === input.projectId).filter((message) => message.threadId === input.threadId).filter((message) => input.afterSeq === undefined ? true : message.seq > input.afterSeq).filter((message) => roles ? roles.has(message.role) : true).sort((a, b) => order === "asc" ? a.seq - b.seq : b.seq - a.seq);
740
776
  const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
741
777
  return { messages: page.map(clone), hasMore, total };
742
778
  }
@@ -751,31 +787,100 @@ class InMemoryAgentMessageStore {
751
787
  }
752
788
  }
753
789
 
790
+ class InMemoryAgentContextCheckpointStore {
791
+ state;
792
+ constructor(state) {
793
+ this.state = state;
794
+ }
795
+ async create(input) {
796
+ assertCreateAgentContextCheckpointInput(input);
797
+ const run = this.state.runs.get(key(input.projectId, input.createdByRunId)) ?? null;
798
+ const thread = this.state.threads.get(key(input.projectId, input.threadId)) ?? null;
799
+ assertAgentContextCheckpointAuthority({ create: input, run, thread });
800
+ const messages = [...this.state.messages.values()].filter((message) => message.projectId === input.projectId && message.threadId === input.threadId);
801
+ const headSeq = messages.reduce((head, message) => Math.max(head, message.seq), 0);
802
+ const latest = this.findLatest(input.projectId, input.threadId);
803
+ const existingForRun = [...this.state.checkpoints.values()].find((checkpoint) => checkpoint.projectId === input.projectId && checkpoint.createdByRunId === input.createdByRunId);
804
+ if (existingForRun) {
805
+ if (agentContextCheckpointMatchesCreateInput(existingForRun, input)) {
806
+ assertAgentContextCheckpointReplayState({
807
+ create: input,
808
+ existing: existingForRun,
809
+ latest,
810
+ headSeq
811
+ });
812
+ return clone(existingForRun);
813
+ }
814
+ throw new AgentStorageError("invalid_state", `[Sixb] Agent run '${input.createdByRunId}' already created a different context checkpoint.`);
815
+ }
816
+ if (this.state.checkpoints.has(key(input.projectId, input.id))) {
817
+ throw new AgentStorageError("duplicate_id", `[Sixb] Agent context checkpoint '${input.id}' already exists for project '${input.projectId}'.`);
818
+ }
819
+ const firstRetained = messages.filter((message) => message.seq > input.summarizedThroughSeq).sort((left, right) => left.seq - right.seq)[0] ?? null;
820
+ assertAgentContextCheckpointAnchors({
821
+ create: input,
822
+ latest,
823
+ headSeq,
824
+ firstRetained
825
+ });
826
+ const record = {
827
+ id: input.id,
828
+ projectId: input.projectId,
829
+ threadId: input.threadId,
830
+ createdByRunId: input.createdByRunId,
831
+ ...input.expectedPreviousCheckpointId === null ? {} : { previousCheckpointId: input.expectedPreviousCheckpointId },
832
+ reason: input.reason,
833
+ summary: input.summary,
834
+ summaryFormatVersion: input.summaryFormatVersion,
835
+ summarizedThroughSeq: input.summarizedThroughSeq,
836
+ observedHeadSeq: input.observedHeadSeq,
837
+ estimatedInputTokensBefore: input.estimatedInputTokensBefore,
838
+ estimatedInputTokensAfter: input.estimatedInputTokensAfter,
839
+ summaryModelId: input.summaryModelId,
840
+ createdAt: new Date(input.createdAt ?? new Date)
841
+ };
842
+ this.state.checkpoints.set(key(input.projectId, input.id), clone(record));
843
+ return clone(record);
844
+ }
845
+ async getLatest(input) {
846
+ const record = this.findLatest(input.projectId, input.threadId);
847
+ return record ? clone(record) : null;
848
+ }
849
+ findLatest(projectId, threadId) {
850
+ return [...this.state.checkpoints.values()].filter((checkpoint) => checkpoint.projectId === projectId && checkpoint.threadId === threadId).sort((left, right) => right.summarizedThroughSeq - left.summarizedThroughSeq || right.createdAt.getTime() - left.createdAt.getTime() || right.id.localeCompare(left.id))[0] ?? null;
851
+ }
852
+ }
853
+
754
854
  class InMemoryAgentStorage {
755
855
  state = {
756
856
  threads: new Map,
757
857
  runs: new Map,
758
- messages: new Map
858
+ messages: new Map,
859
+ checkpoints: new Map
759
860
  };
760
861
  threads;
761
862
  runs;
762
863
  messages;
864
+ checkpoints;
763
865
  constructor(executions) {
764
866
  this.threads = new InMemoryAgentThreadStore(this.state);
765
867
  this.runs = new InMemoryAgentRunStore(this.state, executions);
766
868
  this.messages = new InMemoryAgentMessageStore(this.state);
869
+ this.checkpoints = new InMemoryAgentContextCheckpointStore(this.state);
767
870
  }
768
871
  snapshot() {
769
872
  return {
770
873
  threads: structuredClone(this.state.threads),
771
874
  runs: structuredClone(this.state.runs),
772
- messages: structuredClone(this.state.messages)
875
+ messages: structuredClone(this.state.messages),
876
+ checkpoints: structuredClone(this.state.checkpoints)
773
877
  };
774
878
  }
775
879
  restore(snapshot) {
776
880
  replace(this.state.threads, snapshot.threads);
777
881
  replace(this.state.runs, snapshot.runs);
778
882
  replace(this.state.messages, snapshot.messages);
883
+ replace(this.state.checkpoints, snapshot.checkpoints);
779
884
  }
780
885
  }
781
886
  function replace(target, source) {
@@ -784,248 +889,120 @@ function replace(target, source) {
784
889
  target.set(k, value);
785
890
  }
786
891
  }
787
- // src/storage/ai-usage/errors.ts
788
- class AiUsageStorageError extends Error {
892
+ // src/storage/ai-cost/errors.ts
893
+ class AiCostStorageError extends Error {
789
894
  code;
790
- name = "AiUsageStorageError";
895
+ name = "AiCostStorageError";
791
896
  constructor(code, message) {
792
897
  super(message);
793
898
  this.code = code;
794
899
  }
795
900
  }
796
- // src/storage/ai-usage/usage.ts
797
- var USAGE_FIELDS = [
798
- "inputTokens",
799
- "outputTokens",
800
- "uncachedInputTokens",
801
- "cacheReadInputTokens",
802
- "cacheWriteInputTokens",
803
- "textOutputTokens",
804
- "reasoningOutputTokens"
805
- ];
806
- function normalizeAiModelCallUsage(input) {
807
- for (const field of USAGE_FIELDS) {
808
- assertUsageCount(input[field], field);
809
- }
810
- const totalTokens = input.inputTokens === undefined || input.outputTokens === undefined ? undefined : addUsageCounts(input.inputTokens, input.outputTokens, "totalTokens");
811
- const reportingStatus = input.inputTokens !== undefined && input.outputTokens !== undefined ? "complete" : USAGE_FIELDS.some((field) => input[field] !== undefined) ? "partial" : "unavailable";
812
- return {
813
- ...input.inputTokens === undefined ? {} : { inputTokens: input.inputTokens },
814
- ...input.outputTokens === undefined ? {} : { outputTokens: input.outputTokens },
815
- ...totalTokens === undefined ? {} : { totalTokens },
816
- ...input.uncachedInputTokens === undefined ? {} : { uncachedInputTokens: input.uncachedInputTokens },
817
- ...input.cacheReadInputTokens === undefined ? {} : { cacheReadInputTokens: input.cacheReadInputTokens },
818
- ...input.cacheWriteInputTokens === undefined ? {} : { cacheWriteInputTokens: input.cacheWriteInputTokens },
819
- ...input.textOutputTokens === undefined ? {} : { textOutputTokens: input.textOutputTokens },
820
- ...input.reasoningOutputTokens === undefined ? {} : { reasoningOutputTokens: input.reasoningOutputTokens },
821
- reportingStatus
822
- };
823
- }
824
- function aggregateAiModelCallUsage(usages) {
825
- const normalized = Array.from(usages, normalizeAiModelCallUsage);
826
- const fields = Object.fromEntries(USAGE_FIELDS.map((field) => [field, sumUsageField(normalized, field)]));
827
- const aggregate = normalizeAiModelCallUsage(fields);
828
- if (aggregate.reportingStatus === "unavailable" && normalized.some((usage) => usage.reportingStatus !== "unavailable")) {
829
- return { ...aggregate, reportingStatus: "partial" };
830
- }
831
- return aggregate;
832
- }
833
- function sumUsageField(usages, field) {
834
- if (usages.length === 0)
835
- return;
836
- let total = 0;
837
- for (const usage of usages) {
838
- const value = usage[field];
839
- if (value === undefined)
840
- return;
841
- total = addUsageCounts(total, value, `aggregate ${field}`);
842
- }
843
- return total;
844
- }
845
- function assertUsageCount(value, field) {
846
- if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {
847
- throw new TypeError(`[Sixb] AI model-call usage ${field} must be a non-negative safe integer.`);
848
- }
849
- }
850
- function addUsageCounts(left, right, field) {
851
- const result = left + right;
852
- if (!Number.isSafeInteger(result)) {
853
- throw new TypeError(`[Sixb] AI model-call usage ${field} exceeds the safe integer range.`);
854
- }
855
- return result;
856
- }
857
-
858
- // src/storage/ai-usage/record.ts
859
- function normalizeAiModelCallRecord(input) {
860
- assertNonBlank2(input.id, "id");
861
- assertNonBlank2(input.projectId, "projectId");
862
- assertAiUsageExecutionId(input.executionId);
863
- assertPositiveSafeInteger(input.attempt, "attempt");
864
- assertNonBlank2(input.callId, "callId");
865
- assertNonBlank2(input.providerId, "providerId");
866
- assertNonBlank2(input.requestedModelId, "requestedModelId");
867
- if (input.responseModelId !== undefined) {
868
- assertNonBlank2(input.responseModelId, "responseModelId");
869
- }
870
- assertNonBlank2(input.responseId, "responseId");
871
- const occurredAt = cloneValidDate(input.occurredAt, "occurredAt");
872
- const recordedAt = cloneValidDate(input.recordedAt ?? new Date, "recordedAt");
873
- const requesterGroupIds = normalizeRequesterGroupIds(input.requesterGroupIds);
874
- const rawUsage = cloneRawUsage(input.rawUsage);
875
- return {
876
- id: input.id,
877
- projectId: input.projectId,
878
- executionId: input.executionId,
879
- attempt: input.attempt,
880
- callId: input.callId,
881
- requesterGroupIds,
882
- providerId: input.providerId,
883
- requestedModelId: input.requestedModelId,
884
- ...input.responseModelId === undefined ? {} : { responseModelId: input.responseModelId },
885
- responseId: input.responseId,
886
- usage: normalizeAiModelCallUsage(input.usage),
887
- ...rawUsage === undefined ? {} : { rawUsage },
888
- occurredAt,
889
- recordedAt
890
- };
891
- }
892
- function assertAiUsageExecutionId(executionId) {
893
- assertNonBlank2(executionId, "executionId");
894
- }
895
- function cloneRawUsage(rawUsage) {
896
- if (rawUsage === undefined)
897
- return;
898
- if (!isPlainRecord(rawUsage)) {
899
- throw new TypeError("[Sixb] AI usage rawUsage must be a JSON object.");
900
- }
901
- assertJsonValue(rawUsage, "AI usage rawUsage");
902
- return structuredClone(rawUsage);
903
- }
904
- function assertNonBlank2(value, field) {
905
- if (typeof value !== "string" || value.trim().length === 0) {
906
- throw new TypeError(`[Sixb] AI usage ${field} must be nonblank.`);
907
- }
908
- }
909
- function assertPositiveSafeInteger(value, field) {
910
- if (!Number.isSafeInteger(value) || value <= 0) {
911
- throw new TypeError(`[Sixb] AI usage ${field} must be a positive safe integer.`);
901
+ // src/storage/ai-cost/in-memory.ts
902
+ class InMemoryAiCostStorage {
903
+ usage;
904
+ attribution;
905
+ recordsByUsage = new Map;
906
+ constructor(usage, attribution) {
907
+ this.usage = usage;
908
+ this.attribution = attribution;
912
909
  }
913
- }
914
- function cloneValidDate(value, field) {
915
- if (!(value instanceof Date) || !Number.isFinite(value.getTime())) {
916
- throw new TypeError(`[Sixb] AI usage ${field} must be a valid Date.`);
917
- }
918
- return new Date(value);
919
- }
920
-
921
- // src/storage/ai-usage/in-memory.ts
922
- class InMemoryAiUsageStorage {
923
- executions;
924
- records = new Map;
925
- recordKeysByIdempotencyKey = new Map;
926
- groupRows = new Map;
927
- constructor(executions) {
928
- this.executions = executions;
910
+ async recordModelCallCost(input) {
911
+ const record = normalizeAiModelCallCostRecord(input);
912
+ const usage = this.usageRecord(record.projectId, record.usageRecordId);
913
+ if (!usage)
914
+ throw missingUsage(record);
915
+ if (!aiModelCallCostMatchesUsage(record, usage)) {
916
+ throw new AiCostStorageError("cost_mismatch", `[Sixb] AI valuation for usage '${record.usageRecordId}' does not match its usage record.`);
917
+ }
918
+ const key2 = usageRecordKey(record.projectId, record.usageRecordId);
919
+ if (!this.recordsByUsage.has(key2))
920
+ this.recordsByUsage.set(key2, structuredClone(record));
929
921
  }
930
- async recordModelCall(input) {
931
- const record = normalizeAiModelCallRecord(input);
932
- await this.assertExecutionExists(record.projectId, record.executionId);
933
- const idempotencyKey = modelCallIdempotencyKey(record);
934
- const existingRecordKey = this.recordKeysByIdempotencyKey.get(idempotencyKey);
935
- if (existingRecordKey !== undefined) {
936
- const existing = this.records.get(existingRecordKey);
937
- if (!existing) {
938
- throw new Error("[Sixb] In-memory AI usage idempotency index is inconsistent.");
922
+ async summarizeExecutions(input) {
923
+ assertNonBlank2(input.projectId, "cost summary projectId");
924
+ for (const id of input.executionIds)
925
+ assertNonBlank2(id, "cost summary executionId");
926
+ const requested = new Set(input.executionIds);
927
+ const usageByExecution = new Map(input.executionIds.map((id) => [id, []]));
928
+ for (const usage of this.usage.snapshot().records.values()) {
929
+ if (usage.projectId === input.projectId && requested.has(usage.executionId)) {
930
+ usageByExecution.get(usage.executionId).push(usage.id);
939
931
  }
940
- return { record: structuredClone(existing), created: false };
941
- }
942
- const recordKey = modelCallRecordKey(record.projectId, record.id);
943
- if (this.records.has(recordKey)) {
944
- throw new AiUsageStorageError("duplicate_id", `[Sixb] AI usage record '${record.id}' already exists for project '${record.projectId}'.`);
945
- }
946
- this.records.set(recordKey, structuredClone(record));
947
- this.recordKeysByIdempotencyKey.set(idempotencyKey, recordKey);
948
- for (const groupId of record.requesterGroupIds) {
949
- const row = {
950
- projectId: record.projectId,
951
- usageRecordId: record.id,
952
- groupId,
953
- occurredAt: record.occurredAt
954
- };
955
- this.groupRows.set(groupRowKey(row), row);
956
932
  }
957
- return { record: structuredClone(record), created: true };
933
+ return input.executionIds.map((id) => this.summarizeUsageIds(input.projectId, usageByExecution.get(id) ?? []));
958
934
  }
959
- async summarizeExecution(input) {
960
- const [summary] = await this.summarizeExecutions({
961
- projectId: input.projectId,
962
- executionIds: [input.executionId]
963
- });
964
- return summary;
935
+ async queryProjectOverview(input) {
936
+ return buildAiAccountingOverview(input, await this.accountingItems());
965
937
  }
966
- async summarizeExecutions(input) {
967
- if (typeof input.projectId !== "string" || input.projectId.trim().length === 0) {
968
- throw new TypeError("[Sixb] AI usage projectId must be nonblank.");
969
- }
970
- const usageByExecutionId = new Map;
971
- for (const executionId of input.executionIds) {
972
- assertAiUsageExecutionId(executionId);
973
- usageByExecutionId.set(executionId, []);
974
- }
975
- if (usageByExecutionId.size === 0)
976
- return [];
977
- for (const record of this.records.values()) {
978
- if (record.projectId !== input.projectId)
979
- continue;
980
- usageByExecutionId.get(record.executionId)?.push(record.usage);
981
- }
982
- return input.executionIds.map((executionId) => {
983
- const usages = usageByExecutionId.get(executionId) ?? [];
984
- return {
985
- modelCallCount: usages.length,
986
- usage: aggregateAiModelCallUsage(usages)
987
- };
988
- });
938
+ async listModelCalls(input) {
939
+ return buildAiModelCallAccountingList(input, await this.accountingItems());
989
940
  }
990
941
  snapshot() {
991
- return structuredClone({
992
- records: this.records,
993
- recordKeysByIdempotencyKey: this.recordKeysByIdempotencyKey,
994
- groupRows: this.groupRows
995
- });
942
+ return structuredClone({ recordsByUsage: this.recordsByUsage });
996
943
  }
997
944
  restore(snapshot) {
998
- replaceMap(this.records, snapshot.records);
999
- replaceMap(this.recordKeysByIdempotencyKey, snapshot.recordKeysByIdempotencyKey);
1000
- replaceMap(this.groupRows, snapshot.groupRows);
945
+ replaceMap(this.recordsByUsage, snapshot.recordsByUsage);
1001
946
  }
1002
- async assertExecutionExists(projectId, executionId) {
1003
- const execution = await this.executions.getById({ projectId, id: executionId });
1004
- if (execution)
1005
- return;
1006
- throw new AiUsageStorageError("missing_execution", `[Sixb] AI usage execution '${executionId}' does not exist in project '${projectId}'.`);
947
+ usageRecord(projectId, id) {
948
+ return [...this.usage.snapshot().records.values()].find((record) => record.projectId === projectId && record.id === id);
949
+ }
950
+ async accountingItems() {
951
+ return Promise.all([...this.usage.snapshot().records.values()].map(async (usage) => {
952
+ const cost = this.recordsByUsage.get(usageRecordKey(usage.projectId, usage.id));
953
+ const attribution = await this.attribution?.resolve({
954
+ projectId: usage.projectId,
955
+ executionId: usage.executionId
956
+ });
957
+ return {
958
+ usage,
959
+ ...attribution ? { attribution } : {},
960
+ ...cost ? { cost } : {}
961
+ };
962
+ }));
963
+ }
964
+ summarizeUsageIds(projectId, ids) {
965
+ const amounts = new Map;
966
+ let ratedCallCount = 0;
967
+ let unpriceableCallCount = 0;
968
+ let unvaluedCallCount = 0;
969
+ for (const id of ids) {
970
+ const cost = this.recordsByUsage.get(usageRecordKey(projectId, id));
971
+ if (!cost)
972
+ unvaluedCallCount += 1;
973
+ else if (cost.status === "unpriceable")
974
+ unpriceableCallCount += 1;
975
+ else {
976
+ ratedCallCount += 1;
977
+ addMoney(amounts, cost.money);
978
+ }
979
+ }
980
+ return {
981
+ amounts: [...amounts].sort(([left], [right]) => left.localeCompare(right)).map(([currency, amount]) => ({ currency, amountNanos: amount.toString() })),
982
+ ratedCallCount,
983
+ unpriceableCallCount,
984
+ unvaluedCallCount
985
+ };
1007
986
  }
1008
987
  }
1009
- function modelCallRecordKey(projectId, id) {
1010
- return JSON.stringify([projectId, id]);
988
+ function missingUsage(record) {
989
+ return new AiCostStorageError("missing_usage", `[Sixb] AI usage '${record.usageRecordId}' does not exist in project '${record.projectId}'.`);
1011
990
  }
1012
- function modelCallIdempotencyKey(record) {
1013
- return JSON.stringify([
1014
- record.projectId,
1015
- record.executionId,
1016
- record.attempt,
1017
- record.callId,
1018
- record.responseId
1019
- ]);
991
+ function addMoney(amounts, money) {
992
+ amounts.set(money.currency, (amounts.get(money.currency) ?? 0n) + BigInt(money.amountNanos));
993
+ }
994
+ function usageRecordKey(projectId, id) {
995
+ return JSON.stringify([projectId, id]);
1020
996
  }
1021
- function groupRowKey(row) {
1022
- return JSON.stringify([row.projectId, row.usageRecordId, row.groupId]);
997
+ function assertNonBlank2(value, field) {
998
+ if (typeof value !== "string" || value.trim().length === 0) {
999
+ throw new TypeError(`[Sixb] AI ${field} must be nonblank.`);
1000
+ }
1023
1001
  }
1024
1002
  function replaceMap(target, source) {
1025
1003
  target.clear();
1026
- for (const [key2, value] of structuredClone(source)) {
1004
+ for (const [key2, value] of structuredClone(source))
1027
1005
  target.set(key2, value);
1028
- }
1029
1006
  }
1030
1007
  // src/storage/connector-connections/in-memory.ts
1031
1008
  import { timingSafeEqual } from "crypto";
@@ -3949,6 +3926,7 @@ class InMemoryOntologyMaterializationStorage {
3949
3926
  projectId,
3950
3927
  ref: item.ref,
3951
3928
  value: item.value,
3929
+ editedAt: { ...item.editedAt },
3952
3930
  lastCommitId: item.lastCommitId,
3953
3931
  updatedAt: item.updatedAt
3954
3932
  }));
@@ -6659,6 +6637,9 @@ class InMemoryStorage {
6659
6637
  executionStorage = new InMemoryExecutionStorage(this.authStorage);
6660
6638
  agentStorage = new InMemoryAgentStorage(this.executionStorage);
6661
6639
  aiUsageStorage = new InMemoryAiUsageStorage(this.executionStorage);
6640
+ aiCostStorage = new InMemoryAiCostStorage(this.aiUsageStorage, {
6641
+ resolve: (input) => this.resolveAiAccountingAttribution(input)
6642
+ });
6662
6643
  actionRunStorage = new InMemoryActionRunStorage(this.executionStorage);
6663
6644
  syncRunStorage = new InMemorySyncRunStorage(this.executionStorage);
6664
6645
  pipelineRunStorage = new InMemoryPipelineRunStorage(this.executionStorage);
@@ -6675,6 +6656,7 @@ class InMemoryStorage {
6675
6656
  executions;
6676
6657
  agents;
6677
6658
  aiUsage;
6659
+ aiCosts;
6678
6660
  actionRuns;
6679
6661
  syncRuns;
6680
6662
  pipelineRuns;
@@ -6694,6 +6676,7 @@ class InMemoryStorage {
6694
6676
  this.executions = createOperationScopedFacade(this.executionStorage, scope);
6695
6677
  this.agents = createAgentOperationScope(this.agentStorage, scope);
6696
6678
  this.aiUsage = createOperationScopedFacade(this.aiUsageStorage, scope);
6679
+ this.aiCosts = createOperationScopedFacade(this.aiCostStorage, scope);
6697
6680
  this.actionRuns = createOperationScopedFacade(this.actionRunStorage, scope);
6698
6681
  this.syncRuns = createOperationScopedFacade(this.syncRunStorage, scope);
6699
6682
  this.pipelineRuns = createOperationScopedFacade(this.pipelineRunStorage, scope);
@@ -6715,6 +6698,45 @@ class InMemoryStorage {
6715
6698
  this.ontologyStorage.registerTestingAlias(this.ontology);
6716
6699
  registerInMemoryStorageTestingAdapter(this, { snapshot: () => this.snapshot() });
6717
6700
  }
6701
+ async resolveAiAccountingAttribution(input) {
6702
+ const execution = await this.executionStorage.getById({
6703
+ projectId: input.projectId,
6704
+ id: input.executionId
6705
+ });
6706
+ if (!execution || execution.executor.type !== "agent")
6707
+ return;
6708
+ const directRun = await this.agentStorage.runs.getById({
6709
+ projectId: input.projectId,
6710
+ id: execution.executor.runId
6711
+ });
6712
+ if (directRun) {
6713
+ return {
6714
+ kind: "agent",
6715
+ agentId: directRun.agentId,
6716
+ agentRunId: directRun.id,
6717
+ threadId: directRun.threadId
6718
+ };
6719
+ }
6720
+ const agentRun = await this.workflowRunStorage.agentNodes.getByNodeRunId({
6721
+ projectId: input.projectId,
6722
+ nodeRunId: execution.executor.runId
6723
+ });
6724
+ if (!agentRun)
6725
+ return;
6726
+ const node = await this.workflowRunStorage.nodes.getById({
6727
+ projectId: input.projectId,
6728
+ id: agentRun.nodeRunId
6729
+ });
6730
+ if (!node)
6731
+ return;
6732
+ return {
6733
+ kind: "workflowAgent",
6734
+ agentId: agentRun.agentId,
6735
+ nodeRunId: agentRun.nodeRunId,
6736
+ workflowId: node.workflowId,
6737
+ workflowRunId: node.workflowRunId
6738
+ };
6739
+ }
6718
6740
  transactionScope = new AsyncLocalStorage;
6719
6741
  activeTransactionTokens = new WeakSet;
6720
6742
  materializationLifecycles = new WeakMap;
@@ -6795,6 +6817,7 @@ class InMemoryStorage {
6795
6817
  executions: this.executionStorage,
6796
6818
  agents: this.agentStorage,
6797
6819
  aiUsage: this.aiUsageStorage,
6820
+ aiCosts: this.aiCostStorage,
6798
6821
  actionRuns: this.actionRunStorage,
6799
6822
  syncRuns: this.syncRunStorage,
6800
6823
  pipelineRuns: this.pipelineRunStorage,
@@ -6822,6 +6845,7 @@ class InMemoryStorage {
6822
6845
  executions: this.executionStorage.snapshot(),
6823
6846
  agents: this.agentStorage.snapshot(),
6824
6847
  aiUsage: this.aiUsageStorage.snapshot(),
6848
+ aiCosts: this.aiCostStorage.snapshot(),
6825
6849
  actionRuns: this.actionRunStorage.snapshot(),
6826
6850
  syncRuns: this.syncRunStorage.snapshot(),
6827
6851
  pipelineRuns: this.pipelineRunStorage.snapshot(),
@@ -6842,6 +6866,7 @@ class InMemoryStorage {
6842
6866
  this.executionStorage.restore(snapshot.executions);
6843
6867
  this.agentStorage.restore(snapshot.agents);
6844
6868
  this.aiUsageStorage.restore(snapshot.aiUsage);
6869
+ this.aiCostStorage.restore(snapshot.aiCosts);
6845
6870
  this.actionRunStorage.restore(snapshot.actionRuns);
6846
6871
  this.syncRunStorage.restore(snapshot.syncRuns);
6847
6872
  this.pipelineRunStorage.restore(snapshot.pipelineRuns);
@@ -7063,6 +7088,6 @@ function assertAppliedPrefix(migrations, rows) {
7063
7088
  }
7064
7089
  return [...rows].sort((a, b) => a.version - b.version);
7065
7090
  }
7066
- export { actionSubjectsEqual, actionRunParamsEqual, actionRunPhaseRecordsEqual, finishActionRunPhase, canRequeueActionRunAfterEnqueueFailure, isTerminalActionRun, InMemoryActionRunStorage, AGENT_MESSAGE_CONTENT_VERSION, InMemoryAgentStorage, AiUsageStorageError, normalizeAiModelCallUsage, aggregateAiModelCallUsage, normalizeAiModelCallRecord, assertAiUsageExecutionId, InMemoryAiUsageStorage, InMemoryConnectorConnectionStorage, ObjectNotFoundError, ObjectStorageError, StorageTransactionError, isStorageSerializationFailure, FileUploadSessionError, DEFAULT_FILE_UPLOAD_SESSION_TTL_MS, DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS, createUploadExpiresAt, createFileUploadId, InMemoryFileUploadSessions, canRequeuePipelineRunAfterEnqueueFailure, PIPELINE_RUN_FAILURE_CODES, InMemoryPipelineRunStorage, InMemoryProjectionRunStorage, InMemoryRulesStorage, canRequeueSyncRunAfterEnqueueFailure, SYNC_RUN_FAILURE_CODES, InMemorySyncRunStorage, createTransactionStorageProxy, assertTransactionActive, throwNestedStorageTransaction, WEBHOOK_RUN_FAILURE_CODES, canRetryWebhookRun, InMemoryWebhookRunStorage, WorkflowInterventionError, InMemoryWorkflowInterventionStorage, WORKFLOW_RUN_FAILURE_CODES, InMemoryWorkflowRunStorage, InMemoryWorkflowNodeRunStorage, InMemoryWorkflowAgentNodeRunStorage, InMemoryStorage, isMigrationCapableStorage, migrateStorage, checkStorageSchema, step, defineMigrations, runMigrationSet, describeMigrationHistory };
7091
+ export { actionSubjectsEqual, actionRunParamsEqual, actionRunPhaseRecordsEqual, finishActionRunPhase, canRequeueActionRunAfterEnqueueFailure, isTerminalActionRun, InMemoryActionRunStorage, AGENT_MESSAGE_CONTENT_VERSION, InMemoryAgentStorage, AiCostStorageError, InMemoryAiCostStorage, InMemoryConnectorConnectionStorage, ObjectNotFoundError, ObjectStorageError, StorageTransactionError, isStorageSerializationFailure, FileUploadSessionError, DEFAULT_FILE_UPLOAD_SESSION_TTL_MS, DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS, createUploadExpiresAt, createFileUploadId, InMemoryFileUploadSessions, canRequeuePipelineRunAfterEnqueueFailure, PIPELINE_RUN_FAILURE_CODES, InMemoryPipelineRunStorage, InMemoryProjectionRunStorage, InMemoryRulesStorage, canRequeueSyncRunAfterEnqueueFailure, SYNC_RUN_FAILURE_CODES, InMemorySyncRunStorage, createTransactionStorageProxy, assertTransactionActive, throwNestedStorageTransaction, WEBHOOK_RUN_FAILURE_CODES, canRetryWebhookRun, InMemoryWebhookRunStorage, WorkflowInterventionError, InMemoryWorkflowInterventionStorage, WORKFLOW_RUN_FAILURE_CODES, InMemoryWorkflowRunStorage, InMemoryWorkflowNodeRunStorage, InMemoryWorkflowAgentNodeRunStorage, InMemoryStorage, isMigrationCapableStorage, migrateStorage, checkStorageSchema, step, defineMigrations, runMigrationSet, describeMigrationHistory };
7067
7092
 
7068
- //# debugId=0974A6B3A889270064756E2164756E21
7093
+ //# debugId=D421DE165E32FF5B64756E2164756E21