@osfactory/har 0.28.0 → 0.30.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.
- package/dist/index.js +213 -95
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -132,10 +132,10 @@ var init_telemetry_config = __esm({
|
|
|
132
132
|
traces: false
|
|
133
133
|
};
|
|
134
134
|
TELEMETRY_SIGNALS = [
|
|
135
|
-
"Traces (default): Cursor / Claude / Codex activity via
|
|
135
|
+
"Traces (default): Cursor / Claude / Codex activity via @osfactory/otel-hook \u2192 Mission Control",
|
|
136
136
|
"Logs/events (default): hook lifecycle logs without prompt bodies",
|
|
137
137
|
"Metrics (default): token usage derived from span gen_ai.usage.* attributes",
|
|
138
|
-
"Prompts (default): user prompt text via
|
|
138
|
+
"Prompts (default): user prompt text via otel-hook contentMode=raw (also fills Mission Control purpose); disable with har telemetry on --no-prompts",
|
|
139
139
|
"Fallback: har control sync harvests local Claude/Codex session files when hooks telemetry is missing"
|
|
140
140
|
];
|
|
141
141
|
}
|
|
@@ -6623,12 +6623,15 @@ var otel_hooks_exports = {};
|
|
|
6623
6623
|
__export(otel_hooks_exports, {
|
|
6624
6624
|
OTEL_HOOKS_AGENTS: () => OTEL_HOOKS_AGENTS,
|
|
6625
6625
|
OTEL_HOOKS_PACKAGE: () => OTEL_HOOKS_PACKAGE,
|
|
6626
|
+
OTEL_HOOKS_PROVIDERS: () => OTEL_HOOKS_PROVIDERS,
|
|
6626
6627
|
buildOtelHooksConfig: () => buildOtelHooksConfig,
|
|
6627
6628
|
disableOtelHooksExport: () => disableOtelHooksExport,
|
|
6628
6629
|
ensureOtelHooks: () => ensureOtelHooks,
|
|
6629
6630
|
getOtelHooksConfigPath: () => getOtelHooksConfigPath,
|
|
6630
6631
|
getOtelHooksHome: () => getOtelHooksHome,
|
|
6632
|
+
getOtelHooksStateDir: () => getOtelHooksStateDir,
|
|
6631
6633
|
getOtelHooksWrapperPath: () => getOtelHooksWrapperPath,
|
|
6634
|
+
parseResourceAttributesString: () => parseResourceAttributesString,
|
|
6632
6635
|
rewriteHookCommandsToWrapper: () => rewriteHookCommandsToWrapper,
|
|
6633
6636
|
writeOtelHooksConfig: () => writeOtelHooksConfig,
|
|
6634
6637
|
writeOtelHooksWrapper: () => writeOtelHooksWrapper
|
|
@@ -6645,20 +6648,69 @@ function getOtelHooksConfigPath(hooksHome = getOtelHooksHome()) {
|
|
|
6645
6648
|
function getOtelHooksWrapperPath(hooksHome = getOtelHooksHome()) {
|
|
6646
6649
|
return path45.join(hooksHome, "run-otel-hook.sh");
|
|
6647
6650
|
}
|
|
6651
|
+
function getOtelHooksStateDir(hooksHome = getOtelHooksHome()) {
|
|
6652
|
+
return path45.join(hooksHome, "state");
|
|
6653
|
+
}
|
|
6654
|
+
function localOtelHookBin(hooksHome) {
|
|
6655
|
+
return path45.join(hooksHome, "node_modules", ".bin", "otel-hook");
|
|
6656
|
+
}
|
|
6657
|
+
function installedPackageVersion(hooksHome) {
|
|
6658
|
+
try {
|
|
6659
|
+
const pkgPath = path45.join(
|
|
6660
|
+
hooksHome,
|
|
6661
|
+
"node_modules",
|
|
6662
|
+
"@osfactory",
|
|
6663
|
+
"otel-hook",
|
|
6664
|
+
"package.json"
|
|
6665
|
+
);
|
|
6666
|
+
const pkg = JSON.parse(fs42.readFileSync(pkgPath, "utf8"));
|
|
6667
|
+
return typeof pkg.version === "string" ? pkg.version : null;
|
|
6668
|
+
} catch {
|
|
6669
|
+
return null;
|
|
6670
|
+
}
|
|
6671
|
+
}
|
|
6672
|
+
function pinnedVersion() {
|
|
6673
|
+
const at2 = OTEL_HOOKS_PACKAGE.lastIndexOf("@");
|
|
6674
|
+
return at2 > 0 ? OTEL_HOOKS_PACKAGE.slice(at2 + 1) : OTEL_HOOKS_PACKAGE;
|
|
6675
|
+
}
|
|
6676
|
+
function parseResourceAttributesString(raw) {
|
|
6677
|
+
if (!raw?.trim()) return {};
|
|
6678
|
+
const out = {};
|
|
6679
|
+
for (const part of raw.split(",")) {
|
|
6680
|
+
const trimmed = part.trim();
|
|
6681
|
+
if (!trimmed) continue;
|
|
6682
|
+
const eq = trimmed.indexOf("=");
|
|
6683
|
+
if (eq <= 0) continue;
|
|
6684
|
+
const key = trimmed.slice(0, eq).trim();
|
|
6685
|
+
const value = trimmed.slice(eq + 1).trim();
|
|
6686
|
+
if (!key || key === "service.name" || key === "service.namespace") continue;
|
|
6687
|
+
out[key] = value;
|
|
6688
|
+
}
|
|
6689
|
+
return out;
|
|
6690
|
+
}
|
|
6648
6691
|
function buildOtelHooksConfig(options) {
|
|
6649
6692
|
const enabled = options?.enabled ?? isTelemetryEnabled();
|
|
6650
6693
|
const signals2 = getTelemetrySignals();
|
|
6651
6694
|
const apiUrl = (options?.apiUrl ?? getControlApiUrl()).replace(/\/$/, "");
|
|
6695
|
+
const resourceAttributes = parseResourceAttributesString(options?.resourceAttributes);
|
|
6696
|
+
const capturePrompts = enabled && signals2.prompts;
|
|
6652
6697
|
return {
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6698
|
+
exporter: {
|
|
6699
|
+
enabled,
|
|
6700
|
+
...enabled ? { endpoint: `${apiUrl}/api/otel/v1/traces` } : {},
|
|
6701
|
+
protocol: "http/protobuf",
|
|
6702
|
+
serviceName: "har-ide-agent",
|
|
6703
|
+
...Object.keys(resourceAttributes).length > 0 ? { resourceAttributes } : {},
|
|
6704
|
+
logs: {
|
|
6705
|
+
enabled: enabled && signals2.logs,
|
|
6706
|
+
...enabled && signals2.logs ? { endpoint: `${apiUrl}/api/otel/v1/logs` } : {},
|
|
6707
|
+
includeContent: capturePrompts
|
|
6708
|
+
}
|
|
6709
|
+
},
|
|
6710
|
+
privacy: {
|
|
6711
|
+
contentMode: capturePrompts ? "raw" : "omit",
|
|
6712
|
+
allowRawContent: capturePrompts
|
|
6713
|
+
}
|
|
6662
6714
|
};
|
|
6663
6715
|
}
|
|
6664
6716
|
function writeOtelHooksConfig(config2, hooksHome = getOtelHooksHome()) {
|
|
@@ -6674,12 +6726,17 @@ function writeOtelHooksConfig(config2, hooksHome = getOtelHooksHome()) {
|
|
|
6674
6726
|
}
|
|
6675
6727
|
function writeOtelHooksWrapper(otelHookCommand, hooksHome = getOtelHooksHome()) {
|
|
6676
6728
|
fs42.mkdirSync(hooksHome, { recursive: true });
|
|
6729
|
+
fs42.mkdirSync(getOtelHooksStateDir(hooksHome), { recursive: true });
|
|
6677
6730
|
const wrapperPath = getOtelHooksWrapperPath(hooksHome);
|
|
6731
|
+
const configPath = getOtelHooksConfigPath(hooksHome);
|
|
6732
|
+
const stateDir = getOtelHooksStateDir(hooksHome);
|
|
6678
6733
|
const script = `#!/usr/bin/env bash
|
|
6679
|
-
# Managed by har telemetry \u2014 invokes
|
|
6734
|
+
# Managed by har telemetry \u2014 invokes @osfactory/otel-hook with HAR config.
|
|
6680
6735
|
set -euo pipefail
|
|
6681
|
-
|
|
6682
|
-
|
|
6736
|
+
exec "${otelHookCommand}" run \\
|
|
6737
|
+
--config-file "${configPath}" \\
|
|
6738
|
+
--state-dir "${stateDir}" \\
|
|
6739
|
+
"$@"
|
|
6683
6740
|
`;
|
|
6684
6741
|
fs42.writeFileSync(wrapperPath, script, { mode: 493 });
|
|
6685
6742
|
try {
|
|
@@ -6694,72 +6751,68 @@ function commandExists2(command2) {
|
|
|
6694
6751
|
});
|
|
6695
6752
|
return result.status === 0 && Boolean(result.stdout?.trim());
|
|
6696
6753
|
}
|
|
6697
|
-
function resolveOtelHookCommand() {
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
return which.stdout?.trim() || "otel-hook";
|
|
6701
|
-
}
|
|
6754
|
+
function resolveOtelHookCommand(hooksHome) {
|
|
6755
|
+
const local = localOtelHookBin(hooksHome);
|
|
6756
|
+
if (fs42.existsSync(local)) return local;
|
|
6702
6757
|
return null;
|
|
6703
6758
|
}
|
|
6704
|
-
function tryInstallPackage() {
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
"uv",
|
|
6708
|
-
["tool", "install", "--force", OTEL_HOOKS_PACKAGE],
|
|
6709
|
-
{ encoding: "utf8", timeout: 18e4 }
|
|
6710
|
-
);
|
|
6711
|
-
if (result.status === 0) {
|
|
6712
|
-
return { ok: true, detail: `uv tool install ${OTEL_HOOKS_PACKAGE}` };
|
|
6713
|
-
}
|
|
6714
|
-
}
|
|
6715
|
-
if (commandExists2("pipx")) {
|
|
6716
|
-
const result = (0, import_child_process10.spawnSync)("pipx", ["install", "--force", OTEL_HOOKS_PACKAGE], {
|
|
6717
|
-
encoding: "utf8",
|
|
6718
|
-
timeout: 18e4
|
|
6719
|
-
});
|
|
6720
|
-
if (result.status === 0) {
|
|
6721
|
-
return { ok: true, detail: `pipx install ${OTEL_HOOKS_PACKAGE}` };
|
|
6722
|
-
}
|
|
6759
|
+
function tryInstallPackage(hooksHome) {
|
|
6760
|
+
fs42.mkdirSync(hooksHome, { recursive: true });
|
|
6761
|
+
if (!commandExists2("npm")) {
|
|
6723
6762
|
return {
|
|
6724
6763
|
ok: false,
|
|
6725
|
-
detail:
|
|
6764
|
+
detail: "npm not found; install Node.js to use @osfactory/otel-hook"
|
|
6726
6765
|
};
|
|
6727
6766
|
}
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
if (result.status === 0) {
|
|
6736
|
-
return { ok: true, detail: `${pip} install --user ${OTEL_HOOKS_PACKAGE}` };
|
|
6737
|
-
}
|
|
6738
|
-
return {
|
|
6739
|
-
ok: false,
|
|
6740
|
-
detail: `${pip} install failed: ${(result.stderr || result.stdout || "").trim().slice(0, 400)}`
|
|
6741
|
-
};
|
|
6767
|
+
const result = (0, import_child_process10.spawnSync)(
|
|
6768
|
+
"npm",
|
|
6769
|
+
["install", "--prefix", hooksHome, "--no-fund", "--no-audit", OTEL_HOOKS_PACKAGE],
|
|
6770
|
+
{ encoding: "utf8", timeout: 18e4 }
|
|
6771
|
+
);
|
|
6772
|
+
if (result.status === 0 && fs42.existsSync(localOtelHookBin(hooksHome))) {
|
|
6773
|
+
return { ok: true, detail: `npm install --prefix ${hooksHome} ${OTEL_HOOKS_PACKAGE}` };
|
|
6742
6774
|
}
|
|
6743
6775
|
return {
|
|
6744
6776
|
ok: false,
|
|
6745
|
-
detail:
|
|
6777
|
+
detail: `npm install ${OTEL_HOOKS_PACKAGE} failed: ${(result.stderr || result.stdout || "").trim().slice(0, 400)}`
|
|
6746
6778
|
};
|
|
6747
6779
|
}
|
|
6748
|
-
function
|
|
6749
|
-
const
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6780
|
+
function uninstallLegacyPythonHooks() {
|
|
6781
|
+
const attempts = [
|
|
6782
|
+
["uv", ["tool", "uninstall", "opentelemetry-hooks"]],
|
|
6783
|
+
["pipx", ["uninstall", "opentelemetry-hooks"]]
|
|
6784
|
+
];
|
|
6785
|
+
for (const [cmd, args] of attempts) {
|
|
6786
|
+
if (!commandExists2(cmd)) continue;
|
|
6787
|
+
try {
|
|
6788
|
+
(0, import_child_process10.spawnSync)(cmd, args, { encoding: "utf8", timeout: 6e4 });
|
|
6789
|
+
} catch {
|
|
6790
|
+
}
|
|
6791
|
+
}
|
|
6792
|
+
}
|
|
6793
|
+
function runSetupProvider(providerId, otelHookCommand, wrapperPath) {
|
|
6794
|
+
const hookCommand = `${wrapperPath} --provider ${providerId}`;
|
|
6795
|
+
const result = (0, import_child_process10.spawnSync)(
|
|
6796
|
+
otelHookCommand,
|
|
6797
|
+
[
|
|
6798
|
+
"setup",
|
|
6799
|
+
"--provider",
|
|
6800
|
+
providerId,
|
|
6801
|
+
"--scope",
|
|
6802
|
+
"global",
|
|
6803
|
+
"--hook-command",
|
|
6804
|
+
hookCommand,
|
|
6805
|
+
"--managed-marker",
|
|
6806
|
+
"otel-hook"
|
|
6807
|
+
],
|
|
6808
|
+
{ encoding: "utf8", timeout: 6e4 }
|
|
6809
|
+
);
|
|
6757
6810
|
if (result.status === 0) {
|
|
6758
|
-
return { ok: true, detail: `setup --
|
|
6811
|
+
return { ok: true, detail: `setup --provider ${providerId}` };
|
|
6759
6812
|
}
|
|
6760
6813
|
return {
|
|
6761
6814
|
ok: false,
|
|
6762
|
-
detail: `setup --
|
|
6815
|
+
detail: `setup --provider ${providerId} failed: ${(result.stderr || result.stdout || "").trim().slice(0, 400)}`
|
|
6763
6816
|
};
|
|
6764
6817
|
}
|
|
6765
6818
|
function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
|
|
@@ -6777,14 +6830,19 @@ function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
|
|
|
6777
6830
|
return false;
|
|
6778
6831
|
}
|
|
6779
6832
|
if (!parsed || typeof parsed !== "object") return false;
|
|
6780
|
-
const quoted = JSON.stringify(wrapperPath);
|
|
6781
6833
|
const rewriteCommand = (command2) => {
|
|
6782
|
-
if (!command2.includes("otel-hook") && !command2.includes("otel_hook.py")
|
|
6834
|
+
if (!command2.includes("otel-hook") && !command2.includes("otel_hook.py") && !command2.includes("opentelemetry-hooks")) {
|
|
6835
|
+
return command2;
|
|
6836
|
+
}
|
|
6783
6837
|
if (command2.includes(wrapperPath)) return command2;
|
|
6784
|
-
|
|
6785
|
-
/(?:^|[;&|]\s*)(?:env\s+[^=\s]+=\S+\s+)*(?:python3?\s+)?(?:\S*otel[_-]hook\S*)/,
|
|
6786
|
-
(match) => match.replace(
|
|
6838
|
+
const rewritten = command2.replace(
|
|
6839
|
+
/(?:^|[;&|]\s*)(?:env\s+[^=\s]+=\S+\s+)*(?:python3?\s+)?(?:npx\s+)?(?:\S*otel[_-]hook\S*|\S*opentelemetry-hooks\S*)/,
|
|
6840
|
+
(match) => match.replace(
|
|
6841
|
+
/(?:python3?\s+)?(?:npx\s+)?(?:\S*otel[_-]hook\S*|\S*opentelemetry-hooks\S*)/,
|
|
6842
|
+
wrapperPath
|
|
6843
|
+
)
|
|
6787
6844
|
);
|
|
6845
|
+
return rewritten.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");
|
|
6788
6846
|
};
|
|
6789
6847
|
const walk = (node) => {
|
|
6790
6848
|
let changed = false;
|
|
@@ -6823,14 +6881,20 @@ function rewriteKnownHookRegistrations(wrapperPath) {
|
|
|
6823
6881
|
}
|
|
6824
6882
|
}
|
|
6825
6883
|
}
|
|
6884
|
+
function providerLabel(id) {
|
|
6885
|
+
if (id === "claude-code") return "claude";
|
|
6886
|
+
if (id === "cursor") return "cursor";
|
|
6887
|
+
return "codex";
|
|
6888
|
+
}
|
|
6826
6889
|
function ensureOtelHooks(options) {
|
|
6827
6890
|
const hooksHome = getOtelHooksHome();
|
|
6828
6891
|
const errors = [];
|
|
6829
|
-
const
|
|
6892
|
+
const providersSetup = [];
|
|
6830
6893
|
fs42.mkdirSync(hooksHome, { recursive: true });
|
|
6831
|
-
let otelHookCommand = resolveOtelHookCommand();
|
|
6832
|
-
|
|
6833
|
-
|
|
6894
|
+
let otelHookCommand = resolveOtelHookCommand(hooksHome);
|
|
6895
|
+
const needsInstall = !otelHookCommand || installedPackageVersion(hooksHome) !== pinnedVersion();
|
|
6896
|
+
if (needsInstall) {
|
|
6897
|
+
const installed = tryInstallPackage(hooksHome);
|
|
6834
6898
|
if (!installed.ok) {
|
|
6835
6899
|
errors.push(installed.detail);
|
|
6836
6900
|
const configPath2 = writeOtelHooksConfig(
|
|
@@ -6844,13 +6908,14 @@ function ensureOtelHooks(options) {
|
|
|
6844
6908
|
wrapperPath: getOtelHooksWrapperPath(hooksHome),
|
|
6845
6909
|
otelHookCommand: null,
|
|
6846
6910
|
warning: installed.detail,
|
|
6847
|
-
agentsSetup,
|
|
6911
|
+
agentsSetup: [],
|
|
6912
|
+
providersSetup,
|
|
6848
6913
|
errors
|
|
6849
6914
|
};
|
|
6850
6915
|
}
|
|
6851
|
-
otelHookCommand = resolveOtelHookCommand();
|
|
6916
|
+
otelHookCommand = resolveOtelHookCommand(hooksHome);
|
|
6852
6917
|
if (!otelHookCommand) {
|
|
6853
|
-
errors.push("
|
|
6918
|
+
errors.push("@osfactory/otel-hook installed but otel-hook binary is missing");
|
|
6854
6919
|
const configPath2 = writeOtelHooksConfig(
|
|
6855
6920
|
buildOtelHooksConfig({ resourceAttributes: options?.resourceAttributes }),
|
|
6856
6921
|
hooksHome
|
|
@@ -6862,41 +6927,64 @@ function ensureOtelHooks(options) {
|
|
|
6862
6927
|
wrapperPath: getOtelHooksWrapperPath(hooksHome),
|
|
6863
6928
|
otelHookCommand: null,
|
|
6864
6929
|
warning: errors[errors.length - 1],
|
|
6865
|
-
agentsSetup,
|
|
6930
|
+
agentsSetup: [],
|
|
6931
|
+
providersSetup,
|
|
6866
6932
|
errors
|
|
6867
6933
|
};
|
|
6868
6934
|
}
|
|
6869
6935
|
}
|
|
6936
|
+
const resolvedCommand = otelHookCommand;
|
|
6937
|
+
if (!resolvedCommand) {
|
|
6938
|
+
errors.push("@osfactory/otel-hook binary is missing");
|
|
6939
|
+
const configPath2 = writeOtelHooksConfig(
|
|
6940
|
+
buildOtelHooksConfig({ resourceAttributes: options?.resourceAttributes }),
|
|
6941
|
+
hooksHome
|
|
6942
|
+
);
|
|
6943
|
+
return {
|
|
6944
|
+
ok: false,
|
|
6945
|
+
hooksHome,
|
|
6946
|
+
configPath: configPath2,
|
|
6947
|
+
wrapperPath: getOtelHooksWrapperPath(hooksHome),
|
|
6948
|
+
otelHookCommand: null,
|
|
6949
|
+
warning: errors[errors.length - 1],
|
|
6950
|
+
agentsSetup: [],
|
|
6951
|
+
providersSetup,
|
|
6952
|
+
errors
|
|
6953
|
+
};
|
|
6954
|
+
}
|
|
6870
6955
|
const configPath = writeOtelHooksConfig(
|
|
6871
6956
|
buildOtelHooksConfig({ resourceAttributes: options?.resourceAttributes }),
|
|
6872
6957
|
hooksHome
|
|
6873
6958
|
);
|
|
6874
|
-
const wrapperPath = writeOtelHooksWrapper(
|
|
6959
|
+
const wrapperPath = writeOtelHooksWrapper(resolvedCommand, hooksHome);
|
|
6960
|
+
uninstallLegacyPythonHooks();
|
|
6875
6961
|
if (options?.setupAgents !== false && isTelemetryEnabled()) {
|
|
6876
|
-
for (const
|
|
6877
|
-
const setup =
|
|
6878
|
-
if (setup.ok)
|
|
6962
|
+
for (const provider of OTEL_HOOKS_PROVIDERS) {
|
|
6963
|
+
const setup = runSetupProvider(provider.id, resolvedCommand, wrapperPath);
|
|
6964
|
+
if (setup.ok) providersSetup.push(provider.id);
|
|
6879
6965
|
else errors.push(setup.detail);
|
|
6880
6966
|
}
|
|
6881
6967
|
rewriteKnownHookRegistrations(wrapperPath);
|
|
6882
6968
|
}
|
|
6969
|
+
const agentsSetup = providersSetup.map(providerLabel);
|
|
6883
6970
|
const ok = errors.length === 0;
|
|
6884
6971
|
return {
|
|
6885
6972
|
ok,
|
|
6886
6973
|
hooksHome,
|
|
6887
6974
|
configPath,
|
|
6888
6975
|
wrapperPath,
|
|
6889
|
-
otelHookCommand,
|
|
6890
|
-
message: ok ?
|
|
6976
|
+
otelHookCommand: resolvedCommand,
|
|
6977
|
+
message: ok ? `@osfactory/otel-hook ready (${agentsSetup.join(", ") || "config only"}) \u2192 ${configPath}` : void 0,
|
|
6891
6978
|
warning: errors.length ? errors.join("; ") : void 0,
|
|
6892
6979
|
agentsSetup,
|
|
6980
|
+
providersSetup,
|
|
6893
6981
|
errors
|
|
6894
6982
|
};
|
|
6895
6983
|
}
|
|
6896
6984
|
function disableOtelHooksExport() {
|
|
6897
6985
|
return writeOtelHooksConfig(buildOtelHooksConfig({ enabled: false }));
|
|
6898
6986
|
}
|
|
6899
|
-
var import_child_process10, fs42, os14, path45, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_AGENTS;
|
|
6987
|
+
var import_child_process10, fs42, os14, path45, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_PROVIDERS, OTEL_HOOKS_AGENTS;
|
|
6900
6988
|
var init_otel_hooks = __esm({
|
|
6901
6989
|
"src/core/otel-hooks.ts"() {
|
|
6902
6990
|
"use strict";
|
|
@@ -6906,7 +6994,12 @@ var init_otel_hooks = __esm({
|
|
|
6906
6994
|
path45 = __toESM(require("path"));
|
|
6907
6995
|
init_control_config();
|
|
6908
6996
|
init_telemetry_config();
|
|
6909
|
-
OTEL_HOOKS_PACKAGE = "
|
|
6997
|
+
OTEL_HOOKS_PACKAGE = "@osfactory/otel-hook@0.1.1";
|
|
6998
|
+
OTEL_HOOKS_PROVIDERS = [
|
|
6999
|
+
{ id: "cursor", label: "cursor" },
|
|
7000
|
+
{ id: "claude-code", label: "claude" },
|
|
7001
|
+
{ id: "codex", label: "codex" }
|
|
7002
|
+
];
|
|
6910
7003
|
OTEL_HOOKS_AGENTS = ["cursor", "claude", "codex"];
|
|
6911
7004
|
}
|
|
6912
7005
|
});
|
|
@@ -44400,6 +44493,31 @@ var ResetMissionControlResultSchema = external_exports.object({
|
|
|
44400
44493
|
scrubbed: external_exports.array(HarnessScrubResultSchema),
|
|
44401
44494
|
repoPaths: external_exports.array(external_exports.string())
|
|
44402
44495
|
});
|
|
44496
|
+
var DeleteWorktreesInputSchema = external_exports.object({
|
|
44497
|
+
worktrees: external_exports.array(
|
|
44498
|
+
external_exports.object({
|
|
44499
|
+
repoId: external_exports.string().min(1),
|
|
44500
|
+
slotId: external_exports.number().int().positive()
|
|
44501
|
+
})
|
|
44502
|
+
).min(1),
|
|
44503
|
+
/**
|
|
44504
|
+
* When true (default), also drop Mission Control slot rows when the path is
|
|
44505
|
+
* already missing on disk (stale dashboard entries).
|
|
44506
|
+
*/
|
|
44507
|
+
clearMissing: external_exports.boolean().optional().default(true)
|
|
44508
|
+
});
|
|
44509
|
+
var DeleteWorktreeResultSchema = external_exports.object({
|
|
44510
|
+
repoId: external_exports.string(),
|
|
44511
|
+
slotId: external_exports.number(),
|
|
44512
|
+
path: external_exports.string(),
|
|
44513
|
+
deleted: external_exports.boolean(),
|
|
44514
|
+
clearedFromDashboard: external_exports.boolean(),
|
|
44515
|
+
error: external_exports.string().optional()
|
|
44516
|
+
});
|
|
44517
|
+
var DeleteWorktreesResultSchema = external_exports.object({
|
|
44518
|
+
ok: external_exports.literal(true),
|
|
44519
|
+
results: external_exports.array(DeleteWorktreeResultSchema)
|
|
44520
|
+
});
|
|
44403
44521
|
var SyncRunsInputSchema = external_exports.object({
|
|
44404
44522
|
runs: external_exports.array(RunRecordSchema)
|
|
44405
44523
|
});
|
|
@@ -51815,7 +51933,7 @@ function buildTelemetryEnvBlock(attrs) {
|
|
|
51815
51933
|
...attrs.attemptId ? [`HAR_ATTEMPT_ID=${attrs.attemptId}`] : [],
|
|
51816
51934
|
`HAR_CONTROL_API_URL=${apiUrl}`,
|
|
51817
51935
|
`OTEL_RESOURCE_ATTRIBUTES=${buildOtelResourceAttributes(attrs)}`,
|
|
51818
|
-
"# Agent telemetry:
|
|
51936
|
+
"# Agent telemetry: @osfactory/otel-hook \u2192 Mission Control (har telemetry on|off)"
|
|
51819
51937
|
];
|
|
51820
51938
|
return lines2.join("\n") + "\n";
|
|
51821
51939
|
}
|
|
@@ -53199,7 +53317,7 @@ var RunService = class {
|
|
|
53199
53317
|
const ensured = await ensureTelemetryInfrastructure({ startIfNeeded: true });
|
|
53200
53318
|
if (ensured.message) {
|
|
53201
53319
|
telemetryBanner += `${ensured.message}
|
|
53202
|
-
Usage from Cursor / Claude / Codex (
|
|
53320
|
+
Usage from Cursor / Claude / Codex (@osfactory/otel-hook) will appear under Worktrees. Disable: har telemetry off
|
|
53203
53321
|
`;
|
|
53204
53322
|
}
|
|
53205
53323
|
if (ensured.warning) {
|
|
@@ -53214,7 +53332,7 @@ Usage from Cursor / Claude / Codex (opentelemetry-hooks) will appear under Workt
|
|
|
53214
53332
|
if (hooks.warning) telemetryBanner += `${hooks.warning}
|
|
53215
53333
|
`;
|
|
53216
53334
|
} catch (err) {
|
|
53217
|
-
telemetryBanner +=
|
|
53335
|
+
telemetryBanner += `@osfactory/otel-hook setup skipped: ${err instanceof Error ? err.message : String(err)}
|
|
53218
53336
|
`;
|
|
53219
53337
|
}
|
|
53220
53338
|
}
|
|
@@ -66108,7 +66226,7 @@ async function handleOn(argv) {
|
|
|
66108
66226
|
prompts: argv.prompts,
|
|
66109
66227
|
traces: true
|
|
66110
66228
|
});
|
|
66111
|
-
success("Telemetry enabled. Cursor / Claude / Codex export via
|
|
66229
|
+
success("Telemetry enabled. Cursor / Claude / Codex export via @osfactory/otel-hook \u2192 Mission Control.");
|
|
66112
66230
|
info(
|
|
66113
66231
|
`Signals: metrics=${preference.signals.metrics} logs=${preference.signals.logs} prompts=${preference.signals.prompts} traces=${preference.signals.traces}`
|
|
66114
66232
|
);
|
|
@@ -66203,17 +66321,17 @@ async function handleInstallHooks() {
|
|
|
66203
66321
|
if (result.warning) warn(result.warning);
|
|
66204
66322
|
const hooks = ensureOtelHooks({ setupAgents: true });
|
|
66205
66323
|
if (hooks.ok) {
|
|
66206
|
-
success(hooks.message ?? "
|
|
66324
|
+
success(hooks.message ?? "@osfactory/otel-hook installed and agents registered");
|
|
66207
66325
|
info(`Config: ${hooks.configPath}`);
|
|
66208
66326
|
info(`Wrapper: ${hooks.wrapperPath}`);
|
|
66209
66327
|
} else {
|
|
66210
|
-
error(hooks.warning ?? "Failed to install
|
|
66328
|
+
error(hooks.warning ?? "Failed to install @osfactory/otel-hook");
|
|
66211
66329
|
process.exitCode = 1;
|
|
66212
66330
|
}
|
|
66213
66331
|
}
|
|
66214
66332
|
var telemetryCommand = {
|
|
66215
66333
|
command: "telemetry <subcommand>",
|
|
66216
|
-
describe: "Agent usage telemetry (Cursor / Claude / Codex via
|
|
66334
|
+
describe: "Agent usage telemetry (Cursor / Claude / Codex via @osfactory/otel-hook \u2192 Mission Control)",
|
|
66217
66335
|
builder: (yargs) => yargs.command(
|
|
66218
66336
|
"status",
|
|
66219
66337
|
"Show telemetry preference and Mission Control reachability",
|
|
@@ -66223,7 +66341,7 @@ var telemetryCommand = {
|
|
|
66223
66341
|
}
|
|
66224
66342
|
).command(
|
|
66225
66343
|
"on",
|
|
66226
|
-
"Enable full telemetry (incl. prompts), ensure Mission Control, install/configure
|
|
66344
|
+
"Enable full telemetry (incl. prompts), ensure Mission Control, install/configure @osfactory/otel-hook",
|
|
66227
66345
|
(y2) => y2.option("prompts", {
|
|
66228
66346
|
type: "boolean",
|
|
66229
66347
|
default: true,
|
|
@@ -66249,7 +66367,7 @@ var telemetryCommand = {
|
|
|
66249
66367
|
}
|
|
66250
66368
|
).command(
|
|
66251
66369
|
"install-hooks",
|
|
66252
|
-
"Install
|
|
66370
|
+
"Install @osfactory/otel-hook and register Cursor / Claude / Codex",
|
|
66253
66371
|
() => {
|
|
66254
66372
|
},
|
|
66255
66373
|
() => {
|