agent-mission-control 0.1.0__py3-none-any.whl
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.
- agent_mission_control-0.1.0.dist-info/METADATA +255 -0
- agent_mission_control-0.1.0.dist-info/RECORD +56 -0
- agent_mission_control-0.1.0.dist-info/WHEEL +5 -0
- agent_mission_control-0.1.0.dist-info/entry_points.txt +2 -0
- agent_mission_control-0.1.0.dist-info/licenses/LICENSE +21 -0
- agent_mission_control-0.1.0.dist-info/top_level.txt +1 -0
- app/__init__.py +0 -0
- app/adapters/__init__.py +77 -0
- app/adapters/base.py +240 -0
- app/adapters/claude_code_adapter.py +117 -0
- app/adapters/codex_adapter.py +218 -0
- app/adapters/copilot_adapter.py +109 -0
- app/adapters/direct_api_adapter.py +349 -0
- app/adapters/opencode_adapter.py +40 -0
- app/api/__init__.py +0 -0
- app/api/app.py +307 -0
- app/api/routes_artifacts.py +82 -0
- app/api/routes_config.py +593 -0
- app/api/routes_control.py +101 -0
- app/api/routes_stream.py +137 -0
- app/api/routes_tasks.py +540 -0
- app/api/security.py +235 -0
- app/cli.py +2109 -0
- app/core/__init__.py +0 -0
- app/core/backend_detector.py +734 -0
- app/core/config.py +460 -0
- app/core/context_compiler.py +959 -0
- app/core/db.py +647 -0
- app/core/event_bus.py +210 -0
- app/core/execution.py +1138 -0
- app/core/finding_tracker.py +639 -0
- app/core/github_ingest.py +198 -0
- app/core/mission_engine.py +137 -0
- app/core/models.py +181 -0
- app/core/paths.py +432 -0
- app/core/proc.py +719 -0
- app/core/recovery.py +57 -0
- app/core/review_policy.py +85 -0
- app/core/validation.py +143 -0
- app/core/worktree.py +268 -0
- app/mcp_server.py +289 -0
- app/schemas/__init__.py +0 -0
- app/schemas/task.py +24 -0
- app/sdk.py +1121 -0
- app/services/__init__.py +0 -0
- app/services/artifact_store.py +39 -0
- app/services/diff_service.py +20 -0
- app/services/editor_service.py +322 -0
- app/services/local_review_service.py +231 -0
- app/services/review_history.py +433 -0
- app/services/review_result_service.py +482 -0
- app/services/summary_service.py +81 -0
- app/static/index.html +232 -0
- app/static/ui/assets/index-BC6VTyKK.css +1 -0
- app/static/ui/assets/index-BCe5kmpV.js +14 -0
- app/static/ui/index.html +14 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-mission-control
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-first cross-agent code review workbench and CLI for uncommitted local changes and GitHub PRs
|
|
5
|
+
Author: robll-v1
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/robll-v1/mission-control
|
|
8
|
+
Project-URL: Repository, https://github.com/robll-v1/mission-control
|
|
9
|
+
Project-URL: Issues, https://github.com/robll-v1/mission-control/issues
|
|
10
|
+
Keywords: code-review,ai-agents,codex,claude-code,opencode,github-pr,developer-tools,cli
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Environment :: Web Environment
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: fastapi>=0.116.0
|
|
25
|
+
Requires-Dist: uvicorn>=0.35.0
|
|
26
|
+
Requires-Dist: pydantic>=2.11.0
|
|
27
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
28
|
+
Requires-Dist: mcp<2,>=1.0.0
|
|
29
|
+
Requires-Dist: httpx[socks]>=0.27.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
<h1 align="center">Mission Control</h1>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<strong>Don't let the agent that wrote your code be its only reviewer.</strong>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
Cross-review uncommitted local changes or GitHub PRs with a second coding agent CLI already on your machine (Codex, Claude Code, OpenCode, or Copilot), and track every finding across rounds until it is actually fixed.
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
<p align="center">
|
|
45
|
+
<a href="#quick-start"><strong>Quick start</strong></a> ·
|
|
46
|
+
<a href="#why-not-just-ask-your-agent"><strong>Why cross-review</strong></a> ·
|
|
47
|
+
<a href="#real-catch"><strong>Real catch</strong></a> ·
|
|
48
|
+
<a href="#workbench-preview"><strong>Workbench</strong></a> ·
|
|
49
|
+
<a href="#honest-boundaries"><strong>Boundaries</strong></a> ·
|
|
50
|
+
<a href="./README.zh-CN.md"><strong>简体中文</strong></a>
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
<p align="center">
|
|
54
|
+
<a href="https://github.com/robll-v1/mission-control/actions/workflows/ci.yml"><img src="https://github.com/robll-v1/mission-control/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
|
|
55
|
+
<a href="https://www.python.org"><img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square" alt="Python 3.11+" /></a>
|
|
56
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-22663E?style=flat-square" alt="MIT License" /></a>
|
|
57
|
+
<a href="#supported-agents"><img src="https://img.shields.io/badge/agents-Codex_%7C_Claude_Code_%7C_OpenCode_%7C_Copilot-2F55D4?style=flat-square" alt="Works with Codex, Claude Code, OpenCode, and Copilot" /></a>
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
<p align="center">
|
|
61
|
+
<img src="docs/screenshots/hero-explainer.png" alt="Mission Control workflow: code in your agent, cross-review uncommitted changes with a second local CLI, and track findings across rounds as Likely fixed or Persistent" width="960" />
|
|
62
|
+
</p>
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
67
|
+
|
|
68
|
+
Embed directly into your coding agent via **Skill + CLI** (fastest path), or launch the **local Web Workbench** (no Node.js required).
|
|
69
|
+
|
|
70
|
+
### Option A: Agent Skill (embed in Claude Code / Codex / Cursor / OpenCode)
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npx skills add robll-v1/mission-control -g
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Then ask your coding agent before `git push`:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
Use mission-control to cross-review my local changes before I push, fix any confirmed issues, and re-review round 2.
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The bundled skill ([`skills/mission-control/SKILL.md`](skills/mission-control/SKILL.md)) automatically picks a **different** installed CLI from the host agent (for example, Claude Code writes → Codex reviews), runs `amc review --format json` (falling back to `uvx` if `amc` is not installed globally), and loops cleanly until verified.
|
|
83
|
+
|
|
84
|
+
### Option B: CLI or Local Web Workbench (zero-clone with `uvx`)
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Review uncommitted local changes from the terminal (structured JSON + CI exit code)
|
|
88
|
+
uvx --from git+https://github.com/robll-v1/mission-control.git amc review --backend codex --reasoning high --format json --exit-code
|
|
89
|
+
|
|
90
|
+
# Or launch the local Web Workbench (bundled React UI, no Node.js needed)
|
|
91
|
+
uvx --from git+https://github.com/robll-v1/mission-control.git amc start
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Prefer a permanent local install?
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pipx install git+https://github.com/robll-v1/mission-control.git
|
|
98
|
+
amc review # CLI review
|
|
99
|
+
amc start # Web workbench on 127.0.0.1 (stop with `amc stop`)
|
|
100
|
+
amc doctor # Non-LLM static check of installed agent flags & reasoning levels
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
<details>
|
|
104
|
+
<summary>Try the 30-second synthetic demo repo or install from source</summary>
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# 30-second demo with an intentional SQL injection in notes.py
|
|
108
|
+
python3 examples/first-review/make_demo_repo.py /tmp/amc-demo-notes
|
|
109
|
+
amc review --repo /tmp/amc-demo-notes --format json --exit-code
|
|
110
|
+
|
|
111
|
+
# Apply the fix (stays uncommitted) and re-review on another agent/reasoning
|
|
112
|
+
python3 examples/first-review/make_demo_repo.py /tmp/amc-demo-notes --apply-fix
|
|
113
|
+
amc review --repo /tmp/amc-demo-notes --backend codex --reasoning high
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Contributor install from source:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
git clone https://github.com/robll-v1/mission-control.git
|
|
120
|
+
cd mission-control
|
|
121
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
122
|
+
pip install -e ".[dev]"
|
|
123
|
+
pytest -q
|
|
124
|
+
cd frontend && npm ci && npx tsc --noEmit && npm test && npm run build
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Why not just ask your agent?
|
|
132
|
+
|
|
133
|
+
| What goes wrong in chat ("review my changes") | What Mission Control does instead |
|
|
134
|
+
|---|---|
|
|
135
|
+
| **Same-model blind spots.** The agent that just wrote a patch tends to rationalize its own assumptions. | **Cross-agent per round.** Switch agent, model, and reasoning effort on any round (e.g. write in Claude Code, review on Codex `high`). |
|
|
136
|
+
| **Findings vanish between rounds.** When a second pass forgets to mention an earlier bug, you assume it is fixed. | **Cross-round state machine in SQLite.** Omitted findings become `Unverified`, or `Likely fixed` only when the exact diff between round snapshots modified that code — never auto-marked `Resolved`. |
|
|
137
|
+
| **Reviews drift from disk or mutate git state.** Reviewing only staged diffs misses untracked files and unstaged edits. | **Zero-touch local snapshots.** Copies your real index to a temporary `GIT_INDEX_FILE`, writes a snapshot commit parented at `HEAD`, and runs the reviewer in an isolated worktree. |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Real catch
|
|
142
|
+
|
|
143
|
+
During development of Mission Control's own [PR #35](https://github.com/robll-v1/mission-control/pull/35) (Phase 6 workbench), cross-reviewing the patch with a second agent caught **4 P1 security and concurrency issues** before merge:
|
|
144
|
+
|
|
145
|
+
| Category | Bug caught before merge | Fix verified by tests |
|
|
146
|
+
|---|---|---|
|
|
147
|
+
| **Concurrency** | `DELETE /api/tasks/{id}` released its active check before worktree cleanup, racing with concurrent `start_task` and background `ValidationService`. | Unified per-task exclusive slot shared by start, validation, and delete + barrier-synchronized concurrency tests. |
|
|
148
|
+
| **Git safety** | Preflight `git status` on user-supplied paths could execute repo-configured `core.fsmonitor` commands and acquire index locks. | Enforced `--no-optional-locks` and disabled `core.fsmonitor`, `core.hooksPath`, `diff.external`, and LFS filters. |
|
|
149
|
+
| **Windows security** | Allowlisted editor names (`code`) resolve to `code.cmd` on Windows, allowing `cmd.exe` to parse untrusted repo filenames. | Required absolute native `.exe` binaries on Windows, `open -t` on macOS, and `shell=False`. |
|
|
150
|
+
| **Truthful UI** | Progress view labeled every backend as "Read-only sandbox" even when only Codex runs `--sandbox read-only`. | Scoped the sandbox badge strictly to Codex and tracked pending round specs during preflight. |
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Workbench preview
|
|
155
|
+
|
|
156
|
+
<p align="center">
|
|
157
|
+
<img src="docs/screenshots/workbench-hero.png" alt="Full Mission Control workbench view showing multi-round review cards, findings, inline code snippet, and action controls" width="920" />
|
|
158
|
+
</p>
|
|
159
|
+
|
|
160
|
+
| Switch agent, model & reasoning per round | Inspect exact snapshots & diffs | Dynamic local capability detection |
|
|
161
|
+
|---|---|---|
|
|
162
|
+
| <img src="docs/screenshots/workbench-popover.png" alt="RunRoundPopover selecting agent, model, reasoning effort, output language, note, and focus override" /> | <img src="docs/screenshots/workbench-changes.png" alt="Unified diff viewer in the Changes tab showing parameterized SQL query fix in notes.py" /> | <img src="docs/screenshots/workbench-settings.png" alt="Model selection page showing detected local CLIs, per-model reasoning levels, and Check agent static probe" /> |
|
|
163
|
+
| Change agent, model, reasoning effort, output language, note, or focus for any round without creating a new review. | Review exact staged, unstaged, and untracked changes in the unified diff tab and jump straight to `file:line` in your editor. | Models and reasoning levels are read dynamically from your machine — never hardcoded — with a non-LLM `Check agent` probe. |
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Supported agents
|
|
168
|
+
|
|
169
|
+
| Agent | CLI | Model discovery | Reasoning effort | Read-only sandbox |
|
|
170
|
+
|---|---|---|---|---|
|
|
171
|
+
| **Codex CLI** | `codex` | Local `~/.codex/models_cache.json` / config | Per-model levels (`-c model_reasoning_effort=...`) | Yes (`--sandbox read-only`) |
|
|
172
|
+
| **Claude Code** | `claude` | Local CLI / config | Parsed from `claude --help` (`--effort ...`) | No (PATH guardrail only) |
|
|
173
|
+
| **OpenCode** | `opencode` | Local CLI / catalog cache | Legacy `provider/model#variant` alias | No (PATH guardrail only) |
|
|
174
|
+
| **Copilot CLI** | `gh copilot` | Agent default / config | Not exposed by CLI | No (PATH guardrail only) |
|
|
175
|
+
|
|
176
|
+
Default reasoning is always **`Model default`** (`null` — no reasoning flag passed). Switching agents never leaks the previous agent's model or reasoning setting.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## How it compares
|
|
181
|
+
|
|
182
|
+
| | Mission Control | [CodeRabbit](https://www.coderabbit.ai) | [GitHub Copilot Review](https://docs.github.com/en/copilot) | [PR-Agent](https://github.com/The-PR-Agent/pr-agent) |
|
|
183
|
+
|---|---|---|---|---|
|
|
184
|
+
| **Where it runs** | 100% local on your machine | Hosted SaaS (PR bot + CLI) | GitHub / VS Code | Self-hosted, primarily CI |
|
|
185
|
+
| **Models & agents** | Any local CLI agent; switchable per round | Vendor-managed | Vendor-managed | Bring your own API key |
|
|
186
|
+
| **Extra subscription** | None beyond your existing agent | Subscription | Copilot plan | Direct API usage |
|
|
187
|
+
| **Uncommitted local changes** | Yes (index + untracked snapshot) | Yes (CLI) | Yes (VS Code) | PR-focused |
|
|
188
|
+
| **Cross-round finding state** | `New / Persistent / Unverified / Likely fixed` + user `Resolved / Dismissed` | PR thread comments | PR thread comments | PR comments |
|
|
189
|
+
| **License** | MIT | Proprietary | Proprietary | Open source |
|
|
190
|
+
|
|
191
|
+
<sub>Based on public documentation; corrections welcome.</sub>
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## CLI, SDK & Configuration
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# CLI
|
|
199
|
+
amc review [PR_URL] [--repo PATH] [--backend codex|claude-code|opencode|copilot] [--model MODEL] [--reasoning LEVEL] [--focus TEXT] [--format json] [--exit-code]
|
|
200
|
+
amc start [--port 8000] [--no-browser] # amc status / amc stop / amc doctor / amc init [--global]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from app.sdk import ReviewEngine
|
|
205
|
+
|
|
206
|
+
engine = ReviewEngine(language="en", backend="codex", reasoning="high")
|
|
207
|
+
report = engine.review("/path/to/repo")
|
|
208
|
+
for f in report.findings:
|
|
209
|
+
print(f"[{f.severity}] {f.path}:{f.line} — {f.summary}")
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
<details>
|
|
213
|
+
<summary>Configuration layers (<code>.amc.yaml</code>), storage paths, repository layout & archived MCP</summary>
|
|
214
|
+
|
|
215
|
+
Priority: `CLI flag (--model / --reasoning) > env (AMC_MODEL / AMC_REASONING) > repo .amc.yaml > global ~/.config/amc/config.yaml > agent default`.
|
|
216
|
+
|
|
217
|
+
```yaml
|
|
218
|
+
repo:
|
|
219
|
+
base_branch: main
|
|
220
|
+
|
|
221
|
+
backend:
|
|
222
|
+
default: codex
|
|
223
|
+
codex:
|
|
224
|
+
model: gpt-6.1-terra
|
|
225
|
+
reasoning: high
|
|
226
|
+
|
|
227
|
+
validation:
|
|
228
|
+
default_mode: standard
|
|
229
|
+
checks:
|
|
230
|
+
tests:
|
|
231
|
+
command: pytest -q
|
|
232
|
+
modes: [standard, full]
|
|
233
|
+
required: true
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Global config lives at `~/.config/amc/config.yaml` (honoring `XDG_CONFIG_HOME`). SQLite state, artifacts, and short-path isolated worktrees (`<data_dir>/wt/<task_id>`) live in your OS application data directory (`~/Library/Application Support/amc` on macOS, `~/.local/share/amc` on Linux, `%APPDATA%\amc` on Windows), overridable via `AMC_DATA_DIR`.
|
|
237
|
+
|
|
238
|
+
The legacy stdio MCP server (`backend/app/mcp_server.py`) is archived and uses `mcp>=1.0.0,<2` in direct-API mode; use the Agent Skill, `amc review`, `amc start`, or `ReviewEngine` for full multi-round tracking.
|
|
239
|
+
|
|
240
|
+
More reading: [architecture & sequence diagrams](docs/architecture-and-sequence-diagrams.md) · [local snapshot design](docs/local-review-design.md) · [project design history](docs/project-design-history.md)
|
|
241
|
+
|
|
242
|
+
</details>
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Honest boundaries
|
|
247
|
+
|
|
248
|
+
- **Listed models are not call guarantees.** Model and reasoning lists come from local CLI caches, help output, or config files; only a real request proves account access and quota.
|
|
249
|
+
- **PATH shims are guardrails, not an OS sandbox.** Only Codex CLI runs with `--sandbox read-only` (and the UI only shows the sandbox badge when Codex is active).
|
|
250
|
+
- **Silence never equals fixed.** Findings omitted in a later round become `Unverified` (or `Likely fixed` when code at that location changed between snapshots) — never automatically `Resolved`.
|
|
251
|
+
- **Loopback-only local security.** The server binds to `127.0.0.1`, enforces exact `Host`/`Origin` validation, restricts `Open in editor` to allowlisted native executables inside the resolved repository root, and disables repo-configured git commands (`core.fsmonitor`, hooks) during status probes.
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
agent_mission_control-0.1.0.dist-info/licenses/LICENSE,sha256=m9E21HTYkXLV8UvlVUIK71gKZQWgiHZM4VFUpzSuGf0,1065
|
|
2
|
+
app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
app/cli.py,sha256=phWb6yESkw9W5qYrpytpmaHmDqYgIZ8QBUfcLpIbGZY,82647
|
|
4
|
+
app/mcp_server.py,sha256=NHLVgT2OALsATwnwsaZTlvJK0BVhqX3kYf_NziMqh7M,10772
|
|
5
|
+
app/sdk.py,sha256=18VVxo8IrKK01_QKELaRD_O64ULm10TjKhmDY5BSOiM,45281
|
|
6
|
+
app/adapters/__init__.py,sha256=RNe3Qk9DJjp7iUJSyo1-LY5zM2c7s8J1vBbaqhXdRxM,2110
|
|
7
|
+
app/adapters/base.py,sha256=1R6DMlcvR-lkshawD_Gj6V1qVckHY-7i-RsusAcutFA,9901
|
|
8
|
+
app/adapters/claude_code_adapter.py,sha256=7fe_H63ezlPE5omPVXbUCtKtKecovmzr0BzUZJKBt30,4360
|
|
9
|
+
app/adapters/codex_adapter.py,sha256=dyAejpZkjKxYnGtyMqSzparAVhPwNoUBVb-1DdwIKxI,9523
|
|
10
|
+
app/adapters/copilot_adapter.py,sha256=0hE0GnxIZCQRyaVSmKjSF_SVM-5hXt_pL5D4v2eBn4c,4026
|
|
11
|
+
app/adapters/direct_api_adapter.py,sha256=JN0V0QTfD8Rr_WQVaM_21qrwPvhoSI6GVdEZZAka1f8,13547
|
|
12
|
+
app/adapters/opencode_adapter.py,sha256=0DOC6v3QVy3T13T6hbQ0e_AYjwUGeNbsJCjYcmDn1wQ,1791
|
|
13
|
+
app/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
app/api/app.py,sha256=vQ-sHXkMspL_ZqLiQ52a_5XEAEoXqpV1G05QOjPph2U,11898
|
|
15
|
+
app/api/routes_artifacts.py,sha256=7JnqtZttfKuSt2mDCTkjLqN9qv0QwIuP3sDypKtwyiQ,2675
|
|
16
|
+
app/api/routes_config.py,sha256=0xndlYqvjOB8Bejw-td75gV80RtH9dD8l7R_17VVg80,22338
|
|
17
|
+
app/api/routes_control.py,sha256=3Z6D5rYsTNxpUqDceYN5tJF81QgU1ZQLZmdA_Cly9DM,3903
|
|
18
|
+
app/api/routes_stream.py,sha256=75aJV4x6A-_KBossN6zrb_QMI3yNzbjUHMlne3AHvt8,4777
|
|
19
|
+
app/api/routes_tasks.py,sha256=ITLKa4yRyu2OwhNC2o9A3j_fS0ZL3dRZhznE8CGwua8,20081
|
|
20
|
+
app/api/security.py,sha256=n0q7IHWaY6_CSDoa3EIyKLbTSbd7364ijzAjgaAm8hc,8949
|
|
21
|
+
app/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
app/core/backend_detector.py,sha256=ALubSbzKWAbO6gANkUptOF8XMHlBA8qnHUXYqGjQaWg,30078
|
|
23
|
+
app/core/config.py,sha256=xIPlppP49Af0URj5m7X_eIvIxEXaqKae3OGzKuPzwZE,18238
|
|
24
|
+
app/core/context_compiler.py,sha256=bIXE7_JMJxihWm7XzH-oi_3nELmWjacjRyrTCqiPA3Y,44530
|
|
25
|
+
app/core/db.py,sha256=-FV0i59g5GFDJDdnYHp4oHYS4_DC9IfoO7Vf_ZKX4Bg,26584
|
|
26
|
+
app/core/event_bus.py,sha256=yRnkaKKmNjHCepzPIuq51FcAGQyVVQL-MYKHc3FyGas,7517
|
|
27
|
+
app/core/execution.py,sha256=Brzl4N6ViW6mwHkaCOn2WcDCBEclcQzKGC5QBv5fxK8,51654
|
|
28
|
+
app/core/finding_tracker.py,sha256=Pe2ANg1xhtithhdkYfhFBVlODdTPNuyvu08e4PnQxN0,25327
|
|
29
|
+
app/core/github_ingest.py,sha256=sPrjIKg_Ooik0gPXZjTMT1NpZtNWPv_cCPW5Zei2324,8179
|
|
30
|
+
app/core/mission_engine.py,sha256=QK_er2UKZENS0tOsnFKBEgAbFd-S0W7okf35E0UONIQ,4895
|
|
31
|
+
app/core/models.py,sha256=1W8VNYZc2vbxFeHA5an_Xx2YotKFlCKguu4Pm7QsEbo,4924
|
|
32
|
+
app/core/paths.py,sha256=jAZvihhI4fYBZtBmMoefPzKkloewSu5X7Rkcj_DAzfM,15577
|
|
33
|
+
app/core/proc.py,sha256=UvNHBQCPRexq--Bl2AtWnESAFA9llWs6cXgApfgH38U,28168
|
|
34
|
+
app/core/recovery.py,sha256=17TNrnShMQm9sax4TAbnECISTKEA8XpajvKYVCHX1SI,2362
|
|
35
|
+
app/core/review_policy.py,sha256=bZRkbO-WxZCbmPn7XfCYix4kxt0ojPwWrGQiRZwBbck,2614
|
|
36
|
+
app/core/validation.py,sha256=vojc3mZZPYcP6VJYhRRyekidV-xFDkfJkEvbkRTkCZg,6494
|
|
37
|
+
app/core/worktree.py,sha256=7SiSxrlL6LUwtiG36V2ZcwiSexQ04FZVlJJ_YOryqpo,11203
|
|
38
|
+
app/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
+
app/schemas/task.py,sha256=m6wQtT03V-UajWMESBQlSVe3ObVmcA4zvSXZeTq-38c,708
|
|
40
|
+
app/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
|
+
app/services/artifact_store.py,sha256=bk5qX8yW7b9LGgwOV3Rh6qUS8HkYhgOqYuVnSNux02I,1565
|
|
42
|
+
app/services/diff_service.py,sha256=Cg4ATiblAizOlpExBP9CC_0Vfx29QvXVbtPkqZD9i70,803
|
|
43
|
+
app/services/editor_service.py,sha256=JhO1cy7Kk2OqMAeRVbbDmoqNHmyR5yAwHSdcFGcxFnE,12477
|
|
44
|
+
app/services/local_review_service.py,sha256=-_UG1SZ4YnDLfGP9uV3S7fKNjfZG2wiem3WUnH9uMBI,10237
|
|
45
|
+
app/services/review_history.py,sha256=IAnBz5UTdbXEx1XVT5WN9P1oHINjXOJIQxMwnyScyRY,15268
|
|
46
|
+
app/services/review_result_service.py,sha256=zbU07ObabGE9k6mvgfKDR74VfFMxcUBkIY4ufZNXJZo,19988
|
|
47
|
+
app/services/summary_service.py,sha256=60XOFPgqAzCgwrTKKelg6zIcjTHJwi6soaWfjkCIYRM,3342
|
|
48
|
+
app/static/index.html,sha256=utvvNltX41uuurg-g4FCUC7Aey0ouEJxLUhsyv75FSw,18476
|
|
49
|
+
app/static/ui/index.html,sha256=zKdzT4xG0pPsxfQWLIjjGVbd7dUPYfj53y7PkHnhzsI,744
|
|
50
|
+
app/static/ui/assets/index-BC6VTyKK.css,sha256=6C6ArlIkMS9UbUxvsBTXUoqVuEQCmg6XZ2AwJY419v4,54855
|
|
51
|
+
app/static/ui/assets/index-BCe5kmpV.js,sha256=BGqKbuPkJEd1HtwqgDofVRoO6-rNVzEUszZd9qI5GZg,350557
|
|
52
|
+
agent_mission_control-0.1.0.dist-info/METADATA,sha256=d7UnYZmIF_vMTQtjxjqJl1dOE-BEfUc2tW-VplnsrDU,13777
|
|
53
|
+
agent_mission_control-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
54
|
+
agent_mission_control-0.1.0.dist-info/entry_points.txt,sha256=80utemO-0yOXKY3h69a9Mv2n3YEItXB6V95PO36KpTc,37
|
|
55
|
+
agent_mission_control-0.1.0.dist-info/top_level.txt,sha256=io9g7LCbfmTG1SFKgEOGXmCFB9uMP2H5lerm0HiHWQE,4
|
|
56
|
+
agent_mission_control-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 robll-v1
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
app
|
app/__init__.py
ADDED
|
File without changes
|
app/adapters/__init__.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Adapter registry — maps backend names to RunnerAdapter implementations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from app.adapters.base import RunnerAdapter
|
|
6
|
+
from app.adapters.opencode_adapter import OpenCodeAdapter
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
_REGISTRY: dict[str, type[RunnerAdapter]] = {
|
|
10
|
+
'opencode': OpenCodeAdapter,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
AVAILABLE_BACKENDS: list[str] = []
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _rebuild_list() -> None:
|
|
17
|
+
global AVAILABLE_BACKENDS
|
|
18
|
+
AVAILABLE_BACKENDS = sorted(_REGISTRY.keys())
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
_rebuild_list()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def register(name: str, cls: type[RunnerAdapter]) -> None:
|
|
25
|
+
_REGISTRY[name] = cls
|
|
26
|
+
_rebuild_list()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_adapter(
|
|
30
|
+
name: str,
|
|
31
|
+
*,
|
|
32
|
+
model: str | None = None,
|
|
33
|
+
variant: str | None = None,
|
|
34
|
+
reasoning: str | None = None,
|
|
35
|
+
) -> RunnerAdapter:
|
|
36
|
+
"""Instantiate an adapter by backend name.
|
|
37
|
+
|
|
38
|
+
``reasoning`` is the preferred parameter; ``variant`` remains a
|
|
39
|
+
backward-compatible alias. Raises KeyError if name is not registered.
|
|
40
|
+
"""
|
|
41
|
+
cls = _REGISTRY.get(name)
|
|
42
|
+
if cls is None:
|
|
43
|
+
raise KeyError(f'Unknown backend: {name!r}. Available: {AVAILABLE_BACKENDS}')
|
|
44
|
+
import inspect
|
|
45
|
+
sig = inspect.signature(cls.__init__)
|
|
46
|
+
eff_reasoning = reasoning if reasoning is not None else variant
|
|
47
|
+
kwargs: dict = {}
|
|
48
|
+
if 'model' in sig.parameters:
|
|
49
|
+
kwargs['model'] = model
|
|
50
|
+
if 'reasoning' in sig.parameters:
|
|
51
|
+
kwargs['reasoning'] = eff_reasoning
|
|
52
|
+
if 'variant' in sig.parameters:
|
|
53
|
+
kwargs['variant'] = variant if variant is not None else eff_reasoning
|
|
54
|
+
return cls(**kwargs)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _auto_register() -> None:
|
|
58
|
+
"""Import all adapter modules to trigger registration."""
|
|
59
|
+
try:
|
|
60
|
+
from app.adapters.claude_code_adapter import ClaudeCodeAdapter
|
|
61
|
+
_REGISTRY['claude-code'] = ClaudeCodeAdapter
|
|
62
|
+
except ImportError:
|
|
63
|
+
pass
|
|
64
|
+
try:
|
|
65
|
+
from app.adapters.copilot_adapter import CopilotAdapter
|
|
66
|
+
_REGISTRY['copilot'] = CopilotAdapter
|
|
67
|
+
except ImportError:
|
|
68
|
+
pass
|
|
69
|
+
try:
|
|
70
|
+
from app.adapters.codex_adapter import CodexAdapter
|
|
71
|
+
_REGISTRY['codex'] = CodexAdapter
|
|
72
|
+
except ImportError:
|
|
73
|
+
pass
|
|
74
|
+
_rebuild_list()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
_auto_register()
|
app/adapters/base.py
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
import shutil
|
|
6
|
+
import sys
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from dataclasses import dataclass, field
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from app.core.review_policy import BLOCKED_MARKER, forbidden_command_reason
|
|
12
|
+
from app.core.models import Task
|
|
13
|
+
|
|
14
|
+
# Strictly reject whitespace, control chars, and shell metacharacters
|
|
15
|
+
# (especially Windows cmd.exe `& | < > ^ % ! " ' ; ( )` for .cmd/.bat shims).
|
|
16
|
+
_SAFE_MODEL_RE = re.compile(r'^[A-Za-z0-9][A-Za-z0-9_./:@#+-]{0,127}$')
|
|
17
|
+
_SAFE_REASONING_RE = re.compile(r'^[A-Za-z0-9][A-Za-z0-9_.-]{0,31}$')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def validate_model_name(value: str | None) -> str | None:
|
|
21
|
+
if value is None:
|
|
22
|
+
return None
|
|
23
|
+
cleaned = value.strip()
|
|
24
|
+
if not cleaned:
|
|
25
|
+
return None
|
|
26
|
+
if not _SAFE_MODEL_RE.fullmatch(cleaned):
|
|
27
|
+
raise ValueError(f'invalid model name: {value!r}')
|
|
28
|
+
return cleaned
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def validate_reasoning_level(value: str | None) -> str | None:
|
|
32
|
+
if value is None:
|
|
33
|
+
return None
|
|
34
|
+
cleaned = value.strip()
|
|
35
|
+
if not cleaned:
|
|
36
|
+
return None
|
|
37
|
+
if not _SAFE_REASONING_RE.fullmatch(cleaned):
|
|
38
|
+
raise ValueError(f'invalid reasoning effort value: {value!r}')
|
|
39
|
+
return cleaned
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def resolve_executable(name: str) -> str:
|
|
43
|
+
"""Return a launchable path for ``name``, falling back to the bare name.
|
|
44
|
+
|
|
45
|
+
On Windows ``shutil.which`` honours PATHEXT, so npm/codex/gh installed as
|
|
46
|
+
``.cmd`` or ``.bat`` shims resolve correctly. Falling back to the bare name
|
|
47
|
+
preserves macOS/Linux behaviour and keeps preflight error messages familiar
|
|
48
|
+
when the binary is genuinely missing.
|
|
49
|
+
"""
|
|
50
|
+
resolved = shutil.which(name)
|
|
51
|
+
if resolved:
|
|
52
|
+
return resolved
|
|
53
|
+
if sys.platform == 'win32':
|
|
54
|
+
for ext in ('.cmd', '.exe', '.bat'):
|
|
55
|
+
resolved = shutil.which(name + ext)
|
|
56
|
+
if resolved:
|
|
57
|
+
return resolved
|
|
58
|
+
return name
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass
|
|
62
|
+
class AdapterEvent:
|
|
63
|
+
kind: str
|
|
64
|
+
level: str = 'info'
|
|
65
|
+
payload: dict[str, Any] = field(default_factory=dict)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class RunnerAdapter(ABC):
|
|
69
|
+
#: Backend key used in config and on ``Task.backend`` (e.g. ``claude-code``).
|
|
70
|
+
name: str
|
|
71
|
+
#: Name of the program to launch. Often differs from :attr:`name` —
|
|
72
|
+
#: ``claude-code`` runs ``claude``, ``copilot`` runs ``gh``. Preflight must
|
|
73
|
+
#: probe *this*, not :attr:`name`.
|
|
74
|
+
executable: str = ''
|
|
75
|
+
#: Whether this adapter forwards a reasoning effort level to its CLI.
|
|
76
|
+
supports_reasoning: bool = False
|
|
77
|
+
|
|
78
|
+
@abstractmethod
|
|
79
|
+
def make_command(self, *, task: Task, prompt: str) -> list[str]:
|
|
80
|
+
raise NotImplementedError
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def executable_name(cls) -> str:
|
|
84
|
+
"""Program this adapter launches; falls back to the backend key."""
|
|
85
|
+
return cls.executable or cls.name
|
|
86
|
+
|
|
87
|
+
def probe_command(self) -> list[str] | None:
|
|
88
|
+
"""A cheap invocation proving the CLI is usable, or ``None`` to skip.
|
|
89
|
+
|
|
90
|
+
Returning ``None`` means "existence on PATH is the only check we can
|
|
91
|
+
make". That is preferable to running an invocation the CLI does not
|
|
92
|
+
understand, which produces a confusing failure that looks like a
|
|
93
|
+
credentials problem.
|
|
94
|
+
"""
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
def doctor_command(self) -> list[str]:
|
|
98
|
+
"""Strictly non-LLM static command for `Check agent` / `amc doctor`.
|
|
99
|
+
|
|
100
|
+
Validates executable and CLI flag parsing (including selected model and
|
|
101
|
+
reasoning flags when supported) without making any model/network call.
|
|
102
|
+
"""
|
|
103
|
+
return [resolve_executable(self.executable_name()), '--version']
|
|
104
|
+
|
|
105
|
+
def parse_stdout_line(self, line: str) -> list[AdapterEvent]:
|
|
106
|
+
stripped = line.strip()
|
|
107
|
+
if not stripped:
|
|
108
|
+
return []
|
|
109
|
+
try:
|
|
110
|
+
obj = json.loads(stripped)
|
|
111
|
+
except json.JSONDecodeError:
|
|
112
|
+
return [AdapterEvent(kind='agent.text', payload={'text': stripped})]
|
|
113
|
+
event_type = obj.get('type', 'event')
|
|
114
|
+
session_id = str(obj.get('sessionID') or '').strip() or None
|
|
115
|
+
if event_type == 'text':
|
|
116
|
+
text = self._part_text(obj)
|
|
117
|
+
if not text:
|
|
118
|
+
return []
|
|
119
|
+
payload = {'text': text}
|
|
120
|
+
if session_id:
|
|
121
|
+
payload['session_id'] = session_id
|
|
122
|
+
return [AdapterEvent(kind='agent.text', payload=payload)]
|
|
123
|
+
if event_type == 'tool_use':
|
|
124
|
+
return [self._tool_event(obj, session_id=session_id)]
|
|
125
|
+
if event_type == 'step_start':
|
|
126
|
+
payload: dict[str, Any] = {'type': 'step_start'}
|
|
127
|
+
part = obj.get('part', {}) if isinstance(obj.get('part'), dict) else {}
|
|
128
|
+
if session_id:
|
|
129
|
+
payload['session_id'] = session_id
|
|
130
|
+
if part.get('messageID'):
|
|
131
|
+
payload['message_id'] = part.get('messageID')
|
|
132
|
+
if part.get('snapshot'):
|
|
133
|
+
payload['snapshot'] = part.get('snapshot')
|
|
134
|
+
return [AdapterEvent(kind='agent.step_start', payload=payload)]
|
|
135
|
+
if event_type == 'step_finish':
|
|
136
|
+
return [self._step_finish_event(obj, session_id=session_id)]
|
|
137
|
+
payload = {'type': event_type}
|
|
138
|
+
if session_id:
|
|
139
|
+
payload['session_id'] = session_id
|
|
140
|
+
# OpenCode emits stream errors (provider.quota, etc.) as
|
|
141
|
+
# {"type":"error","error":{...}}; without the nested message a quota
|
|
142
|
+
# exhaustion looks like a content-less failure.
|
|
143
|
+
error = obj.get('error')
|
|
144
|
+
if isinstance(error, dict):
|
|
145
|
+
level = 'error'
|
|
146
|
+
for key in ('type', 'message', 'status'):
|
|
147
|
+
if error.get(key) is not None:
|
|
148
|
+
payload[f'error_{key}'] = error.get(key)
|
|
149
|
+
return [AdapterEvent(kind=f'agent.{event_type}', level=level, payload=payload)]
|
|
150
|
+
return [AdapterEvent(kind=f'agent.{event_type}', payload=payload)]
|
|
151
|
+
|
|
152
|
+
def parse_stderr_line(self, line: str) -> list[AdapterEvent]:
|
|
153
|
+
stripped = line.rstrip()
|
|
154
|
+
if not stripped:
|
|
155
|
+
return []
|
|
156
|
+
return [AdapterEvent(kind='agent.stderr', level='warning', payload={'text': stripped})]
|
|
157
|
+
|
|
158
|
+
@staticmethod
|
|
159
|
+
def _part_text(obj: dict[str, Any]) -> str:
|
|
160
|
+
part = obj.get('part')
|
|
161
|
+
if isinstance(part, dict) and isinstance(part.get('text'), str):
|
|
162
|
+
return str(part.get('text')).strip()
|
|
163
|
+
return ''
|
|
164
|
+
|
|
165
|
+
def _tool_event(self, obj: dict[str, Any], *, session_id: str | None) -> AdapterEvent:
|
|
166
|
+
part = obj.get('part', {}) if isinstance(obj.get('part'), dict) else {}
|
|
167
|
+
state = part.get('state', {}) if isinstance(part.get('state'), dict) else {}
|
|
168
|
+
tool = str(part.get('tool') or '')
|
|
169
|
+
metadata = state.get('metadata', {}) if isinstance(state.get('metadata'), dict) else {}
|
|
170
|
+
raw_input = state.get('input', {}) if isinstance(state.get('input'), dict) else {}
|
|
171
|
+
payload: dict[str, Any] = {
|
|
172
|
+
'tool': tool,
|
|
173
|
+
'status': state.get('status'),
|
|
174
|
+
'title': state.get('title') or metadata.get('description') or '',
|
|
175
|
+
}
|
|
176
|
+
if session_id:
|
|
177
|
+
payload['session_id'] = session_id
|
|
178
|
+
|
|
179
|
+
level = 'info'
|
|
180
|
+
if tool == 'bash':
|
|
181
|
+
command = str(raw_input.get('command') or '').strip()
|
|
182
|
+
payload['command_preview'] = self._truncate(command, 220)
|
|
183
|
+
exit_code = metadata.get('exit')
|
|
184
|
+
payload['exit_code'] = exit_code
|
|
185
|
+
output = str(metadata.get('output') or state.get('output') or '').strip()
|
|
186
|
+
if output:
|
|
187
|
+
payload['output_preview'] = self._truncate(output, 360)
|
|
188
|
+
reason = forbidden_command_reason(command)
|
|
189
|
+
if reason:
|
|
190
|
+
payload['policy_violation'] = True
|
|
191
|
+
payload['warning_reason'] = reason
|
|
192
|
+
level = 'error'
|
|
193
|
+
elif BLOCKED_MARKER in output:
|
|
194
|
+
payload['policy_violation'] = True
|
|
195
|
+
payload['warning_reason'] = 'command was blocked by static review policy'
|
|
196
|
+
level = 'error'
|
|
197
|
+
elif isinstance(exit_code, int) and exit_code != 0:
|
|
198
|
+
payload['warning_reason'] = 'command exited non-zero'
|
|
199
|
+
level = 'warning'
|
|
200
|
+
elif 'timeout' in output.lower() or 'timed out' in output.lower():
|
|
201
|
+
payload['warning_reason'] = 'command timed out'
|
|
202
|
+
level = 'warning'
|
|
203
|
+
elif tool == 'read':
|
|
204
|
+
payload['file_path'] = raw_input.get('filePath')
|
|
205
|
+
elif tool == 'grep':
|
|
206
|
+
payload['pattern'] = raw_input.get('pattern')
|
|
207
|
+
payload['path'] = raw_input.get('path')
|
|
208
|
+
matches = metadata.get('matches')
|
|
209
|
+
if matches is not None:
|
|
210
|
+
payload['matches'] = matches
|
|
211
|
+
output = str(state.get('output') or '').strip()
|
|
212
|
+
if output and output != 'No files found':
|
|
213
|
+
payload['output_preview'] = self._truncate(output, 260)
|
|
214
|
+
else:
|
|
215
|
+
output = str(state.get('output') or '').strip()
|
|
216
|
+
if output:
|
|
217
|
+
payload['output_preview'] = self._truncate(output, 260)
|
|
218
|
+
|
|
219
|
+
return AdapterEvent(kind='agent.tool_use', level=level, payload=payload)
|
|
220
|
+
|
|
221
|
+
def _step_finish_event(self, obj: dict[str, Any], *, session_id: str | None) -> AdapterEvent:
|
|
222
|
+
part = obj.get('part', {}) if isinstance(obj.get('part'), dict) else {}
|
|
223
|
+
tokens = part.get('tokens', {}) if isinstance(part.get('tokens'), dict) else {}
|
|
224
|
+
payload: dict[str, Any] = {
|
|
225
|
+
'reason': part.get('reason'),
|
|
226
|
+
'cost': part.get('cost'),
|
|
227
|
+
'token_total': tokens.get('total'),
|
|
228
|
+
'token_output': tokens.get('output'),
|
|
229
|
+
'token_reasoning': tokens.get('reasoning'),
|
|
230
|
+
}
|
|
231
|
+
if session_id:
|
|
232
|
+
payload['session_id'] = session_id
|
|
233
|
+
return AdapterEvent(kind='agent.step_finish', payload=payload)
|
|
234
|
+
|
|
235
|
+
@staticmethod
|
|
236
|
+
def _truncate(value: str, limit: int) -> str:
|
|
237
|
+
text = value.strip()
|
|
238
|
+
if len(text) <= limit:
|
|
239
|
+
return text
|
|
240
|
+
return text[:limit].rstrip() + '...'
|