codesession-cli 1.0.0 → 1.2.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/README.md +179 -119
- package/dist/agents.d.ts +151 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +305 -0
- package/dist/agents.js.map +1 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +4 -2
- package/dist/db.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +210 -50
- package/dist/index.js.map +1 -1
- package/package.json +30 -5
- package/skills/codesession/SKILL.md +97 -0
- package/src/db.ts +0 -239
- package/src/formatters.ts +0 -152
- package/src/git.ts +0 -44
- package/src/index.ts +0 -206
- package/src/types.ts +0 -49
- package/src/watcher.ts +0 -52
- package/test.ts +0 -4
- package/tsconfig.json +0 -20
package/README.md
CHANGED
|
@@ -1,186 +1,250 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>codesession-cli</h1>
|
|
3
|
+
<p><strong>Track what your AI agents actually cost</strong></p>
|
|
4
|
+
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://www.npmjs.com/package/codesession-cli"><img src="https://img.shields.io/npm/v/codesession-cli?color=brightgreen" alt="npm version"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/codesession-cli"><img src="https://img.shields.io/npm/dm/codesession-cli" alt="npm downloads"></a>
|
|
8
|
+
<a href="https://github.com/brian-mwirigi/codesession-cli/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/codesession-cli" alt="license"></a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p><em>Track agent runs • Monitor files • Log commits • Enforce budgets</em></p>
|
|
12
|
+
</div>
|
|
2
13
|
|
|
3
|
-
|
|
14
|
+
---
|
|
4
15
|
|
|
5
|
-
##
|
|
16
|
+
## The Problem
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
- **File Monitoring** - Automatically track file changes
|
|
9
|
-
- **Git Integration** - Log commits during sessions
|
|
10
|
-
- **AI Cost Tracking** - Record AI API usage per session
|
|
11
|
-
- **Statistics** - View productivity metrics
|
|
12
|
-
- **Local Storage** - All data stored locally in SQLite
|
|
18
|
+
Your AI agent just ran for 45 minutes. It made 23 API calls, edited 15 files, and created 4 commits.
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
**You have no idea what it cost.**
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
# Install
|
|
18
|
-
npm install -g codesession
|
|
22
|
+
OpenClaw, Claude Code, custom agents — they all burn tokens with zero visibility. You find out when the bill arrives.
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
cs start "Build user auth"
|
|
24
|
+
## The Solution
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
One command to start tracking. Everything logged automatically.
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
```bash
|
|
29
|
+
# Start tracking an agent run
|
|
30
|
+
cs start "Fix authentication bug"
|
|
31
|
+
|
|
32
|
+
# Agent does its thing... (files, commits, AI calls tracked automatically)
|
|
27
33
|
|
|
28
|
-
#
|
|
29
|
-
cs
|
|
34
|
+
# End and see the damage
|
|
35
|
+
cs end
|
|
36
|
+
# Session: 47m • 15 files • 4 commits • $8.47 AI cost
|
|
30
37
|
```
|
|
31
38
|
|
|
39
|
+
## Works With
|
|
40
|
+
|
|
41
|
+
- **[OpenClaw](https://openclaw.ai)** — Ships as an OpenClaw skill ([install from ClawHub](#openclaw-skill))
|
|
42
|
+
- **Claude Code** — Track autonomous coding sessions
|
|
43
|
+
- **Custom agents** — Programmatic API with budget enforcement
|
|
44
|
+
- **Manual sessions** — Track your own coding time and costs
|
|
45
|
+
|
|
32
46
|
## Installation
|
|
33
47
|
|
|
34
48
|
```bash
|
|
35
|
-
npm install -g codesession
|
|
49
|
+
npm install -g codesession-cli
|
|
36
50
|
```
|
|
37
51
|
|
|
38
|
-
##
|
|
52
|
+
## Quick Start
|
|
39
53
|
|
|
40
|
-
###
|
|
54
|
+
### CLI Usage
|
|
41
55
|
|
|
42
56
|
```bash
|
|
43
|
-
# Start
|
|
44
|
-
cs start "
|
|
57
|
+
# Start a session
|
|
58
|
+
cs start "Build user auth"
|
|
59
|
+
|
|
60
|
+
# Log AI usage (after API calls)
|
|
61
|
+
cs log-ai -p anthropic -m claude-opus-4-6 -t 15000 -c 0.30
|
|
62
|
+
|
|
63
|
+
# Check current costs mid-session
|
|
64
|
+
cs status
|
|
65
|
+
|
|
66
|
+
# End session
|
|
67
|
+
cs end -n "Auth complete, all tests passing"
|
|
45
68
|
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
69
|
+
# View session history
|
|
70
|
+
cs list
|
|
71
|
+
cs show --files --commits
|
|
72
|
+
cs stats
|
|
50
73
|
```
|
|
51
74
|
|
|
52
|
-
###
|
|
75
|
+
### JSON Output (for agents)
|
|
76
|
+
|
|
77
|
+
Every command supports `--json` for machine-readable output:
|
|
53
78
|
|
|
54
79
|
```bash
|
|
55
|
-
|
|
56
|
-
|
|
80
|
+
cs status --json
|
|
81
|
+
# {"id":42,"name":"Fix auth","status":"active","aiCost":3.47,"aiTokens":89000,...}
|
|
57
82
|
|
|
58
|
-
|
|
83
|
+
cs log-ai -p openai -m gpt-4o -t 5000 -c 0.05 --json
|
|
84
|
+
# {"logged":{"provider":"openai","model":"gpt-4o","tokens":5000,"cost":0.05},"session":{"id":42,"aiCost":3.52,"aiTokens":94000}}
|
|
59
85
|
```
|
|
60
86
|
|
|
61
|
-
|
|
87
|
+
---
|
|
62
88
|
|
|
63
|
-
|
|
64
|
-
# Show last session
|
|
65
|
-
cs show
|
|
89
|
+
## OpenClaw Skill
|
|
66
90
|
|
|
67
|
-
|
|
68
|
-
cs show 5
|
|
91
|
+
codesession-cli ships as an [OpenClaw](https://openclaw.ai) skill. The agent automatically tracks its own session costs.
|
|
69
92
|
|
|
70
|
-
|
|
71
|
-
cs show --files --commits
|
|
93
|
+
### Install the skill
|
|
72
94
|
|
|
73
|
-
|
|
74
|
-
|
|
95
|
+
Copy the skill to your OpenClaw workspace:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Option 1: Copy from npm package
|
|
99
|
+
cp -r $(npm root -g)/codesession-cli/skills/codesession ~/.openclaw/skills/
|
|
75
100
|
|
|
76
|
-
#
|
|
77
|
-
|
|
101
|
+
# Option 2: Clone and copy
|
|
102
|
+
git clone https://github.com/brian-mwirigi/codesession-cli.git
|
|
103
|
+
cp -r codesession-cli/skills/codesession ~/.openclaw/skills/
|
|
78
104
|
```
|
|
79
105
|
|
|
80
|
-
###
|
|
106
|
+
### What it does
|
|
107
|
+
|
|
108
|
+
Once installed, the OpenClaw agent will:
|
|
109
|
+
|
|
110
|
+
1. Run `cs start "task name"` at the beginning of each task
|
|
111
|
+
2. Log API usage with `cs log-ai` after each AI call
|
|
112
|
+
3. Check costs with `cs status --json` during long tasks
|
|
113
|
+
4. Run `cs end` when the task completes
|
|
114
|
+
|
|
115
|
+
### Example: Agent run tracked by codesession
|
|
81
116
|
|
|
82
|
-
```bash
|
|
83
|
-
# Overall stats
|
|
84
|
-
cs stats
|
|
85
117
|
```
|
|
118
|
+
You: Fix the payment processing bug and add retry logic
|
|
86
119
|
|
|
87
|
-
|
|
120
|
+
Agent: Starting session tracking...
|
|
121
|
+
$ cs start "Fix payment processing + retry"
|
|
122
|
+
✓ Session started
|
|
88
123
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
cs log-ai -p anthropic -m claude-
|
|
124
|
+
[Agent works: reads files, edits code, runs tests...]
|
|
125
|
+
$ cs log-ai -p anthropic -m claude-opus-4-6 -t 12000 -c 0.24
|
|
126
|
+
$ cs log-ai -p anthropic -m claude-opus-4-6 -t 18000 -c 0.36
|
|
127
|
+
$ cs log-ai -p anthropic -m claude-opus-4-6 -t 8000 -c 0.16
|
|
128
|
+
|
|
129
|
+
$ cs end -n "Fixed payment bug, added exponential backoff retry"
|
|
130
|
+
✓ Session ended
|
|
131
|
+
|
|
132
|
+
Session: 12m • 6 files • 2 commits • $0.76 AI cost
|
|
92
133
|
```
|
|
93
134
|
|
|
94
|
-
|
|
135
|
+
After 50 agent runs:
|
|
95
136
|
|
|
96
137
|
```bash
|
|
97
|
-
|
|
98
|
-
|
|
138
|
+
$ cs stats
|
|
139
|
+
┌──────────────┬────────────────┐
|
|
140
|
+
│ Total Sessions│ 50 │
|
|
141
|
+
│ Total Time │ 8h 34m │
|
|
142
|
+
│ Files Changed│ 312 │
|
|
143
|
+
│ Commits │ 87 │
|
|
144
|
+
│ Total AI Cost│ $47.23 │
|
|
145
|
+
└──────────────┴────────────────┘
|
|
99
146
|
```
|
|
100
147
|
|
|
101
|
-
|
|
148
|
+
---
|
|
102
149
|
|
|
103
|
-
|
|
104
|
-
$ cs show
|
|
150
|
+
## Programmatic API (for agent frameworks)
|
|
105
151
|
|
|
106
|
-
|
|
152
|
+
Build codesession tracking directly into your agent:
|
|
107
153
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
│ Commits │ 5 │
|
|
117
|
-
│ AI Tokens │ 45,000 │
|
|
118
|
-
│ AI Cost │ $2.34 │
|
|
119
|
-
│ Notes │ Completed basic auth flow │
|
|
120
|
-
└──────────────┴────────────────────────────┘
|
|
121
|
-
```
|
|
154
|
+
```typescript
|
|
155
|
+
import { AgentSession, BudgetExceededError } from 'codesession-cli/agents';
|
|
156
|
+
|
|
157
|
+
const session = new AgentSession('Refactor auth module', {
|
|
158
|
+
budget: 5.00, // Hard cap: stop at $5
|
|
159
|
+
directory: './src', // Watch this directory
|
|
160
|
+
git: true, // Track commits
|
|
161
|
+
});
|
|
122
162
|
|
|
123
|
-
|
|
163
|
+
session.start();
|
|
124
164
|
|
|
125
|
-
|
|
126
|
-
|
|
165
|
+
// After each AI call
|
|
166
|
+
session.logAI('anthropic', 'claude-opus-4-6', 15000, 0.30);
|
|
127
167
|
|
|
128
|
-
|
|
129
|
-
|
|
168
|
+
// Pre-flight check
|
|
169
|
+
if (!session.canAfford(2.00)) {
|
|
170
|
+
console.log('Switching to cheaper model...');
|
|
171
|
+
}
|
|
130
172
|
|
|
131
|
-
|
|
132
|
-
|
|
173
|
+
// Budget enforcement is automatic
|
|
174
|
+
try {
|
|
175
|
+
session.logAI('openai', 'gpt-4o', 50000, 4.80);
|
|
176
|
+
} catch (e) {
|
|
177
|
+
if (e instanceof BudgetExceededError) {
|
|
178
|
+
console.log(`Stopped at $${e.spent} (limit: $${e.budget})`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
133
181
|
|
|
134
|
-
|
|
135
|
-
|
|
182
|
+
const summary = session.end();
|
|
183
|
+
// { duration: 847, filesChanged: 12, aiCost: 4.80, commits: 3, ... }
|
|
184
|
+
```
|
|
136
185
|
|
|
137
|
-
###
|
|
138
|
-
Show concrete evidence of shipping speed.
|
|
186
|
+
### `runAgentSession` helper
|
|
139
187
|
|
|
140
|
-
|
|
188
|
+
Wraps start/end/error handling automatically:
|
|
141
189
|
|
|
142
|
-
|
|
190
|
+
```typescript
|
|
191
|
+
import { runAgentSession } from 'codesession-cli/agents';
|
|
143
192
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
193
|
+
const summary = await runAgentSession(
|
|
194
|
+
'Fix all linting errors',
|
|
195
|
+
{ budget: 3.00, directory: './src' },
|
|
196
|
+
async (session) => {
|
|
197
|
+
// Your agent logic
|
|
198
|
+
const response = await anthropic.messages.create({ ... });
|
|
199
|
+
session.logAI('anthropic', 'claude-sonnet-4-5', tokens, cost);
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
console.log(`Done: ${summary.filesChanged} files, $${summary.aiCost}`);
|
|
147
204
|
```
|
|
148
205
|
|
|
149
|
-
|
|
206
|
+
---
|
|
150
207
|
|
|
151
|
-
|
|
208
|
+
## All Commands
|
|
152
209
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
cs
|
|
157
|
-
|
|
210
|
+
| Command | Description |
|
|
211
|
+
|---------|-------------|
|
|
212
|
+
| `cs start <name>` | Start tracking a session |
|
|
213
|
+
| `cs end [-n notes]` | End session, show summary |
|
|
214
|
+
| `cs status` | Show active session |
|
|
215
|
+
| `cs show [id] [--files] [--commits]` | Show session details |
|
|
216
|
+
| `cs list [-l limit]` | List recent sessions |
|
|
217
|
+
| `cs stats` | Overall statistics |
|
|
218
|
+
| `cs log-ai -p <provider> -m <model> -t <tokens> -c <cost>` | Log AI usage |
|
|
219
|
+
|
|
220
|
+
All commands support `--json` for machine-readable output.
|
|
158
221
|
|
|
159
222
|
## Data Storage
|
|
160
223
|
|
|
161
|
-
All data stored locally in `~/.
|
|
224
|
+
All data stored locally in `~/.devsession/sessions.db` (SQLite).
|
|
162
225
|
|
|
163
|
-
No
|
|
226
|
+
No telemetry. No cloud. 100% local.
|
|
164
227
|
|
|
165
|
-
##
|
|
228
|
+
## Example Output
|
|
166
229
|
|
|
167
230
|
```bash
|
|
168
|
-
|
|
169
|
-
git clone https://github.com/brian-mwirigi/codesession.git
|
|
170
|
-
cd codesession
|
|
171
|
-
|
|
172
|
-
# Install
|
|
173
|
-
npm install
|
|
174
|
-
|
|
175
|
-
# Dev mode
|
|
176
|
-
npm run dev -- start "Test session"
|
|
231
|
+
$ cs show
|
|
177
232
|
|
|
178
|
-
|
|
179
|
-
npm run build
|
|
233
|
+
Session: Build user auth
|
|
180
234
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
235
|
+
┌──────────────┬────────────────────────────┐
|
|
236
|
+
│ Metric │ Value │
|
|
237
|
+
├──────────────┼────────────────────────────┤
|
|
238
|
+
│ Status │ Completed │
|
|
239
|
+
│ Started │ Feb 09, 2026 14:30 │
|
|
240
|
+
│ Ended │ Feb 09, 2026 16:45 │
|
|
241
|
+
│ Duration │ 2h 15m │
|
|
242
|
+
│ Files Changed│ 12 │
|
|
243
|
+
│ Commits │ 5 │
|
|
244
|
+
│ AI Tokens │ 45,000 │
|
|
245
|
+
│ AI Cost │ $2.34 │
|
|
246
|
+
│ Notes │ Completed basic auth flow │
|
|
247
|
+
└──────────────┴────────────────────────────┘
|
|
184
248
|
```
|
|
185
249
|
|
|
186
250
|
## License
|
|
@@ -191,10 +255,6 @@ MIT
|
|
|
191
255
|
|
|
192
256
|
Built by [Brian Mwirigi](https://github.com/brian-mwirigi)
|
|
193
257
|
|
|
194
|
-
## Testing
|
|
195
|
-
|
|
196
|
-
This is a test modification to trigger file watcher.
|
|
197
|
-
|
|
198
258
|
---
|
|
199
259
|
|
|
200
|
-
**
|
|
260
|
+
**Know what your agents cost. Ship with confidence.**
|
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Sessions - Programmatic API for AI agents
|
|
3
|
+
*
|
|
4
|
+
* Track agent runs with automatic file watching, git tracking,
|
|
5
|
+
* AI cost logging, and budget enforcement.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { AgentSession } from 'codesession-cli/agents';
|
|
10
|
+
*
|
|
11
|
+
* const session = new AgentSession('Refactor auth module', {
|
|
12
|
+
* budget: 5.00,
|
|
13
|
+
* directory: './src',
|
|
14
|
+
* git: true,
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* session.start();
|
|
18
|
+
* // ... agent does work ...
|
|
19
|
+
* const summary = session.end();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export interface AgentSessionConfig {
|
|
23
|
+
/** Hard budget cap in dollars. Session auto-ends if exceeded. */
|
|
24
|
+
budget?: number;
|
|
25
|
+
/** Directory to watch for file changes. Defaults to cwd. */
|
|
26
|
+
directory?: string;
|
|
27
|
+
/** Enable git commit tracking. Defaults to true. */
|
|
28
|
+
git?: boolean;
|
|
29
|
+
/** Interval (ms) to check for new git commits. Defaults to 5000. */
|
|
30
|
+
gitPollInterval?: number;
|
|
31
|
+
/** Callback when budget is exceeded. Called before session ends. */
|
|
32
|
+
onBudgetExceeded?: (spent: number, budget: number) => void;
|
|
33
|
+
/** Callback when AI usage is logged. */
|
|
34
|
+
onAIUsage?: (cost: number, totalCost: number, model: string) => void;
|
|
35
|
+
/** Callback on each file change. */
|
|
36
|
+
onFileChange?: (filePath: string, changeType: string) => void;
|
|
37
|
+
/** Optional metadata to attach to the session. */
|
|
38
|
+
metadata?: Record<string, any>;
|
|
39
|
+
}
|
|
40
|
+
export interface AgentSessionSummary {
|
|
41
|
+
sessionId: number;
|
|
42
|
+
name: string;
|
|
43
|
+
duration: number;
|
|
44
|
+
filesChanged: number;
|
|
45
|
+
commits: number;
|
|
46
|
+
aiCost: number;
|
|
47
|
+
aiTokens: number;
|
|
48
|
+
budgetRemaining: number | null;
|
|
49
|
+
files: {
|
|
50
|
+
path: string;
|
|
51
|
+
type: string;
|
|
52
|
+
timestamp: string;
|
|
53
|
+
}[];
|
|
54
|
+
commitList: {
|
|
55
|
+
hash: string;
|
|
56
|
+
message: string;
|
|
57
|
+
timestamp: string;
|
|
58
|
+
}[];
|
|
59
|
+
aiUsageBreakdown: {
|
|
60
|
+
provider: string;
|
|
61
|
+
model: string;
|
|
62
|
+
tokens: number;
|
|
63
|
+
cost: number;
|
|
64
|
+
timestamp: string;
|
|
65
|
+
}[];
|
|
66
|
+
metadata?: Record<string, any>;
|
|
67
|
+
}
|
|
68
|
+
export declare class AgentSession {
|
|
69
|
+
private sessionId;
|
|
70
|
+
private name;
|
|
71
|
+
private config;
|
|
72
|
+
private gitInterval;
|
|
73
|
+
private totalCost;
|
|
74
|
+
private totalTokens;
|
|
75
|
+
private started;
|
|
76
|
+
private ended;
|
|
77
|
+
constructor(name: string, config?: AgentSessionConfig);
|
|
78
|
+
/**
|
|
79
|
+
* Start the agent session. Begins file watching and git tracking.
|
|
80
|
+
* @returns The session ID
|
|
81
|
+
*/
|
|
82
|
+
start(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Log AI usage for this session. Automatically checks budget.
|
|
85
|
+
* @returns The remaining budget (null if no budget set)
|
|
86
|
+
* @throws BudgetExceededError if budget is exceeded
|
|
87
|
+
*/
|
|
88
|
+
logAI(provider: string, model: string, tokens: number, cost: number): number | null;
|
|
89
|
+
/**
|
|
90
|
+
* Check how much budget remains.
|
|
91
|
+
* @returns Remaining budget in dollars, or null if no budget set
|
|
92
|
+
*/
|
|
93
|
+
get budgetRemaining(): number | null;
|
|
94
|
+
/** Current total cost spent in this session */
|
|
95
|
+
get spent(): number;
|
|
96
|
+
/** Current total tokens used in this session */
|
|
97
|
+
get tokens(): number;
|
|
98
|
+
/** Whether this session is currently active */
|
|
99
|
+
get isActive(): boolean;
|
|
100
|
+
/** The database session ID (null if not started) */
|
|
101
|
+
get id(): number | null;
|
|
102
|
+
/**
|
|
103
|
+
* End the agent session and return a full summary.
|
|
104
|
+
*/
|
|
105
|
+
end(notes?: string): AgentSessionSummary;
|
|
106
|
+
/**
|
|
107
|
+
* Check if an AI call would exceed the budget.
|
|
108
|
+
* Useful for pre-flight checks before making expensive API calls.
|
|
109
|
+
* @returns true if the call would stay within budget
|
|
110
|
+
*/
|
|
111
|
+
canAfford(estimatedCost: number): boolean;
|
|
112
|
+
private assertStarted;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Thrown when an agent session exceeds its budget.
|
|
116
|
+
* Catch this to handle budget enforcement gracefully.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* try {
|
|
121
|
+
* session.logAI('openai', 'gpt-4o', 5000, 0.10);
|
|
122
|
+
* } catch (e) {
|
|
123
|
+
* if (e instanceof BudgetExceededError) {
|
|
124
|
+
* console.log(`Over budget: spent $${e.spent}, limit $${e.budget}`);
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export declare class BudgetExceededError extends Error {
|
|
130
|
+
spent: number;
|
|
131
|
+
budget: number;
|
|
132
|
+
constructor(spent: number, budget: number);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Quick helper to run an agent function within a tracked session.
|
|
136
|
+
* Handles start/end/error automatically.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const summary = await runAgentSession('Fix all linting errors', {
|
|
141
|
+
* budget: 3.00,
|
|
142
|
+
* directory: './src',
|
|
143
|
+
* }, async (session) => {
|
|
144
|
+
* // Your agent logic here
|
|
145
|
+
* const response = await openai.chat.completions.create({ ... });
|
|
146
|
+
* session.logAI('openai', 'gpt-4o', response.usage.total_tokens, 0.05);
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare function runAgentSession(name: string, config: AgentSessionConfig, agentFn: (session: AgentSession) => Promise<void>): Promise<AgentSessionSummary>;
|
|
151
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAcH,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,wCAAwC;IACxC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,I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