@osfactory/otel-hook 0.13.1 → 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/dist/testing.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { O as OtelHookConfig, i as OtelHookConfigPatch } from './schema-SpFM6YQY.js';
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-BKQhhIO3.js';
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-D5imE0Qc.js';
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, path4) => {
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[path4] = primitive;
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[path4] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
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, `${path4}.${index}`);
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, path4 === "" ? key : `${path4}.${key}`);
978
+ walk(entry, path5 === "" ? key : `${path5}.${key}`);
959
979
  }
960
980
  };
961
981
  walk(value, prefix);
@@ -4202,6 +4222,7 @@ var permissionModeSchema = z18.enum([
4202
4222
  var codexUsageSchema = z18.object({
4203
4223
  input_tokens: z18.number().int().min(0).optional(),
4204
4224
  cached_input_tokens: z18.number().int().min(0).optional(),
4225
+ cache_write_input_tokens: z18.number().int().min(0).optional(),
4205
4226
  output_tokens: z18.number().int().min(0).optional(),
4206
4227
  reasoning_output_tokens: z18.number().int().min(0).optional(),
4207
4228
  total_tokens: z18.number().int().min(0).optional()
@@ -4457,6 +4478,10 @@ var codexUsageToReport = (usage, temporality) => ({
4457
4478
  temporality,
4458
4479
  ...usage.input_tokens === void 0 ? {} : { inputTokens: usage.input_tokens },
4459
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
+ },
4460
4485
  ...usage.output_tokens === void 0 ? {} : { outputTokens: usage.output_tokens },
4461
4486
  ...usage.reasoning_output_tokens === void 0 ? {} : { reasoningOutputTokens: usage.reasoning_output_tokens },
4462
4487
  ...usage.total_tokens === void 0 ? {} : { providerTotalTokens: usage.total_tokens }
@@ -4485,8 +4510,9 @@ var CODEX_CAPABILITIES = Object.freeze({
4485
4510
  // turn; see docs/usage-semantics.md.
4486
4511
  cumulativeUsageSeries: "session-lifetime",
4487
4512
  reportsCachedInput: true,
4488
- reportsCacheCreation: false,
4489
- cacheCreationAccounting: "not-reported",
4513
+ // Codex 0.163+ reports `cache_write_input_tokens`, a subset of `input_tokens`.
4514
+ reportsCacheCreation: true,
4515
+ cacheCreationAccounting: "included-in-input",
4490
4516
  reportsReasoningOutput: true,
4491
4517
  reportsProviderTotal: true,
4492
4518
  reportsCost: false,
@@ -4845,6 +4871,11 @@ var createCodexAdapter = () => ({
4845
4871
  hookResponse
4846
4872
  });
4847
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
+
4848
4879
  // src/providers/gemini/delivery.ts
4849
4880
  var GEMINI_UNIDENTIFIABLE_CALLBACKS = Object.freeze({
4850
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",
@@ -5869,9 +5900,9 @@ var resolveDeliveryIdentity = (input) => {
5869
5900
  };
5870
5901
 
5871
5902
  // src/runtime/ids.ts
5872
- import { createHash as createHash3, randomUUID } from "crypto";
5903
+ import { createHash as createHash4, randomUUID } from "crypto";
5873
5904
  var digest = (namespace, parts) => {
5874
- const hash = createHash3("sha256");
5905
+ const hash = createHash4("sha256");
5875
5906
  hash.update(namespace);
5876
5907
  for (const part of parts) {
5877
5908
  hash.update("\0");
@@ -6003,16 +6034,16 @@ var createNullLogger = () => ({
6003
6034
  });
6004
6035
 
6005
6036
  // src/runtime/target-resolution.ts
6006
- import * as path2 from "path";
6037
+ import * as path3 from "path";
6007
6038
  var DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS = 50;
6008
6039
  var absolutePathsOf = (hint) => {
6009
- const base = hint.baseDirectory !== void 0 && path2.isAbsolute(hint.baseDirectory) ? hint.baseDirectory : void 0;
6040
+ const base = hint.baseDirectory !== void 0 && path3.isAbsolute(hint.baseDirectory) ? hint.baseDirectory : void 0;
6010
6041
  const resolved = [];
6011
6042
  for (const candidate of hint.paths) {
6012
- if (path2.isAbsolute(candidate)) {
6013
- resolved.push(path2.resolve(candidate));
6043
+ if (path3.isAbsolute(candidate)) {
6044
+ resolved.push(path3.resolve(candidate));
6014
6045
  } else if (base !== void 0) {
6015
- resolved.push(path2.resolve(base, candidate));
6046
+ resolved.push(path3.resolve(base, candidate));
6016
6047
  } else {
6017
6048
  return void 0;
6018
6049
  }
@@ -6119,8 +6150,8 @@ var withOptionalSessionLock = async (store, sessionId, fn, options) => {
6119
6150
  };
6120
6151
 
6121
6152
  // src/runtime/session-context.ts
6122
- import { open as open2 } from "fs/promises";
6123
- import * as path3 from "path";
6153
+ import { open as open3 } from "fs/promises";
6154
+ import * as path4 from "path";
6124
6155
  import { z as z22 } from "zod";
6125
6156
  var SESSION_CONTEXT_FILE_VERSION = 1;
6126
6157
  var DEFAULT_SESSION_CONTEXT_MAX_BYTES = 256 * 1024;