@drawbridge/drawbridge-utils 0.0.37 → 0.0.38

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/dist/ai.cjs CHANGED
@@ -240,7 +240,7 @@ var billRequest = async ({
240
240
  }) => {
241
241
  const gross = priceForRequest(model, usage, tools);
242
242
  const cogs = costForRequest(model, usage, tools);
243
- const id = (0, import_drawbridge_telemetry.currentTraceId)();
243
+ const trace = (0, import_drawbridge_telemetry.currentTraceId)();
244
244
  await debit({
245
245
  db,
246
246
  user,
@@ -248,7 +248,7 @@ var billRequest = async ({
248
248
  type: "ai",
249
249
  category: "usage",
250
250
  source: "user",
251
- ...id && { trace: { id } },
251
+ ...trace && { trace },
252
252
  ai: {
253
253
  name: "google",
254
254
  model,
package/dist/ai.d.cts CHANGED
@@ -185,13 +185,12 @@ const billRequest = async ({
185
185
 
186
186
  // Stamp the current trace ID so multiple AI calls inside one HTTP request
187
187
  // (or one BullMQ job) share a grouping key — the UI can collapse rows
188
- // per trace.id to show "this preview cost $0.12 across 5 calls" without
188
+ // per trace to show "this preview cost $0.12 across 5 calls" without
189
189
  // the user needing to mentally fold them together. currentTraceId()
190
190
  // returns undefined when called outside any traced scope, in which case
191
191
  // the field is omitted from the row (additionalProperties:false would
192
- // reject `trace: undefined`). Nested as `trace.id` to match the `ai` /
193
- // `balance` sub-object pattern already on this document.
194
- const id = currentTraceId();
192
+ // reject `trace: undefined`).
193
+ const trace = currentTraceId();
195
194
 
196
195
  await debit({
197
196
  db,
@@ -200,7 +199,7 @@ const billRequest = async ({
200
199
  type : 'ai',
201
200
  category : 'usage',
202
201
  source : 'user',
203
- ...( id && { trace : { id } }),
202
+ ...( trace && { trace }),
204
203
  ai : {
205
204
  name : 'google',
206
205
  model,
package/dist/ai.d.ts CHANGED
@@ -185,13 +185,12 @@ const billRequest = async ({
185
185
 
186
186
  // Stamp the current trace ID so multiple AI calls inside one HTTP request
187
187
  // (or one BullMQ job) share a grouping key — the UI can collapse rows
188
- // per trace.id to show "this preview cost $0.12 across 5 calls" without
188
+ // per trace to show "this preview cost $0.12 across 5 calls" without
189
189
  // the user needing to mentally fold them together. currentTraceId()
190
190
  // returns undefined when called outside any traced scope, in which case
191
191
  // the field is omitted from the row (additionalProperties:false would
192
- // reject `trace: undefined`). Nested as `trace.id` to match the `ai` /
193
- // `balance` sub-object pattern already on this document.
194
- const id = currentTraceId();
192
+ // reject `trace: undefined`).
193
+ const trace = currentTraceId();
195
194
 
196
195
  await debit({
197
196
  db,
@@ -200,7 +199,7 @@ const billRequest = async ({
200
199
  type : 'ai',
201
200
  category : 'usage',
202
201
  source : 'user',
203
- ...( id && { trace : { id } }),
202
+ ...( trace && { trace }),
204
203
  ai : {
205
204
  name : 'google',
206
205
  model,
package/dist/ai.js CHANGED
@@ -94,7 +94,7 @@ var billRequest = async ({
94
94
  }) => {
95
95
  const gross = priceForRequest(model, usage, tools);
96
96
  const cogs = costForRequest(model, usage, tools);
97
- const id = currentTraceId();
97
+ const trace = currentTraceId();
98
98
  await debit({
99
99
  db,
100
100
  user,
@@ -102,7 +102,7 @@ var billRequest = async ({
102
102
  type: "ai",
103
103
  category: "usage",
104
104
  source: "user",
105
- ...id && { trace: { id } },
105
+ ...trace && { trace },
106
106
  ai: {
107
107
  name: "google",
108
108
  model,
package/package.json CHANGED
@@ -104,5 +104,5 @@
104
104
  "build": "tsup && npm publish"
105
105
  },
106
106
  "types": "dist/index.d.ts",
107
- "version": "0.0.37"
107
+ "version": "0.0.38"
108
108
  }