@osfactory/har 1.4.0 → 1.5.0

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.
Files changed (2) hide show
  1. package/dist/index.js +48 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -59049,10 +59049,12 @@ var require_run_async = __commonJS({
59049
59049
  // src/core/otel-hooks.ts
59050
59050
  var otel_hooks_exports = {};
59051
59051
  __export(otel_hooks_exports, {
59052
+ HOOK_TIMEOUT_SECONDS: () => HOOK_TIMEOUT_SECONDS,
59052
59053
  LEGACY_CURSOR_ONLY_HOOK_EVENTS: () => LEGACY_CURSOR_ONLY_HOOK_EVENTS,
59053
59054
  OTEL_HOOKS_AGENTS: () => OTEL_HOOKS_AGENTS,
59054
59055
  OTEL_HOOKS_PACKAGE: () => OTEL_HOOKS_PACKAGE,
59055
59056
  OTEL_HOOKS_PROVIDERS: () => OTEL_HOOKS_PROVIDERS,
59057
+ buildOtelHookSetupArgs: () => buildOtelHookSetupArgs,
59056
59058
  buildOtelHooksConfig: () => buildOtelHooksConfig,
59057
59059
  disableOtelHooksExport: () => disableOtelHooksExport,
59058
59060
  ensureOtelHooks: () => ensureOtelHooks,
@@ -59158,11 +59160,22 @@ function writeOtelHooksWrapper(otelHookCommand, hooksHome = getOtelHooksHome())
59158
59160
  const stateDir = getOtelHooksStateDir(hooksHome);
59159
59161
  const script = `#!/usr/bin/env bash
59160
59162
  # Managed by har telemetry \u2014 invokes @osfactory/otel-hook with HAR config.
59161
- set -euo pipefail
59162
- exec "${otelHookCommand}" run \\
59163
+ #
59164
+ # Two rules for this wrapper (#328):
59165
+ # 1. Bounded. Export and flush budgets keep it well inside the per-hook
59166
+ # timeout the agent enforces, so an unreachable Mission Control costs
59167
+ # milliseconds instead of stalling the session.
59168
+ # 2. Silent about its own failures. Dropped telemetry must never fail an
59169
+ # agent turn, so the exit status is always 0 \u2014 a non-zero hook exit can
59170
+ # block a tool call.
59171
+ set -uo pipefail
59172
+ "${otelHookCommand}" run \\
59163
59173
  --config-file "${configPath}" \\
59164
59174
  --state-dir "${stateDir}" \\
59165
- "$@"
59175
+ --timeout-ms ${HOOK_EXPORT_TIMEOUT_MS} \\
59176
+ --flush-timeout-ms ${HOOK_FLUSH_TIMEOUT_MS} \\
59177
+ "$@" || true
59178
+ exit 0
59166
59179
  `;
59167
59180
  fs68.writeFileSync(wrapperPath, script, { mode: 493 });
59168
59181
  try {
@@ -59255,23 +59268,30 @@ function isOtelHookCommand(command2, wrapperPath) {
59255
59268
  function normalizeLegacyProviderFlagsInCommand(command2) {
59256
59269
  return command2.replace(/(^|\s)--cursor(?=\s|$)/g, "$1--provider cursor").replace(/(^|\s)--claude(?=\s|$)/g, "$1--provider claude-code").replace(/(^|\s)--codex(?=\s|$)/g, "$1--provider codex");
59257
59270
  }
59271
+ function buildOtelHookSetupArgs(providerId, hookCommand) {
59272
+ return [
59273
+ "setup",
59274
+ "--provider",
59275
+ providerId,
59276
+ "--scope",
59277
+ "global",
59278
+ "--hook-command",
59279
+ hookCommand,
59280
+ "--managed-marker",
59281
+ "otel-hook",
59282
+ // Written into each generated hook entry so the agent bounds it (#328).
59283
+ // Without this the agent falls back to its own default and an unreachable
59284
+ // collector stalls the session before its first model request.
59285
+ "--timeout-seconds",
59286
+ String(HOOK_TIMEOUT_SECONDS)
59287
+ ];
59288
+ }
59258
59289
  function runSetupProvider(providerId, otelHookCommand, wrapperPath) {
59259
59290
  const hookCommand = `${wrapperPath} --provider ${providerId}`;
59260
- const result = (0, import_child_process19.spawnSync)(
59261
- otelHookCommand,
59262
- [
59263
- "setup",
59264
- "--provider",
59265
- providerId,
59266
- "--scope",
59267
- "global",
59268
- "--hook-command",
59269
- hookCommand,
59270
- "--managed-marker",
59271
- "otel-hook"
59272
- ],
59273
- { encoding: "utf8", timeout: 6e4 }
59274
- );
59291
+ const result = (0, import_child_process19.spawnSync)(otelHookCommand, buildOtelHookSetupArgs(providerId, hookCommand), {
59292
+ encoding: "utf8",
59293
+ timeout: 6e4
59294
+ });
59275
59295
  if (result.status === 0) {
59276
59296
  return { ok: true, detail: `setup --provider ${providerId}` };
59277
59297
  }
@@ -59498,7 +59518,7 @@ function ensureOtelHooks(options) {
59498
59518
  function disableOtelHooksExport() {
59499
59519
  return writeOtelHooksConfig(buildOtelHooksConfig({ enabled: false }));
59500
59520
  }
59501
- var import_child_process19, fs68, os22, path76, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_PROVIDERS, OTEL_HOOKS_AGENTS, LEGACY_CURSOR_ONLY_HOOK_EVENTS;
59521
+ var import_child_process19, fs68, os22, path76, OTEL_HOOKS_PACKAGE, HOOK_TIMEOUT_SECONDS, HOOK_EXPORT_TIMEOUT_MS, HOOK_FLUSH_TIMEOUT_MS, OTEL_HOOKS_PROVIDERS, OTEL_HOOKS_AGENTS, LEGACY_CURSOR_ONLY_HOOK_EVENTS;
59502
59522
  var init_otel_hooks = __esm({
59503
59523
  "src/core/otel-hooks.ts"() {
59504
59524
  "use strict";
@@ -59509,6 +59529,9 @@ var init_otel_hooks = __esm({
59509
59529
  init_control_config();
59510
59530
  init_telemetry_config();
59511
59531
  OTEL_HOOKS_PACKAGE = "@osfactory/otel-hook@0.2.0";
59532
+ HOOK_TIMEOUT_SECONDS = 10;
59533
+ HOOK_EXPORT_TIMEOUT_MS = 1500;
59534
+ HOOK_FLUSH_TIMEOUT_MS = 500;
59512
59535
  OTEL_HOOKS_PROVIDERS = [
59513
59536
  { id: "cursor", label: "cursor" },
59514
59537
  { id: "claude-code", label: "claude" },
@@ -92517,6 +92540,12 @@ async function handleStatus3(argv) {
92517
92540
  info(`Mission Control: ${apiUrl} (${reachable ? "reachable" : "not reachable"})`);
92518
92541
  info(`OTLP endpoint: ${payload.otelEndpoint}`);
92519
92542
  info(`Hooks home: ${payload.otelHooksHome}`);
92543
+ if (enabled && !reachable) {
92544
+ warn(
92545
+ "Agent hooks are installed but Mission Control is not reachable \u2014 each turn pays the export timeout for telemetry nobody receives."
92546
+ );
92547
+ info("Start it with: har control up \u2022 or stop exporting: har telemetry off");
92548
+ }
92520
92549
  printSignals();
92521
92550
  }
92522
92551
  async function handleOn(argv) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osfactory/har",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "HAR: open agent harness CLI and MCP server for coding agents, isolated worktrees, and software-factory workflows",
5
5
  "keywords": [
6
6
  "har",