ai-hist-native 0.21.1 → 0.22.1

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
@@ -70,6 +70,11 @@ export interface NativeSessionEvent {
70
70
  text?: string
71
71
  model?: string
72
72
  tokenJson?: string
73
+ /**
74
+ * The upstream inference provider the harness named, when it names one
75
+ * (OpenCode's `providerID`). Null elsewhere rather than inferred.
76
+ */
77
+ provider?: string
73
78
  eventUid: string
74
79
  /**
75
80
  * Per-tool-result fidelity. Null on every row that is not a tool result,
@@ -95,6 +100,7 @@ export interface NativeSessionEvent {
95
100
  subagentSessionId?: string
96
101
  agentId?: string
97
102
  requestId?: string
103
+ /** Why the turn ended, as the harness reported it. */
98
104
  stopReason?: string
99
105
  agentVersion?: string
100
106
  isSidechain?: boolean
@@ -222,6 +228,101 @@ export interface SessionFileEditsPage {
222
228
  fileEdits: Array<NativeSessionFileEdit>
223
229
  nextCursor?: EvidenceCursor
224
230
  }
231
+ /**
232
+ * Normalized usage for one request or one session.
233
+ *
234
+ * The optional fields stay optional across the boundary: `null` means the
235
+ * provider did not report that counter, which is a different fact from a
236
+ * reported zero and the only thing that makes `coverage` interpretable.
237
+ */
238
+ export interface NativeNormalizedUsage {
239
+ inputTokens: number
240
+ outputTokens: number
241
+ reasoningTokens?: number
242
+ cacheReadTokens: number
243
+ cacheWriteTokens: number
244
+ cacheWrite5mTokens?: number
245
+ cacheWrite1hTokens?: number
246
+ providerTotalTokens?: number
247
+ reportedCostUsd?: number
248
+ /**
249
+ * `per-request`, `per-message`, `cumulative-delta`, `context-proxy`, or
250
+ * `mixed` on a summary spanning more than one.
251
+ */
252
+ accounting: string
253
+ hasInputTokens: boolean
254
+ hasOutputTokens: boolean
255
+ hasReasoningTokens: boolean
256
+ hasCacheReadTokens: boolean
257
+ hasCacheWriteTokens: boolean
258
+ }
259
+ export interface NativeSessionRequest {
260
+ id: number
261
+ source: string
262
+ sessionId: string
263
+ requestKey: string
264
+ /** `request-id`, `provider-message-id`, `request-span` or `record-id`. */
265
+ requestKeySource: string
266
+ messageIds: Array<string>
267
+ model?: string
268
+ provider?: string
269
+ firstTsMs: number
270
+ lastTsMs: number
271
+ /**
272
+ * Absent when the request carried no usage evidence, or when the
273
+ * evidence could not be trusted — `diagnostics` says which.
274
+ */
275
+ usage?: NativeNormalizedUsage
276
+ usageError?: string
277
+ toolUseIds: Array<string>
278
+ hasThinking: boolean
279
+ eventCount: number
280
+ diagnostics: Array<string>
281
+ }
282
+ export interface RequestCursor {
283
+ tsMs: number
284
+ id: number
285
+ }
286
+ export interface RequestPageOptions {
287
+ dbPath?: string
288
+ limit?: number
289
+ after?: RequestCursor
290
+ }
291
+ export interface SessionRequestsPage {
292
+ contractVersion: number
293
+ source: string
294
+ sessionId: string
295
+ requests: Array<NativeSessionRequest>
296
+ nextCursor?: RequestCursor
297
+ }
298
+ export interface SessionUsageOptions {
299
+ dbPath?: string
300
+ }
301
+ /**
302
+ * One session's usage rollup. `usage` is absent when the session has no
303
+ * usage evidence at all — not zeroed, because zero is a claim.
304
+ */
305
+ export interface SessionUsage {
306
+ contractVersion: number
307
+ source: string
308
+ sessionId: string
309
+ usage?: NativeNormalizedUsage
310
+ /** Requests that contributed to `usage`. */
311
+ requestCount: number
312
+ /** Requests seen, including ones with no usage. */
313
+ totalRequestCount: number
314
+ /**
315
+ * Every accounting mode present. More than one means the totals mix
316
+ * units and should be read per mode.
317
+ */
318
+ accounting: Array<string>
319
+ models: Array<string>
320
+ firstTsMs?: number
321
+ lastTsMs?: number
322
+ diagnostics: Array<string>
323
+ /** The totals exceeded what can be represented and must not be used. */
324
+ overflowed: boolean
325
+ }
225
326
  export interface SourceCount {
226
327
  source: string
227
328
  count: number
@@ -280,6 +381,15 @@ export declare function getSessionToolCallsPage(source: string, sessionId: strin
280
381
  export declare function getSessionUserTurnsPage(source: string, sessionId: string, options?: UserTurnsPageOptions | undefined | null): Promise<SessionUserTurnsPage>
281
382
  /** One bounded page of recorded file edits for one session. */
282
383
  export declare function getSessionFileEditsPage(source: string, sessionId: string, options?: EvidencePageOptions | undefined | null): Promise<SessionFileEditsPage>
384
+ /**
385
+ * One bounded page of a session's model requests, oldest first.
386
+ *
387
+ * Both halves of the identity are required for the same reason the evidence
388
+ * pages require them: provider session ids collide across providers.
389
+ */
390
+ export declare function getSessionRequestsPage(source: string, sessionId: string, options?: RequestPageOptions | undefined | null): Promise<SessionRequestsPage>
391
+ /** Provider-neutral usage rollup for one session. */
392
+ export declare function getSessionUsage(source: string, sessionId: string, options?: SessionUsageOptions | undefined | null): Promise<SessionUsage>
283
393
  /** Database statistics over already-indexed data. */
284
394
  export declare function stats(options?: StatsOptions | undefined | null): Promise<NativeStats>
285
395
  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.22.1",
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.22.1",
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.22.1",
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.22.1",
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.22.1",
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.22.1",
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.22.1",
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.22.1",
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.22.1",
48
+ "ai-hist-native-darwin-x64": "0.22.1",
49
+ "ai-hist-native-linux-x64-gnu": "0.22.1",
50
+ "ai-hist-native-linux-arm64-gnu": "0.22.1",
51
+ "ai-hist-native-linux-x64-musl": "0.22.1",
52
+ "ai-hist-native-linux-arm64-musl": "0.22.1",
53
+ "ai-hist-native-win32-x64-msvc": "0.22.1"
54
54
  }
55
55
  }