jiva-core 0.2.2 → 0.3.1
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/.dockerignore +53 -0
- package/.gcloudignore +49 -0
- package/CONTRIBUTING.md +92 -0
- package/Dockerfile +63 -0
- package/LICENSE +21 -0
- package/README.md +248 -102
- package/cloud-run-deploy.yaml +135 -0
- package/cloud-run.yaml +135 -0
- package/cloud-run.yaml.template +143 -0
- package/deploy.sh +107 -0
- package/dist/core/agent-spawner.d.ts +89 -0
- package/dist/core/agent-spawner.d.ts.map +1 -0
- package/dist/core/agent-spawner.js +195 -0
- package/dist/core/agent-spawner.js.map +1 -0
- package/dist/core/client-agent.d.ts +82 -0
- package/dist/core/client-agent.d.ts.map +1 -0
- package/dist/core/client-agent.js +406 -0
- package/dist/core/client-agent.js.map +1 -0
- package/dist/core/config.d.ts +59 -10
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +19 -2
- package/dist/core/config.js.map +1 -1
- package/dist/core/conversation-manager.d.ts +10 -18
- package/dist/core/conversation-manager.d.ts.map +1 -1
- package/dist/core/conversation-manager.js +28 -60
- package/dist/core/conversation-manager.js.map +1 -1
- package/dist/core/dual-agent.d.ts +24 -3
- package/dist/core/dual-agent.d.ts.map +1 -1
- package/dist/core/dual-agent.js +112 -19
- package/dist/core/dual-agent.js.map +1 -1
- package/dist/core/manager-agent.d.ts +3 -1
- package/dist/core/manager-agent.d.ts.map +1 -1
- package/dist/core/manager-agent.js +66 -14
- package/dist/core/manager-agent.js.map +1 -1
- package/dist/core/worker-agent.d.ts +15 -1
- package/dist/core/worker-agent.d.ts.map +1 -1
- package/dist/core/worker-agent.js +244 -11
- package/dist/core/worker-agent.js.map +1 -1
- package/dist/core/workspace.d.ts +5 -0
- package/dist/core/workspace.d.ts.map +1 -1
- package/dist/core/workspace.js +47 -7
- package/dist/core/workspace.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/cli/index.js +376 -44
- package/dist/interfaces/cli/index.js.map +1 -1
- package/dist/interfaces/cli/repl.d.ts.map +1 -1
- package/dist/interfaces/cli/repl.js +6 -0
- package/dist/interfaces/cli/repl.js.map +1 -1
- package/dist/interfaces/http/index.d.ts +22 -0
- package/dist/interfaces/http/index.d.ts.map +1 -0
- package/dist/interfaces/http/index.js +135 -0
- package/dist/interfaces/http/index.js.map +1 -0
- package/dist/interfaces/http/middleware/auth.d.ts +32 -0
- package/dist/interfaces/http/middleware/auth.d.ts.map +1 -0
- package/dist/interfaces/http/middleware/auth.js +176 -0
- package/dist/interfaces/http/middleware/auth.js.map +1 -0
- package/dist/interfaces/http/routes/chat.d.ts +7 -0
- package/dist/interfaces/http/routes/chat.d.ts.map +1 -0
- package/dist/interfaces/http/routes/chat.js +144 -0
- package/dist/interfaces/http/routes/chat.js.map +1 -0
- package/dist/interfaces/http/routes/health.d.ts +6 -0
- package/dist/interfaces/http/routes/health.d.ts.map +1 -0
- package/dist/interfaces/http/routes/health.js +25 -0
- package/dist/interfaces/http/routes/health.js.map +1 -0
- package/dist/interfaces/http/routes/session.d.ts +7 -0
- package/dist/interfaces/http/routes/session.d.ts.map +1 -0
- package/dist/interfaces/http/routes/session.js +114 -0
- package/dist/interfaces/http/routes/session.js.map +1 -0
- package/dist/interfaces/http/session-manager.d.ts +76 -0
- package/dist/interfaces/http/session-manager.d.ts.map +1 -0
- package/dist/interfaces/http/session-manager.js +339 -0
- package/dist/interfaces/http/session-manager.js.map +1 -0
- package/dist/interfaces/http/websocket-handler.d.ts +18 -0
- package/dist/interfaces/http/websocket-handler.d.ts.map +1 -0
- package/dist/interfaces/http/websocket-handler.js +146 -0
- package/dist/interfaces/http/websocket-handler.js.map +1 -0
- package/dist/mcp/client.d.ts +11 -2
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +44 -19
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/server-manager.d.ts +1 -1
- package/dist/mcp/server-manager.d.ts.map +1 -1
- package/dist/mcp/server-manager.js +12 -2
- package/dist/mcp/server-manager.js.map +1 -1
- package/dist/personas/index.d.ts +13 -0
- package/dist/personas/index.d.ts.map +1 -0
- package/dist/personas/index.js +13 -0
- package/dist/personas/index.js.map +1 -0
- package/dist/personas/persona-loader.d.ts +30 -0
- package/dist/personas/persona-loader.d.ts.map +1 -0
- package/dist/personas/persona-loader.js +246 -0
- package/dist/personas/persona-loader.js.map +1 -0
- package/dist/personas/persona-manager.d.ts +82 -0
- package/dist/personas/persona-manager.d.ts.map +1 -0
- package/dist/personas/persona-manager.js +211 -0
- package/dist/personas/persona-manager.js.map +1 -0
- package/dist/personas/skill-loader.d.ts +35 -0
- package/dist/personas/skill-loader.d.ts.map +1 -0
- package/dist/personas/skill-loader.js +144 -0
- package/dist/personas/skill-loader.js.map +1 -0
- package/dist/personas/skill-packager.d.ts +25 -0
- package/dist/personas/skill-packager.d.ts.map +1 -0
- package/dist/personas/skill-packager.js +233 -0
- package/dist/personas/skill-packager.js.map +1 -0
- package/dist/personas/types.d.ts +134 -0
- package/dist/personas/types.d.ts.map +1 -0
- package/dist/personas/types.js +7 -0
- package/dist/personas/types.js.map +1 -0
- package/dist/personas/validator.d.ts +22 -0
- package/dist/personas/validator.d.ts.map +1 -0
- package/dist/personas/validator.js +144 -0
- package/dist/personas/validator.js.map +1 -0
- package/dist/storage/factory.d.ts +51 -0
- package/dist/storage/factory.d.ts.map +1 -0
- package/dist/storage/factory.js +154 -0
- package/dist/storage/factory.js.map +1 -0
- package/dist/storage/gcp-bucket-provider.d.ts +59 -0
- package/dist/storage/gcp-bucket-provider.d.ts.map +1 -0
- package/dist/storage/gcp-bucket-provider.js +275 -0
- package/dist/storage/gcp-bucket-provider.js.map +1 -0
- package/dist/storage/index.d.ts +33 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +37 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/local-provider.d.ts +36 -0
- package/dist/storage/local-provider.d.ts.map +1 -0
- package/dist/storage/local-provider.js +219 -0
- package/dist/storage/local-provider.js.map +1 -0
- package/dist/storage/provider.d.ts +137 -0
- package/dist/storage/provider.d.ts.map +1 -0
- package/dist/storage/provider.js +136 -0
- package/dist/storage/provider.js.map +1 -0
- package/dist/storage/types.d.ts +78 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +14 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/utils/orchestration-logger.d.ts +36 -0
- package/dist/utils/orchestration-logger.d.ts.map +1 -0
- package/dist/utils/orchestration-logger.js +224 -0
- package/dist/utils/orchestration-logger.js.map +1 -0
- package/jiva-new-demo.gif +0 -0
- package/package.json +30 -2
- package/.fluen/cache/state.json +0 -7
- package/actions/action_registry.py +0 -75
- package/actions/python_coder.py +0 -470
- package/api/main.py +0 -269
- package/downloaded_image.avif +0 -0
- package/downloads/snipping_tool.avif +0 -0
- package/image.avif +0 -0
- package/ms_image.avif +0 -0
- package/screenshot.png +0 -0
- package/snipping_tool.avif +0 -0
- package/tmp_image.avif +0 -0
package/README.md
CHANGED
|
@@ -1,40 +1,84 @@
|
|
|
1
1
|
# Jiva - Versatile Autonomous AI Agent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/jiva-core) [](LICENSE) [](https://github.com/KarmaloopAI/Jiva)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Jiva is a powerful autonomous AI agent with a three-agent architecture (Manager, Worker, Client) powered by gpt-oss-120b with full MCP (Model Context Protocol) support. Deploy as a CLI tool or scale to production on Google Cloud Run.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **[Configuration Guide](docs/CONFIGURATION.md)** - Detailed configuration and provider setup
|
|
9
|
-
- **[New Features Guide](docs/NEW_FEATURES.md)** - Latest improvements and features
|
|
10
|
-
- **[Build Instructions](docs/BUILD.md)** - Detailed setup and development workflow
|
|
11
|
-
- **[Troubleshooting](docs/TROUBLESHOOTING.md)** - Common issues and solutions
|
|
7
|
+
## Quick Links
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
- **[Quick Start Guide](docs/guides/QUICKSTART.md)** - Get up and running in 30 seconds
|
|
10
|
+
- **[Cloud Run Deployment](docs/deployment/CLOUD_RUN_DEPLOYMENT.md)** - Deploy to production
|
|
11
|
+
- **[Configuration Guide](docs/guides/CONFIGURATION.md)** - Detailed configuration and provider setup
|
|
12
|
+
- **[Documentation](docs/README.md)** - Complete documentation index
|
|
13
|
+
- **[Build Instructions](docs/guides/BUILD.md)** - Detailed setup and development workflow
|
|
14
|
+
- **[Troubleshooting](docs/guides/TROUBLESHOOTING.md)** - Common issues and solutions
|
|
15
|
+
|
|
16
|
+
## Demo
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
## Features
|
|
14
21
|
|
|
15
22
|
### Core Capabilities
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
- **Three-Agent Architecture**: Manager for planning, Worker for execution, Client for quality validation
|
|
24
|
+
- **Adaptive Quality Control**: Client agent uses tiered validation (MINIMAL→STANDARD→THOROUGH) based on task complexity
|
|
25
|
+
- **Unjustified Failure Detection**: LLM-powered analysis catches agents giving up without trying
|
|
26
|
+
- **Cloud-Ready Deployment**: Run on Google Cloud Run with auto-scaling, WebSocket support, and GCS storage
|
|
27
|
+
- **Multi-Tenancy**: Per-tenant isolation with authenticated session management
|
|
28
|
+
- **Provider Agnostic**: Works with Krutrim, Groq, OpenAI, Ollama, and any OpenAI-compatible API
|
|
29
|
+
- **MCP Integration**: Seamless integration with Model Context Protocol servers for extensible tooling
|
|
30
|
+
- **Smart Conversations**: Auto-save, restore, and AI-generated titles for all conversations
|
|
31
|
+
- **Directive-Based**: Orient agent behavior with custom `jiva-directive.md` files
|
|
32
|
+
- **Storage Abstraction**: Local filesystem or cloud storage (GCS, future: S3, Redis)
|
|
33
|
+
|
|
34
|
+
### v0.3.1 Features
|
|
35
|
+
- **Production Deployment**: One-command Cloud Run deployment with GCS persistence
|
|
36
|
+
- **Client Agent**: Intelligent validation that ensures work quality and catches false failures
|
|
37
|
+
- **HTTP/WebSocket API**: RESTful endpoints and real-time bidirectional communication
|
|
38
|
+
- **Authentication**: Firebase Auth, custom JWT, or development mode
|
|
39
|
+
- **Session Management**: Auto-scaling agent instances with idle timeout and cleanup
|
|
40
|
+
- **Container Orchestration**: Multi-stage Docker builds, health probes, graceful shutdown
|
|
41
|
+
- **Personas & Skills**: 100% compatible with Claude's Skills/Plugins system - extend Jiva with domain-specific capabilities
|
|
42
|
+
|
|
43
|
+
### Personas (Skills & Plugins)
|
|
44
|
+
|
|
45
|
+
Jiva supports persona-based skill management, fully compatible with Claude's Skills/Plugins system:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# List available personas
|
|
49
|
+
jiva persona list
|
|
50
|
+
|
|
51
|
+
# Activate a persona
|
|
52
|
+
jiva persona activate data-analyst
|
|
53
|
+
|
|
54
|
+
# Create your own skill
|
|
55
|
+
jiva persona create-skill my-skill \
|
|
56
|
+
--description "Custom functionality" \
|
|
57
|
+
--author "Your Name"
|
|
58
|
+
|
|
59
|
+
# Package and distribute
|
|
60
|
+
jiva persona package-skill my-skill
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Key Features:**
|
|
64
|
+
- **Progressive Disclosure**: Skills load only what's needed (L1→L2→L3)
|
|
65
|
+
- **Automatic Routing**: Agent selects skills based on user request
|
|
66
|
+
- **Composable**: Bundle skills, commands, agents, and MCP servers
|
|
67
|
+
- **Portable**: Same .skill files work on Claude and Jiva
|
|
68
|
+
|
|
69
|
+
See **[Personas Guide](docs/guides/PERSONAS.md)** for complete documentation.
|
|
70
|
+
|
|
71
|
+
### v0.2.1 Features
|
|
27
72
|
- **Dual-Agent System**: Separate Manager and Worker agents for better task focus and reliability
|
|
28
73
|
- **Chain-of-Thought Logging**: Transparent reasoning at INFO level with clean ASCII formatting
|
|
29
74
|
- **Robust Error Recovery**: Automatic retry with error feedback for API and tool failures
|
|
30
75
|
- **Workspace-Aware Operations**: Smart path resolution for file operations
|
|
31
76
|
- **Slash Commands**: Use `/help`, `/load`, `/save`, `/list` for easy conversation management
|
|
32
77
|
- **Smart Tool Format Detection**: Auto-detects Harmony vs Standard OpenAI tool calling format
|
|
33
|
-
- **Extensible Architecture**: Designed to expand from CLI to desktop or web applications
|
|
34
78
|
|
|
35
|
-
See [
|
|
79
|
+
See [release notes](docs/release_notes/) for detailed version history.
|
|
36
80
|
|
|
37
|
-
##
|
|
81
|
+
## Installation
|
|
38
82
|
|
|
39
83
|
### Global Install (Recommended)
|
|
40
84
|
|
|
@@ -51,22 +95,16 @@ jiva setup
|
|
|
51
95
|
### Development Install
|
|
52
96
|
|
|
53
97
|
```bash
|
|
54
|
-
git clone https://github.com/
|
|
55
|
-
cd
|
|
56
|
-
npm install
|
|
57
|
-
npm run build
|
|
58
|
-
npm link # For global CLI access
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## 🚀 Quick Start
|
|
98
|
+
git clone https://github.com/KarmaloopAI/Jiva.git
|
|
99
|
+
cd jCLI Mode (Local Development)
|
|
62
100
|
|
|
63
|
-
|
|
101
|
+
#### 1. Install Jiva
|
|
64
102
|
|
|
65
103
|
```bash
|
|
66
104
|
npm install -g jiva-core
|
|
67
105
|
```
|
|
68
106
|
|
|
69
|
-
|
|
107
|
+
#### 2. First-Time Setup
|
|
70
108
|
|
|
71
109
|
Run the interactive setup wizard:
|
|
72
110
|
|
|
@@ -75,12 +113,12 @@ jiva setup
|
|
|
75
113
|
```
|
|
76
114
|
|
|
77
115
|
You'll be prompted for:
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
116
|
+
- Krutrim API endpoint (default: `https://cloud.olakrutrim.com/v1/chat/completions`)
|
|
117
|
+
- API key for gpt-oss-120b ([Get your API key](https://cloud.olakrutrim.com))
|
|
118
|
+
- Optional multimodal model (Llama-4-Maverick-17B)
|
|
119
|
+
- MCP server configuration
|
|
82
120
|
|
|
83
|
-
|
|
121
|
+
#### 3. Start Chatting
|
|
84
122
|
|
|
85
123
|
Launch interactive mode:
|
|
86
124
|
|
|
@@ -98,8 +136,69 @@ You: /save # Save this conversation
|
|
|
98
136
|
You: /list # View all saved conversations
|
|
99
137
|
```
|
|
100
138
|
|
|
139
|
+
### Cloud Run Mode (Production)
|
|
140
|
+
|
|
141
|
+
Deploy Jiva as an auto-scaling HTTP/WebSocket service:
|
|
142
|
+
|
|
143
|
+
#### 1. Prerequisites
|
|
144
|
+
|
|
145
|
+
- Google Cloud account with billing enabled
|
|
146
|
+
- `gcloud` CLI installed and configured
|
|
147
|
+
- Docker installed (for local testing)
|
|
148
|
+
|
|
149
|
+
#### 2. One-Command Deployment
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
git clone https://github.com/KarmaloopAI/Jiva.git
|
|
153
|
+
cd jiva
|
|
154
|
+
./deploy.sh YOUR_PROJECT_ID us-central1
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The script automatically:
|
|
158
|
+
- Enables required GCP APIs
|
|
159
|
+
- Creates GCS bucket for state storage
|
|
160
|
+
- Configures service account and IAM roles
|
|
161
|
+
- Builds and deploys container to Cloud Run
|
|
162
|
+
- Outputs service URL
|
|
163
|
+
|
|
164
|
+
#### 3. Test Deployment
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
SERVICE_URL=$(gcloud run services describe jiva --region=us-central1 --format='value(status.url)')
|
|
168
|
+
|
|
169
|
+
# Health check
|
|
170
|
+
curl $SERVICE_URL/health
|
|
171
|
+
|
|
172
|
+
# Chat endpoint (with auth bypass for testing)
|
|
173
|
+
curl -X POST $SERVICE_URL/api/chat \
|
|
174
|
+
-H "Content-Type: application/json" \
|
|
175
|
+
-H "X-Session-Id: test-session" \
|
|
176
|
+
-d '{"message": "Hello, Jiva!"}'
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Full deployment guide:** [Cloud Run Deployment](docs/deployment/CLOUD_RUN_DEPLOYMENT.md)ry these commands:**
|
|
180
|
+
```bash
|
|
181
|
+
You: /help # Show all available commands
|
|
182
|
+
You: /servers # Check MCP server status
|
|
183
|
+
You: /tools # List all available tools
|
|
184
|
+
You: List files in this directory
|
|
185
|
+
You: /save # Save this conversation
|
|
186
|
+
You: /list # View all saved conversations
|
|
187
|
+
```
|
|
188
|
+
|
|
101
189
|
### 4. Advanced Usage
|
|
102
190
|
|
|
191
|
+
**View current configuration:**
|
|
192
|
+
```bash
|
|
193
|
+
jiva config --show
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Use a custom configuration file:**
|
|
197
|
+
```bash
|
|
198
|
+
jiva chat --config ./my-project-config.json
|
|
199
|
+
jiva run "analyze code" --config ./team-config.json
|
|
200
|
+
```
|
|
201
|
+
|
|
103
202
|
**Custom workspace and directive:**
|
|
104
203
|
```bash
|
|
105
204
|
jiva chat --workspace /path/to/project --directive ./project-directive.md
|
|
@@ -198,7 +297,7 @@ Jiva will automatically look for this file in:
|
|
|
198
297
|
2. `jiva-directive.md` in workspace root
|
|
199
298
|
3. `.jiva/directive.md` in workspace root
|
|
200
299
|
|
|
201
|
-
##
|
|
300
|
+
## MCP Servers
|
|
202
301
|
|
|
203
302
|
Jiva leverages the Model Context Protocol (MCP) to provide extensible tooling. It comes pre-configured with the Filesystem server and makes it easy to add more.
|
|
204
303
|
|
|
@@ -210,7 +309,7 @@ Provides comprehensive file operations across user directories (subject to OS pe
|
|
|
210
309
|
- **Package:** `@modelcontextprotocol/server-filesystem`
|
|
211
310
|
- **Access:** `/Users` (macOS/Linux) or `C:\Users` (Windows)
|
|
212
311
|
- **Tools:** read_file, write_file, list_directory, create_directory, and more
|
|
213
|
-
- **Details:** See [FILESYSTEM_ACCESS.md](docs/FILESYSTEM_ACCESS.md)
|
|
312
|
+
- **Details:** See [FILESYSTEM_ACCESS.md](docs/architecture/FILESYSTEM_ACCESS.md)
|
|
214
313
|
|
|
215
314
|
### Recommended Additional Servers
|
|
216
315
|
|
|
@@ -314,93 +413,140 @@ Edit your config file at `~/.config/jiva-nodejs/config.json` (Linux) or `~/Libra
|
|
|
314
413
|
#### Programmatically
|
|
315
414
|
|
|
316
415
|
```typescript
|
|
317
|
-
|
|
416
|
+
### Three-Agent System (v0.3.1)
|
|
318
417
|
|
|
319
|
-
|
|
320
|
-
command: 'npx',
|
|
321
|
-
args: ['@playwright/mcp@latest'],
|
|
322
|
-
enabled: true,
|
|
323
|
-
});
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
### Checking MCP Server Status
|
|
327
|
-
|
|
328
|
-
```bash
|
|
329
|
-
jiva chat
|
|
330
|
-
# Type: /servers
|
|
331
|
-
```
|
|
418
|
+
Jiva uses a three-agent architecture for intelligent task execution:
|
|
332
419
|
|
|
333
|
-
You'll see:
|
|
334
420
|
```
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
421
|
+
User Request
|
|
422
|
+
↓
|
|
423
|
+
┌────────────────┐
|
|
424
|
+
│ Manager Agent │ Plans subtasks, coordinates workflow
|
|
425
|
+
└────────┬───────┘
|
|
426
|
+
↓
|
|
427
|
+
┌────────────────┐
|
|
428
|
+
│ Worker Agent │ Executes subtasks with MCP tools
|
|
429
|
+
└────────┬───────┘
|
|
430
|
+
↓
|
|
431
|
+
┌────────────────┐
|
|
432
|
+
│ Client Agent │ Validates outputs, ensures quality
|
|
433
|
+
└────────┬───────┘
|
|
434
|
+
↓
|
|
435
|
+
Final Response
|
|
339
436
|
```
|
|
340
437
|
|
|
341
|
-
**
|
|
438
|
+
**Manager Agent**: High-level planning and task decomposition
|
|
439
|
+
**Worker Agent**: Tool execution and information gathering
|
|
440
|
+
**Client Agent**: Adaptive validation and quality control (new in v0.3.1)
|
|
342
441
|
|
|
343
|
-
|
|
442
|
+
The Client agent uses tiered involvement levels to balance quality with efficiency:
|
|
443
|
+
- **MINIMAL**: Information requests → metadata validation only
|
|
444
|
+
- **STANDARD**: Creation tasks → file exists + basic checks
|
|
445
|
+
- **THOROUGH**: Complex tasks or after failures → full E2E validation
|
|
344
446
|
|
|
345
|
-
###
|
|
346
|
-
|
|
347
|
-
While in chat mode, you can use these commands (prefix with `/`):
|
|
348
|
-
|
|
349
|
-
- `/help` - Show available commands
|
|
350
|
-
- `/exit` / `/quit` - Exit the session
|
|
351
|
-
- `/reset` - Reset conversation history
|
|
352
|
-
- `/history` - Show conversation history
|
|
353
|
-
- `/tools` - List available MCP tools
|
|
354
|
-
- `/servers` - Show MCP server status
|
|
355
|
-
- `/save` - Save current conversation ✨ NEW
|
|
356
|
-
- `/load` - Load a saved conversation ✨ NEW
|
|
357
|
-
- `/list` - List all saved conversations ✨ NEW
|
|
358
|
-
|
|
359
|
-
## Architecture
|
|
360
|
-
|
|
361
|
-
Jiva is designed with extensibility in mind:
|
|
447
|
+
### Project Structure
|
|
362
448
|
|
|
363
449
|
```
|
|
364
450
|
jiva/
|
|
365
451
|
├── src/
|
|
366
|
-
│ ├── core/
|
|
367
|
-
│ ├──
|
|
368
|
-
│ ├──
|
|
369
|
-
│ ├──
|
|
370
|
-
│ └──
|
|
452
|
+
│ ├── core/ # Three-agent system
|
|
453
|
+
│ │ ├── dual-agent.ts # Main orchestrator
|
|
454
|
+
│ │ ├── manager-agent.ts # Planning & coordination
|
|
455
|
+
│ │ ├── worker-agent.ts # Tool execution
|
|
456
|
+
│ │ └── client-agent.ts # Quality validation (v0.3.1)
|
|
457
|
+
│ ├── models/ # Model integrations and Harmony format
|
|
458
|
+
│ ├── mcp/ # MCP client and server management
|
|
459
|
+
│ ├── storage/ # Storage abstraction (v0.3.1)
|
|
460
|
+
│ │ ├── local-provider.ts # Filesystem storage
|
|
461
|
+
│ │ └── gcp-bucket-provider.ts # Cloud storage
|
|
462
|
+
│ ├── interfaces/ # CLI and HTTP interfaces
|
|
463
|
+
│ │ ├── cli/ # CLI interface
|
|
464
|
+
│ │ └── http/ # Cloud Run HTTP/WebSocket (v0.3.1)
|
|
465
|
+
│ └── utils/ # Utilities and helpers
|
|
371
466
|
```
|
|
372
467
|
|
|
373
468
|
### Key Components
|
|
374
469
|
|
|
375
|
-
1. **DualAgent**: Main orchestrator coordinating Manager and
|
|
470
|
+
1. **DualAgent**: Main orchestrator coordinating Manager, Worker, and Client agents
|
|
376
471
|
2. **ManagerAgent**: High-level planning, task breakdown, and result synthesis
|
|
377
472
|
3. **WorkerAgent**: Focused tool execution and information gathering
|
|
378
|
-
4. **
|
|
379
|
-
5. **
|
|
380
|
-
6. **
|
|
381
|
-
7. **
|
|
473
|
+
4. **ClientAgent**: Adaptive validation with unjustified failure detection
|
|
474
|
+
5. **ModelOrchestrator**: Manages multi-model coordination (reasoning + multimodal)
|
|
475
|
+
6. **MCPServerManager**: Handles MCP server lifecycle and tool discovery
|
|
476
|
+
7. **StorageProvider**: Unified interface for local/cloud persistence
|
|
477
|
+
8. **SessionManager**: Manages DualAgent lifecycle in cloud deployments
|
|
478
|
+
|
|
479
|
+
**Troubleshooting MCP Issues:** See [TROUBLESHOOTING.md](docs/guides/TROUBLESHOOTING.md#mcp-server-issues)
|
|
480
|
+
|
|
481
|
+
### CLI/Library Mode
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
import {
|
|
485
|
+
DualAgent,
|
|
486
|
+
createKrutrimModel,
|
|
487
|
+
ModelOrchestrator,
|
|
488
|
+
MCPServerManager,
|
|
489
|
+
WorkspaceManager,
|
|
490
|
+
ConversationManager,
|
|
491
|
+
createStorageProvider,
|
|
492
|
+
} from 'jiva-core';
|
|
493
|
+
|
|
494
|
+
// Create storage provider (auto-detects local/cloud)
|
|
495
|
+
const storageProvider = await createStorageProvider();
|
|
496
|
+
|
|
497
|
+
// Create models
|
|
498
|
+
const reasoningModel = createKrutrimModel({
|
|
499
|
+
endpoint: 'https://cloud.olakrutrim.com/v1/chat/completions',
|
|
500
|
+
apiKey: 'your-api-key',
|
|
501
|
+
model: 'gpt-oss-120b',
|
|
502
|
+
type: 'reasoning',
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
// Create orchestrator
|
|
506
|
+
const orchestrator = new ModelOrchestrator({ reasoningModel });
|
|
382
507
|
|
|
383
|
-
|
|
508
|
+
// Initialize MCP
|
|
509
|
+
const mcpManager = new MCPServerManager();
|
|
510
|
+
await mcpManager.initialize({
|
|
511
|
+
filesystem: {
|
|
512
|
+
command: 'npx',
|
|
513
|
+
args: ['-y', '@modelcontextprotocol/server-filesystem', process.cwd()],
|
|
514
|
+
enabled: true,
|
|
515
|
+
},
|
|
516
|
+
});
|
|
384
517
|
|
|
385
|
-
|
|
518
|
+
// Initialize workspace
|
|
519
|
+
const workspace = new WorkspaceManager(storageProvider);
|
|
520
|
+
await workspace.initialize();
|
|
386
521
|
|
|
387
|
-
|
|
522
|
+
// Initialize conversation manager
|
|
523
|
+
const conversationManager = new ConversationManager(storageProvider);
|
|
388
524
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
525
|
+
// Create three-agent system
|
|
526
|
+
const agent = new DualAgent({
|
|
527
|
+
orchestrator,
|
|
528
|
+
mcpManager,
|
|
529
|
+
workspace,
|
|
530
|
+
conversationManager,
|
|
531
|
+
maxSubtasks: 20, // Manager's subtask limit
|
|
532
|
+
maxIterations: 10, // Worker's iteration limit per subtask
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// Use agent
|
|
536
|
+
const response = await agent.chat('Hello, Jiva!');
|
|
537
|
+
console.log(response.content);
|
|
538
|
+
console.log(`Plan: ${response.plan?.subtasks.join(', ')}`);
|
|
539
|
+
console.log(`Tools used: ${response.toolsUsed.join(', ')}`);
|
|
540
|
+
|
|
541
|
+
// Cleanup
|
|
542
|
+
await agent.cleanup();
|
|
543
|
+
```
|
|
393
544
|
|
|
394
|
-
###
|
|
395
|
-
- Analysis channel: Chain-of-thought reasoning
|
|
396
|
-
- Final channel: User-facing responses
|
|
397
|
-
- Tool calling: Structured function calls
|
|
545
|
+
### Cloud Mode (HTTP/WebSocket)
|
|
398
546
|
|
|
399
|
-
|
|
400
|
-
- Retry logic for malformed tool calls
|
|
401
|
-
- Graceful degradation when tools fail
|
|
402
|
-
- Detailed logging for debugging
|
|
547
|
+
For cloud deployments, see the [HTTP interface documentation](docs/deployment/CLOUD_RUN_IMPLEMENTATION.md) and [example programs](examples/).
|
|
403
548
|
|
|
549
|
+
**Key difference:** Cloud mode uses `SessionManager` to handle multiple concurrent agent instances with per-tenant isolation.
|
|
404
550
|
## Development
|
|
405
551
|
|
|
406
552
|
### Build
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Cloud Run service configuration for Jiva
|
|
2
|
+
# Deploy with: gcloud run services replace cloud-run.yaml
|
|
3
|
+
|
|
4
|
+
apiVersion: serving.knative.dev/v1
|
|
5
|
+
kind: Service
|
|
6
|
+
metadata:
|
|
7
|
+
name: jiva
|
|
8
|
+
labels:
|
|
9
|
+
app: jiva
|
|
10
|
+
environment: production
|
|
11
|
+
spec:
|
|
12
|
+
template:
|
|
13
|
+
metadata:
|
|
14
|
+
annotations:
|
|
15
|
+
# Launch stage for beta features
|
|
16
|
+
run.googleapis.com/launch-stage: "BETA"
|
|
17
|
+
|
|
18
|
+
# Scale to zero when idle
|
|
19
|
+
autoscaling.knative.dev/minScale: "0"
|
|
20
|
+
autoscaling.knative.dev/maxScale: "10"
|
|
21
|
+
|
|
22
|
+
# CPU allocation - always allocated since we need WebSocket support
|
|
23
|
+
run.googleapis.com/cpu-throttling: "false"
|
|
24
|
+
|
|
25
|
+
# Startup probe for slow initialization
|
|
26
|
+
run.googleapis.com/startup-cpu-boost: "true"
|
|
27
|
+
|
|
28
|
+
# Container execution environment
|
|
29
|
+
run.googleapis.com/execution-environment: gen2
|
|
30
|
+
|
|
31
|
+
# Session affinity for WebSocket connections
|
|
32
|
+
run.googleapis.com/session-affinity: "true"
|
|
33
|
+
spec:
|
|
34
|
+
# Timeout for long-running WebSocket sessions
|
|
35
|
+
timeoutSeconds: 3600 # 60 minutes
|
|
36
|
+
|
|
37
|
+
# Container concurrency (WebSocket connections per instance)
|
|
38
|
+
containerConcurrency: 80
|
|
39
|
+
|
|
40
|
+
serviceAccountName: jiva-cloud-run@gritsa-technologies.iam.gserviceaccount.com
|
|
41
|
+
|
|
42
|
+
containers:
|
|
43
|
+
- name: jiva
|
|
44
|
+
image: gcr.io/gritsa-technologies/jiva:latest
|
|
45
|
+
|
|
46
|
+
ports:
|
|
47
|
+
- name: http1
|
|
48
|
+
containerPort: 8080
|
|
49
|
+
|
|
50
|
+
env:
|
|
51
|
+
# Node environment
|
|
52
|
+
- name: NODE_ENV
|
|
53
|
+
value: "production"
|
|
54
|
+
|
|
55
|
+
# Server configuration
|
|
56
|
+
- name: LOG_LEVEL
|
|
57
|
+
value: "info"
|
|
58
|
+
|
|
59
|
+
# Storage configuration
|
|
60
|
+
- name: JIVA_STORAGE_PROVIDER
|
|
61
|
+
value: "gcp"
|
|
62
|
+
- name: JIVA_GCP_BUCKET
|
|
63
|
+
value: "jiva-state-gritsa-technologies"
|
|
64
|
+
- name: JIVA_GCP_PROJECT
|
|
65
|
+
value: "gritsa-technologies"
|
|
66
|
+
|
|
67
|
+
# Session configuration
|
|
68
|
+
- name: MAX_CONCURRENT_SESSIONS
|
|
69
|
+
value: "100"
|
|
70
|
+
- name: SESSION_IDLE_TIMEOUT_MS
|
|
71
|
+
value: "1800000" # 30 minutes
|
|
72
|
+
|
|
73
|
+
# Authentication
|
|
74
|
+
- name: AUTH_STRATEGY
|
|
75
|
+
value: "firebase" # or "custom"
|
|
76
|
+
- name: AUTH_DISABLED
|
|
77
|
+
value: "true" # Set to false for production
|
|
78
|
+
|
|
79
|
+
# Model configuration (from Secret Manager)
|
|
80
|
+
- name: JIVA_MODEL_PROVIDER
|
|
81
|
+
value: "krutrim"
|
|
82
|
+
- name: JIVA_MODEL_API_KEY
|
|
83
|
+
valueFrom:
|
|
84
|
+
secretKeyRef:
|
|
85
|
+
name: jiva-model-api-key
|
|
86
|
+
key: latest
|
|
87
|
+
- name: JIVA_MODEL_BASE_URL
|
|
88
|
+
value: "https://cloud.olakrutrim.com/v1/chat/completions"
|
|
89
|
+
- name: JIVA_MODEL_NAME
|
|
90
|
+
value: "gpt-oss-120b"
|
|
91
|
+
|
|
92
|
+
# MCP Server Configuration
|
|
93
|
+
- name: ENABLE_MCP_SERVERS
|
|
94
|
+
value: "true"
|
|
95
|
+
- name: MCP_FILESYSTEM_ENABLED
|
|
96
|
+
value: "true"
|
|
97
|
+
- name: MCP_FILESYSTEM_ALLOWED_PATHS
|
|
98
|
+
value: "/tmp,/workspace"
|
|
99
|
+
|
|
100
|
+
# CORS allowed origins
|
|
101
|
+
- name: ALLOWED_ORIGINS
|
|
102
|
+
value: "https://yourdomain.com,https://app.yourdomain.com"
|
|
103
|
+
|
|
104
|
+
resources:
|
|
105
|
+
limits:
|
|
106
|
+
# CPU: 2 vCPU for handling concurrent sessions
|
|
107
|
+
cpu: "2000m"
|
|
108
|
+
# Memory: 4GB for model inference and session state
|
|
109
|
+
memory: "4Gi"
|
|
110
|
+
requests:
|
|
111
|
+
cpu: "1000m"
|
|
112
|
+
memory: "2Gi"
|
|
113
|
+
|
|
114
|
+
# Health probes
|
|
115
|
+
startupProbe:
|
|
116
|
+
httpGet:
|
|
117
|
+
path: /startup
|
|
118
|
+
port: 8080
|
|
119
|
+
initialDelaySeconds: 0
|
|
120
|
+
periodSeconds: 10
|
|
121
|
+
timeoutSeconds: 5
|
|
122
|
+
failureThreshold: 3
|
|
123
|
+
|
|
124
|
+
livenessProbe:
|
|
125
|
+
httpGet:
|
|
126
|
+
path: /health
|
|
127
|
+
port: 8080
|
|
128
|
+
initialDelaySeconds: 0
|
|
129
|
+
periodSeconds: 10
|
|
130
|
+
timeoutSeconds: 5
|
|
131
|
+
failureThreshold: 3
|
|
132
|
+
|
|
133
|
+
traffic:
|
|
134
|
+
- percent: 100
|
|
135
|
+
latestRevision: true
|