@osfactory/otel-hook 0.1.1 → 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.
- package/dist/cli.js +55 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/dist/install.js +6 -1
- package/dist/install.js.map +1 -1
- package/dist/integration.js +7 -2
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.js +1 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/providers.js +36 -8
- package/dist/providers.js.map +1 -1
- package/dist/runtime.js +6 -1
- package/dist/runtime.js.map +1 -1
- package/dist/telemetry.js +1 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.js +36 -8
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -356,6 +356,23 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
356
356
|
"--require-callback-id",
|
|
357
357
|
"--no-derive-callback-id"
|
|
358
358
|
]);
|
|
359
|
+
var LEGACY_PROVIDER_FLAGS = {
|
|
360
|
+
"--cursor": "cursor",
|
|
361
|
+
"--claude": "claude-code",
|
|
362
|
+
"--codex": "codex"
|
|
363
|
+
};
|
|
364
|
+
function normalizeLegacyProviderFlags(argv) {
|
|
365
|
+
const out = [];
|
|
366
|
+
for (const token of argv) {
|
|
367
|
+
const providerId = LEGACY_PROVIDER_FLAGS[token];
|
|
368
|
+
if (providerId !== void 0) {
|
|
369
|
+
out.push("--provider", providerId);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
out.push(token);
|
|
373
|
+
}
|
|
374
|
+
return out;
|
|
375
|
+
}
|
|
359
376
|
var tokenize = (argv) => {
|
|
360
377
|
const values = /* @__PURE__ */ new Map();
|
|
361
378
|
const booleans = /* @__PURE__ */ new Set();
|
|
@@ -704,7 +721,7 @@ var parseCliArgs = (argv) => {
|
|
|
704
721
|
if (rest.includes("--help") || rest.includes("-h")) {
|
|
705
722
|
return { status: "help", topic: command };
|
|
706
723
|
}
|
|
707
|
-
const tokens = tokenize(rest);
|
|
724
|
+
const tokens = tokenize(normalizeLegacyProviderFlags(rest));
|
|
708
725
|
const errors = [...tokens.errors];
|
|
709
726
|
if (command === "providers") {
|
|
710
727
|
rejectFlagsFor(command, tokens, PROVIDERS_FLAGS, errors);
|
|
@@ -4685,7 +4702,12 @@ var usageFields = {
|
|
|
4685
4702
|
cache_write_tokens: z19.number().int().min(0).optional()
|
|
4686
4703
|
};
|
|
4687
4704
|
var envelopeShape = {
|
|
4688
|
-
|
|
4705
|
+
// Not `.min(1)`: see `cursorSessionId`. A payload naming neither
|
|
4706
|
+
// `conversation_id` nor `session_id` is still rejected — by
|
|
4707
|
+
// `recognizeCursorPayload`'s post-parse check — but rejecting it here would
|
|
4708
|
+
// fail the whole discriminated union on a field the adapter can source from
|
|
4709
|
+
// either name.
|
|
4710
|
+
conversation_id: z19.string().optional(),
|
|
4689
4711
|
generation_id: z19.string().optional(),
|
|
4690
4712
|
session_id: z19.string().optional(),
|
|
4691
4713
|
model: z19.string().optional(),
|
|
@@ -4859,12 +4881,25 @@ var recognizeCursorPayload = (payload) => {
|
|
|
4859
4881
|
detail: issue === void 0 ? "payload does not satisfy the cursor hook schema" : `${issue.path.join(".") || "<root>"}: ${issue.message}`
|
|
4860
4882
|
};
|
|
4861
4883
|
}
|
|
4884
|
+
if (cursorSessionId(parsed.data) === void 0) {
|
|
4885
|
+
return {
|
|
4886
|
+
status: "invalid",
|
|
4887
|
+
eventName,
|
|
4888
|
+
detail: "payload names neither conversation_id nor session_id, so it carries no session to attribute telemetry to"
|
|
4889
|
+
};
|
|
4890
|
+
}
|
|
4862
4891
|
return { status: "modelled", payload: parsed.data };
|
|
4863
4892
|
};
|
|
4864
4893
|
var normalizeCursorPayload = (payload) => {
|
|
4865
4894
|
const recognized = recognizeCursorPayload(payload);
|
|
4866
4895
|
return recognized?.status === "modelled" ? recognized.payload : void 0;
|
|
4867
4896
|
};
|
|
4897
|
+
var cursorSessionId = (payload) => {
|
|
4898
|
+
if (payload.conversation_id !== void 0 && payload.conversation_id.length > 0) {
|
|
4899
|
+
return payload.conversation_id;
|
|
4900
|
+
}
|
|
4901
|
+
return payload.session_id !== void 0 && payload.session_id.length > 0 ? payload.session_id : void 0;
|
|
4902
|
+
};
|
|
4868
4903
|
|
|
4869
4904
|
// src/providers/cursor/delivery.ts
|
|
4870
4905
|
var deliveryComponents2 = (payload) => {
|
|
@@ -4922,12 +4957,16 @@ var cursorDeliveryIdentity = (input) => {
|
|
|
4922
4957
|
if (payload === void 0) {
|
|
4923
4958
|
return void 0;
|
|
4924
4959
|
}
|
|
4960
|
+
const sessionId = cursorSessionId(payload);
|
|
4961
|
+
if (sessionId === void 0) {
|
|
4962
|
+
return void 0;
|
|
4963
|
+
}
|
|
4925
4964
|
const identified = deliveryComponents2(payload);
|
|
4926
4965
|
if (identified === void 0) {
|
|
4927
4966
|
return void 0;
|
|
4928
4967
|
}
|
|
4929
4968
|
return {
|
|
4930
|
-
sessionId
|
|
4969
|
+
sessionId,
|
|
4931
4970
|
sourceEventName: payload.hook_event_name,
|
|
4932
4971
|
components: identified.components,
|
|
4933
4972
|
evidence: identified.evidence
|
|
@@ -5124,10 +5163,14 @@ var createCursorAdapter = (options = {}) => {
|
|
|
5124
5163
|
}
|
|
5125
5164
|
const workspace = deriveWorkspace(context, payload);
|
|
5126
5165
|
const discriminator = invocationDiscriminator(payload);
|
|
5166
|
+
const sessionId = cursorSessionId(payload);
|
|
5167
|
+
if (sessionId === void 0) {
|
|
5168
|
+
return [];
|
|
5169
|
+
}
|
|
5127
5170
|
const occurredAt = context.clock.now();
|
|
5128
5171
|
const invocationId = context.ids.newInvocationId({
|
|
5129
5172
|
providerId: id,
|
|
5130
|
-
sessionId
|
|
5173
|
+
sessionId,
|
|
5131
5174
|
sourceEventName: payload.hook_event_name,
|
|
5132
5175
|
occurredAt,
|
|
5133
5176
|
...discriminator === void 0 ? {} : { discriminator }
|
|
@@ -5136,10 +5179,7 @@ var createCursorAdapter = (options = {}) => {
|
|
|
5136
5179
|
source: `adapter:${id}`,
|
|
5137
5180
|
confidence: input.detection.confidence,
|
|
5138
5181
|
fields: {
|
|
5139
|
-
|
|
5140
|
-
// normalized, parent/child matched, or substituted for a derived value.
|
|
5141
|
-
// `session_id` repeats it in every capture and is not preferred over it.
|
|
5142
|
-
sessionId: payload.conversation_id,
|
|
5182
|
+
sessionId,
|
|
5143
5183
|
invocationId,
|
|
5144
5184
|
startedAt: occurredAt,
|
|
5145
5185
|
...workspace === void 0 ? {} : { workspace }
|
|
@@ -6186,6 +6226,7 @@ var createProviderRegistry = (adapters) => {
|
|
|
6186
6226
|
errors
|
|
6187
6227
|
};
|
|
6188
6228
|
}
|
|
6229
|
+
const nearMisses = [];
|
|
6189
6230
|
for (const adapter of frozen) {
|
|
6190
6231
|
let detection;
|
|
6191
6232
|
try {
|
|
@@ -6195,6 +6236,10 @@ var createProviderRegistry = (adapters) => {
|
|
|
6195
6236
|
continue;
|
|
6196
6237
|
}
|
|
6197
6238
|
if (detection.confidence === "none") {
|
|
6239
|
+
for (const reason of detection.reasons) {
|
|
6240
|
+
const prefixed = `${adapter.id}: ${reason}`;
|
|
6241
|
+
nearMisses.push(prefixed.length <= 160 ? prefixed : `${prefixed.slice(0, 159)}\u2026`);
|
|
6242
|
+
}
|
|
6198
6243
|
continue;
|
|
6199
6244
|
}
|
|
6200
6245
|
if (detection.providerId !== adapter.id) {
|
|
@@ -6214,7 +6259,7 @@ var createProviderRegistry = (adapters) => {
|
|
|
6214
6259
|
return {
|
|
6215
6260
|
status: "unknown",
|
|
6216
6261
|
reason: "no-candidates",
|
|
6217
|
-
detection: unknownDetection(),
|
|
6262
|
+
detection: unknownDetection(nearMisses.length === 0 ? void 0 : nearMisses.slice(0, 8)),
|
|
6218
6263
|
candidates,
|
|
6219
6264
|
errors
|
|
6220
6265
|
};
|
|
@@ -7164,7 +7209,7 @@ import {
|
|
|
7164
7209
|
} from "@opentelemetry/semantic-conventions/incubating";
|
|
7165
7210
|
|
|
7166
7211
|
// src/version.ts
|
|
7167
|
-
var VERSION = "0.1.
|
|
7212
|
+
var VERSION = "0.1.3";
|
|
7168
7213
|
|
|
7169
7214
|
// src/telemetry/semconv.ts
|
|
7170
7215
|
var SCOPE_NAME = "@osfactory/otel-hook";
|