agent-observability-trace-cli 0.1.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/LICENSE ADDED
@@ -0,0 +1,198 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and incorporated
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a
80
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
81
+ or a Contribution incorporated within the Work constitutes direct
82
+ or contributory patent infringement, then any patent licenses
83
+ granted to You under this License for that Work shall terminate
84
+ as of the date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or as an addendum to
115
+ the NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the
117
+ License.
118
+
119
+ You may add Your own license statement for Your modifications and
120
+ may provide additional grant of rights to use, copy, modify, merge,
121
+ publish, distribute, sublicense, and/or sell copies of the
122
+ Contribution, either on an unchanged basis, or on the basis of
123
+ derivatives of it, solely to the extent these changes are necessary
124
+ to conform to other license requirements applicable to those
125
+ derivatives.
126
+
127
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
128
+ any Contribution intentionally submitted for inclusion in the Work
129
+ by You to the Licensor shall be under the terms and conditions of
130
+ this License, without any additional terms or conditions.
131
+ Notwithstanding the above, nothing herein shall supersede or modify
132
+ the terms of any separate license agreement you may have executed
133
+ with Licensor regarding such Contributions.
134
+
135
+ 6. Trademarks. This License does not grant permission to use the trade
136
+ names, trademarks, service marks, or product names of the Licensor,
137
+ except as required for reasonable and customary use in describing the
138
+ origin of the Work and reproducing the content of the NOTICE file.
139
+
140
+ 7. Disclaimer of Warranty. Unless required by applicable law or
141
+ agreed to in writing, Licensor provides the Work (and each
142
+ Contributor provides its Contributions) on an "AS IS" BASIS,
143
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
144
+ implied, including, without limitation, any warranties or conditions
145
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
146
+ PARTICULAR PURPOSE. You are solely responsible for determining the
147
+ appropriateness of using or reproducing the Work and assume any
148
+ risks associated with Your exercise of permissions under this License.
149
+
150
+ 8. Limitation of Liability. In no event and under no legal theory,
151
+ whether in tort (including negligence), contract, or otherwise,
152
+ unless required by applicable law (such as deliberate and grossly
153
+ negligent acts) or agreed to in writing, shall any Contributor be
154
+ liable to You for damages, including any direct, indirect, special,
155
+ incidental, or exemplary damages of any character arising as a
156
+ result of this License or out of the use or inability to use the
157
+ Work (including but not limited to damages for loss of goodwill,
158
+ work stoppage, computer failure or malfunction, or all other
159
+ commercial damages or losses), even if such Contributor has been
160
+ advised of the possibility of such damages.
161
+
162
+ 9. Accepting Warranty or Additional Liability. While redistributing
163
+ the Work or Derivative Works thereof, You may choose to offer,
164
+ and charge a fee for, acceptance of support, warranty, indemnity,
165
+ or other liability obligations and/or rights consistent with this
166
+ License. However, in accepting such obligations, You may act only
167
+ on Your own behalf and on Your sole responsibility, not on behalf
168
+ of any other Contributor, and only if You agree to indemnify,
169
+ defend, and hold each Contributor harmless for any liability
170
+ incurred by, or claims asserted against, such Contributor by reason
171
+ of your accepting any such warranty or additional liability.
172
+
173
+ END OF TERMS AND CONDITIONS
174
+
175
+ APPENDIX: How to apply the Apache License to your work.
176
+
177
+ To apply the Apache License to your work, attach the following
178
+ boilerplate notice, with the fields enclosed by brackets "[]"
179
+ replaced with your own identifying information. (Don't include
180
+ the brackets!) The text should be enclosed in the appropriate
181
+ comment syntax for the file format in question. It is also
182
+ recommended that a file or directory name and a description of the
183
+ purpose of the file be included on the same "PRINT" or "on the
184
+ first page" of each appropriate file.
185
+
186
+ Copyright 2026 Rudrendu Paul and Sourav Nandy
187
+
188
+ Licensed under the Apache License, Version 2.0 (the "License");
189
+ you may not use this file except in compliance with the License.
190
+ You may obtain a copy of the License at
191
+
192
+ http://www.apache.org/licenses/LICENSE-2.0
193
+
194
+ Unless required by applicable law or agreed to in writing, software
195
+ distributed under the License is distributed on an "AS IS" BASIS,
196
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
197
+ See the License for the specific language governing permissions and
198
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # agent-observability-trace-cli (npm wrapper)
2
+
3
+ An npm-installable wrapper for [`agent-trace`](https://github.com/RudrenduPaul/agent-observability), the deterministic record/replay tool for LLM agents. This package does not reimplement `agent-trace`. It puts the real `agent-trace` command on your PATH through `npm install`/`npx`, then forwards every argument straight through to the actual Python CLI.
4
+
5
+ ## What agent-trace does
6
+
7
+ `agent-trace` records every HTTP request and response your agent makes, verbatim, to a local SQLite fixture, then replays those exact bytes later with zero network calls. It patches `httpx.Client`, `httpx.AsyncClient`, and `requests.Session` at the transport layer, so it works with any Python HTTP client, including the clients used internally by the OpenAI Python SDK and the Anthropic SDK. The project's own benchmark suite (`benchmarks/test_overhead.py`, `benchmarks/test_replay_vs_live.py`, `benchmarks/test_fidelity.py` in the main repo) reports 0.011% recording overhead, 0.93ms mean replay latency, and byte-for-byte replay fidelity, at $0 API cost per replay.
8
+
9
+ ## Why this wrapper exists
10
+
11
+ `agent-trace` is a Python tool. If your team, CI pipeline, or agent harness already reaches for `npx` to run CLIs, this wrapper skips the "how do I invoke a Python tool from a Node-first workflow" step. It is a thin exec-and-forward shim, nothing more: the actual record/replay engine, interceptors, and CLI logic all live in the `agent_trace` Python package.
12
+
13
+ ## Prerequisites
14
+
15
+ - Python 3.10 or newer
16
+ - The [`agent-observability-trace-cli`](https://pypi.org/project/agent-observability-trace-cli/) PyPI package installed on the same machine (its console command is `agent-trace`):
17
+
18
+ ```bash
19
+ pip install agent-observability-trace-cli
20
+ # or
21
+ uv add agent-observability-trace-cli
22
+ # or, for an isolated global install
23
+ pipx install agent-observability-trace-cli
24
+ ```
25
+
26
+ Without that package installed, this wrapper prints install instructions and exits non-zero. It never installs anything on your behalf.
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ npm install -g agent-observability-trace-cli
32
+ # or run without installing
33
+ npx agent-observability-trace-cli version
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ Once installed, `agent-trace` on your PATH is this wrapper, and every subcommand is forwarded unchanged to the real CLI:
39
+
40
+ ```bash
41
+ agent-trace version
42
+ agent-trace list
43
+ agent-trace show run_abc123def456
44
+ agent-trace show run_abc123def456 --errors-only
45
+ agent-trace replay run_abc123def456
46
+ agent-trace inspect run_abc123def456
47
+ agent-trace diff run_a run_b
48
+ agent-trace run -- langgraph dev
49
+ ```
50
+
51
+ A recording/replay round trip in Python, using the underlying library directly:
52
+
53
+ ```python
54
+ from agent_trace import tracer
55
+ import httpx
56
+
57
+ @tracer.instrument(record=True)
58
+ def fetch_data(query: str) -> dict:
59
+ with tracer.span("http-call") as span:
60
+ resp = httpx.get("https://httpbin.org/get", params={"q": query})
61
+ span.set_attribute("http.status_code", resp.status_code)
62
+ return resp.json()
63
+
64
+ result = fetch_data("hello")
65
+ # Trace and fixture saved to ~/.agent-trace/runs/run_<id>/
66
+ ```
67
+
68
+ Full command reference, the record/replay model, and framework integrations (LangGraph, OpenAI Agents SDK, CrewAI, and more) are documented in the [main repository](https://github.com/RudrenduPaul/agent-observability).
69
+
70
+ ## How it works
71
+
72
+ The `agent-trace` bin script this package installs does two things, in order:
73
+
74
+ 1. Looks for a real `agent-trace` executable on your PATH (the console script `pip`/`uv`/`pipx` installs) and execs it with your arguments.
75
+ 2. If that isn't found, falls back to invoking the `agent_trace` Python module directly through `python3`/`python`.
76
+
77
+ If neither is available, it prints the install instructions above and exits with a non-zero status.
78
+
79
+ ## How it compares
80
+
81
+ Most observability tools for LLM agents, including LangSmith, Langfuse, Helicone, and OpenLLMetry, are observe-only: they show you a trace of what happened, but reproducing a failure still means re-running the full agent against live APIs. `agent-trace` additionally lets you reproduce that exact run offline, deterministically, without touching the live API.
82
+
83
+ The closest built-in comparison is LangSmith's `LANGSMITH_TEST_CACHE` (VCR-style cassettes via `langsmith[vcr]`). It's Python plus LangChain only, captures HTTP calls to `api.openai.com` specifically rather than any HTTP client, doesn't record full wire-level bytes, and requires a LangSmith account. `agent-trace` works with any Python HTTP client, records full request and response bytes locally, and needs no account or hosted service.
84
+
85
+ The full capability table against LangSmith, Langfuse, Helicone, and OpenLLMetry lives in the [main repository's README](https://github.com/RudrenduPaul/agent-observability#how-agent-observability-compares).
86
+
87
+ ## Known limitations
88
+
89
+ This wrapper only forwards arguments; the limitations below belong to `agent-trace` itself (documented in full in the main repo's README):
90
+
91
+ - Recording and replay happen inside the Python process you import `agent_trace` into. It cannot observe or replay calls made by a third-party hosted service you don't run yourself, only your own process's outbound calls.
92
+ - gRPC coverage is partial: unary-unary and sync unary-stream calls (used by Gemini/Vertex AI) are captured and replayed, but client-streaming, bidirectional-streaming, and any `grpc.aio` streaming call are not.
93
+ - Capture starts once a fully-constructed HTTP request object reaches the interceptor. Exceptions raised earlier, while an SDK is still serializing a tool schema or building headers, produce zero fixture rows unless a wired-in framework integration's own error callback catches them first.
94
+
95
+ ## FAQ
96
+
97
+ **Does this package reimplement `agent-trace` in JavaScript?**
98
+
99
+ No. It is a thin wrapper. The `bin/agent-trace.js` script it installs execs the real `agent-trace` console script if it finds one on your PATH, or falls back to invoking the `agent_trace` Python module through `python3`/`python`. All record/replay logic, HTTP interceptors, and CLI commands live in the Python package.
100
+
101
+ **Why would I install a Node wrapper for a Python tool?**
102
+
103
+ If your team already standardizes on `npx`/`npm` to run CLIs, whether in local scripts, CI steps, or agent tooling, this lets `agent-trace` slot into that same invocation pattern without a separate "activate a Python environment first" step. You still need the Python package installed; this wrapper does not remove that dependency.
104
+
105
+ **What do I need installed before this works?**
106
+
107
+ Python 3.10 or newer, plus the `agent-observability-trace-cli` PyPI package (`pip install agent-observability-trace-cli`, `uv add agent-observability-trace-cli`, or `pipx install agent-observability-trace-cli`). This npm package alone does nothing useful without it.
108
+
109
+ **What happens if I run `agent-trace` through this wrapper without the Python package installed?**
110
+
111
+ The wrapper tries the real console script first, then falls back to a direct Python module import. If both fail, it prints the exact `pip`/`uv`/`pipx` install commands above and exits with a non-zero status. It never installs anything automatically.
112
+
113
+ **Which commands does this wrapper support?**
114
+
115
+ All of them, unmodified. Every argument you pass to `agent-trace` through this wrapper is forwarded verbatim to the real CLI, so `agent-trace version`, `agent-trace list`, `agent-trace show <run-id>`, `agent-trace replay <run-id>`, `agent-trace inspect <run-id>`, `agent-trace diff <run-a> <run-b>`, and `agent-trace run -- <command>` all work exactly as documented in the main repository.
116
+
117
+ **How is this different from LangSmith's tracing/caching?**
118
+
119
+ LangSmith's `LANGSMITH_TEST_CACHE` needs LangChain and a LangSmith account, and only captures calls to `api.openai.com`. `agent-trace` works with any Python HTTP client (`httpx`, `requests`, and the transports used inside the OpenAI and Anthropic SDKs), records full request/response bytes locally, and needs no account. See the comparison table in the main repository for the full breakdown against LangSmith, Langfuse, Helicone, and OpenLLMetry.
120
+
121
+ **Does this wrapper work on Windows?**
122
+
123
+ The wrapper itself is plain Node.js and has no OS-specific code. Whether the underlying `agent-trace` Python package works on your platform depends on that package's own support, documented in the main repository; its automated CI currently runs on Ubuntu only.
124
+
125
+ **Is it safe to commit recorded fixtures to version control?**
126
+
127
+ Not by default, and this is a property of `agent-trace` itself, not this wrapper. Fixture files can contain full HTTP request and response bodies, including API keys and prompt contents. See the main repository's README for guidance on `.gitignore` entries and redacting secrets before committing a fixture.
128
+
129
+ **Is this free to use commercially?**
130
+
131
+ Yes. Both this npm package and the underlying `agent-observability-trace-cli` PyPI package are Apache 2.0 licensed, which permits commercial use, modification, and redistribution, subject to the license's attribution and notice terms.
132
+
133
+ ## License
134
+
135
+ Apache-2.0
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+
6
+ const args = process.argv.slice(2);
7
+
8
+ const INSTALL_HELP = `
9
+ agent-trace-cli is an npm wrapper: the actual CLI ships as a Python package.
10
+
11
+ Install it, then re-run this command:
12
+
13
+ pip install agent-observability-trace-cli
14
+ # or
15
+ uv add agent-observability-trace-cli
16
+ # or, for an isolated global install
17
+ pipx install agent-observability-trace-cli
18
+
19
+ Docs: https://github.com/RudrenduPaul/agent-observability
20
+ `;
21
+
22
+ function run(command, commandArgs) {
23
+ return spawnSync(command, commandArgs, { stdio: "inherit" });
24
+ }
25
+
26
+ // Preferred path: the real "agent-trace" console script is on PATH
27
+ // (installed via pip/uv/pipx per project.scripts in pyproject.toml).
28
+ let result = run("agent-trace", args);
29
+ if (!(result.error && result.error.code === "ENOENT")) {
30
+ if (result.error) {
31
+ throw result.error;
32
+ }
33
+ process.exit(result.status === null ? 1 : result.status);
34
+ }
35
+
36
+ // Fallback: agent-trace's console script isn't on PATH (e.g. pip
37
+ // installed into a venv not exported to PATH). Try invoking the
38
+ // module's CLI entry point directly through Python. Output is
39
+ // captured (not streamed) here so a missing module can be turned into
40
+ // the friendlier INSTALL_HELP message below instead of a raw traceback.
41
+ const pyScript =
42
+ "import sys; from agent_trace._cli import main; sys.argv = ['agent-trace'] + sys.argv[1:]; main()";
43
+ let pythonFound = false;
44
+ for (const python of ["python3", "python"]) {
45
+ const pyResult = spawnSync(python, ["-c", pyScript, ...args], {
46
+ stdio: ["inherit", "inherit", "pipe"],
47
+ encoding: "utf8",
48
+ });
49
+ if (pyResult.error && pyResult.error.code === "ENOENT") {
50
+ continue;
51
+ }
52
+ pythonFound = true;
53
+ if (pyResult.stderr && pyResult.stderr.includes("ModuleNotFoundError: No module named 'agent_trace'")) {
54
+ break;
55
+ }
56
+ if (pyResult.stderr) {
57
+ process.stderr.write(pyResult.stderr);
58
+ }
59
+ process.exit(pyResult.status === null ? 1 : pyResult.status);
60
+ }
61
+
62
+ process.stderr.write(INSTALL_HELP);
63
+ process.exit(1);
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "agent-observability-trace-cli",
3
+ "version": "0.1.0",
4
+ "description": "npm-installable CLI wrapper for agent-trace, deterministic record/replay for LLM agents. Requires Python 3.10+ and the agent-observability-trace-cli PyPI package.",
5
+ "bin": {
6
+ "agent-trace": "bin/agent-trace.js"
7
+ },
8
+ "files": [
9
+ "bin",
10
+ "LICENSE",
11
+ "README.md"
12
+ ],
13
+ "keywords": [
14
+ "agent-trace",
15
+ "ai-agents",
16
+ "observability",
17
+ "tracing",
18
+ "llm",
19
+ "langgraph",
20
+ "openai",
21
+ "record-replay",
22
+ "debugging",
23
+ "cli"
24
+ ],
25
+ "homepage": "https://github.com/RudrenduPaul/agent-observability#readme",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/RudrenduPaul/agent-observability.git",
29
+ "directory": "npm"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/RudrenduPaul/agent-observability/issues"
33
+ },
34
+ "license": "Apache-2.0",
35
+ "author": "Rudrendu Paul",
36
+ "engines": {
37
+ "node": ">=18"
38
+ }
39
+ }