aura-code 0.3.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 +21 -0
- package/README.md +137 -0
- package/dist/agent/context.d.ts +13 -0
- package/dist/agent/context.js +183 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/loop.d.ts +60 -0
- package/dist/agent/loop.js +228 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/session-store.d.ts +30 -0
- package/dist/agent/session-store.js +178 -0
- package/dist/agent/session-store.js.map +1 -0
- package/dist/agent/spawner.d.ts +57 -0
- package/dist/agent/spawner.js +112 -0
- package/dist/agent/spawner.js.map +1 -0
- package/dist/agent/system-prompt.d.ts +3 -0
- package/dist/agent/system-prompt.js +100 -0
- package/dist/agent/system-prompt.js.map +1 -0
- package/dist/architect/engine.d.ts +47 -0
- package/dist/architect/engine.js +217 -0
- package/dist/architect/engine.js.map +1 -0
- package/dist/architect/types.d.ts +61 -0
- package/dist/architect/types.js +6 -0
- package/dist/architect/types.js.map +1 -0
- package/dist/cli/diamond.d.ts +1 -0
- package/dist/cli/diamond.js +23 -0
- package/dist/cli/diamond.js.map +1 -0
- package/dist/cli/display.d.ts +44 -0
- package/dist/cli/display.js +234 -0
- package/dist/cli/display.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +1734 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/defaults.d.ts +46 -0
- package/dist/config/defaults.js +106 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/project-config.d.ts +90 -0
- package/dist/config/project-config.js +141 -0
- package/dist/config/project-config.js.map +1 -0
- package/dist/harness/proposer.d.ts +26 -0
- package/dist/harness/proposer.js +204 -0
- package/dist/harness/proposer.js.map +1 -0
- package/dist/harness/weakness-miner.d.ts +28 -0
- package/dist/harness/weakness-miner.js +359 -0
- package/dist/harness/weakness-miner.js.map +1 -0
- package/dist/integrations/harnesses.d.ts +23 -0
- package/dist/integrations/harnesses.js +161 -0
- package/dist/integrations/harnesses.js.map +1 -0
- package/dist/orchestration/competence.d.ts +53 -0
- package/dist/orchestration/competence.js +181 -0
- package/dist/orchestration/competence.js.map +1 -0
- package/dist/orchestration/executor.d.ts +42 -0
- package/dist/orchestration/executor.js +206 -0
- package/dist/orchestration/executor.js.map +1 -0
- package/dist/orchestration/index.d.ts +20 -0
- package/dist/orchestration/index.js +39 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/orchestrator-prompts.d.ts +11 -0
- package/dist/orchestration/orchestrator-prompts.js +153 -0
- package/dist/orchestration/orchestrator-prompts.js.map +1 -0
- package/dist/orchestration/orchestrator.d.ts +27 -0
- package/dist/orchestration/orchestrator.js +169 -0
- package/dist/orchestration/orchestrator.js.map +1 -0
- package/dist/orchestration/plan-store.d.ts +53 -0
- package/dist/orchestration/plan-store.js +176 -0
- package/dist/orchestration/plan-store.js.map +1 -0
- package/dist/orchestration/router-prompts.d.ts +6 -0
- package/dist/orchestration/router-prompts.js +55 -0
- package/dist/orchestration/router-prompts.js.map +1 -0
- package/dist/orchestration/router.d.ts +23 -0
- package/dist/orchestration/router.js +70 -0
- package/dist/orchestration/router.js.map +1 -0
- package/dist/orchestration/ruby-detect.d.ts +6 -0
- package/dist/orchestration/ruby-detect.js +130 -0
- package/dist/orchestration/ruby-detect.js.map +1 -0
- package/dist/orchestration/ruby-types.d.ts +44 -0
- package/dist/orchestration/ruby-types.js +6 -0
- package/dist/orchestration/ruby-types.js.map +1 -0
- package/dist/orchestration/specialist-prompts.d.ts +19 -0
- package/dist/orchestration/specialist-prompts.js +143 -0
- package/dist/orchestration/specialist-prompts.js.map +1 -0
- package/dist/orchestration/specialists.d.ts +66 -0
- package/dist/orchestration/specialists.js +175 -0
- package/dist/orchestration/specialists.js.map +1 -0
- package/dist/orchestration/types.d.ts +82 -0
- package/dist/orchestration/types.js +6 -0
- package/dist/orchestration/types.js.map +1 -0
- package/dist/perception/extractor.d.ts +7 -0
- package/dist/perception/extractor.js +521 -0
- package/dist/perception/extractor.js.map +1 -0
- package/dist/perception/graph-store.d.ts +25 -0
- package/dist/perception/graph-store.js +117 -0
- package/dist/perception/graph-store.js.map +1 -0
- package/dist/perception/index.d.ts +4 -0
- package/dist/perception/index.js +18 -0
- package/dist/perception/index.js.map +1 -0
- package/dist/perception/queries.d.ts +29 -0
- package/dist/perception/queries.js +354 -0
- package/dist/perception/queries.js.map +1 -0
- package/dist/perception/types.d.ts +103 -0
- package/dist/perception/types.js +6 -0
- package/dist/perception/types.js.map +1 -0
- package/dist/providers/anthropic.d.ts +11 -0
- package/dist/providers/anthropic.js +172 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/factory.d.ts +58 -0
- package/dist/providers/factory.js +354 -0
- package/dist/providers/factory.js.map +1 -0
- package/dist/providers/fallback.d.ts +24 -0
- package/dist/providers/fallback.js +72 -0
- package/dist/providers/fallback.js.map +1 -0
- package/dist/providers/google.d.ts +11 -0
- package/dist/providers/google.js +129 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +24 -0
- package/dist/providers/openai-compatible.js +216 -0
- package/dist/providers/openai-compatible.js.map +1 -0
- package/dist/providers/resilient-factory.d.ts +24 -0
- package/dist/providers/resilient-factory.js +57 -0
- package/dist/providers/resilient-factory.js.map +1 -0
- package/dist/providers/resilient.d.ts +63 -0
- package/dist/providers/resilient.js +145 -0
- package/dist/providers/resilient.js.map +1 -0
- package/dist/providers/types.d.ts +84 -0
- package/dist/providers/types.js +6 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/ruby/alternator.d.ts +40 -0
- package/dist/ruby/alternator.js +233 -0
- package/dist/ruby/alternator.js.map +1 -0
- package/dist/ruby/competence.d.ts +34 -0
- package/dist/ruby/competence.js +264 -0
- package/dist/ruby/competence.js.map +1 -0
- package/dist/ruby/episode-capture.d.ts +56 -0
- package/dist/ruby/episode-capture.js +193 -0
- package/dist/ruby/episode-capture.js.map +1 -0
- package/dist/ruby/fine-tune.d.ts +16 -0
- package/dist/ruby/fine-tune.js +253 -0
- package/dist/ruby/fine-tune.js.map +1 -0
- package/dist/ruby/index.d.ts +10 -0
- package/dist/ruby/index.js +26 -0
- package/dist/ruby/index.js.map +1 -0
- package/dist/ruby/ruby-model.d.ts +36 -0
- package/dist/ruby/ruby-model.js +81 -0
- package/dist/ruby/ruby-model.js.map +1 -0
- package/dist/ruby/training-data.d.ts +11 -0
- package/dist/ruby/training-data.js +107 -0
- package/dist/ruby/training-data.js.map +1 -0
- package/dist/ruby/types.d.ts +136 -0
- package/dist/ruby/types.js +20 -0
- package/dist/ruby/types.js.map +1 -0
- package/dist/safety/permissions.d.ts +32 -0
- package/dist/safety/permissions.js +304 -0
- package/dist/safety/permissions.js.map +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +342 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/session.d.ts +22 -0
- package/dist/server/session.js +16 -0
- package/dist/server/session.js.map +1 -0
- package/dist/setup/first-run.d.ts +41 -0
- package/dist/setup/first-run.js +386 -0
- package/dist/setup/first-run.js.map +1 -0
- package/dist/setup/global-config.d.ts +19 -0
- package/dist/setup/global-config.js +97 -0
- package/dist/setup/global-config.js.map +1 -0
- package/dist/tools/audio-transcribe.d.ts +8 -0
- package/dist/tools/audio-transcribe.js +156 -0
- package/dist/tools/audio-transcribe.js.map +1 -0
- package/dist/tools/browser.d.ts +15 -0
- package/dist/tools/browser.js +241 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/calendar.d.ts +12 -0
- package/dist/tools/calendar.js +196 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/clipboard.d.ts +7 -0
- package/dist/tools/clipboard.js +90 -0
- package/dist/tools/clipboard.js.map +1 -0
- package/dist/tools/cron.d.ts +10 -0
- package/dist/tools/cron.js +167 -0
- package/dist/tools/cron.js.map +1 -0
- package/dist/tools/edit-file.d.ts +6 -0
- package/dist/tools/edit-file.js +98 -0
- package/dist/tools/edit-file.js.map +1 -0
- package/dist/tools/email.d.ts +11 -0
- package/dist/tools/email.js +153 -0
- package/dist/tools/email.js.map +1 -0
- package/dist/tools/git.d.ts +1 -0
- package/dist/tools/git.js +7 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/http-request.d.ts +12 -0
- package/dist/tools/http-request.js +91 -0
- package/dist/tools/http-request.js.map +1 -0
- package/dist/tools/image-read.d.ts +7 -0
- package/dist/tools/image-read.js +125 -0
- package/dist/tools/image-read.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +201 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-dir.d.ts +1 -0
- package/dist/tools/list-dir.js +6 -0
- package/dist/tools/list-dir.js.map +1 -0
- package/dist/tools/mcp.d.ts +11 -0
- package/dist/tools/mcp.js +356 -0
- package/dist/tools/mcp.js.map +1 -0
- package/dist/tools/memory.d.ts +9 -0
- package/dist/tools/memory.js +124 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/notify.d.ts +9 -0
- package/dist/tools/notify.js +40 -0
- package/dist/tools/notify.js.map +1 -0
- package/dist/tools/read-file.d.ts +6 -0
- package/dist/tools/read-file.js +76 -0
- package/dist/tools/read-file.js.map +1 -0
- package/dist/tools/run-shell.d.ts +1 -0
- package/dist/tools/run-shell.js +6 -0
- package/dist/tools/run-shell.js.map +1 -0
- package/dist/tools/run-tests.d.ts +1 -0
- package/dist/tools/run-tests.js +6 -0
- package/dist/tools/run-tests.js.map +1 -0
- package/dist/tools/search-code.d.ts +1 -0
- package/dist/tools/search-code.js +6 -0
- package/dist/tools/search-code.js.map +1 -0
- package/dist/tools/telegram-bot.d.ts +2 -0
- package/dist/tools/telegram-bot.js +693 -0
- package/dist/tools/telegram-bot.js.map +1 -0
- package/dist/tools/telegram-safety.d.ts +52 -0
- package/dist/tools/telegram-safety.js +189 -0
- package/dist/tools/telegram-safety.js.map +1 -0
- package/dist/tools/telegram.d.ts +16 -0
- package/dist/tools/telegram.js +227 -0
- package/dist/tools/telegram.js.map +1 -0
- package/dist/tools/tools.d.ts +48 -0
- package/dist/tools/tools.js +328 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +11 -0
- package/dist/tools/web-fetch.js +119 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +8 -0
- package/dist/tools/web-search.js +81 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/whatsapp.d.ts +10 -0
- package/dist/tools/whatsapp.js +222 -0
- package/dist/tools/whatsapp.js.map +1 -0
- package/dist/tools/write-file.d.ts +1 -0
- package/dist/tools/write-file.js +6 -0
- package/dist/tools/write-file.js.map +1 -0
- package/dist/tools/youtube-transcript.d.ts +9 -0
- package/dist/tools/youtube-transcript.js +200 -0
- package/dist/tools/youtube-transcript.js.map +1 -0
- package/dist/util/circuit-breaker.d.ts +44 -0
- package/dist/util/circuit-breaker.js +78 -0
- package/dist/util/circuit-breaker.js.map +1 -0
- package/dist/util/env.d.ts +18 -0
- package/dist/util/env.js +39 -0
- package/dist/util/env.js.map +1 -0
- package/dist/util/errors.d.ts +42 -0
- package/dist/util/errors.js +121 -0
- package/dist/util/errors.js.map +1 -0
- package/dist/util/rate-limiter.d.ts +71 -0
- package/dist/util/rate-limiter.js +141 -0
- package/dist/util/rate-limiter.js.map +1 -0
- package/dist/util/retry.d.ts +30 -0
- package/dist/util/retry.js +57 -0
- package/dist/util/retry.js.map +1 -0
- package/dist/util/sanitize.d.ts +16 -0
- package/dist/util/sanitize.js +255 -0
- package/dist/util/sanitize.js.map +1 -0
- package/dist/verify/checks.d.ts +21 -0
- package/dist/verify/checks.js +311 -0
- package/dist/verify/checks.js.map +1 -0
- package/dist/verify/index.d.ts +33 -0
- package/dist/verify/index.js +127 -0
- package/dist/verify/index.js.map +1 -0
- package/dist/verify/types.d.ts +20 -0
- package/dist/verify/types.js +3 -0
- package/dist/verify/types.js.map +1 -0
- package/dist/versioncheck.d.ts +22 -0
- package/dist/versioncheck.js +203 -0
- package/dist/versioncheck.js.map +1 -0
- package/dist/viz/index.d.ts +2 -0
- package/dist/viz/index.js +733 -0
- package/dist/viz/index.js.map +1 -0
- package/dist/workflows/engine.d.ts +46 -0
- package/dist/workflows/engine.js +320 -0
- package/dist/workflows/engine.js.map +1 -0
- package/dist/workflows/types.d.ts +92 -0
- package/dist/workflows/types.js +6 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dušan Milosavljević
|
|
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
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./README-hero.jpg" alt="Aura">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<h1 align="center">Aura Code — Autonomous Coding Agent</h1>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<em>I don't try. I verify.</em>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/aura-code"><img src="https://img.shields.io/npm/v/aura-code?color=cc0000&label=npm&logo=npm" alt="npm version"></a>
|
|
14
|
+
<a href="https://github.com/milodule3-debug/aura-code/actions/workflows/ci.yml"><img src="https://github.com/milodule3-debug/aura-code/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/tests-734%2B-brightgreen" alt="734+ tests">
|
|
16
|
+
<a href="https://github.com/milodule3-debug/aura-code/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18-339933?logo=node.js&logoColor=white" alt="Node.js 18+">
|
|
18
|
+
<a href="https://github.com/milodule3-debug/aura-code"><img src="https://img.shields.io/github/stars/milodule3-debug/aura-code?style=social" alt="GitHub Stars"></a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="./docs/ARCHITECTURE.md">
|
|
23
|
+
<img src="./assets/architecture-diagram.png" alt="Architecture Diagram" width="800">
|
|
24
|
+
</a>
|
|
25
|
+
<br>
|
|
26
|
+
<em><a href="./docs/ARCHITECTURE.md">View full architecture documentation →</a></em>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<img src="./assets/demo.gif" alt="Aura Code CLI Demo" width="800">
|
|
31
|
+
<br>
|
|
32
|
+
<em>CLI demo — help, models, and version overview</em>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## What is Aura Code?
|
|
38
|
+
|
|
39
|
+
Aura Code was developed using AI-assisted engineering workflows, with multiple AI agents contributing to design, implementation, testing, and verification. Written in TypeScript — not related to the Ruby programming language.
|
|
40
|
+
|
|
41
|
+
Built on the **Praktess** framework — from Ancient Greek: *she who acts and executes*.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g aura-code
|
|
49
|
+
aura 'your task here'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Set at least one API key before running:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
export ANTHROPIC_API_KEY="sk-ant-..." # Claude
|
|
56
|
+
export OPENAI_API_KEY="sk-..." # GPT
|
|
57
|
+
export GOOGLE_API_KEY="..." # Gemini
|
|
58
|
+
export XIAOMI_API_KEY="tp-..." # MiMo
|
|
59
|
+
# Local — no API key needed:
|
|
60
|
+
# ollama pull qwen2.5-coder:1.5b
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## What Aura Does
|
|
66
|
+
|
|
67
|
+
1. **Reads** your codebase — files, structure, dependencies
|
|
68
|
+
2. **Plans** a strategy — decides what to change and how
|
|
69
|
+
3. **Executes** — writes code, runs commands, makes edits
|
|
70
|
+
4. **Verifies** — runs tests, checks file integrity, confirms changes
|
|
71
|
+
5. **Reports** — summarizes what was done and what passed
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Modes
|
|
76
|
+
|
|
77
|
+
| Mode | What it does |
|
|
78
|
+
|------|-------------|
|
|
79
|
+
| `normal` | Single-agent loop: read → plan → execute → verify |
|
|
80
|
+
| `orchestrate` | Multi-agent: Researcher → Coder → Reviewer |
|
|
81
|
+
| `architect` | High-level design and planning before implementation |
|
|
82
|
+
| `verify` | Post-task checks with automatic retry on failure |
|
|
83
|
+
| `analyze` | Scan session history for failure patterns |
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
aura 'fix the bug' # normal
|
|
87
|
+
aura --orchestrate 'add error handling to all endpoints' # orchestrate
|
|
88
|
+
aura --architect 'design the new auth system' # architect
|
|
89
|
+
aura --verify --test-command "npm test" 'fix the tests' # verify
|
|
90
|
+
aura --analyze # analyze
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Providers
|
|
96
|
+
|
|
97
|
+
| Provider | Models |
|
|
98
|
+
|----------|--------|
|
|
99
|
+
| **Claude** (Anthropic) | Opus, Sonnet, Haiku |
|
|
100
|
+
| **GPT** (OpenAI) | gpt-4o, gpt-4o-mini |
|
|
101
|
+
| **Gemini** (Google) | gemini-2.5-pro, gemini-2.5-flash |
|
|
102
|
+
| **MiMo** (Xiaomi) | mimo-v2.5-pro, mimo-v2.5 |
|
|
103
|
+
| **DeepSeek** (OpenRouter) | deepseek-v4-pro, deepseek-v4-flash:free |
|
|
104
|
+
| **Ollama** (Local) | Any local model — no API key needed |
|
|
105
|
+
|
|
106
|
+
Any OpenAI-compatible endpoint also works via `openrouter/<model>`.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Stats
|
|
111
|
+
|
|
112
|
+
| Metric | Value |
|
|
113
|
+
|--------|-------|
|
|
114
|
+
| Tests | 734+ passing, 0 failures |
|
|
115
|
+
| Version | v0.3.0 |
|
|
116
|
+
| Language | TypeScript (strict) |
|
|
117
|
+
| License | MIT |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Repository
|
|
122
|
+
|
|
123
|
+
GitHub: https://github.com/milodule3-debug/aura-code
|
|
124
|
+
(Repo renamed from milodule3-debug/rubyness — existing clone URLs redirect automatically)
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Links
|
|
129
|
+
|
|
130
|
+
- [Lean Progress IQ](https://lean-progress-iq-site.vercel.app)
|
|
131
|
+
- [Aura Manifesto](her-rubyness-manifesto.html)
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
<p align="center">
|
|
136
|
+
Built by <a href="https://lean-progress-iq-site.vercel.app">Lean Progress IQ</a>
|
|
137
|
+
</p>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ProjectContext {
|
|
2
|
+
root: string;
|
|
3
|
+
name: string;
|
|
4
|
+
language: string;
|
|
5
|
+
framework: string;
|
|
6
|
+
readme: string;
|
|
7
|
+
tree: string;
|
|
8
|
+
config: string;
|
|
9
|
+
recentCommits: string;
|
|
10
|
+
graphSummary?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function loadProjectContext(cwd: string): Promise<ProjectContext>;
|
|
13
|
+
export declare function loadGraphSummary(root: string): string | undefined;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadProjectContext = loadProjectContext;
|
|
37
|
+
exports.loadGraphSummary = loadGraphSummary;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const defaults_js_1 = require("../config/defaults.js");
|
|
42
|
+
async function loadProjectContext(cwd) {
|
|
43
|
+
const root = path.resolve(cwd);
|
|
44
|
+
const name = detectProjectName(root);
|
|
45
|
+
const { language, framework } = detectStack(root);
|
|
46
|
+
return {
|
|
47
|
+
root,
|
|
48
|
+
name,
|
|
49
|
+
language,
|
|
50
|
+
framework,
|
|
51
|
+
readme: readTruncated(root, ['README.md', 'README.txt', 'README.rst'], 2000),
|
|
52
|
+
tree: buildTree(root),
|
|
53
|
+
config: readConfig(root),
|
|
54
|
+
recentCommits: readGitLog(root),
|
|
55
|
+
graphSummary: loadGraphSummary(root),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function loadGraphSummary(root) {
|
|
59
|
+
const graphPath = path.join(root, 'graphify-out', 'graph.json');
|
|
60
|
+
if (!fs.existsSync(graphPath))
|
|
61
|
+
return undefined;
|
|
62
|
+
try {
|
|
63
|
+
const raw = fs.readFileSync(graphPath, 'utf8');
|
|
64
|
+
const graph = JSON.parse(raw);
|
|
65
|
+
if (!Array.isArray(graph.nodes) || graph.nodes.length === 0)
|
|
66
|
+
return undefined;
|
|
67
|
+
const top = graph.nodes.slice(0, 40);
|
|
68
|
+
const lines = top.map(n => {
|
|
69
|
+
const loc = n.file ? ` (${n.file})` : '';
|
|
70
|
+
const summary = n.summary ? `: ${n.summary.slice(0, 120)}` : '';
|
|
71
|
+
return ` ${n.type ?? 'node'} ${n.label ?? n.id}${loc}${summary}`;
|
|
72
|
+
});
|
|
73
|
+
return `Top ${top.length} of ${graph.nodes.length} nodes:\n${lines.join('\n')}`;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function detectProjectName(root) {
|
|
80
|
+
// Try package.json
|
|
81
|
+
const pkg = path.join(root, 'package.json');
|
|
82
|
+
if (fs.existsSync(pkg)) {
|
|
83
|
+
try {
|
|
84
|
+
return JSON.parse(fs.readFileSync(pkg, 'utf8')).name ?? path.basename(root);
|
|
85
|
+
}
|
|
86
|
+
catch { /* fallthrough */ }
|
|
87
|
+
}
|
|
88
|
+
return path.basename(root);
|
|
89
|
+
}
|
|
90
|
+
function detectStack(root) {
|
|
91
|
+
if (fs.existsSync(path.join(root, 'package.json'))) {
|
|
92
|
+
try {
|
|
93
|
+
const p = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
94
|
+
const deps = { ...(p.dependencies ?? {}), ...(p.devDependencies ?? {}) };
|
|
95
|
+
const fw = deps.next ? 'Next.js' :
|
|
96
|
+
deps.react ? 'React' :
|
|
97
|
+
deps.vue ? 'Vue' :
|
|
98
|
+
deps.express || deps.fastify ? 'Node.js API' :
|
|
99
|
+
deps.electron ? 'Electron' :
|
|
100
|
+
deps['@tauri-apps/cli'] ? 'Tauri' : 'Node.js';
|
|
101
|
+
const lang = deps.typescript || p.scripts?.build?.includes('tsc') ? 'TypeScript' : 'JavaScript';
|
|
102
|
+
return { language: lang, framework: fw };
|
|
103
|
+
}
|
|
104
|
+
catch { /* fallthrough */ }
|
|
105
|
+
}
|
|
106
|
+
if (fs.existsSync(path.join(root, 'requirements.txt')) || fs.existsSync(path.join(root, 'pyproject.toml'))) {
|
|
107
|
+
return { language: 'Python', framework: 'Python' };
|
|
108
|
+
}
|
|
109
|
+
if (fs.existsSync(path.join(root, 'Cargo.toml'))) {
|
|
110
|
+
return { language: 'Rust', framework: 'Rust' };
|
|
111
|
+
}
|
|
112
|
+
if (fs.existsSync(path.join(root, 'go.mod'))) {
|
|
113
|
+
return { language: 'Go', framework: 'Go' };
|
|
114
|
+
}
|
|
115
|
+
return { language: 'Unknown', framework: 'Unknown' };
|
|
116
|
+
}
|
|
117
|
+
function readTruncated(root, names, maxChars) {
|
|
118
|
+
for (const name of names) {
|
|
119
|
+
const p = path.join(root, name);
|
|
120
|
+
if (fs.existsSync(p)) {
|
|
121
|
+
try {
|
|
122
|
+
const content = fs.readFileSync(p, 'utf8');
|
|
123
|
+
return content.length > maxChars
|
|
124
|
+
? content.slice(0, maxChars) + '\n\n[...truncated]'
|
|
125
|
+
: content;
|
|
126
|
+
}
|
|
127
|
+
catch { /* next */ }
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return '(no README found)';
|
|
131
|
+
}
|
|
132
|
+
function buildTree(root) {
|
|
133
|
+
const lines = [path.basename(root) + '/'];
|
|
134
|
+
function walk(dir, prefix, depth) {
|
|
135
|
+
if (depth > 3)
|
|
136
|
+
return;
|
|
137
|
+
let entries;
|
|
138
|
+
try {
|
|
139
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const filtered = entries.filter(e => !defaults_js_1.IGNORE_PATTERNS.some(p => e.name === p || (p.startsWith('*') && e.name.endsWith(p.slice(1))))
|
|
145
|
+
&& !e.name.startsWith('.'));
|
|
146
|
+
filtered.sort((a, b) => {
|
|
147
|
+
if (a.isDirectory() !== b.isDirectory())
|
|
148
|
+
return a.isDirectory() ? -1 : 1;
|
|
149
|
+
return a.name.localeCompare(b.name);
|
|
150
|
+
});
|
|
151
|
+
for (let i = 0; i < filtered.length; i++) {
|
|
152
|
+
const e = filtered[i];
|
|
153
|
+
const last = i === filtered.length - 1;
|
|
154
|
+
lines.push(`${prefix}${last ? '└── ' : '├── '}${e.name}${e.isDirectory() ? '/' : ''}`);
|
|
155
|
+
if (e.isDirectory())
|
|
156
|
+
walk(path.join(dir, e.name), prefix + (last ? ' ' : '│ '), depth + 1);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
walk(root, '', 1);
|
|
160
|
+
return lines.join('\n');
|
|
161
|
+
}
|
|
162
|
+
function readConfig(root) {
|
|
163
|
+
for (const name of ['package.json', 'requirements.txt', 'Cargo.toml', 'go.mod', 'pyproject.toml']) {
|
|
164
|
+
const p = path.join(root, name);
|
|
165
|
+
if (fs.existsSync(p)) {
|
|
166
|
+
try {
|
|
167
|
+
const content = fs.readFileSync(p, 'utf8');
|
|
168
|
+
return `${name}:\n${content.slice(0, 1500)}${content.length > 1500 ? '\n[...truncated]' : ''}`;
|
|
169
|
+
}
|
|
170
|
+
catch { /* next */ }
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return '(no config file found)';
|
|
174
|
+
}
|
|
175
|
+
function readGitLog(root) {
|
|
176
|
+
try {
|
|
177
|
+
return (0, child_process_1.execSync)('git log --oneline -10', { cwd: root, encoding: 'utf8' }).trim();
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return '(not a git repository)';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/agent/context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;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,OAAO,GAAG,IAAI,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YACjG,CAAC;YAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,OAAO,IAAA,wBAAQ,EAAC,uBAAuB,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACnF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,wBAAwB,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { LLMProvider, HistoryMessage } from '../providers/types.js';
|
|
2
|
+
import { PermissionSystem } from '../safety/permissions.js';
|
|
3
|
+
import type { ProjectContext } from './context.js';
|
|
4
|
+
import type { Display } from '../cli/display.js';
|
|
5
|
+
import type { VerificationConfig } from '../verify/types.js';
|
|
6
|
+
export interface LoopOptions {
|
|
7
|
+
provider: LLMProvider;
|
|
8
|
+
task: string;
|
|
9
|
+
context: ProjectContext;
|
|
10
|
+
permissions: PermissionSystem;
|
|
11
|
+
display: Display;
|
|
12
|
+
maxTurns?: number;
|
|
13
|
+
/** Optional model id for token pricing — falls back to provider.model */
|
|
14
|
+
pricingModel?: string;
|
|
15
|
+
/** Path to a session file to persist history to; undefined = ephemeral */
|
|
16
|
+
sessionPath?: string;
|
|
17
|
+
/** Pre-existing conversation history to resume from (e.g. loaded session). */
|
|
18
|
+
initialHistory?: HistoryMessage[];
|
|
19
|
+
/** Base config passed to spawned sub-agents. If undefined, spawn_task returns an error. */
|
|
20
|
+
spawnConfig?: {
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
baseUrl?: string;
|
|
23
|
+
};
|
|
24
|
+
/** Disables subagent tool entirely (e.g. for tests) */
|
|
25
|
+
disableSpawn?: boolean;
|
|
26
|
+
/** Internal: skip post-task verification (used by runWithVerification wrapper). */
|
|
27
|
+
verify?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Custom confirmation function for destructive operations.
|
|
30
|
+
* Defaults to terminal-based confirm() from permissions.
|
|
31
|
+
* Telegram bot overrides this to send approval requests via Telegram messages.
|
|
32
|
+
*/
|
|
33
|
+
confirmFn?: (message: string) => Promise<boolean>;
|
|
34
|
+
}
|
|
35
|
+
export interface LoopResult {
|
|
36
|
+
success: boolean;
|
|
37
|
+
summary: string;
|
|
38
|
+
turns: number;
|
|
39
|
+
toolCallCount: number;
|
|
40
|
+
usage: TokenUsage;
|
|
41
|
+
costUsd: number;
|
|
42
|
+
/** Full conversation history after the loop (including prior turns if resumed). */
|
|
43
|
+
history: HistoryMessage[];
|
|
44
|
+
/** Every tool call made during this loop run — used by the verify layer. */
|
|
45
|
+
toolCallLog: Array<{
|
|
46
|
+
name: string;
|
|
47
|
+
input: Record<string, unknown>;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
export interface TokenUsage {
|
|
51
|
+
inputTokens: number;
|
|
52
|
+
outputTokens: number;
|
|
53
|
+
totalTokens: number;
|
|
54
|
+
}
|
|
55
|
+
export declare function runAgentLoop(opts: LoopOptions): Promise<LoopResult>;
|
|
56
|
+
export declare function runAgentLoopVerified(opts: LoopOptions, config: VerificationConfig, projectRoot: string): Promise<{
|
|
57
|
+
loopResult: LoopResult;
|
|
58
|
+
verifyResult: import('../verify/types.js').VerificationResult;
|
|
59
|
+
totalAttempts: number;
|
|
60
|
+
}>;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runAgentLoop = runAgentLoop;
|
|
37
|
+
exports.runAgentLoopVerified = runAgentLoopVerified;
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const index_js_1 = require("../tools/index.js");
|
|
40
|
+
const permissions_js_1 = require("../safety/permissions.js");
|
|
41
|
+
const system_prompt_js_1 = require("./system-prompt.js");
|
|
42
|
+
const defaults_js_1 = require("../config/defaults.js");
|
|
43
|
+
const session_store_js_1 = require("./session-store.js");
|
|
44
|
+
const spawner_js_1 = require("./spawner.js");
|
|
45
|
+
const PRICING_USD_PER_MTOK = {
|
|
46
|
+
'claude-opus-4-5-20251001': { in: 15, out: 75 },
|
|
47
|
+
'claude-sonnet-4-5-20251001': { in: 3, out: 15 },
|
|
48
|
+
'claude-haiku-4-5-20251001': { in: 0.8, out: 4 },
|
|
49
|
+
'gpt-4o': { in: 2.5, out: 10 },
|
|
50
|
+
'gpt-4o-mini': { in: 0.15, out: 0.6 },
|
|
51
|
+
'gemini-2.5-pro': { in: 1.25, out: 10 },
|
|
52
|
+
'gemini-2.5-flash': { in: 0.075, out: 0.3 },
|
|
53
|
+
'grok-beta': { in: 5, out: 15 },
|
|
54
|
+
'mimo-v2.5-pro': { in: 1, out: 4 },
|
|
55
|
+
'mimo-v2.5': { in: 0.5, out: 2 },
|
|
56
|
+
'mimo-v2-flash': { in: 0.1, out: 0.4 },
|
|
57
|
+
};
|
|
58
|
+
function costFor(model, input, output) {
|
|
59
|
+
const p = PRICING_USD_PER_MTOK[model] ?? PRICING_USD_PER_MTOK[Object.keys(PRICING_USD_PER_MTOK).find(k => model.includes(k.split('-')[1] ?? '') && k.startsWith(model.split('-')[0] ?? '')) ?? ''] ?? { in: 0, out: 0 };
|
|
60
|
+
return (input / 1_000_000) * p.in + (output / 1_000_000) * p.out;
|
|
61
|
+
}
|
|
62
|
+
async function runAgentLoop(opts) {
|
|
63
|
+
const { provider, task, context, permissions, display } = opts;
|
|
64
|
+
const maxTurns = opts.maxTurns ?? defaults_js_1.DEFAULTS.maxTurns;
|
|
65
|
+
const pricingModel = opts.pricingModel ?? provider.model;
|
|
66
|
+
const system = (0, system_prompt_js_1.buildSystemPrompt)(context, provider.name);
|
|
67
|
+
const history = [
|
|
68
|
+
...(opts.initialHistory ?? []),
|
|
69
|
+
{ role: 'user', content: task },
|
|
70
|
+
];
|
|
71
|
+
let turns = 0;
|
|
72
|
+
let toolCallCount = 0;
|
|
73
|
+
const usage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
74
|
+
if (!opts.disableSpawn) {
|
|
75
|
+
(0, spawner_js_1.registerSpawner)((0, spawner_js_1.makeDefaultSpawner)(context, opts.spawnConfig ?? {}, display));
|
|
76
|
+
}
|
|
77
|
+
display.agentThinking();
|
|
78
|
+
try {
|
|
79
|
+
return await runLoopBody({ opts, provider, system, history, maxTurns, pricingModel, display, permissions, turns, toolCallCount, usage });
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
(0, spawner_js_1.clearSpawner)();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function runLoopBody(args) {
|
|
86
|
+
const { opts, provider, system, history, maxTurns, pricingModel, display, permissions } = args;
|
|
87
|
+
let { turns, toolCallCount, usage } = args;
|
|
88
|
+
const toolCallLog = [];
|
|
89
|
+
while (turns < maxTurns) {
|
|
90
|
+
turns++;
|
|
91
|
+
let responseText = '';
|
|
92
|
+
const responseToolCalls = [];
|
|
93
|
+
let finalResponse = null;
|
|
94
|
+
try {
|
|
95
|
+
const stream = provider.stream(system, history, index_js_1.TOOL_DEFINITIONS);
|
|
96
|
+
for await (const chunk of stream) {
|
|
97
|
+
switch (chunk.type) {
|
|
98
|
+
case 'text':
|
|
99
|
+
display.streamText(chunk.text);
|
|
100
|
+
responseText += chunk.text;
|
|
101
|
+
break;
|
|
102
|
+
case 'tool_start':
|
|
103
|
+
display.toolStart(chunk.name, chunk.id);
|
|
104
|
+
break;
|
|
105
|
+
case 'tool_input':
|
|
106
|
+
break;
|
|
107
|
+
case 'tool_end':
|
|
108
|
+
responseToolCalls.push(chunk.call);
|
|
109
|
+
break;
|
|
110
|
+
case 'done':
|
|
111
|
+
finalResponse = { stopReason: chunk.response.stopReason };
|
|
112
|
+
if (chunk.response.toolCalls.length > 0 && responseToolCalls.length === 0) {
|
|
113
|
+
responseToolCalls.push(...chunk.response.toolCalls);
|
|
114
|
+
}
|
|
115
|
+
const u = chunk.response.usage;
|
|
116
|
+
if (u) {
|
|
117
|
+
const inT = u.inputTokens ?? 0;
|
|
118
|
+
const outT = u.outputTokens ?? 0;
|
|
119
|
+
usage.inputTokens += inT;
|
|
120
|
+
usage.outputTokens += outT;
|
|
121
|
+
usage.totalTokens += inT + outT;
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
display.error(`Provider error: ${String(e)}`);
|
|
129
|
+
await persist(opts.sessionPath, history);
|
|
130
|
+
return {
|
|
131
|
+
success: false,
|
|
132
|
+
summary: `Provider error on turn ${turns}: ${String(e)}`,
|
|
133
|
+
turns, toolCallCount, usage, history, toolCallLog,
|
|
134
|
+
costUsd: costFor(pricingModel, usage.inputTokens, usage.outputTokens),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (responseText)
|
|
138
|
+
display.streamEnd();
|
|
139
|
+
const noProgress = !responseText && responseToolCalls.length === 0;
|
|
140
|
+
if (noProgress || finalResponse?.stopReason === 'done') {
|
|
141
|
+
history.push({ role: 'assistant', content: responseText });
|
|
142
|
+
await persist(opts.sessionPath, history);
|
|
143
|
+
return {
|
|
144
|
+
success: true,
|
|
145
|
+
summary: responseText || '(Task completed with no output)',
|
|
146
|
+
turns, toolCallCount, usage, history, toolCallLog,
|
|
147
|
+
costUsd: costFor(pricingModel, usage.inputTokens, usage.outputTokens),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (finalResponse?.stopReason === 'limit') {
|
|
151
|
+
display.warning('Hit token limit — stopping loop');
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
history.push({
|
|
155
|
+
role: 'assistant',
|
|
156
|
+
content: responseText,
|
|
157
|
+
toolCalls: responseToolCalls,
|
|
158
|
+
});
|
|
159
|
+
const toolResults = [];
|
|
160
|
+
for (const call of responseToolCalls) {
|
|
161
|
+
toolCallCount++;
|
|
162
|
+
display.toolCall(call.name, call.input);
|
|
163
|
+
let result;
|
|
164
|
+
let isError = false;
|
|
165
|
+
try {
|
|
166
|
+
const perm = permissions.check(call.name, call.input);
|
|
167
|
+
if (!perm.allowed) {
|
|
168
|
+
display.toolBlocked(call.name, perm.reason ?? 'not permitted');
|
|
169
|
+
toolResults.push({ id: call.id, name: call.name, content: `Blocked: ${perm.reason}`, isError: true });
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (perm.needsConfirm) {
|
|
173
|
+
const desc = formatCallForConfirmation(call);
|
|
174
|
+
const doConfirm = opts.confirmFn ?? permissions_js_1.confirm;
|
|
175
|
+
const approved = await doConfirm(`Allow: ${desc}?`);
|
|
176
|
+
if (!approved) {
|
|
177
|
+
display.toolBlocked(call.name, 'denied by user');
|
|
178
|
+
toolResults.push({ id: call.id, name: call.name, content: 'User denied this action.', isError: true });
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const startMs = Date.now();
|
|
183
|
+
result = await (0, index_js_1.executeTool)(call.name, call.input, opts.context.root);
|
|
184
|
+
const elapsed = Date.now() - startMs;
|
|
185
|
+
display.toolResult(call.name, result, elapsed);
|
|
186
|
+
isError = result.startsWith('Error:') || result.startsWith('Tool error');
|
|
187
|
+
toolCallLog.push({ name: call.name, input: call.input });
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
result = `Tool error (${call.name}): ${String(e)}`;
|
|
191
|
+
isError = true;
|
|
192
|
+
display.error(result);
|
|
193
|
+
}
|
|
194
|
+
toolResults.push({ id: call.id, name: call.name, content: result, isError });
|
|
195
|
+
}
|
|
196
|
+
history.push({ role: 'tool_result', results: toolResults });
|
|
197
|
+
display.agentThinking();
|
|
198
|
+
}
|
|
199
|
+
await persist(opts.sessionPath, history);
|
|
200
|
+
const sessionId = opts.sessionPath ? path.basename(opts.sessionPath, '.json') : undefined;
|
|
201
|
+
const resumeHint = sessionId ? ` Type /continue to resume session ${sessionId}` : '';
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
summary: `Loop ended after ${turns} turns.${resumeHint}`,
|
|
205
|
+
turns, toolCallCount, usage, history, toolCallLog,
|
|
206
|
+
costUsd: costFor(pricingModel, usage.inputTokens, usage.outputTokens),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
async function runAgentLoopVerified(opts, config, projectRoot) {
|
|
210
|
+
const { runWithVerification } = await Promise.resolve().then(() => __importStar(require('../verify/index.js')));
|
|
211
|
+
return runWithVerification({ loopOpts: opts, config, projectRoot, display: opts.display });
|
|
212
|
+
}
|
|
213
|
+
async function persist(path, history) {
|
|
214
|
+
if (!path)
|
|
215
|
+
return;
|
|
216
|
+
try {
|
|
217
|
+
await session_store_js_1.sessionStore.save(path, history);
|
|
218
|
+
}
|
|
219
|
+
catch { /* persistence is best-effort */ }
|
|
220
|
+
}
|
|
221
|
+
function formatCallForConfirmation(call) {
|
|
222
|
+
if (call.name === 'run_shell')
|
|
223
|
+
return `$ ${call.input.command}`;
|
|
224
|
+
if (call.name === 'write_file')
|
|
225
|
+
return `overwrite ${call.input.path}`;
|
|
226
|
+
return `${call.name}(${JSON.stringify(call.input).slice(0, 80)})`;
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=loop.js.map
|