ai-hist-native 0.21.1 → 0.21.2

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.
package/index.d.ts CHANGED
@@ -222,6 +222,101 @@ export interface SessionFileEditsPage {
222
222
  fileEdits: Array<NativeSessionFileEdit>
223
223
  nextCursor?: EvidenceCursor
224
224
  }
225
+ /**
226
+ * Normalized usage for one request or one session.
227
+ *
228
+ * The optional fields stay optional across the boundary: `null` means the
229
+ * provider did not report that counter, which is a different fact from a
230
+ * reported zero and the only thing that makes `coverage` interpretable.
231
+ */
232
+ export interface NativeNormalizedUsage {
233
+ inputTokens: number
234
+ outputTokens: number
235
+ reasoningTokens?: number
236
+ cacheReadTokens: number
237
+ cacheWriteTokens: number
238
+ cacheWrite5mTokens?: number
239
+ cacheWrite1hTokens?: number
240
+ providerTotalTokens?: number
241
+ reportedCostUsd?: number
242
+ /**
243
+ * `per-request`, `per-message`, `cumulative-delta`, `context-proxy`, or
244
+ * `mixed` on a summary spanning more than one.
245
+ */
246
+ accounting: string
247
+ hasInputTokens: boolean
248
+ hasOutputTokens: boolean
249
+ hasReasoningTokens: boolean
250
+ hasCacheReadTokens: boolean
251
+ hasCacheWriteTokens: boolean
252
+ }
253
+ export interface NativeSessionRequest {
254
+ id: number
255
+ source: string
256
+ sessionId: string
257
+ requestKey: string
258
+ /** `request-id`, `provider-message-id`, `request-span` or `record-id`. */
259
+ requestKeySource: string
260
+ messageIds: Array<string>
261
+ model?: string
262
+ provider?: string
263
+ firstTsMs: number
264
+ lastTsMs: number
265
+ /**
266
+ * Absent when the request carried no usage evidence, or when the
267
+ * evidence could not be trusted — `diagnostics` says which.
268
+ */
269
+ usage?: NativeNormalizedUsage
270
+ usageError?: string
271
+ toolUseIds: Array<string>
272
+ hasThinking: boolean
273
+ eventCount: number
274
+ diagnostics: Array<string>
275
+ }
276
+ export interface RequestCursor {
277
+ tsMs: number
278
+ id: number
279
+ }
280
+ export interface RequestPageOptions {
281
+ dbPath?: string
282
+ limit?: number
283
+ after?: RequestCursor
284
+ }
285
+ export interface SessionRequestsPage {
286
+ contractVersion: number
287
+ source: string
288
+ sessionId: string
289
+ requests: Array<NativeSessionRequest>
290
+ nextCursor?: RequestCursor
291
+ }
292
+ export interface SessionUsageOptions {
293
+ dbPath?: string
294
+ }
295
+ /**
296
+ * One session's usage rollup. `usage` is absent when the session has no
297
+ * usage evidence at all — not zeroed, because zero is a claim.
298
+ */
299
+ export interface SessionUsage {
300
+ contractVersion: number
301
+ source: string
302
+ sessionId: string
303
+ usage?: NativeNormalizedUsage
304
+ /** Requests that contributed to `usage`. */
305
+ requestCount: number
306
+ /** Requests seen, including ones with no usage. */
307
+ totalRequestCount: number
308
+ /**
309
+ * Every accounting mode present. More than one means the totals mix
310
+ * units and should be read per mode.
311
+ */
312
+ accounting: Array<string>
313
+ models: Array<string>
314
+ firstTsMs?: number
315
+ lastTsMs?: number
316
+ diagnostics: Array<string>
317
+ /** The totals exceeded what can be represented and must not be used. */
318
+ overflowed: boolean
319
+ }
225
320
  export interface SourceCount {
226
321
  source: string
227
322
  count: number
@@ -280,6 +375,15 @@ export declare function getSessionToolCallsPage(source: string, sessionId: strin
280
375
  export declare function getSessionUserTurnsPage(source: string, sessionId: string, options?: UserTurnsPageOptions | undefined | null): Promise<SessionUserTurnsPage>
281
376
  /** One bounded page of recorded file edits for one session. */
282
377
  export declare function getSessionFileEditsPage(source: string, sessionId: string, options?: EvidencePageOptions | undefined | null): Promise<SessionFileEditsPage>
378
+ /**
379
+ * One bounded page of a session's model requests, oldest first.
380
+ *
381
+ * Both halves of the identity are required for the same reason the evidence
382
+ * pages require them: provider session ids collide across providers.
383
+ */
384
+ export declare function getSessionRequestsPage(source: string, sessionId: string, options?: RequestPageOptions | undefined | null): Promise<SessionRequestsPage>
385
+ /** Provider-neutral usage rollup for one session. */
386
+ export declare function getSessionUsage(source: string, sessionId: string, options?: SessionUsageOptions | undefined | null): Promise<SessionUsage>
283
387
  /** Database statistics over already-indexed data. */
284
388
  export declare function stats(options?: StatsOptions | undefined | null): Promise<NativeStats>
285
389
  export interface CatalogSession {
package/index.js CHANGED
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { historyDelivery, historyDeliveryDrain, getSourceObservation, applySourceObservations, applySourceEvidence, nativeContractVersion, nativeBuildProfile, search, recent, getSession, getSessionEventsPage, getSessionToolCallsPage, getSessionUserTurnsPage, getSessionFileEditsPage, stats, listSessionCatalogPage, listSessionCatalog, discoverSessions, hydrateSession, getSessionRelationships, getSessionTree, getSessionChildrenPage, sync, syncLocal, installGitHooks, linkGitCommit } = nativeBinding
313
+ const { historyDelivery, historyDeliveryDrain, getSourceObservation, applySourceObservations, applySourceEvidence, nativeContractVersion, nativeBuildProfile, search, recent, getSession, getSessionEventsPage, getSessionToolCallsPage, getSessionUserTurnsPage, getSessionFileEditsPage, getSessionRequestsPage, getSessionUsage, stats, listSessionCatalogPage, listSessionCatalog, discoverSessions, hydrateSession, getSessionRelationships, getSessionTree, getSessionChildrenPage, sync, syncLocal, installGitHooks, linkGitCommit } = nativeBinding
314
314
 
315
315
  module.exports.historyDelivery = historyDelivery
316
316
  module.exports.historyDeliveryDrain = historyDeliveryDrain
@@ -326,6 +326,8 @@ module.exports.getSessionEventsPage = getSessionEventsPage
326
326
  module.exports.getSessionToolCallsPage = getSessionToolCallsPage
327
327
  module.exports.getSessionUserTurnsPage = getSessionUserTurnsPage
328
328
  module.exports.getSessionFileEditsPage = getSessionFileEditsPage
329
+ module.exports.getSessionRequestsPage = getSessionRequestsPage
330
+ module.exports.getSessionUsage = getSessionUsage
329
331
  module.exports.stats = stats
330
332
  module.exports.listSessionCatalogPage = listSessionCatalogPage
331
333
  module.exports.listSessionCatalog = listSessionCatalog
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hist-native-darwin-arm64",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "os": [
5
5
  "darwin"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hist-native-darwin-x64",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "os": [
5
5
  "darwin"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hist-native-linux-arm64-gnu",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "os": [
5
5
  "linux"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hist-native-linux-arm64-musl",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "os": [
5
5
  "linux"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hist-native-linux-x64-gnu",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "os": [
5
5
  "linux"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hist-native-linux-x64-musl",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "os": [
5
5
  "linux"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hist-native-win32-x64-msvc",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "os": [
5
5
  "win32"
6
6
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hist-native",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "description": "Mandatory Node-API engine for RelayHistory.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -44,12 +44,12 @@
44
44
  "@napi-rs/cli": "^2.18.4"
45
45
  },
46
46
  "optionalDependencies": {
47
- "ai-hist-native-darwin-arm64": "0.21.1",
48
- "ai-hist-native-darwin-x64": "0.21.1",
49
- "ai-hist-native-linux-x64-gnu": "0.21.1",
50
- "ai-hist-native-linux-arm64-gnu": "0.21.1",
51
- "ai-hist-native-linux-x64-musl": "0.21.1",
52
- "ai-hist-native-linux-arm64-musl": "0.21.1",
53
- "ai-hist-native-win32-x64-msvc": "0.21.1"
47
+ "ai-hist-native-darwin-arm64": "0.21.2",
48
+ "ai-hist-native-darwin-x64": "0.21.2",
49
+ "ai-hist-native-linux-x64-gnu": "0.21.2",
50
+ "ai-hist-native-linux-arm64-gnu": "0.21.2",
51
+ "ai-hist-native-linux-x64-musl": "0.21.2",
52
+ "ai-hist-native-linux-arm64-musl": "0.21.2",
53
+ "ai-hist-native-win32-x64-msvc": "0.21.2"
54
54
  }
55
55
  }