@osfactory/otel-hook 0.1.0 → 0.1.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/dist/index.d.ts CHANGED
@@ -38,7 +38,9 @@ import '@opentelemetry/sdk-logs';
38
38
  /**
39
39
  * Package version, kept in its own module so the CLI can report it without
40
40
  * importing the whole library barrel (and every provider adapter with it).
41
+ *
42
+ * Updated by `scripts/release/sync-version.mjs` during semantic-release.
41
43
  */
42
- declare const VERSION = "0.1.0";
44
+ declare const VERSION = "0.1.2";
43
45
 
44
46
  export { VERSION };
package/dist/index.js CHANGED
@@ -2290,6 +2290,7 @@ var createProviderRegistry = (adapters) => {
2290
2290
  errors
2291
2291
  };
2292
2292
  }
2293
+ const nearMisses = [];
2293
2294
  for (const adapter of frozen) {
2294
2295
  let detection;
2295
2296
  try {
@@ -2299,6 +2300,10 @@ var createProviderRegistry = (adapters) => {
2299
2300
  continue;
2300
2301
  }
2301
2302
  if (detection.confidence === "none") {
2303
+ for (const reason of detection.reasons) {
2304
+ const prefixed = `${adapter.id}: ${reason}`;
2305
+ nearMisses.push(prefixed.length <= 160 ? prefixed : `${prefixed.slice(0, 159)}\u2026`);
2306
+ }
2302
2307
  continue;
2303
2308
  }
2304
2309
  if (detection.providerId !== adapter.id) {
@@ -2318,7 +2323,7 @@ var createProviderRegistry = (adapters) => {
2318
2323
  return {
2319
2324
  status: "unknown",
2320
2325
  reason: "no-candidates",
2321
- detection: unknownDetection(),
2326
+ detection: unknownDetection(nearMisses.length === 0 ? void 0 : nearMisses.slice(0, 8)),
2322
2327
  candidates,
2323
2328
  errors
2324
2329
  };
@@ -3139,7 +3144,12 @@ var usageFields = {
3139
3144
  cache_write_tokens: z16.number().int().min(0).optional()
3140
3145
  };
3141
3146
  var envelopeShape = {
3142
- conversation_id: z16.string().min(1),
3147
+ // Not `.min(1)`: see `cursorSessionId`. A payload naming neither
3148
+ // `conversation_id` nor `session_id` is still rejected — by
3149
+ // `recognizeCursorPayload`'s post-parse check — but rejecting it here would
3150
+ // fail the whole discriminated union on a field the adapter can source from
3151
+ // either name.
3152
+ conversation_id: z16.string().optional(),
3143
3153
  generation_id: z16.string().optional(),
3144
3154
  session_id: z16.string().optional(),
3145
3155
  model: z16.string().optional(),
@@ -3313,12 +3323,25 @@ var recognizeCursorPayload = (payload) => {
3313
3323
  detail: issue === void 0 ? "payload does not satisfy the cursor hook schema" : `${issue.path.join(".") || "<root>"}: ${issue.message}`
3314
3324
  };
3315
3325
  }
3326
+ if (cursorSessionId(parsed.data) === void 0) {
3327
+ return {
3328
+ status: "invalid",
3329
+ eventName,
3330
+ detail: "payload names neither conversation_id nor session_id, so it carries no session to attribute telemetry to"
3331
+ };
3332
+ }
3316
3333
  return { status: "modelled", payload: parsed.data };
3317
3334
  };
3318
3335
  var normalizeCursorPayload = (payload) => {
3319
3336
  const recognized = recognizeCursorPayload(payload);
3320
3337
  return recognized?.status === "modelled" ? recognized.payload : void 0;
3321
3338
  };
3339
+ var cursorSessionId = (payload) => {
3340
+ if (payload.conversation_id !== void 0 && payload.conversation_id.length > 0) {
3341
+ return payload.conversation_id;
3342
+ }
3343
+ return payload.session_id !== void 0 && payload.session_id.length > 0 ? payload.session_id : void 0;
3344
+ };
3322
3345
 
3323
3346
  // src/providers/cursor/delivery.ts
3324
3347
  var deliveryComponents = (payload) => {
@@ -3376,12 +3399,16 @@ var cursorDeliveryIdentity = (input) => {
3376
3399
  if (payload === void 0) {
3377
3400
  return void 0;
3378
3401
  }
3402
+ const sessionId = cursorSessionId(payload);
3403
+ if (sessionId === void 0) {
3404
+ return void 0;
3405
+ }
3379
3406
  const identified = deliveryComponents(payload);
3380
3407
  if (identified === void 0) {
3381
3408
  return void 0;
3382
3409
  }
3383
3410
  return {
3384
- sessionId: payload.conversation_id,
3411
+ sessionId,
3385
3412
  sourceEventName: payload.hook_event_name,
3386
3413
  components: identified.components,
3387
3414
  evidence: identified.evidence
@@ -3578,10 +3605,14 @@ var createCursorAdapter = (options = {}) => {
3578
3605
  }
3579
3606
  const workspace = deriveWorkspace(context, payload);
3580
3607
  const discriminator = invocationDiscriminator(payload);
3608
+ const sessionId = cursorSessionId(payload);
3609
+ if (sessionId === void 0) {
3610
+ return [];
3611
+ }
3581
3612
  const occurredAt = context.clock.now();
3582
3613
  const invocationId = context.ids.newInvocationId({
3583
3614
  providerId: id,
3584
- sessionId: payload.conversation_id,
3615
+ sessionId,
3585
3616
  sourceEventName: payload.hook_event_name,
3586
3617
  occurredAt,
3587
3618
  ...discriminator === void 0 ? {} : { discriminator }
@@ -3590,10 +3621,7 @@ var createCursorAdapter = (options = {}) => {
3590
3621
  source: `adapter:${id}`,
3591
3622
  confidence: input.detection.confidence,
3592
3623
  fields: {
3593
- // Cursor's own conversation id, used exactly as reported: never
3594
- // normalized, parent/child matched, or substituted for a derived value.
3595
- // `session_id` repeats it in every capture and is not preferred over it.
3596
- sessionId: payload.conversation_id,
3624
+ sessionId,
3597
3625
  invocationId,
3598
3626
  startedAt: occurredAt,
3599
3627
  ...workspace === void 0 ? {} : { workspace }
@@ -6920,10 +6948,15 @@ import {
6920
6948
  ATTR_GEN_AI_USAGE_REASONING_OUTPUT_TOKENS,
6921
6949
  ATTR_SESSION_ID
6922
6950
  } from "@opentelemetry/semantic-conventions/incubating";
6951
+
6952
+ // src/version.ts
6953
+ var VERSION = "0.1.2";
6954
+
6955
+ // src/telemetry/semconv.ts
6923
6956
  var SCOPE_NAME = "@osfactory/otel-hook";
6924
6957
  var DEFAULT_INSTRUMENTATION_SCOPE = Object.freeze({
6925
6958
  name: SCOPE_NAME,
6926
- version: "0.1.0"
6959
+ version: VERSION
6927
6960
  });
6928
6961
  var ATTR_OTELHOOK_INVOCATION_ID = "otelhook.invocation.id";
6929
6962
  var ATTR_OTELHOOK_PROVIDER_ID = "otelhook.provider.id";
@@ -11473,9 +11506,6 @@ var planProviderRegistration = (input) => {
11473
11506
  changes: result.changes
11474
11507
  };
11475
11508
  };
11476
-
11477
- // src/version.ts
11478
- var VERSION = "0.1.0";
11479
11509
  export {
11480
11510
  ANTIGRAVITY_CAPABILITIES,
11481
11511
  ANTIGRAVITY_HOOK_EVENT_NAMES,