@devshub198211/devguard 2.0.2 → 2.0.3

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 CHANGED
@@ -1,167 +1,151 @@
1
- # devguard
1
+ # @devshub198211/devguard
2
2
 
3
- > **One install. 14 features. Zero external dependencies.**
4
- > Security · AI Tooling · Auth · DX — everything a production Node.js/TypeScript project needs.
3
+ > **One install. 14 modules. Zero external dependencies.**
4
+ > Security · AI Tooling · Auth · DX — everything a production Node.js project needs.
5
5
 
6
6
  ```bash
7
- npm install devguard
8
- npx devguard # instant security scan — no install needed
7
+ npm install @devshub198211/devguard
9
8
  ```
10
9
 
11
- [![npm](https://img.shields.io/npm/v/devguard)](https://www.npmjs.com/package/devguard)
12
- [![license](https://img.shields.io/npm/l/devguard)](LICENSE)
13
- [![node](https://img.shields.io/node/v/devguard)](package.json)
14
-
15
- ---
16
-
17
- ## Features
18
-
19
- | Category | Feature | What it does |
20
- |----------|---------|-------------|
21
- | 🔒 Security | `lockfile-guardian` | SHA-512 tamper detection for npm/yarn/pnpm lockfiles |
22
- | 🔒 Security | `hook-scanner` | 23-rule malware scanner for install scripts (obfuscation-aware) |
23
- | 🔒 Security | `token-rotator` | Live API verification + age alerts for npm/GitHub tokens |
24
- | 🔒 Security | `dep-pincer` | Enforce exact version pins + SRI hash verification |
25
- | 🤖 AI | `agent-schema` | Validate LLM JSON output, auto-retry on malformed responses |
26
- | 🤖 AI | `mcp-server-kit` | Build Claude-compatible MCP tool servers in minutes |
27
- | 🤖 AI | `agent-memory` | Durable agent state: Memory / FileSystem / Redis / DynamoDB |
28
- | 🤖 AI | `llm-budget` | Token counting + cost tracking for OpenAI/Anthropic/Gemini |
29
- | 🔑 Auth | `zero-trust-jwt` | JWT verify (HS256/RS256/JWKS), revocation, anomaly detection |
30
- | 🔑 Auth | `bot-fence` | Multi-signal bot detection middleware for Express/Fastify |
31
- | 🔑 Auth | `passkey-node` | Production WebAuthn passkey registration & authentication |
32
- | 🛠 DX | `env-safe` | Typed .env validation with built-in parser — fail fast |
33
- | 🛠 DX | `log-otlp` | Structured JSON logger with OpenTelemetry trace injection |
34
- | 🛠 DX | `api-contract` | Zero-dep schema builder with full TypeScript type inference |
35
-
36
10
  ---
37
11
 
38
12
  ## Quick Start
39
13
 
40
- ### CLI
41
14
  ```bash
42
- npx devguard # full security scan + score
43
- npx devguard lockfile snapshot # create baseline after clean install
44
- npx devguard lockfile verify # check integrity
45
- npx devguard hooks # scan node_modules for malware
46
- npx devguard pins --fix # auto-pin unpinned dependencies
47
- npx devguard tokens --live # verify tokens via API
48
- npx devguard --json # machine-readable output for CI
49
- ```
15
+ # Initialize DevGuard in your project
16
+ npx @devshub198211/devguard init
50
17
 
51
- ### Programmatic
52
- ```typescript
53
- import { runAllChecks } from 'devguard';
18
+ # Run a full security audit
19
+ npx @devshub198211/devguard check
54
20
 
55
- const report = await runAllChecks();
56
- // { score: 94, passedAll: true, lockfile: {...}, hooks: {...}, ... }
57
- if (!report.passedAll) process.exit(1);
21
+ # AI-powered code refactor (free, runs locally)
22
+ npx @devshub198211/devguard refactor src/app.ts
58
23
  ```
59
24
 
60
- ### Tree-shakeable sub-path imports
61
- ```typescript
62
- import { verifyLockfile } from 'devguard/security';
63
- import { LLMBudget } from 'devguard/ai';
64
- import { JWTVerifier } from 'devguard/auth';
65
- import { loadEnv } from 'devguard/dx';
25
+ For global CLI access:
26
+ ```bash
27
+ npm install -g @devshub198211/devguard
28
+ devguard check
66
29
  ```
67
30
 
68
31
  ---
69
32
 
70
- ## Examples
33
+ ## All 14 Modules
34
+
35
+ | # | Category | Module | CLI Command | What It Does |
36
+ |---|----------|--------|-------------|--------------|
37
+ | 1 | 🔒 Security | `lockfile-guardian` | `check` / `snapshot` | SHA-512 lockfile tamper detection |
38
+ | 2 | 🔒 Security | `hook-scanner` | `scan` | 23-rule malware scanner for install scripts |
39
+ | 3 | 🔒 Security | `token-rotator` | `tokens` | Live API token verification + age alerts |
40
+ | 4 | 🔒 Security | `dep-pincer` | `pin --fix` | Enforce exact version pins + SRI hashes |
41
+ | 5 | 🤖 AI | `refactor-engine` | `refactor <file>` | Complexity analysis + security patching |
42
+ | 6 | 🤖 AI | `agent-schema` | `schema <json>` | Validate & auto-repair LLM JSON output |
43
+ | 7 | 🤖 AI | `mcp-server-kit` | `mcp` | Build Claude-compatible MCP tool servers |
44
+ | 8 | 🤖 AI | `agent-memory` | `memory --agent <id>` | Durable state for AI agents (FS/Redis) |
45
+ | 9 | 🤖 AI | `llm-budget` | `budget` | Token counting + cost tracking |
46
+ | 10 | 🔑 Auth | `zero-trust-jwt` | `jwt-verify` / `jwt-sign` | JWT sign & verify with anomaly detection |
47
+ | 11 | 🔑 Auth | `bot-fence` | `bot-check --ip <ip>` | Multi-signal bot detection middleware |
48
+ | 12 | 🔑 Auth | `passkey-node` | `passkey-verify` | WebAuthn passkey registration & auth |
49
+ | 13 | 🛠 DX | `env-safe` | `env-verify` | Typed .env validation — fail fast |
50
+ | 14 | 🛠 DX | `log-otlp` | `log --msg <text>` | Structured JSON logger + OpenTelemetry |
51
+
52
+ **Bonus:** `api-contract` — zero-dep schema builder with TypeScript inference.
71
53
 
72
- ### Security — run all checks
73
- ```typescript
74
- import { runAllChecks } from 'devguard';
75
- const report = await runAllChecks();
76
- console.log(`Security score: ${report.score}/100`);
77
- ```
54
+ ---
78
55
 
79
- ### AI validate LLM output
80
- ```typescript
81
- import { c, parseWithRetry } from 'devguard';
82
-
83
- const TaskSchema = c.object({
84
- title: c.string().min(1),
85
- priority: c.string().enum(["high","medium","low"]),
86
- dueDate: c.string().optional(),
87
- });
88
-
89
- const result = await parseWithRetry(TaskSchema, async (ctx) => {
90
- return await callYourLLM(ctx); // your LLM call here
91
- });
92
- // result.data is fully typed: { title: string; priority: "high"|"medium"|"low"; dueDate?: string }
93
- ```
56
+ ## Use From Any Language (Python, Go, Bash, etc.)
94
57
 
95
- ### AI agent with durable memory
96
- ```typescript
97
- import { createMemory } from 'devguard';
58
+ Every command supports `--json` output, making DevGuard usable from **any programming language**:
59
+
60
+ ### Python
61
+ ```python
62
+ import subprocess, json
98
63
 
99
- // Persists across serverless invocations
100
- const memory = createMemory({ agentId: 'agent-001', adapter: 'fs', ttl: 7200 });
101
- await memory.setState({ step: 3, context: 'processing order' });
102
- await memory.appendHistory('user', 'Cancel my order');
103
- const history = await memory.getHistory(10); // last 10 messages
64
+ result = subprocess.run(
65
+ ["npx", "@devshub198211/devguard", "check", "--json"],
66
+ capture_output=True, text=True
67
+ )
68
+ report = json.loads(result.stdout)
69
+ print(f"Security Score: {report['score']}/100")
104
70
  ```
105
71
 
106
- ### AI — build an MCP tool server
107
- ```typescript
108
- import { MCPServerBuilder } from 'devguard';
109
-
110
- new MCPServerBuilder('my-tools', '1.0.0')
111
- .addTool({
112
- name: 'get_weather',
113
- description: 'Get weather for a city',
114
- inputSchema: { type:'object', properties:{ city:{type:'string'} }, required:['city'] },
115
- handler: async ({ city }) => ({ temp: '22°C', city })
116
- })
117
- .startStdio(); // works with Claude Desktop + any MCP client
72
+ ### Go
73
+ ```go
74
+ cmd := exec.Command("npx", "@devshub198211/devguard", "scan", "--json")
75
+ output, _ := cmd.Output()
76
+ // Parse JSON output
118
77
  ```
119
78
 
120
- ### Auth — JWT verification
121
- ```typescript
122
- import { JWTVerifier } from 'devguard';
79
+ ### Bash
80
+ ```bash
81
+ SCORE=$(npx @devshub198211/devguard check --json | jq '.score')
82
+ echo "Score: $SCORE"
123
83
 
124
- const verifier = new JWTVerifier({ secret: process.env.JWT_SECRET! });
125
- const { valid, payload, anomalies } = await verifier.verify(token);
126
- // anomalies: { score: 0, level: 'safe', warnings: [] }
84
+ # Sign a JWT
85
+ TOKEN=$(devguard jwt-sign --payload '{"sub":"user-1"}' --secret mykey --json | jq -r '.token')
86
+
87
+ # Check an IP
88
+ devguard bot-check --ip 203.0.113.5 --json | jq '.verdict'
127
89
  ```
128
90
 
129
- ### Auth — bot detection middleware
130
- ```typescript
131
- import express from 'express';
132
- import { createMiddleware, IPRateLimiter } from 'devguard';
133
-
134
- const app = express();
135
- app.use(createMiddleware({
136
- blockThreshold: 70,
137
- rateLimiter: new IPRateLimiter(100, 60_000)
138
- }));
91
+ ### Ruby
92
+ ```ruby
93
+ result = `npx @devshub198211/devguard check --json`
94
+ report = JSON.parse(result)
95
+ puts "Score: #{report['score']}"
139
96
  ```
140
97
 
141
- ### DX — typed .env validation
142
- ```typescript
143
- import { loadEnv } from 'devguard';
144
-
145
- const env = loadEnv({
146
- DATABASE_URL: { type: 'url', required: true },
147
- PORT: { type: 'integer', default: '3000', min: 1, max: 65535 },
148
- NODE_ENV: { type: 'string', enum: ['development','production','test'] },
149
- API_KEY: { type: 'string', required: true, minLength: 32, secret: true },
150
- });
151
- // Throws with clear message if invalid. env.PORT is typed as number.
98
+ ---
99
+
100
+ ## CLI Reference
101
+
102
+ ```bash
103
+ # Core
104
+ devguard init # Set up project
105
+ devguard check [--json] # Full security audit
106
+ devguard refactor <file> [--json] # AI code refactor
107
+ devguard mcp # Start MCP server
108
+
109
+ # Security
110
+ devguard snapshot # Create lockfile baseline
111
+ devguard scan [--json] # Malware scan
112
+ devguard tokens [--json] # Token health check
113
+ devguard pin [--fix] [--json] # Pin dependencies
114
+
115
+ # AI
116
+ devguard schema '<json>' [--json] # Validate JSON
117
+ devguard memory [--agent <id>] [--json] # Query agent state
118
+ devguard budget [--json] # LLM cost summary
119
+
120
+ # Auth
121
+ devguard jwt-verify --token <t> --secret <s> # Verify JWT
122
+ devguard jwt-sign --payload '<json>' --secret <s> # Sign JWT
123
+ devguard bot-check --ip <ip> [--json] # Bot detection
124
+
125
+ # DX
126
+ devguard env-verify [--file .env] [--json] # Validate env
127
+ devguard log --msg <text> [--level info|warn|error] # Emit log
152
128
  ```
153
129
 
154
- ### DX — structured logging
130
+ ---
131
+
132
+ ## Programmatic Usage (Node.js / TypeScript)
133
+
155
134
  ```typescript
156
- import { createLogger } from 'devguard';
135
+ import { runAllChecks } from '@devshub198211/devguard';
157
136
 
158
- const log = createLogger({ service: 'api', level: 'info' });
159
- log.info('Request received', { userId: 'u-123', path: '/orders' });
160
- log.error('Payment failed', { orderId: 'o-456', reason: 'declined' });
137
+ const report = await runAllChecks();
138
+ console.log(`Security Score: ${report.score}/100`);
139
+ if (!report.passedAll) process.exit(1);
140
+ ```
141
+
142
+ ### Tree-Shakeable Sub-Path Imports
161
143
 
162
- // Child logger inherits bindings
163
- const reqLog = log.child({ requestId: 'req-789' });
164
- reqLog.info('Processing');
144
+ ```typescript
145
+ import { verifyLockfile } from '@devshub198211/devguard/security';
146
+ import { LLMBudget } from '@devshub198211/devguard/ai';
147
+ import { JWTVerifier } from '@devshub198211/devguard/auth';
148
+ import { loadEnv } from '@devshub198211/devguard/dx';
165
149
  ```
166
150
 
167
151
  ---
@@ -179,29 +163,36 @@ jobs:
179
163
  - uses: actions/setup-node@v4
180
164
  with: { node-version: '20' }
181
165
  - run: npm ci
182
- - run: npx devguard --json > devguard-report.json
183
- env:
184
- DEVGUARD_TOKENS: NPM_TOKEN,GITHUB_TOKEN
185
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
186
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187
- - uses: actions/upload-artifact@v4
188
- with: { name: security-report, path: devguard-report.json }
189
- - run: node -e "const r=require('./devguard-report.json'); if(!r.passedAll) process.exit(1)"
166
+ - run: npx @devshub198211/devguard check --json > report.json
167
+ - run: node -e "const r=JSON.parse(require('fs').readFileSync('report.json'));if(!r.passedAll)process.exit(1)"
190
168
  ```
191
169
 
192
170
  ---
193
171
 
194
- ## Security
172
+ ## Security Guarantees
195
173
 
196
174
  - ✅ **Zero external runtime dependencies** — only Node.js built-ins
197
- - ✅ **No network calls** at runtime except token inspection (opt-in)
175
+ - ✅ **No network calls** at runtime (except opt-in token verification)
198
176
  - ✅ **No telemetry, no tracking, no phone-home**
199
- - ✅ **Constant-time JWT comparison** — prevents timing attacks
177
+ - ✅ **Constant-time JWT comparison** — timing attack protection
200
178
  - ✅ **Sign-count replay protection** in WebAuthn
179
+ - ✅ **Path traversal protection** — all file IDs are SHA-256 hashed
180
+ - ✅ **Prototype pollution prevention** in CBOR/JSON parsers
181
+ - ✅ **Atomic file writes** — no data corruption during crashes
201
182
  - ✅ **Works fully offline** — all security checks are local
202
183
 
203
184
  ---
204
185
 
186
+ ## Requirements
187
+
188
+ - Node.js >= 18.0.0
189
+
205
190
  ## License
206
191
 
207
192
  MIT © DevGuard Contributors
193
+
194
+ ---
195
+
196
+ *Your custom notes below:*
197
+
198
+ <!-- Add your personal notes, contact info, or acknowledgments here -->
package/SETUP.md CHANGED
@@ -1,168 +1,111 @@
1
- # devguard — Complete Setup, Publish & Monetisation Guide
1
+ # DevGuard Setup Guide
2
2
 
3
- ## PART 1: Local Setup
3
+ Get your project secured in under 2 minutes.
4
4
 
5
- ### Step 1 — Prerequisites
6
- ```
7
- node --version # must be >= 18.0.0
8
- npm --version # must be >= 9.0.0
9
- ```
5
+ ---
10
6
 
11
- ### Step 2 — Unzip & Install
12
- ```
13
- unzip devguard-final.zip
14
- cd devguard-final
15
- npm install
16
- ```
7
+ ## Step 1: Install
17
8
 
18
- ### Step 3 — Build
9
+ ```bash
10
+ npm install @devshub198211/devguard
19
11
  ```
20
- npm run build
21
- ```
22
- Generates dist/ with CJS + ESM + TypeScript declarations + CLI.
23
12
 
24
- ### Step 4 Test CLI locally
25
- ```
26
- node dist/cli.js # full security scan
27
- node dist/cli.js lockfile snapshot # create integrity baseline
28
- node dist/cli.js lockfile verify # verify against baseline
29
- node dist/cli.js hooks # scan for malicious scripts
30
- node dist/cli.js pins --fix # auto-fix unpinned deps
31
- node dist/cli.js tokens --live # live API token check
32
- node dist/cli.js --json # machine-readable output
33
- node dist/cli.js help # all commands
13
+ Or install globally for CLI access anywhere:
14
+ ```bash
15
+ npm install -g @devshub198211/devguard
34
16
  ```
35
17
 
36
- ### Step 5 Use in your project
37
- ```
38
- npm install devguard
39
- ```
40
-
41
- ```typescript
42
- import { runAllChecks } from 'devguard';
43
- const report = await runAllChecks();
44
- console.log(report.score); // 0-100
45
- if (!report.passedAll) process.exit(1);
18
+ Or run instantly without installing:
19
+ ```bash
20
+ npx @devshub198211/devguard check
46
21
  ```
47
22
 
48
23
  ---
49
24
 
50
- ## PART 2: Publish to npm
51
-
52
- ### Step 1 — Create Account
53
- 1. https://www.npmjs.com/signup
54
- 2. Verify email
55
- 3. Enable 2FA (mandatory): https://www.npmjs.com/settings/~/profile
25
+ ## Step 2: Initialize Your Project
56
26
 
57
- ### Step 2 — Login
58
- ```
59
- npm login
60
- npm whoami
27
+ ```bash
28
+ devguard init
61
29
  ```
62
30
 
63
- ### Step 3 — Check name availability
64
- ```
65
- npm info devguard
66
- ```
67
- If taken, rename in package.json: "name": "@yourscope/devguard"
31
+ This creates:
32
+ - **`.devguardrc`** — Configuration file for security rules
33
+ - **`.devguard-memory/`** — Local storage for AI agent state
34
+ - **Security snapshot** — Baseline integrity hash of your lockfiles
68
35
 
69
- ### Step 4 — Dry run
70
- ```
71
- npm publish --dry-run --access public
72
- ```
36
+ ---
73
37
 
74
- ### Step 5 Publish
75
- ```
76
- npm run build
77
- npm publish --access public
78
- ```
38
+ ## Step 3: Run Your First Audit
79
39
 
80
- ### Step 6 — Verify
81
- ```
82
- npm info devguard
83
- npx devguard help
40
+ ```bash
41
+ devguard check
84
42
  ```
85
43
 
86
- ### Step 7 Update versions
87
- ```
88
- npm version patch # 2.0.0 -> 2.0.1
89
- npm run build
90
- npm publish --access public
91
- ```
44
+ You'll see a score out of 100. A perfect project scores 100/100.
92
45
 
93
46
  ---
94
47
 
95
- ## PART 3: GitHub Setup
48
+ ## Step 4: Refactor Code (Free, Runs Locally)
96
49
 
97
- ```
98
- git init
99
- git add .
100
- git commit -m "feat: devguard v2.0.0"
101
- gh repo create devguard --public --push
50
+ ```bash
51
+ devguard refactor src/your-file.ts
102
52
  ```
103
53
 
104
- Add CI (.github/workflows/ci.yml):
105
- ```yaml
106
- name: CI
107
- on: [push, pull_request]
108
- jobs:
109
- build:
110
- runs-on: ubuntu-latest
111
- steps:
112
- - uses: actions/checkout@v4
113
- - uses: actions/setup-node@v4
114
- with: { node-version: '20', cache: 'npm' }
115
- - run: npm ci && npm run build
116
- - run: node dist/cli.js --json
117
- ```
54
+ This opens a browser window showing:
55
+ - **Original code** on the left
56
+ - **Optimized code** on the right
57
+ - **Time complexity** analysis (e.g., O(n²) → O(n))
58
+ - **Security fixes** applied (eval removal, XSS patches)
59
+
60
+ Click "Apply" to save the changes.
118
61
 
119
62
  ---
120
63
 
121
- ## PART 4: Monetisation
64
+ ## Step 5: Optional — Enable Cloud AI Mode
122
65
 
123
- ### Free (builds audience)
124
- - GitHub Sponsors: github.com/sponsors/onboarding — $5/$15/$50 tiers
125
- - Polar.sh: polar.sh — connect repo, create paid issues
126
- - Target: $200-2000/month at 1k+ weekly downloads
66
+ For deeper AI-powered refactoring using Google Gemini:
127
67
 
128
- ### Pro SaaS ($19-299/month)
129
- Create @devguard/pro package with:
130
- - Web dashboard (Next.js + Stripe + Supabase)
131
- - Slack/email alerts for stale tokens
132
- - Team management
133
- - PDF reports
68
+ 1. Get a free API key: https://aistudio.google.com/app/apikey
69
+ 2. Set it:
70
+ ```bash
71
+ export DEVGUARD_AI_KEY="your_key_here"
72
+ ```
73
+ 3. Run refactor again — it will use Cloud AI automatically.
134
74
 
135
- Pricing: Indie $19 | Team $79 | Enterprise $299
75
+ Without a key, all features still work using the built-in local analysis engine.
136
76
 
137
- ### GitHub Marketplace Action
138
- Publish a scan action, charge per CI minute.
139
- Guide: github.com/marketplace/actions/new
77
+ ---
78
+
79
+ ## Step 6: Add to CI/CD
140
80
 
141
- ### VS Code Extension
142
- Inline warnings for ^ ~ deps, missing env vars, security score in status bar.
143
- Freemium: free basic, paid Pro ($4.99/month).
81
+ Add this to your GitHub Actions workflow:
144
82
 
145
- ### Enterprise ($5k-50k/year)
146
- Commercial license + SLA + private registry + security audits.
83
+ ```yaml
84
+ - run: npx @devshub198211/devguard check --json > report.json
85
+ ```
147
86
 
148
87
  ---
149
88
 
150
- ## PART 5: Marketing
89
+ ## Troubleshooting
151
90
 
152
- Week 1: npm publish + GitHub + post on r/node + Hacker News Show HN
153
- Week 2: Blog post + awesome-nodejs PR + newsletter outreach
154
- Month 1: Product Hunt + YouTube demo + devguard.dev landing page
91
+ | Problem | Solution |
92
+ |---------|----------|
93
+ | `command not found: devguard` | Use `npx @devshub198211/devguard` instead |
94
+ | `missing script` error | Don't use `npm run devguard` — use `npx devguard` |
95
+ | Refactor opens blank page | Wait 2 seconds, then refresh the browser |
96
+ | Score is 0 | Run `devguard init` first to create a baseline |
155
97
 
156
98
  ---
157
99
 
158
- ## Quick Reference
100
+ ## Uninstall
159
101
 
102
+ ```bash
103
+ npm uninstall @devshub198211/devguard
104
+ rm -rf .devguardrc .devguard-memory .devguard-snapshot.json
160
105
  ```
161
- npm install devguard
162
106
 
163
- import { runAllChecks } from 'devguard';
164
- import { verifyLockfile } from 'devguard/security';
165
- import { LLMBudget } from 'devguard/ai';
166
- import { JWTVerifier } from 'devguard/auth';
167
- import { loadEnv } from 'devguard/dx';
168
- ```
107
+ ---
108
+
109
+ *Your custom notes below:*
110
+
111
+ <!-- Add your personal notes here -->
package/dist/ai.d.ts CHANGED
@@ -162,6 +162,14 @@ declare class LLMBudget {
162
162
  remaining: number;
163
163
  isExceeded: boolean;
164
164
  };
165
+ report(): {
166
+ totalCost: number;
167
+ recordCount: number;
168
+ monthlyLimitUSD: number;
169
+ remaining: number;
170
+ isOverBudget: boolean;
171
+ warnAtUSD: number | null;
172
+ };
165
173
  getHistory(limit?: number): LLMUsage[];
166
174
  reset(): void;
167
175
  }
package/dist/ai.js CHANGED
@@ -1,2 +1,2 @@
1
- export { AgentMemory, FileSystemAdapter, LLMBudget, MCPServerBuilder, RedisAdapter, cleanLLMOutput, parseSchema, parseWithRetry } from './chunk-4WCL5IUZ.js';
1
+ export { AgentMemory, FileSystemAdapter, LLMBudget, MCPServerBuilder, RedisAdapter, cleanLLMOutput, parseSchema, parseWithRetry } from './chunk-UXM7HRTI.js';
2
2
  export { c, c as s } from './chunk-KSFZPDFO.js';
@@ -127,7 +127,7 @@ async function parseWithRetry(schema, promptFn, maxRetries = 3) {
127
127
 
128
128
  // src/ai/mcp-server-kit.ts
129
129
  var ERR = { PARSE: -32700, INVALID: -32600, NOT_FOUND: -32601, PARAMS: -32602, INTERNAL: -32603 };
130
- var MAX_MESSAGE_SIZE = 10 * 1024 * 1024;
130
+ var MAX_MESSAGE_SIZE = 50 * 1024 * 1024;
131
131
  var MAX_NAME_LENGTH = 256;
132
132
  var HANDLER_TIMEOUT_MS = 3e4;
133
133
  function validateToolInput(args, schema) {
@@ -447,7 +447,7 @@ var AgentMemory = class {
447
447
  await this.adapter.clear(agentId);
448
448
  }
449
449
  };
450
- var MAX_RECORDS = 5e3;
450
+ var MAX_RECORDS = 5e4;
451
451
  var LLMBudget = class {
452
452
  constructor(config) {
453
453
  this.records = [];
@@ -481,6 +481,16 @@ var LLMBudget = class {
481
481
  isExceeded: this.totalCost >= this.config.monthlyLimitUSD
482
482
  };
483
483
  }
484
+ report() {
485
+ return {
486
+ totalCost: this.totalCost,
487
+ recordCount: this.records.length,
488
+ monthlyLimitUSD: this.config.monthlyLimitUSD,
489
+ remaining: Math.max(0, this.config.monthlyLimitUSD - this.totalCost),
490
+ isOverBudget: this.totalCost >= this.config.monthlyLimitUSD,
491
+ warnAtUSD: this.config.warnAtUSD ?? null
492
+ };
493
+ }
484
494
  getHistory(limit = 100) {
485
495
  return this.records.slice(-limit);
486
496
  }