@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/README.md +5 -4
- package/dist/cli.js +42 -12
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +42 -12
- package/dist/index.js.map +1 -1
- package/dist/install.js +6 -1
- package/dist/install.js.map +1 -1
- package/dist/integration.js +12 -2
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.js +6 -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 +6 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.js +36 -8
- package/dist/testing.js.map +1 -1
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -9,10 +9,11 @@ accounted for usage, and exported over OTLP.
|
|
|
9
9
|
|
|
10
10
|
## Status
|
|
11
11
|
|
|
12
|
-
**Published
|
|
13
|
-
`npx @osfactory/otel-hook`.
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
**Published on npm.** Install with `npm install -g @osfactory/otel-hook` or
|
|
13
|
+
`npx @osfactory/otel-hook`. Releases are cut automatically from Conventional
|
|
14
|
+
Commit PR titles on `main` — see [docs/release-checklist.md](docs/release-checklist.md).
|
|
15
|
+
[Known limitations](#known-limitations) document what a given release
|
|
16
|
+
intentionally does and does not claim.
|
|
16
17
|
|
|
17
18
|
## Principles
|
|
18
19
|
|
package/dist/cli.js
CHANGED
|
@@ -4685,7 +4685,12 @@ var usageFields = {
|
|
|
4685
4685
|
cache_write_tokens: z19.number().int().min(0).optional()
|
|
4686
4686
|
};
|
|
4687
4687
|
var envelopeShape = {
|
|
4688
|
-
|
|
4688
|
+
// Not `.min(1)`: see `cursorSessionId`. A payload naming neither
|
|
4689
|
+
// `conversation_id` nor `session_id` is still rejected — by
|
|
4690
|
+
// `recognizeCursorPayload`'s post-parse check — but rejecting it here would
|
|
4691
|
+
// fail the whole discriminated union on a field the adapter can source from
|
|
4692
|
+
// either name.
|
|
4693
|
+
conversation_id: z19.string().optional(),
|
|
4689
4694
|
generation_id: z19.string().optional(),
|
|
4690
4695
|
session_id: z19.string().optional(),
|
|
4691
4696
|
model: z19.string().optional(),
|
|
@@ -4859,12 +4864,25 @@ var recognizeCursorPayload = (payload) => {
|
|
|
4859
4864
|
detail: issue === void 0 ? "payload does not satisfy the cursor hook schema" : `${issue.path.join(".") || "<root>"}: ${issue.message}`
|
|
4860
4865
|
};
|
|
4861
4866
|
}
|
|
4867
|
+
if (cursorSessionId(parsed.data) === void 0) {
|
|
4868
|
+
return {
|
|
4869
|
+
status: "invalid",
|
|
4870
|
+
eventName,
|
|
4871
|
+
detail: "payload names neither conversation_id nor session_id, so it carries no session to attribute telemetry to"
|
|
4872
|
+
};
|
|
4873
|
+
}
|
|
4862
4874
|
return { status: "modelled", payload: parsed.data };
|
|
4863
4875
|
};
|
|
4864
4876
|
var normalizeCursorPayload = (payload) => {
|
|
4865
4877
|
const recognized = recognizeCursorPayload(payload);
|
|
4866
4878
|
return recognized?.status === "modelled" ? recognized.payload : void 0;
|
|
4867
4879
|
};
|
|
4880
|
+
var cursorSessionId = (payload) => {
|
|
4881
|
+
if (payload.conversation_id !== void 0 && payload.conversation_id.length > 0) {
|
|
4882
|
+
return payload.conversation_id;
|
|
4883
|
+
}
|
|
4884
|
+
return payload.session_id !== void 0 && payload.session_id.length > 0 ? payload.session_id : void 0;
|
|
4885
|
+
};
|
|
4868
4886
|
|
|
4869
4887
|
// src/providers/cursor/delivery.ts
|
|
4870
4888
|
var deliveryComponents2 = (payload) => {
|
|
@@ -4922,12 +4940,16 @@ var cursorDeliveryIdentity = (input) => {
|
|
|
4922
4940
|
if (payload === void 0) {
|
|
4923
4941
|
return void 0;
|
|
4924
4942
|
}
|
|
4943
|
+
const sessionId = cursorSessionId(payload);
|
|
4944
|
+
if (sessionId === void 0) {
|
|
4945
|
+
return void 0;
|
|
4946
|
+
}
|
|
4925
4947
|
const identified = deliveryComponents2(payload);
|
|
4926
4948
|
if (identified === void 0) {
|
|
4927
4949
|
return void 0;
|
|
4928
4950
|
}
|
|
4929
4951
|
return {
|
|
4930
|
-
sessionId
|
|
4952
|
+
sessionId,
|
|
4931
4953
|
sourceEventName: payload.hook_event_name,
|
|
4932
4954
|
components: identified.components,
|
|
4933
4955
|
evidence: identified.evidence
|
|
@@ -5124,10 +5146,14 @@ var createCursorAdapter = (options = {}) => {
|
|
|
5124
5146
|
}
|
|
5125
5147
|
const workspace = deriveWorkspace(context, payload);
|
|
5126
5148
|
const discriminator = invocationDiscriminator(payload);
|
|
5149
|
+
const sessionId = cursorSessionId(payload);
|
|
5150
|
+
if (sessionId === void 0) {
|
|
5151
|
+
return [];
|
|
5152
|
+
}
|
|
5127
5153
|
const occurredAt = context.clock.now();
|
|
5128
5154
|
const invocationId = context.ids.newInvocationId({
|
|
5129
5155
|
providerId: id,
|
|
5130
|
-
sessionId
|
|
5156
|
+
sessionId,
|
|
5131
5157
|
sourceEventName: payload.hook_event_name,
|
|
5132
5158
|
occurredAt,
|
|
5133
5159
|
...discriminator === void 0 ? {} : { discriminator }
|
|
@@ -5136,10 +5162,7 @@ var createCursorAdapter = (options = {}) => {
|
|
|
5136
5162
|
source: `adapter:${id}`,
|
|
5137
5163
|
confidence: input.detection.confidence,
|
|
5138
5164
|
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,
|
|
5165
|
+
sessionId,
|
|
5143
5166
|
invocationId,
|
|
5144
5167
|
startedAt: occurredAt,
|
|
5145
5168
|
...workspace === void 0 ? {} : { workspace }
|
|
@@ -6186,6 +6209,7 @@ var createProviderRegistry = (adapters) => {
|
|
|
6186
6209
|
errors
|
|
6187
6210
|
};
|
|
6188
6211
|
}
|
|
6212
|
+
const nearMisses = [];
|
|
6189
6213
|
for (const adapter of frozen) {
|
|
6190
6214
|
let detection;
|
|
6191
6215
|
try {
|
|
@@ -6195,6 +6219,10 @@ var createProviderRegistry = (adapters) => {
|
|
|
6195
6219
|
continue;
|
|
6196
6220
|
}
|
|
6197
6221
|
if (detection.confidence === "none") {
|
|
6222
|
+
for (const reason of detection.reasons) {
|
|
6223
|
+
const prefixed = `${adapter.id}: ${reason}`;
|
|
6224
|
+
nearMisses.push(prefixed.length <= 160 ? prefixed : `${prefixed.slice(0, 159)}\u2026`);
|
|
6225
|
+
}
|
|
6198
6226
|
continue;
|
|
6199
6227
|
}
|
|
6200
6228
|
if (detection.providerId !== adapter.id) {
|
|
@@ -6214,7 +6242,7 @@ var createProviderRegistry = (adapters) => {
|
|
|
6214
6242
|
return {
|
|
6215
6243
|
status: "unknown",
|
|
6216
6244
|
reason: "no-candidates",
|
|
6217
|
-
detection: unknownDetection(),
|
|
6245
|
+
detection: unknownDetection(nearMisses.length === 0 ? void 0 : nearMisses.slice(0, 8)),
|
|
6218
6246
|
candidates,
|
|
6219
6247
|
errors
|
|
6220
6248
|
};
|
|
@@ -7162,10 +7190,15 @@ import {
|
|
|
7162
7190
|
ATTR_GEN_AI_USAGE_REASONING_OUTPUT_TOKENS,
|
|
7163
7191
|
ATTR_SESSION_ID
|
|
7164
7192
|
} from "@opentelemetry/semantic-conventions/incubating";
|
|
7193
|
+
|
|
7194
|
+
// src/version.ts
|
|
7195
|
+
var VERSION = "0.1.2";
|
|
7196
|
+
|
|
7197
|
+
// src/telemetry/semconv.ts
|
|
7165
7198
|
var SCOPE_NAME = "@osfactory/otel-hook";
|
|
7166
7199
|
var DEFAULT_INSTRUMENTATION_SCOPE = Object.freeze({
|
|
7167
7200
|
name: SCOPE_NAME,
|
|
7168
|
-
version:
|
|
7201
|
+
version: VERSION
|
|
7169
7202
|
});
|
|
7170
7203
|
var ATTR_OTELHOOK_INVOCATION_ID = "otelhook.invocation.id";
|
|
7171
7204
|
var ATTR_OTELHOOK_PROVIDER_ID = "otelhook.provider.id";
|
|
@@ -8428,9 +8461,6 @@ var createOtlpTraceSink = (options) => {
|
|
|
8428
8461
|
};
|
|
8429
8462
|
};
|
|
8430
8463
|
|
|
8431
|
-
// src/version.ts
|
|
8432
|
-
var VERSION = "0.1.0";
|
|
8433
|
-
|
|
8434
8464
|
// src/cli/doctor.ts
|
|
8435
8465
|
var DOCTOR_STATE_NAMESPACE = "doctor";
|
|
8436
8466
|
var PROBE_KEY = "diagnostics:doctor-probe";
|