agent-workflow-inspector 0.0.0-stage → 2.0.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/CHANGELOG.md +23 -0
- package/CODE_OF_CONDUCT.md +5 -0
- package/CONTRIBUTING.md +9 -0
- package/LICENSE +21 -0
- package/README.md +341 -2
- package/SECURITY.md +5 -0
- package/awi.config.example.json +39 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1338 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +256 -0
- package/dist/index.js +1159 -0
- package/dist/index.js.map +1 -0
- package/docs/architecture.md +21 -0
- package/docs/assets/architecture.svg +139 -0
- package/docs/assets/banner.svg +105 -0
- package/docs/assets/detection-patterns.svg +134 -0
- package/docs/assets/terminal-preview.svg +93 -0
- package/docs/audit.md +91 -0
- package/docs/ci-integration.md +45 -0
- package/docs/configuration.md +17 -0
- package/docs/detection-rules.md +38 -0
- package/docs/getting-started.md +70 -0
- package/docs/limitations.md +15 -0
- package/docs/releases/v1.0.0.md +32 -0
- package/docs/releasing.md +23 -0
- package/docs/report-schema.md +29 -0
- package/docs/schemas/config.schema.json +183 -0
- package/docs/schemas/report.schema.json +158 -0
- package/docs/schemas/trace.schema.json +98 -0
- package/docs/security.md +34 -0
- package/docs/trace-formats.md +41 -0
- package/docs/troubleshooting.md +12 -0
- package/docs/verification.md +44 -0
- package/examples/argument-drift.config.json +9 -0
- package/examples/healthy/basic.json +30 -0
- package/examples/opentelemetry/tools.json +210 -0
- package/examples/suspicious/argument-drift.json +62 -0
- package/examples/suspicious/cycle.json +78 -0
- package/examples/suspicious/retries.json +116 -0
- package/package.json +78 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
Changed the report contract to v2. Reports use local aliases for trace and operation IDs and AWI006 currency keys. AWI007 reports counts and references without raw tool names or error codes. `--show-content` retains recorded labels and IDs in its separate content section. See the [migration notes](docs/report-schema.md).
|
|
6
|
+
|
|
7
|
+
Added opt-in AWI007 (Repeated Failure with Argument Drift), strict configuration, synthetic example, privacy and sequence regression coverage. Uses existing fingerprints and timing normalization. No runtime dependencies or network operations added.
|
|
8
|
+
|
|
9
|
+
Added an offline synthetic quickstart verifier and CI matrix step; corrected publication status and source/consumer instructions. No runtime, API, or dependency changes.
|
|
10
|
+
|
|
11
|
+
Pinned the three affected development dependency edges to `minimatch` 11.0.1 to address [GHSA-g3hv-75wg-m249](https://github.com/advisories/GHSA-g3hv-75wg-m249). CI audits the full dependency tree as well as production dependencies.
|
|
12
|
+
|
|
13
|
+
## 1.0.0 — 2026-10-19
|
|
14
|
+
|
|
15
|
+
Initial local V1: canonical AWI JSON and OTLP subset; strict validation; SHA-256 fingerprints; six bounded rules; CLI/library; human/JSON reports; configuration; synthetic examples; security/regression/CLI tests; schemas; cross-platform CI. Published on GitHub and npm; status confirmed October 20, 2026 (see [release procedure](docs/releasing.md)).
|
|
16
|
+
|
|
17
|
+
### Release preparation
|
|
18
|
+
|
|
19
|
+
Added package homepage, issue tracker, keywords and optional funding metadata; clearer installation and maintainer guidance; release notes and an explicit approval-gated publication procedure. The audited commit passed all nine hosted CI jobs. Release-preparation commits require a fresh matrix before publication. No runtime behavior or dependencies changed.
|
|
20
|
+
|
|
21
|
+
### Pre-release audit fixes
|
|
22
|
+
|
|
23
|
+
Fixed canonicalization CPU amplification, bounded ignored-path compilation/caching, missing-identity evidence handling, repeated tools hidden by interleaved model spans, nanosecond/concurrent sequence false positives, retry-storm recovery handling, partial AWI002 defaults, impossible thresholds, source-reference validation, metadata amplification, malformed OTLP coercions, blank failure evidence, fragment determinism, public-renderer injection, symlink ancestors, invalid UTF-8 and broken pipes. Packed maintainer documents are included; the isolated-consumer smoke test now checks all examples, executable mode and TypeScript declarations. CI actions are SHA-pinned with no persisted checkout credentials.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Code of conduct
|
|
2
|
+
|
|
3
|
+
Be respectful, constructive and inclusive. Harassment, threats, discrimination, doxxing, sexual harassment and deliberate disruption are unacceptable in project spaces.
|
|
4
|
+
|
|
5
|
+
Maintainers may remove harmful contributions, warn, restrict or ban participants according to severity and recurrence. Protect affected participants and preserve confidentiality. Report conduct issues privately through a maintainer channel listed on the repository owner's profile; do not publish private details in issues. Maintainers should recuse themselves from reports about their own conduct.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Use supported Node and pinned pnpm. Run pnpm install --frozen-lockfile, pnpm check and pnpm format:check. Add positive/negative behavior tests for detector changes and adversarial cases for security changes. Use only synthetic credential-free fixtures.
|
|
4
|
+
|
|
5
|
+
Changes to rule IDs, fingerprint identity, schema versions or exit codes require compatibility review and changelog entries. Update documentation and regenerate schemas with pnpm schemas. Check dependency engines and pnpm audit. Never weaken tests to accept defects.
|
|
6
|
+
|
|
7
|
+
Describe the problem, resulting behavior, limitations and verification in PRs. No automated publishing occurs. Maintainer approval is required for releases and remote actions.
|
|
8
|
+
|
|
9
|
+
Read the [release procedure](docs/releasing.md) before proposing package or release-workflow changes. Contact maintainer [Jigar Prajapati](https://github.com/jigar48) through GitHub for project questions; use [Security](SECURITY.md) for sensitive reports. Do not post private traces or credentials in issues.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jigar Prajapati
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,342 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Workflow Inspector (AWI)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="docs/assets/banner.svg" alt="Agent Workflow Inspector Banner" width="100%">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/jigar48/awi/releases"><img src="https://img.shields.io/github/v/release/jigar48/awi?style=flat-square" alt="Latest GitHub release"></a>
|
|
9
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node.js-22.18+%20%7C%2024.11+%20%7C%2026.x-brightgreen.svg?style=flat-square" alt="Node.js Versions"></a>
|
|
10
|
+
<a href="https://github.com/jigar48/awi/actions"><img src="https://img.shields.io/badge/tests-69%20passed-success.svg?style=flat-square" alt="Tests"></a>
|
|
11
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-purple.svg?style=flat-square" alt="License: MIT"></a>
|
|
12
|
+
<img src="https://img.shields.io/badge/local--first-zero%20telemetry-teal.svg?style=flat-square" alt="Local First">
|
|
13
|
+
<img src="https://img.shields.io/badge/otel-compatible-orange.svg?style=flat-square" alt="OpenTelemetry Compatible">
|
|
14
|
+
<a href="https://buymeacoffee.com/buildwithjigar"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=flat-square" alt="Buy Me A Coffee"></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
**Local-first, deterministic linter and diagnostics for AI agent execution traces.**
|
|
18
|
+
|
|
19
|
+
Agent Workflow Inspector (AWI) is an offline developer tool and CI gatekeeper that detects suspicious retry storms, repeated failing tool calls, non-converging execution cycles, runaway delegation trees, and resource burn in AI agent traces.
|
|
20
|
+
|
|
21
|
+
It reads versioned AWI JSON or OpenTelemetry (OTLP) JSON exports and emits deterministic evidence for local developer review or automated CI pipelines. Analysis requires **no accounts, no cloud services, no LLM API keys, no network access, and zero telemetry**.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="docs/assets/terminal-preview.svg" alt="AWI Terminal Inspection Demo" width="100%">
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Why AWI?
|
|
32
|
+
|
|
33
|
+
Autonomous agents and LLM-powered workflows are prone to silent execution bugs: an agent might retry a broken search query five times in 3 seconds, get trapped in a circular loop between two editing tools, or spawn recursive child tasks that run away with token budgets.
|
|
34
|
+
|
|
35
|
+
| Challenge with Traditional Observability | The AWI Approach |
|
|
36
|
+
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
37
|
+
| **Expensive LLM Judges**: Cloud evaluators use LLMs to evaluate LLMs, incurring high API costs and latency. | **Deterministic & Instant**: Pure computational heuristics analyze 50,000 operations in milliseconds with zero LLM API costs. |
|
|
38
|
+
| **Cloud-Only & Telemetry Heavy**: Platforms require streaming sensitive agent prompts and customer data to external SaaS servers. | **100% Local & Privacy-Preserving**: Runs completely on your machine or inside air-gapped CI. Sensitive tool payloads are omitted by default. |
|
|
39
|
+
| **Probabilistic Results**: The same trace analyzed twice by an LLM evaluator can yield different answers. | **100% Reproducible**: Exact mathematical algorithms ensure identical inputs always yield identical reports. |
|
|
40
|
+
| **Difficult CI Integration**: Flaky external webhooks and latency make automated PR gating challenging. | **Native CI Exit Codes**: Returns `0` (clean), `1` (syntax/limits error), or `2` (findings over threshold) for seamless pipeline gating. |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Architecture & How It Works
|
|
45
|
+
|
|
46
|
+
AWI operates as a streamlined three-stage pipeline designed for memory safety, strict recursion limits, and zero external side effects:
|
|
47
|
+
|
|
48
|
+
<p align="center">
|
|
49
|
+
<img src="docs/assets/architecture.svg" alt="AWI Pipeline Architecture" width="100%">
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
1. **Ingestion & Normalization**:
|
|
53
|
+
- Parses canonical AWI JSON or OpenTelemetry OTLP JSON traces.
|
|
54
|
+
- Enforces strict memory budgets (up to 16 MiB per file, 64 MiB total, depth limits) against adversarial or corrupt trace files.
|
|
55
|
+
- Maps spans into parent-child operation timelines while projecting out generic model spans.
|
|
56
|
+
- Computes deterministic parameter fingerprints while stripping sensitive payload arguments.
|
|
57
|
+
|
|
58
|
+
2. **Deterministic Detection Engine**:
|
|
59
|
+
- Segments non-overlapping, timed sibling tool invocations under each parent.
|
|
60
|
+
- Provides 7 heuristic detectors (AWI001 through AWI007; AWI007 is opt-in) to identify repetition, retry storms, execution cycles, graph explosion, and resource waste.
|
|
61
|
+
|
|
62
|
+
3. **Outputs & Gating**:
|
|
63
|
+
- **Terminal Human Format**: High-contrast, colorized terminal summary highlighting rule IDs, implicated operation IDs, and specific evidence.
|
|
64
|
+
- **Structured JSON**: Complete, schema-validated report file ready for automated analytics and test assertions.
|
|
65
|
+
- **Pipeline Exit Codes**: Acts as an automated quality gate for GitHub Actions, GitLab CI, or pre-commit hooks.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Detection Rules & Heuristics
|
|
70
|
+
|
|
71
|
+
AWI analyzes structural execution patterns. Findings indicate suspicious behavioral patterns, separating observed evidence from explanatory heuristics:
|
|
72
|
+
|
|
73
|
+
<p align="center">
|
|
74
|
+
<img src="docs/assets/detection-patterns.svg" alt="AWI Detection Patterns" width="100%">
|
|
75
|
+
</p>
|
|
76
|
+
|
|
77
|
+
| Rule ID | Default Severity | Pattern Detected | Default Condition | Why It Matters |
|
|
78
|
+
| ---------- | ---------------- | ------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
|
|
79
|
+
| **AWI001** | `medium` | Repeated identical tool call | 4 equivalent calls within a bounded 100-call window | Redundant operations, caching misses, or unmemoized retrieval. |
|
|
80
|
+
| **AWI002** | `high` | Repeated identical failing call | 3 equivalent failures with matching error payload | Broken external integrations, expired credentials, or unchanging bad arguments. |
|
|
81
|
+
| **AWI003** | `medium` | Execution cycle | Periodic sequence of 2–6 tool calls repeating 3 times | Non-converging agent loops (e.g., `read` → `edit` → `test` → `read` → `edit` → `test`). |
|
|
82
|
+
| **AWI004** | `high` | Rapid retry storm | 5 equivalent attempts in a 30s window after explicit failure | Aggressive, unbacked retry loops hammering downstream APIs. |
|
|
83
|
+
| **AWI005** | `medium` | Runaway trace complexity | > 100 total operations or parent depth > 20 | Runaway recursive subagent delegation or infinite planning trees. |
|
|
84
|
+
| **AWI006** | `medium` | Resource burn on faulty calls | Implicated leaf operations with recorded usage or cost | Direct financial and token waste attributed to faulty loops. |
|
|
85
|
+
|
|
86
|
+
AWI007 (medium severity, moderate confidence; disabled by default) detects at least four consecutive recorded failures under the same trace and parent, with the same tool name and explicit error code, and at least three distinct argument fingerprints. Calls must have positive durations and form a non-overlapping sequence. It records repeated failures with changing arguments; it does not infer intent or lack of progress. See [conditions and limitations](docs/detection-rules.md#awi007-repeated-failure-with-argument-drift).
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
node dist/cli/index.js inspect examples/suspicious/argument-drift.json --config examples/argument-drift.config.json --format json --fail-on medium
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
> [!NOTE]
|
|
93
|
+
> Findings are heuristics, not proof of bugs. Intentional polling loops, exponential backoff sequences, or idempotent retries may trigger rules depending on thresholds. AWI does not infer agent intent from timestamps.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Installation & Quick Start
|
|
98
|
+
|
|
99
|
+
### Installation
|
|
100
|
+
|
|
101
|
+
These docs describe v2.0.0. If you consume JSON reports from v1, read the [v2 migration guide](docs/report-schema.md#migrating-from-v1) before upgrading.
|
|
102
|
+
|
|
103
|
+
Install v2.0.0 from the [GitHub release tarball](https://github.com/jigar48/awi/releases/tag/v2.0.0):
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
npm install --global https://github.com/jigar48/awi/releases/download/v2.0.0/agent-workflow-inspector-2.0.0.tgz
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
When v2.0.0 is available on [npm](https://www.npmjs.com/package/agent-workflow-inspector?activeTab=versions), you can also run it via `npx`:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
npx agent-workflow-inspector@2.0.0 inspect trace.json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Run from Source
|
|
116
|
+
|
|
117
|
+
Requires **Node.js 22.18+ (22.x), 24.11+ (24.x), or 26.x** and **pnpm 11.25.0**:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
git clone https://github.com/jigar48/awi.git
|
|
121
|
+
cd awi
|
|
122
|
+
pnpm install --frozen-lockfile
|
|
123
|
+
pnpm build
|
|
124
|
+
pnpm verify:quickstart
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The verifier checks the healthy trace exits 0 with no findings and the retry trace exits 2 with `AWI002`, `AWI004`, and `AWI006`. It uses only checked-in synthetic examples and performs no network operations. See [getting started](docs/getting-started.md) for toolchain setup and full checks.
|
|
128
|
+
|
|
129
|
+
Inspect the included sample traces:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
# Clean healthy trace (exits 0)
|
|
133
|
+
node dist/cli/index.js inspect examples/healthy/basic.json
|
|
134
|
+
|
|
135
|
+
# Suspicious retry storm (exits 2)
|
|
136
|
+
node dist/cli/index.js inspect examples/suspicious/retries.json
|
|
137
|
+
|
|
138
|
+
# OpenTelemetry OTLP format
|
|
139
|
+
node dist/cli/index.js inspect examples/opentelemetry/tools.json --input-format otel
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## CLI Reference
|
|
145
|
+
|
|
146
|
+
### Command Syntax
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
awi inspect <paths...> [options]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Options
|
|
153
|
+
|
|
154
|
+
| Flag | Argument | Description | Default |
|
|
155
|
+
| ---------------- | ------------------------------------- | ----------------------------------------------------------------- | -------- |
|
|
156
|
+
| `--format` | `human` \| `json` | Output presentation format. | `human` |
|
|
157
|
+
| `--input-format` | `auto` \| `awi` \| `otel` | Input parser mode. `auto` detects format from root structure. | `auto` |
|
|
158
|
+
| `--fail-on` | `low` \| `medium` \| `high` \| `none` | Minimum finding severity that causes exit code 2. | `high` |
|
|
159
|
+
| `--output` | `<path>` | Write structured report to a new file (existing files refused). | none |
|
|
160
|
+
| `--config` | `<path>` | Path to custom `awi.config.json` threshold configuration. | none |
|
|
161
|
+
| `--show-content` | none | Include recorded IDs, labels and payloads with limited redaction. | disabled |
|
|
162
|
+
| `--no-color` | none | Disable terminal ANSI color codes. | disabled |
|
|
163
|
+
| `-V, --version` | none | Display version number. | |
|
|
164
|
+
| `-h, --help` | none | Display CLI help. | |
|
|
165
|
+
|
|
166
|
+
### Sharing reports
|
|
167
|
+
|
|
168
|
+
Human and JSON reports use report-local trace and operation references. They omit recorded names, tool names, error codes, payloads, and fingerprint values, including when AWI007 is enabled. Counts, timing, resource amounts, source indices, and operation relationships remain visible. Use `--show-content` (or `analyze(traces, config, true)`) only for private inspection. It can expose recorded identifiers, labels and payloads despite key-based redaction. See the [synthetic before/after example](docs/security.md#synthetic-before-and-after) and [report v2 migration notes](docs/report-schema.md).
|
|
169
|
+
|
|
170
|
+
### Exit Codes
|
|
171
|
+
|
|
172
|
+
| Exit Code | Meaning | Details |
|
|
173
|
+
| --------- | --------------------- | -------------------------------------------------------------------------------------------------- |
|
|
174
|
+
| **`0`** | Clean / Passing | Analysis completed; no findings met or exceeded the `--fail-on` severity threshold. |
|
|
175
|
+
| **`1`** | Operational Error | Invalid CLI arguments, unreadable files, corrupt JSON, or exceeded input size/depth limits. |
|
|
176
|
+
| **`2`** | Lint Threshold Failed | Analysis succeeded, but one or more findings met or exceeded the configured `--fail-on` threshold. |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Trace Formats
|
|
181
|
+
|
|
182
|
+
### 1. Canonical AWI JSON Format
|
|
183
|
+
|
|
184
|
+
A minimal valid canonical trace file:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"version": 1,
|
|
189
|
+
"traceId": "research-agent-run-42",
|
|
190
|
+
"operations": [
|
|
191
|
+
{
|
|
192
|
+
"id": "op-001",
|
|
193
|
+
"type": "tool",
|
|
194
|
+
"name": "fetch_web_page",
|
|
195
|
+
"arguments": { "url": "https://example.com/api" },
|
|
196
|
+
"status": "error",
|
|
197
|
+
"error": {
|
|
198
|
+
"code": "HTTP_500",
|
|
199
|
+
"message": "Internal Server Error"
|
|
200
|
+
},
|
|
201
|
+
"startTime": "2026-10-19T10:00:00.000Z",
|
|
202
|
+
"endTime": "2026-10-19T10:00:01.500Z",
|
|
203
|
+
"usage": {
|
|
204
|
+
"inputTokens": 45,
|
|
205
|
+
"outputTokens": 0
|
|
206
|
+
},
|
|
207
|
+
"cost": {
|
|
208
|
+
"currency": "USD",
|
|
209
|
+
"amount": 0.00045
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### 2. OpenTelemetry (OTLP) Traces
|
|
217
|
+
|
|
218
|
+
AWI natively parses the documented OpenTelemetry `resourceSpans` JSON subset. It automatically maps:
|
|
219
|
+
|
|
220
|
+
- `spanId` → `operation.id`
|
|
221
|
+
- `parentSpanId` → `operation.parentId`
|
|
222
|
+
- Span attributes (`gen_ai.tool.name`, `rpc.method`, etc.) → `operation.name`
|
|
223
|
+
- Span status (`STATUS_CODE_ERROR`) → `operation.status`
|
|
224
|
+
- Timestamps from nanoseconds to ISO strings.
|
|
225
|
+
|
|
226
|
+
Specify `--input-format otel` or let AWI automatically detect the schema.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## TypeScript Library API
|
|
231
|
+
|
|
232
|
+
AWI exports an ESM library for embedding deterministic trace auditing directly into your TypeScript or JavaScript services:
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import { readFile } from 'node:fs/promises';
|
|
236
|
+
import { analyze, ingest, parseJson } from 'agent-workflow-inspector';
|
|
237
|
+
|
|
238
|
+
// 1. Read and safely parse trace JSON
|
|
239
|
+
const rawContent = await readFile('trace.json', 'utf8');
|
|
240
|
+
const traces = ingest(parseJson(rawContent));
|
|
241
|
+
|
|
242
|
+
// 2. Run deterministic analysis with custom rules
|
|
243
|
+
const report = analyze(traces, {
|
|
244
|
+
rules: {
|
|
245
|
+
AWI001: { threshold: 5 },
|
|
246
|
+
AWI004: { windowSeconds: 20 },
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// 3. Inspect findings
|
|
251
|
+
for (const finding of report.findings) {
|
|
252
|
+
console.log(
|
|
253
|
+
`[${finding.severity.toUpperCase()}] ${finding.ruleId}: ${finding.title}`,
|
|
254
|
+
);
|
|
255
|
+
console.log(` Implicated operations: ${finding.operationIds.join(', ')}`);
|
|
256
|
+
console.log(` Evidence:`, finding.evidence);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (!report.complete) {
|
|
260
|
+
throw new Error('Analysis incomplete');
|
|
261
|
+
}
|
|
262
|
+
if (report.findings.some((finding) => finding.severity !== 'low')) {
|
|
263
|
+
console.error(`Quality gate failed with ${report.findings.length} findings.`);
|
|
264
|
+
process.exitCode = 1;
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## CI / CD Integration
|
|
271
|
+
|
|
272
|
+
See [CI integration](docs/ci-integration.md) for separate examples for this source checkout and for installing AWI in another repository. Both use the same exit-code gate.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Configuration (`awi.config.json`)
|
|
277
|
+
|
|
278
|
+
Customize detection sensitivities using a strict configuration file:
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
{
|
|
282
|
+
"version": 1,
|
|
283
|
+
"rules": {
|
|
284
|
+
"AWI001": { "enabled": true, "threshold": 4 },
|
|
285
|
+
"AWI002": { "enabled": true, "threshold": 3 },
|
|
286
|
+
"AWI003": { "enabled": true, "minRepetitions": 3, "maxCycleLength": 6 },
|
|
287
|
+
"AWI004": { "enabled": true, "threshold": 5, "windowSeconds": 30 },
|
|
288
|
+
"AWI005": { "enabled": true, "maxOperations": 100, "maxDepth": 20 },
|
|
289
|
+
"AWI006": { "enabled": true },
|
|
290
|
+
"AWI007": { "enabled": false, "threshold": 4, "minDistinctArguments": 3 }
|
|
291
|
+
},
|
|
292
|
+
"fingerprint": {
|
|
293
|
+
"ignorePaths": ["timestamp", "requestId", "metadata.nonce"]
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Apply with:
|
|
299
|
+
|
|
300
|
+
```sh
|
|
301
|
+
awi inspect traces/ --config awi.config.json
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Documentation
|
|
307
|
+
|
|
308
|
+
- [Getting started](docs/getting-started.md)
|
|
309
|
+
- [Trace formats & OTLP mapping](docs/trace-formats.md)
|
|
310
|
+
- [Detection rules reference](docs/detection-rules.md)
|
|
311
|
+
- [Configuration options](docs/configuration.md)
|
|
312
|
+
- [Architecture & design decisions](docs/architecture.md)
|
|
313
|
+
- [Security & privacy model](docs/security.md)
|
|
314
|
+
- [CI/CD integration guide](docs/ci-integration.md)
|
|
315
|
+
- [Report JSON schema](docs/report-schema.md)
|
|
316
|
+
- [Troubleshooting](docs/troubleshooting.md)
|
|
317
|
+
- [Known limitations](docs/limitations.md)
|
|
318
|
+
- [Verification record](docs/verification.md)
|
|
319
|
+
- [Contributing guide](CONTRIBUTING.md)
|
|
320
|
+
- [Release notes (v1.0.0)](docs/releases/v1.0.0.md)
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
[MIT](LICENSE) © 2026 Jigar Prajapati.
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## About the author
|
|
331
|
+
|
|
332
|
+
Built by **Jigar Prajapati**, freelance software developer and automation engineer in Ahmedabad, India (Python, Playwright, FastAPI, AWS, e-commerce platforms, AI agents).
|
|
333
|
+
|
|
334
|
+
- GitHub: [github.com/jigar48](https://github.com/jigar48)
|
|
335
|
+
- Portfolio: [jigar48.github.io/automatewithjigar](https://jigar48.github.io/automatewithjigar/)
|
|
336
|
+
- LinkedIn: [Jigar Prajapati](https://www.linkedin.com/in/buildaiwith-jigar-prajapati/)
|
|
337
|
+
|
|
338
|
+
## Support my work
|
|
339
|
+
|
|
340
|
+
If awi saves you time, you can buy me a coffee.
|
|
341
|
+
|
|
342
|
+
<a href="https://buymeacoffee.com/buildwithjigar"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy me a coffee" height="41"></a>
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
The 1.x line receives security fixes. Never post credentials, private traces or sensitive exploit details publicly. Use GitHub private vulnerability reporting if enabled, or contact the maintainer privately through their GitHub profile. If no private channel exists, open a minimal issue requesting one without sensitive details.
|
|
4
|
+
|
|
5
|
+
Provide affected version, synthetic reproduction, expected/observed behavior and impact. There is no guaranteed response SLA. See the [security and privacy documentation](docs/security.md) for default report guarantees, sharing limits and the risks of opting into recorded content.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"rules": {
|
|
4
|
+
"AWI001": {
|
|
5
|
+
"enabled": true,
|
|
6
|
+
"threshold": 4
|
|
7
|
+
},
|
|
8
|
+
"AWI002": {
|
|
9
|
+
"enabled": true,
|
|
10
|
+
"threshold": 3
|
|
11
|
+
},
|
|
12
|
+
"AWI003": {
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"minRepetitions": 3,
|
|
15
|
+
"maxCycleLength": 6
|
|
16
|
+
},
|
|
17
|
+
"AWI004": {
|
|
18
|
+
"enabled": true,
|
|
19
|
+
"threshold": 5,
|
|
20
|
+
"windowSeconds": 30
|
|
21
|
+
},
|
|
22
|
+
"AWI005": {
|
|
23
|
+
"enabled": true,
|
|
24
|
+
"maxOperations": 100,
|
|
25
|
+
"maxDepth": 20
|
|
26
|
+
},
|
|
27
|
+
"AWI006": {
|
|
28
|
+
"enabled": true
|
|
29
|
+
},
|
|
30
|
+
"AWI007": {
|
|
31
|
+
"enabled": false,
|
|
32
|
+
"threshold": 4,
|
|
33
|
+
"minDistinctArguments": 3
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"fingerprint": {
|
|
37
|
+
"ignorePaths": []
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|