@osfactory/otel-hook 0.13.0 → 0.13.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 +51 -3
- package/dist/cli.js +907 -164
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +5 -3
- package/dist/config.js +39 -5
- package/dist/config.js.map +1 -1
- package/dist/{destinations-DvqsPulb.d.ts → destinations-C4sSKjDO.d.ts} +1 -1
- package/dist/{export-destinations-Bey2djRk.d.ts → export-destinations-BjRXDots.d.ts} +37 -5
- package/dist/{hook-D5imE0Qc.d.ts → hook-CKLpgrYP.d.ts} +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +921 -182
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +1 -1
- package/dist/install.js +5 -1
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +15 -8
- package/dist/integration.js +998 -160
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.d.ts +8 -1
- package/dist/lifecycle.js +10 -3
- package/dist/lifecycle.js.map +1 -1
- package/dist/{metric-model-CFIeUwqd.d.ts → metric-model-B4lIuk6i.d.ts} +8 -0
- package/dist/{payload-CdDKeRpH.d.ts → payload-DLK7QaBB.d.ts} +17 -1
- package/dist/providers.d.ts +91 -6
- package/dist/providers.js +311 -4
- package/dist/providers.js.map +1 -1
- package/dist/{registry-BKQhhIO3.d.ts → registry-DM-4YvIA.d.ts} +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +23 -3
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-SpFM6YQY.d.ts → schema-CD61uW99.d.ts} +32 -3
- package/dist/state.js +20 -6
- package/dist/state.js.map +1 -1
- package/dist/telemetry.d.ts +4 -4
- package/dist/telemetry.js +865 -472
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +61 -21
- package/dist/testing.js.map +1 -1
- package/package.json +2 -1
package/dist/testing.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { O as OtelHookConfig,
|
|
1
|
+
import { O as OtelHookConfig, k as OtelHookConfigPatch } from './schema-CD61uW99.js';
|
|
2
2
|
import { b as CanonicalEvent } from './events-fcomX6d5.js';
|
|
3
3
|
import { I as IdentityClaim, d as InvocationIdentity, S as SourceProvenance } from './identity-BrVBs901.js';
|
|
4
4
|
import { P as PrivacyService } from './service-CbI9CObT.js';
|
|
5
5
|
import { d as ProviderCapabilities, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext, l as ProviderIdentityInput, f as ProviderDeliveryClaim, k as ProviderHookResponseInput, j as ProviderHookResponse, P as ProviderAdapter } from './adapter-DyCb7y1N.js';
|
|
6
|
-
import { P as ProviderRegistry } from './registry-
|
|
6
|
+
import { P as ProviderRegistry } from './registry-DM-4YvIA.js';
|
|
7
7
|
import { I as IdGenerator, W as WorktreeLocator, P as PayloadEnricher, S as SessionContextReader } from './ports-DhpSDIkp.js';
|
|
8
8
|
import { c as RecordingTelemetrySink, I as InMemoryStateStore, F as FixedClock, R as RecordingLogger } from './memory-B3r6sZtC.js';
|
|
9
9
|
export { e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, j as createRecordingLogger, k as createRecordingTelemetrySink } from './memory-B3r6sZtC.js';
|
|
10
|
-
import { O as OtelHook } from './hook-
|
|
10
|
+
import { O as OtelHook } from './hook-CKLpgrYP.js';
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { a as ContentDisclosure, b as ContentFact } from './content-M9xIKG7h.js';
|
|
13
13
|
import './primitives-CJ8-rn-f.js';
|
package/dist/testing.js
CHANGED
|
@@ -397,7 +397,22 @@ var exporterPolicySchema = z5.strictObject({
|
|
|
397
397
|
* Per-destination retry spool bounds, each optional and merged per leaf; any
|
|
398
398
|
* bound left unset takes its value from `DEFAULT_SPOOL_POLICY`.
|
|
399
399
|
*/
|
|
400
|
-
spool: spoolPolicySchema.partial().optional()
|
|
400
|
+
spool: spoolPolicySchema.partial().optional(),
|
|
401
|
+
/**
|
|
402
|
+
* The most time one hook invocation spends trying to reach one endpoint, in
|
|
403
|
+
* milliseconds: caps `timeoutMillis` for every OTLP request (connection setup
|
|
404
|
+
* included) and the exporter's own retries inside it. A batch that does not
|
|
405
|
+
* get through in time is spooled. Default {@link DEFAULT_EXPORT_BUDGET_MILLIS}:
|
|
406
|
+
* the host agent waits for its hooks, so a down collector must not stall it.
|
|
407
|
+
*/
|
|
408
|
+
exportBudgetMillis: z5.number().int().min(50).max(6e5).optional(),
|
|
409
|
+
/**
|
|
410
|
+
* After an endpoint was unreachable (refused, timed out, or answered a
|
|
411
|
+
* retryable status), every hook spools for it without trying for this long,
|
|
412
|
+
* in milliseconds; then one hook probes it again. 0 disables the window.
|
|
413
|
+
* Default {@link DEFAULT_ENDPOINT_DOWN_MILLIS}.
|
|
414
|
+
*/
|
|
415
|
+
endpointDownMillis: z5.number().int().min(0).max(36e5).optional()
|
|
401
416
|
});
|
|
402
417
|
var detectionPolicySchema = z5.strictObject({
|
|
403
418
|
/** Detections below this confidence resolve to the unknown provider. */
|
|
@@ -415,6 +430,9 @@ var diagnosticsPolicySchema = z5.strictObject({
|
|
|
415
430
|
var providersPolicySchema = z5.strictObject({
|
|
416
431
|
claudeCode: z5.strictObject({
|
|
417
432
|
readTranscriptUsage: z5.boolean()
|
|
433
|
+
}).optional(),
|
|
434
|
+
codex: z5.strictObject({
|
|
435
|
+
readRolloutUsage: z5.boolean()
|
|
418
436
|
}).optional()
|
|
419
437
|
});
|
|
420
438
|
var sessionContextPolicySchema = z5.strictObject({
|
|
@@ -444,7 +462,8 @@ var otelHookConfigPatchSchema = z5.strictObject({
|
|
|
444
462
|
detection: detectionPolicySchema.partial().optional(),
|
|
445
463
|
diagnostics: diagnosticsPolicySchema.partial().optional(),
|
|
446
464
|
providers: z5.strictObject({
|
|
447
|
-
claudeCode: z5.strictObject({ readTranscriptUsage: z5.boolean() }).partial().optional()
|
|
465
|
+
claudeCode: z5.strictObject({ readTranscriptUsage: z5.boolean() }).partial().optional(),
|
|
466
|
+
codex: z5.strictObject({ readRolloutUsage: z5.boolean() }).partial().optional()
|
|
448
467
|
}).partial().optional(),
|
|
449
468
|
sessionContext: sessionContextPolicySchema.partial().optional()
|
|
450
469
|
});
|
|
@@ -471,7 +490,8 @@ var DEFAULT_DIAGNOSTICS_POLICY = Object.freeze({
|
|
|
471
490
|
emitErrorEvents: true
|
|
472
491
|
});
|
|
473
492
|
var DEFAULT_PROVIDERS_POLICY = Object.freeze({
|
|
474
|
-
claudeCode: Object.freeze({ readTranscriptUsage: false })
|
|
493
|
+
claudeCode: Object.freeze({ readTranscriptUsage: false }),
|
|
494
|
+
codex: Object.freeze({ readRolloutUsage: false })
|
|
475
495
|
});
|
|
476
496
|
var DEFAULT_CONFIG = Object.freeze({
|
|
477
497
|
exporter: DEFAULT_EXPORTER_POLICY,
|
|
@@ -923,11 +943,11 @@ var createPrivacyService = (policyInput) => {
|
|
|
923
943
|
};
|
|
924
944
|
const flattenToAttributes = (value, prefix) => {
|
|
925
945
|
const attributes = {};
|
|
926
|
-
const walk = (current,
|
|
946
|
+
const walk = (current, path5) => {
|
|
927
947
|
if (typeof current === "string" || typeof current === "number" || typeof current === "boolean") {
|
|
928
948
|
const primitive = toAttributePrimitive(current);
|
|
929
949
|
if (primitive !== void 0) {
|
|
930
|
-
attributes[
|
|
950
|
+
attributes[path5] = primitive;
|
|
931
951
|
}
|
|
932
952
|
return;
|
|
933
953
|
}
|
|
@@ -946,16 +966,16 @@ var createPrivacyService = (policyInput) => {
|
|
|
946
966
|
primitives.push(entryPrimitive);
|
|
947
967
|
}
|
|
948
968
|
if (uniform) {
|
|
949
|
-
attributes[
|
|
969
|
+
attributes[path5] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
|
|
950
970
|
return;
|
|
951
971
|
}
|
|
952
972
|
for (const [index, entry] of current.entries()) {
|
|
953
|
-
walk(entry, `${
|
|
973
|
+
walk(entry, `${path5}.${index}`);
|
|
954
974
|
}
|
|
955
975
|
return;
|
|
956
976
|
}
|
|
957
977
|
for (const [key, entry] of Object.entries(current)) {
|
|
958
|
-
walk(entry,
|
|
978
|
+
walk(entry, path5 === "" ? key : `${path5}.${key}`);
|
|
959
979
|
}
|
|
960
980
|
};
|
|
961
981
|
walk(value, prefix);
|
|
@@ -2232,7 +2252,10 @@ var postToolUseFailurePayloadSchema = z16.object({
|
|
|
2232
2252
|
hook_event_name: z16.literal("PostToolUseFailure"),
|
|
2233
2253
|
tool_name: z16.string().min(1),
|
|
2234
2254
|
tool_input: z16.unknown().optional(),
|
|
2235
|
-
|
|
2255
|
+
// Optional: a failure that names no message still ends its tool call. The
|
|
2256
|
+
// `error` spelling Claude Code 2.1.x sends is folded onto it by
|
|
2257
|
+
// `normalizeClaudeHookPayload`.
|
|
2258
|
+
tool_error: z16.unknown().optional(),
|
|
2236
2259
|
tool_use_id: z16.string().min(1)
|
|
2237
2260
|
});
|
|
2238
2261
|
var permissionRequestPayloadSchema = z16.object({
|
|
@@ -2601,7 +2624,13 @@ var normalizeClaudeHookPayload = (payload) => {
|
|
|
2601
2624
|
if (record === void 0) {
|
|
2602
2625
|
return payload;
|
|
2603
2626
|
}
|
|
2604
|
-
return applyUsageShape(applyPrintResultShape(applyFieldAliases(record)));
|
|
2627
|
+
return applyUsageShape(applyToolFailureShape(applyPrintResultShape(applyFieldAliases(record))));
|
|
2628
|
+
};
|
|
2629
|
+
var applyToolFailureShape = (record) => {
|
|
2630
|
+
if (record.hook_event_name !== "PostToolUseFailure" || record.tool_error !== void 0 || record.error === void 0) {
|
|
2631
|
+
return record;
|
|
2632
|
+
}
|
|
2633
|
+
return { ...record, tool_error: record.error };
|
|
2605
2634
|
};
|
|
2606
2635
|
var applyUsageShape = (record) => {
|
|
2607
2636
|
const usage = coerceClaudeUsage(record.usage) ?? coerceClaudeUsage(record.token_usage) ?? coerceClaudeUsage(record.tokenUsage);
|
|
@@ -4193,6 +4222,7 @@ var permissionModeSchema = z18.enum([
|
|
|
4193
4222
|
var codexUsageSchema = z18.object({
|
|
4194
4223
|
input_tokens: z18.number().int().min(0).optional(),
|
|
4195
4224
|
cached_input_tokens: z18.number().int().min(0).optional(),
|
|
4225
|
+
cache_write_input_tokens: z18.number().int().min(0).optional(),
|
|
4196
4226
|
output_tokens: z18.number().int().min(0).optional(),
|
|
4197
4227
|
reasoning_output_tokens: z18.number().int().min(0).optional(),
|
|
4198
4228
|
total_tokens: z18.number().int().min(0).optional()
|
|
@@ -4448,6 +4478,10 @@ var codexUsageToReport = (usage, temporality) => ({
|
|
|
4448
4478
|
temporality,
|
|
4449
4479
|
...usage.input_tokens === void 0 ? {} : { inputTokens: usage.input_tokens },
|
|
4450
4480
|
...usage.cached_input_tokens === void 0 ? {} : { cachedInputTokens: usage.cached_input_tokens },
|
|
4481
|
+
...usage.cache_write_input_tokens === void 0 ? {} : {
|
|
4482
|
+
cacheCreationInputTokens: usage.cache_write_input_tokens,
|
|
4483
|
+
cacheCreationAccounting: "included-in-input"
|
|
4484
|
+
},
|
|
4451
4485
|
...usage.output_tokens === void 0 ? {} : { outputTokens: usage.output_tokens },
|
|
4452
4486
|
...usage.reasoning_output_tokens === void 0 ? {} : { reasoningOutputTokens: usage.reasoning_output_tokens },
|
|
4453
4487
|
...usage.total_tokens === void 0 ? {} : { providerTotalTokens: usage.total_tokens }
|
|
@@ -4476,8 +4510,9 @@ var CODEX_CAPABILITIES = Object.freeze({
|
|
|
4476
4510
|
// turn; see docs/usage-semantics.md.
|
|
4477
4511
|
cumulativeUsageSeries: "session-lifetime",
|
|
4478
4512
|
reportsCachedInput: true,
|
|
4479
|
-
|
|
4480
|
-
|
|
4513
|
+
// Codex 0.163+ reports `cache_write_input_tokens`, a subset of `input_tokens`.
|
|
4514
|
+
reportsCacheCreation: true,
|
|
4515
|
+
cacheCreationAccounting: "included-in-input",
|
|
4481
4516
|
reportsReasoningOutput: true,
|
|
4482
4517
|
reportsProviderTotal: true,
|
|
4483
4518
|
reportsCost: false,
|
|
@@ -4836,6 +4871,11 @@ var createCodexAdapter = () => ({
|
|
|
4836
4871
|
hookResponse
|
|
4837
4872
|
});
|
|
4838
4873
|
|
|
4874
|
+
// src/providers/codex/rollout-usage.ts
|
|
4875
|
+
import { createHash as createHash3 } from "crypto";
|
|
4876
|
+
import { open as open2, readdir, stat as stat2 } from "fs/promises";
|
|
4877
|
+
import path2 from "path";
|
|
4878
|
+
|
|
4839
4879
|
// src/providers/gemini/delivery.ts
|
|
4840
4880
|
var GEMINI_UNIDENTIFIABLE_CALLBACKS = Object.freeze({
|
|
4841
4881
|
SessionStart: "fires again within the same session_id on resume and clear (payload `source`), so session_id names a class of firings rather than one",
|
|
@@ -5860,9 +5900,9 @@ var resolveDeliveryIdentity = (input) => {
|
|
|
5860
5900
|
};
|
|
5861
5901
|
|
|
5862
5902
|
// src/runtime/ids.ts
|
|
5863
|
-
import { createHash as
|
|
5903
|
+
import { createHash as createHash4, randomUUID } from "crypto";
|
|
5864
5904
|
var digest = (namespace, parts) => {
|
|
5865
|
-
const hash =
|
|
5905
|
+
const hash = createHash4("sha256");
|
|
5866
5906
|
hash.update(namespace);
|
|
5867
5907
|
for (const part of parts) {
|
|
5868
5908
|
hash.update("\0");
|
|
@@ -5994,16 +6034,16 @@ var createNullLogger = () => ({
|
|
|
5994
6034
|
});
|
|
5995
6035
|
|
|
5996
6036
|
// src/runtime/target-resolution.ts
|
|
5997
|
-
import * as
|
|
6037
|
+
import * as path3 from "path";
|
|
5998
6038
|
var DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS = 50;
|
|
5999
6039
|
var absolutePathsOf = (hint) => {
|
|
6000
|
-
const base = hint.baseDirectory !== void 0 &&
|
|
6040
|
+
const base = hint.baseDirectory !== void 0 && path3.isAbsolute(hint.baseDirectory) ? hint.baseDirectory : void 0;
|
|
6001
6041
|
const resolved = [];
|
|
6002
6042
|
for (const candidate of hint.paths) {
|
|
6003
|
-
if (
|
|
6004
|
-
resolved.push(
|
|
6043
|
+
if (path3.isAbsolute(candidate)) {
|
|
6044
|
+
resolved.push(path3.resolve(candidate));
|
|
6005
6045
|
} else if (base !== void 0) {
|
|
6006
|
-
resolved.push(
|
|
6046
|
+
resolved.push(path3.resolve(base, candidate));
|
|
6007
6047
|
} else {
|
|
6008
6048
|
return void 0;
|
|
6009
6049
|
}
|
|
@@ -6110,8 +6150,8 @@ var withOptionalSessionLock = async (store, sessionId, fn, options) => {
|
|
|
6110
6150
|
};
|
|
6111
6151
|
|
|
6112
6152
|
// src/runtime/session-context.ts
|
|
6113
|
-
import { open as
|
|
6114
|
-
import * as
|
|
6153
|
+
import { open as open3 } from "fs/promises";
|
|
6154
|
+
import * as path4 from "path";
|
|
6115
6155
|
import { z as z22 } from "zod";
|
|
6116
6156
|
var SESSION_CONTEXT_FILE_VERSION = 1;
|
|
6117
6157
|
var DEFAULT_SESSION_CONTEXT_MAX_BYTES = 256 * 1024;
|