jiva-core 0.2.3 → 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.
Files changed (140) hide show
  1. package/.dockerignore +53 -0
  2. package/.gcloudignore +49 -0
  3. package/CONTRIBUTING.md +92 -0
  4. package/Dockerfile +63 -0
  5. package/README.md +228 -88
  6. package/cloud-run-deploy.yaml +135 -0
  7. package/cloud-run.yaml +135 -0
  8. package/cloud-run.yaml.template +143 -0
  9. package/deploy.sh +107 -0
  10. package/dist/core/agent-spawner.d.ts +89 -0
  11. package/dist/core/agent-spawner.d.ts.map +1 -0
  12. package/dist/core/agent-spawner.js +195 -0
  13. package/dist/core/agent-spawner.js.map +1 -0
  14. package/dist/core/client-agent.d.ts +82 -0
  15. package/dist/core/client-agent.d.ts.map +1 -0
  16. package/dist/core/client-agent.js +406 -0
  17. package/dist/core/client-agent.js.map +1 -0
  18. package/dist/core/config.d.ts +59 -10
  19. package/dist/core/config.d.ts.map +1 -1
  20. package/dist/core/config.js +19 -2
  21. package/dist/core/config.js.map +1 -1
  22. package/dist/core/conversation-manager.d.ts +10 -18
  23. package/dist/core/conversation-manager.d.ts.map +1 -1
  24. package/dist/core/conversation-manager.js +28 -60
  25. package/dist/core/conversation-manager.js.map +1 -1
  26. package/dist/core/dual-agent.d.ts +22 -3
  27. package/dist/core/dual-agent.d.ts.map +1 -1
  28. package/dist/core/dual-agent.js +84 -10
  29. package/dist/core/dual-agent.js.map +1 -1
  30. package/dist/core/manager-agent.d.ts +3 -1
  31. package/dist/core/manager-agent.d.ts.map +1 -1
  32. package/dist/core/manager-agent.js +7 -1
  33. package/dist/core/manager-agent.js.map +1 -1
  34. package/dist/core/worker-agent.d.ts +9 -1
  35. package/dist/core/worker-agent.d.ts.map +1 -1
  36. package/dist/core/worker-agent.js +160 -13
  37. package/dist/core/worker-agent.js.map +1 -1
  38. package/dist/core/workspace.d.ts +5 -0
  39. package/dist/core/workspace.d.ts.map +1 -1
  40. package/dist/core/workspace.js +47 -7
  41. package/dist/core/workspace.js.map +1 -1
  42. package/dist/index.d.ts +3 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +4 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/interfaces/cli/index.js +349 -42
  47. package/dist/interfaces/cli/index.js.map +1 -1
  48. package/dist/interfaces/http/index.d.ts +22 -0
  49. package/dist/interfaces/http/index.d.ts.map +1 -0
  50. package/dist/interfaces/http/index.js +135 -0
  51. package/dist/interfaces/http/index.js.map +1 -0
  52. package/dist/interfaces/http/middleware/auth.d.ts +32 -0
  53. package/dist/interfaces/http/middleware/auth.d.ts.map +1 -0
  54. package/dist/interfaces/http/middleware/auth.js +176 -0
  55. package/dist/interfaces/http/middleware/auth.js.map +1 -0
  56. package/dist/interfaces/http/routes/chat.d.ts +7 -0
  57. package/dist/interfaces/http/routes/chat.d.ts.map +1 -0
  58. package/dist/interfaces/http/routes/chat.js +144 -0
  59. package/dist/interfaces/http/routes/chat.js.map +1 -0
  60. package/dist/interfaces/http/routes/health.d.ts +6 -0
  61. package/dist/interfaces/http/routes/health.d.ts.map +1 -0
  62. package/dist/interfaces/http/routes/health.js +25 -0
  63. package/dist/interfaces/http/routes/health.js.map +1 -0
  64. package/dist/interfaces/http/routes/session.d.ts +7 -0
  65. package/dist/interfaces/http/routes/session.d.ts.map +1 -0
  66. package/dist/interfaces/http/routes/session.js +114 -0
  67. package/dist/interfaces/http/routes/session.js.map +1 -0
  68. package/dist/interfaces/http/session-manager.d.ts +76 -0
  69. package/dist/interfaces/http/session-manager.d.ts.map +1 -0
  70. package/dist/interfaces/http/session-manager.js +339 -0
  71. package/dist/interfaces/http/session-manager.js.map +1 -0
  72. package/dist/interfaces/http/websocket-handler.d.ts +18 -0
  73. package/dist/interfaces/http/websocket-handler.d.ts.map +1 -0
  74. package/dist/interfaces/http/websocket-handler.js +146 -0
  75. package/dist/interfaces/http/websocket-handler.js.map +1 -0
  76. package/dist/mcp/client.d.ts +11 -2
  77. package/dist/mcp/client.d.ts.map +1 -1
  78. package/dist/mcp/client.js +44 -19
  79. package/dist/mcp/client.js.map +1 -1
  80. package/dist/mcp/server-manager.d.ts +1 -1
  81. package/dist/mcp/server-manager.d.ts.map +1 -1
  82. package/dist/mcp/server-manager.js +12 -2
  83. package/dist/mcp/server-manager.js.map +1 -1
  84. package/dist/personas/index.d.ts +13 -0
  85. package/dist/personas/index.d.ts.map +1 -0
  86. package/dist/personas/index.js +13 -0
  87. package/dist/personas/index.js.map +1 -0
  88. package/dist/personas/persona-loader.d.ts +30 -0
  89. package/dist/personas/persona-loader.d.ts.map +1 -0
  90. package/dist/personas/persona-loader.js +246 -0
  91. package/dist/personas/persona-loader.js.map +1 -0
  92. package/dist/personas/persona-manager.d.ts +82 -0
  93. package/dist/personas/persona-manager.d.ts.map +1 -0
  94. package/dist/personas/persona-manager.js +211 -0
  95. package/dist/personas/persona-manager.js.map +1 -0
  96. package/dist/personas/skill-loader.d.ts +35 -0
  97. package/dist/personas/skill-loader.d.ts.map +1 -0
  98. package/dist/personas/skill-loader.js +144 -0
  99. package/dist/personas/skill-loader.js.map +1 -0
  100. package/dist/personas/skill-packager.d.ts +25 -0
  101. package/dist/personas/skill-packager.d.ts.map +1 -0
  102. package/dist/personas/skill-packager.js +233 -0
  103. package/dist/personas/skill-packager.js.map +1 -0
  104. package/dist/personas/types.d.ts +134 -0
  105. package/dist/personas/types.d.ts.map +1 -0
  106. package/dist/personas/types.js +7 -0
  107. package/dist/personas/types.js.map +1 -0
  108. package/dist/personas/validator.d.ts +22 -0
  109. package/dist/personas/validator.d.ts.map +1 -0
  110. package/dist/personas/validator.js +144 -0
  111. package/dist/personas/validator.js.map +1 -0
  112. package/dist/storage/factory.d.ts +51 -0
  113. package/dist/storage/factory.d.ts.map +1 -0
  114. package/dist/storage/factory.js +154 -0
  115. package/dist/storage/factory.js.map +1 -0
  116. package/dist/storage/gcp-bucket-provider.d.ts +59 -0
  117. package/dist/storage/gcp-bucket-provider.d.ts.map +1 -0
  118. package/dist/storage/gcp-bucket-provider.js +275 -0
  119. package/dist/storage/gcp-bucket-provider.js.map +1 -0
  120. package/dist/storage/index.d.ts +33 -0
  121. package/dist/storage/index.d.ts.map +1 -0
  122. package/dist/storage/index.js +37 -0
  123. package/dist/storage/index.js.map +1 -0
  124. package/dist/storage/local-provider.d.ts +36 -0
  125. package/dist/storage/local-provider.d.ts.map +1 -0
  126. package/dist/storage/local-provider.js +219 -0
  127. package/dist/storage/local-provider.js.map +1 -0
  128. package/dist/storage/provider.d.ts +137 -0
  129. package/dist/storage/provider.d.ts.map +1 -0
  130. package/dist/storage/provider.js +136 -0
  131. package/dist/storage/provider.js.map +1 -0
  132. package/dist/storage/types.d.ts +78 -0
  133. package/dist/storage/types.d.ts.map +1 -0
  134. package/dist/storage/types.js +14 -0
  135. package/dist/storage/types.js.map +1 -0
  136. package/package.json +30 -2
  137. package/.fluen/cache/state.json +0 -7
  138. package/actions/action_registry.py +0 -75
  139. package/actions/python_coder.py +0 -470
  140. package/api/main.py +0 -269
package/.dockerignore ADDED
@@ -0,0 +1,53 @@
1
+ # Node modules (will be reinstalled)
2
+ node_modules/
3
+
4
+ # Build outputs (will be rebuilt)
5
+ dist/
6
+
7
+ # Development files
8
+ *.log
9
+ npm-debug.log*
10
+ yarn-debug.log*
11
+ yarn-error.log*
12
+ .npm
13
+ .eslintcache
14
+
15
+ # IDE
16
+ .vscode/
17
+ .idea/
18
+ *.swp
19
+ *.swo
20
+ *~
21
+ .DS_Store
22
+
23
+ # Git
24
+ .git/
25
+ .gitignore
26
+ .gitattributes
27
+
28
+ # Documentation
29
+ *.md
30
+ !README.md
31
+ docs/
32
+ examples/
33
+
34
+ # Tests
35
+ test/
36
+ tests/
37
+ *.test.ts
38
+ *.spec.ts
39
+
40
+ # CI/CD
41
+ .github/
42
+ .gitlab-ci.yml
43
+ .travis.yml
44
+
45
+ # Local development
46
+ .env
47
+ .env.local
48
+ .env.*.local
49
+
50
+ # Temporary files
51
+ tmp/
52
+ temp/
53
+ *.tmp
package/.gcloudignore ADDED
@@ -0,0 +1,49 @@
1
+ # Google Cloud Build ignore patterns
2
+ # Files not needed in Cloud Build/Container Registry
3
+
4
+ # Node modules (will be installed in container)
5
+ node_modules/
6
+
7
+ # Development and docs
8
+ docs/
9
+ examples/
10
+ *.md
11
+ !README.md
12
+
13
+ # Git
14
+ .git/
15
+ .gitignore
16
+ .gitattributes
17
+
18
+ # Editor
19
+ .vscode/
20
+ .idea/
21
+ *.swp
22
+ *.swo
23
+
24
+ # OS
25
+ .DS_Store
26
+ Thumbs.db
27
+
28
+ # Logs
29
+ *.log
30
+
31
+ # Build artifacts (will be rebuilt)
32
+ dist/
33
+ *.tsbuildinfo
34
+
35
+ # Test files
36
+ test/
37
+ tests/
38
+ *.test.ts
39
+ *.test.js
40
+ *.spec.ts
41
+ *.spec.js
42
+
43
+ # npm package files
44
+ .npmignore
45
+ .npmrc
46
+
47
+ # Scripts (except deploy.sh which is needed)
48
+ setup.sh
49
+ fix-filesystem-config.js
@@ -0,0 +1,92 @@
1
+ # Contributing to Jiva
2
+
3
+ Thank you for your interest in contributing to Jiva! This document provides guidelines for contributing to the project.
4
+
5
+ ## Code of Conduct
6
+
7
+ Be respectful and constructive in your interactions with other contributors.
8
+
9
+ ## Getting Started
10
+
11
+ 1. **Fork the repository** on GitHub
12
+ 2. **Clone your fork:**
13
+ ```bash
14
+ git clone https://github.com/YOUR_USERNAME/Jiva.git
15
+ cd Jiva
16
+ ```
17
+ 3. **Install dependencies:**
18
+ ```bash
19
+ npm install
20
+ ```
21
+ 4. **Build the project:**
22
+ ```bash
23
+ npm run build
24
+ ```
25
+
26
+ ## Development Workflow
27
+
28
+ See [docs/guides/DEV_WORKFLOW.md](docs/guides/DEV_WORKFLOW.md) for detailed development instructions.
29
+
30
+ ### Quick Commands
31
+
32
+ ```bash
33
+ npm run build # Compile TypeScript
34
+ npm run dev # Watch mode for development
35
+ npm run type-check # Check TypeScript types
36
+ npm test # Run tests (when available)
37
+ ```
38
+
39
+ ## Making Changes
40
+
41
+ 1. **Create a feature branch:**
42
+ ```bash
43
+ git checkout -b feature/your-feature-name
44
+ ```
45
+
46
+ 2. **Make your changes** following the coding standards
47
+
48
+ 3. **Test your changes:**
49
+ ```bash
50
+ npm run build
51
+ npm link # Test CLI globally
52
+ jiva chat # Verify functionality
53
+ ```
54
+
55
+ 4. **Commit with clear messages:**
56
+ ```bash
57
+ git commit -m "feat: add new feature X"
58
+ ```
59
+
60
+ ## Coding Standards
61
+
62
+ - **TypeScript**: All code must be in TypeScript
63
+ - **Formatting**: Follow existing code style
64
+ - **Error Handling**: All functions should handle errors gracefully
65
+ - **Logging**: Use the logger utility for consistent logging
66
+ - **Documentation**: Update docs for new features
67
+
68
+ ## Pull Request Process
69
+
70
+ 1. **Update documentation** for any changed functionality
71
+ 2. **Update README.md** if adding new features
72
+ 3. **Add release notes** in `docs/release_notes/` if applicable
73
+ 4. **Create pull request** with clear description of changes
74
+ 5. **Link related issues** in the PR description
75
+
76
+ ## Areas for Contribution
77
+
78
+ - Bug fixes
79
+ - New MCP server integrations
80
+ - Documentation improvements
81
+ - Performance optimizations
82
+ - Test coverage
83
+ - Storage provider implementations (S3, Redis, etc.)
84
+ - UI/UX improvements for CLI interface
85
+
86
+ ## Questions?
87
+
88
+ Open an issue on GitHub for any questions about contributing.
89
+
90
+ ## License
91
+
92
+ By contributing to Jiva, you agree that your contributions will be licensed under the MIT License.
package/Dockerfile ADDED
@@ -0,0 +1,63 @@
1
+ # Multi-stage build for Jiva Cloud Run deployment
2
+ # Stage 1: Build
3
+ FROM node:20-alpine AS builder
4
+
5
+ WORKDIR /app
6
+
7
+ # Copy package files
8
+ COPY package*.json ./
9
+ COPY tsconfig.json ./
10
+
11
+ # Install dependencies (including dev dependencies for build)
12
+ RUN npm ci
13
+
14
+ # Copy source code
15
+ COPY src ./src
16
+
17
+ # Build TypeScript
18
+ RUN npm run build
19
+
20
+ # Stage 2: Production
21
+ FROM node:20-alpine
22
+
23
+ WORKDIR /app
24
+
25
+ # Install dumb-init for proper signal handling
26
+ RUN apk add --no-cache dumb-init
27
+
28
+ # Copy package files
29
+ COPY package*.json ./
30
+
31
+ # Install production dependencies only
32
+ RUN npm ci --omit=dev && npm cache clean --force
33
+
34
+ # Copy built application from builder
35
+ COPY --from=builder /app/dist ./dist
36
+
37
+ # Create non-root user
38
+ RUN addgroup -g 1001 -S nodejs && \
39
+ adduser -S nodejs -u 1001 && \
40
+ chown -R nodejs:nodejs /app
41
+
42
+ USER nodejs
43
+
44
+ # Environment variables (overrideable)
45
+ ENV NODE_ENV=production \
46
+ PORT=8080 \
47
+ LOG_LEVEL=info \
48
+ JIVA_STORAGE_PROVIDER=gcp \
49
+ MAX_CONCURRENT_SESSIONS=100 \
50
+ SESSION_IDLE_TIMEOUT_MS=1800000
51
+
52
+ # Expose port
53
+ EXPOSE 8080
54
+
55
+ # Health check
56
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
57
+ CMD node -e "require('http').get('http://localhost:8080/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
58
+
59
+ # Use dumb-init to handle signals properly
60
+ ENTRYPOINT ["dumb-init", "--"]
61
+
62
+ # Start HTTP server
63
+ CMD ["node", "dist/interfaces/http/index.js"]
package/README.md CHANGED
@@ -2,15 +2,16 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/jiva-core.svg)](https://www.npmjs.com/package/jiva-core) [![License](https://img.shields.io/github/license/KarmaloopAI/Jiva.svg)](LICENSE) [![GitHub stars](https://img.shields.io/github/stars/KarmaloopAI/Jiva.svg?style=social&label=Star)](https://github.com/KarmaloopAI/Jiva)
4
4
 
5
- Jiva is a powerful autonomous AI agent powered by gpt-oss-120b with full MCP (Model Context Protocol) support. It's designed to be highly goal-oriented, autonomous, and extensible for various use cases.
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
7
  ## Quick Links
8
8
 
9
- - **[Quick Start Guide](docs/QUICKSTART.md)** - Get up and running in 30 seconds
10
- - **[Configuration Guide](docs/CONFIGURATION.md)** - Detailed configuration and provider setup
11
- - **[New Features Guide](docs/NEW_FEATURES.md)** - Latest improvements and features
12
- - **[Build Instructions](docs/BUILD.md)** - Detailed setup and development workflow
13
- - **[Troubleshooting](docs/TROUBLESHOOTING.md)** - Common issues and solutions
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
14
15
 
15
16
  ## Demo
16
17
 
@@ -19,26 +20,63 @@ Jiva is a powerful autonomous AI agent powered by gpt-oss-120b with full MCP (Mo
19
20
  ## Features
20
21
 
21
22
  ### Core Capabilities
22
- - **Dual-Agent Architecture**: Manager + Worker pattern for reliable task execution and planning
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
23
28
  - **Provider Agnostic**: Works with Krutrim, Groq, OpenAI, Ollama, and any OpenAI-compatible API
24
- - **Three-Phase Execution**: Planning → Execution → Synthesis for structured task completion
25
29
  - **MCP Integration**: Seamless integration with Model Context Protocol servers for extensible tooling
26
30
  - **Smart Conversations**: Auto-save, restore, and AI-generated titles for all conversations
27
- - **Pretty Markdown**: Beautiful terminal output with syntax highlighting
28
31
  - **Directive-Based**: Orient agent behavior with custom `jiva-directive.md` files
29
- - **Multi-Modal Support**: Optional image understanding via Llama-4-Maverick-17B
30
- - **Auto-Condensing**: Intelligent conversation history management to prevent token overload
32
+ - **Storage Abstraction**: Local filesystem or cloud storage (GCS, future: S3, Redis)
31
33
 
32
- ### Advanced Features (v0.2.1)
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
33
72
  - **Dual-Agent System**: Separate Manager and Worker agents for better task focus and reliability
34
73
  - **Chain-of-Thought Logging**: Transparent reasoning at INFO level with clean ASCII formatting
35
74
  - **Robust Error Recovery**: Automatic retry with error feedback for API and tool failures
36
75
  - **Workspace-Aware Operations**: Smart path resolution for file operations
37
76
  - **Slash Commands**: Use `/help`, `/load`, `/save`, `/list` for easy conversation management
38
77
  - **Smart Tool Format Detection**: Auto-detects Harmony vs Standard OpenAI tool calling format
39
- - **Extensible Architecture**: Designed to expand from CLI to desktop or web applications
40
78
 
41
- See [NEW_FEATURES.md](docs/NEW_FEATURES.md) for detailed information.
79
+ See [release notes](docs/release_notes/) for detailed version history.
42
80
 
43
81
  ## Installation
44
82
 
@@ -58,21 +96,15 @@ jiva setup
58
96
 
59
97
  ```bash
60
98
  git clone https://github.com/KarmaloopAI/Jiva.git
61
- cd jiva
62
- npm install
63
- npm run build
64
- npm link # For global CLI access
65
- ```
99
+ cd jCLI Mode (Local Development)
66
100
 
67
- ## Quick Start
68
-
69
- ### 1. Install Jiva
101
+ #### 1. Install Jiva
70
102
 
71
103
  ```bash
72
104
  npm install -g jiva-core
73
105
  ```
74
106
 
75
- ### 2. First-Time Setup
107
+ #### 2. First-Time Setup
76
108
 
77
109
  Run the interactive setup wizard:
78
110
 
@@ -86,7 +118,7 @@ You'll be prompted for:
86
118
  - Optional multimodal model (Llama-4-Maverick-17B)
87
119
  - MCP server configuration
88
120
 
89
- ### 3. Start Chatting
121
+ #### 3. Start Chatting
90
122
 
91
123
  Launch interactive mode:
92
124
 
@@ -104,8 +136,69 @@ You: /save # Save this conversation
104
136
  You: /list # View all saved conversations
105
137
  ```
106
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
+
107
189
  ### 4. Advanced Usage
108
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
+
109
202
  **Custom workspace and directive:**
110
203
  ```bash
111
204
  jiva chat --workspace /path/to/project --directive ./project-directive.md
@@ -216,7 +309,7 @@ Provides comprehensive file operations across user directories (subject to OS pe
216
309
  - **Package:** `@modelcontextprotocol/server-filesystem`
217
310
  - **Access:** `/Users` (macOS/Linux) or `C:\Users` (Windows)
218
311
  - **Tools:** read_file, write_file, list_directory, create_directory, and more
219
- - **Details:** See [FILESYSTEM_ACCESS.md](docs/FILESYSTEM_ACCESS.md)
312
+ - **Details:** See [FILESYSTEM_ACCESS.md](docs/architecture/FILESYSTEM_ACCESS.md)
220
313
 
221
314
  ### Recommended Additional Servers
222
315
 
@@ -320,93 +413,140 @@ Edit your config file at `~/.config/jiva-nodejs/config.json` (Linux) or `~/Libra
320
413
  #### Programmatically
321
414
 
322
415
  ```typescript
323
- import { configManager } from 'jiva-core';
416
+ ### Three-Agent System (v0.3.1)
324
417
 
325
- configManager.addMCPServer('playwright', {
326
- command: 'npx',
327
- args: ['@playwright/mcp@latest'],
328
- enabled: true,
329
- });
330
- ```
331
-
332
- ### Checking MCP Server Status
333
-
334
- ```bash
335
- jiva chat
336
- # Type: /servers
337
- ```
418
+ Jiva uses a three-agent architecture for intelligent task execution:
338
419
 
339
- You'll see:
340
420
  ```
341
- MCP Servers:
342
- ✓ filesystem: 12 tools
343
- ✓ playwright: 8 tools
344
- desktop-commander: 6 tools
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
345
436
  ```
346
437
 
347
- **Troubleshooting MCP Issues:** See [TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md#mcp-server-issues)
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)
348
441
 
349
- ## CLI Commands
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
350
446
 
351
- ### Interactive Mode Commands
352
-
353
- While in chat mode, you can use these commands (prefix with `/`):
354
-
355
- - `/help` - Show available commands
356
- - `/exit` / `/quit` - Exit the session
357
- - `/reset` - Reset conversation history
358
- - `/history` - Show conversation history
359
- - `/tools` - List available MCP tools
360
- - `/servers` - Show MCP server status
361
- - `/save` - Save current conversation ✨ NEW
362
- - `/load` - Load a saved conversation ✨ NEW
363
- - `/list` - List all saved conversations ✨ NEW
364
-
365
- ## Architecture
366
-
367
- Jiva is designed with extensibility in mind:
447
+ ### Project Structure
368
448
 
369
449
  ```
370
450
  jiva/
371
451
  ├── src/
372
- │ ├── core/ # Core agent logic
373
- │ ├── models/ # Model integrations and Harmony format
374
- │ ├── mcp/ # MCP client and server management
375
- │ ├── interfaces/ # CLI, Electron, Web interfaces
376
- │ └── utils/ # Utilities and helpers
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
377
466
  ```
378
467
 
379
468
  ### Key Components
380
469
 
381
- 1. **DualAgent**: Main orchestrator coordinating Manager and Worker agents (v0.2.1+)
470
+ 1. **DualAgent**: Main orchestrator coordinating Manager, Worker, and Client agents
382
471
  2. **ManagerAgent**: High-level planning, task breakdown, and result synthesis
383
472
  3. **WorkerAgent**: Focused tool execution and information gathering
384
- 4. **ModelOrchestrator**: Manages multi-model coordination (reasoning + multimodal)
385
- 5. **MCPServerManager**: Handles MCP server lifecycle and tool discovery
386
- 6. **WorkspaceManager**: Manages workspace directory and directive files
387
- 7. **Harmony Format Handler**: Implements gpt-oss-120b's required response format
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 });
388
507
 
389
- **Legacy:** JivaAgent (single-agent) remains available for compatibility
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
+ });
390
517
 
391
- ## Working with gpt-oss-120b
518
+ // Initialize workspace
519
+ const workspace = new WorkspaceManager(storageProvider);
520
+ await workspace.initialize();
392
521
 
393
- The gpt-oss-120b model requires the Harmony response format. Jiva handles this automatically with:
522
+ // Initialize conversation manager
523
+ const conversationManager = new ConversationManager(storageProvider);
394
524
 
395
- ### Tool Call Parsing
396
- - Robust parsing of `<|call|>function_name({"param": "value"})<|return|>` format
397
- - Automatic JSON fixing for common formatting issues
398
- - Validation against available tools
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
+ ```
399
544
 
400
- ### Multi-Channel Output
401
- - Analysis channel: Chain-of-thought reasoning
402
- - Final channel: User-facing responses
403
- - Tool calling: Structured function calls
545
+ ### Cloud Mode (HTTP/WebSocket)
404
546
 
405
- ### Error Handling
406
- - Retry logic for malformed tool calls
407
- - Graceful degradation when tools fail
408
- - Detailed logging for debugging
547
+ For cloud deployments, see the [HTTP interface documentation](docs/deployment/CLOUD_RUN_IMPLEMENTATION.md) and [example programs](examples/).
409
548
 
549
+ **Key difference:** Cloud mode uses `SessionManager` to handle multiple concurrent agent instances with per-tenant isolation.
410
550
  ## Development
411
551
 
412
552
  ### Build