@praveencs/agent 0.9.8 → 0.9.10

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.
@@ -0,0 +1,154 @@
1
+ # Agent Studio — Visual Management Console
2
+
3
+ > The web-based command center for your Agent Runtime instances.
4
+
5
+ Agent Studio is the visual companion to the CLI. It provides a unified dashboard where
6
+ you can monitor live instances, manage goals, create skills and commands, control the
7
+ daemon, and explore agent memory — all from your browser.
8
+
9
+ ---
10
+
11
+ ## 🚀 Launching Studio
12
+
13
+ ```bash
14
+ agent studio
15
+ # → Agent Studio running at http://localhost:3333
16
+ ```
17
+
18
+ The command starts an Express server that serves both the REST API and the React frontend.
19
+
20
+ ---
21
+
22
+ ## Dashboard
23
+
24
+ The landing page shows all active Agent instances — both interactive REPL sessions and
25
+ background daemon processes.
26
+
27
+ Each instance card displays:
28
+ - **Project name** and working directory
29
+ - **PID** for process identification
30
+ - **Status badge** (Active / Daemon)
31
+ - Quick navigation buttons for Console and Capabilities
32
+
33
+ ![Agent Studio Dashboard](studio-screenshot-1.png)
34
+
35
+ ---
36
+
37
+ ## Instance Control Panel
38
+
39
+ Click any instance to enter the **control panel** with a sidebar of 9 sections:
40
+
41
+ | Section | Purpose |
42
+ |---------|---------|
43
+ | **Console** | Live terminal — send commands, see agent output in real-time |
44
+ | **Capabilities** | Read-only view of loaded skills, commands, scripts, plugins |
45
+ | **Goals & Plans** | Create goals, view tasks, update statuses |
46
+ | **Skills** | CRUD manager for skill definitions (skill.json + prompt.md) |
47
+ | **Commands** | Create/delete lightweight command templates |
48
+ | **Scripts** | Create/delete local automation scripts |
49
+ | **Plugins** | View and remove installed plugin bundles |
50
+ | **Daemon** | Start/stop the background worker, view daemon logs |
51
+ | **Memory** | Search, add, and browse persistent agent memories |
52
+
53
+ ![Agent Console View](studio-screenshot-agent-console-2.png)
54
+
55
+ ---
56
+
57
+ ## Goals & Plans
58
+
59
+ The Goals panel lets you:
60
+
61
+ 1. **Create goals** with title, description, and priority
62
+ 2. **View task breakdown** — expand a goal to see its decomposed tasks
63
+ 3. **Update status** — pause, resume, or complete goals
64
+ 4. **Delete goals** and their associated tasks
65
+
66
+ Each task shows its execution status (pending → running → completed/failed) and
67
+ the assigned skill.
68
+
69
+ ---
70
+
71
+ ## Skills Manager
72
+
73
+ Skills are reusable AI capabilities defined by `skill.json` + `prompt.md`.
74
+
75
+ From the Studio you can:
76
+ - **Create** a new skill with name, description, tools, and prompt content
77
+ - **Edit** the prompt markdown inline with a code editor
78
+ - **Delete** skills you no longer need
79
+
80
+ Changes are written directly to `.agent/skills/` on disk.
81
+
82
+ ---
83
+
84
+ ## Commands Manager
85
+
86
+ Commands are lightweight goal templates — just markdown files with YAML frontmatter.
87
+
88
+ - **Create** commands with name, description, allowed tools, and body
89
+ - **Delete** commands
90
+ - Commands appear as `/slash-commands` in the interactive REPL
91
+
92
+ ---
93
+
94
+ ## Scripts Manager
95
+
96
+ Scripts are deterministic automation tasks (shell, TypeScript, Python) with a
97
+ `script.yaml` manifest.
98
+
99
+ - **Create** scripts by choosing a language and writing the entrypoint
100
+ - **Delete** scripts
101
+ - Scripts execute without LLM involvement — perfect for CI/CD
102
+
103
+ ---
104
+
105
+ ## Daemon Control
106
+
107
+ The daemon is the background worker that processes goals autonomously.
108
+
109
+ - **Start/Stop** the daemon with one click
110
+ - **Live status** — see PID, uptime, and running state
111
+ - **Log viewer** — color-coded logs with auto-refresh
112
+
113
+ ---
114
+
115
+ ## Memory Explorer
116
+
117
+ Agent memory is a SQLite-backed persistent store with full-text search.
118
+
119
+ - **Search** across all memories using FTS5
120
+ - **Add** new memories with category and tags
121
+ - **Browse** memories grouped by category (project, fact, preference, learned, general)
122
+ - **Delete** individual memories
123
+ - **Stats** — see totals broken down by category
124
+
125
+ ---
126
+
127
+ ## REST API
128
+
129
+ Studio exposes a comprehensive REST API. See [API Reference](../API.md) for full details.
130
+
131
+ Key endpoints:
132
+ - `GET /api/instances` — list active instances
133
+ - `POST /api/instances/:id/goals` — create a goal
134
+ - `GET /api/instances/:id/skills` — list skills
135
+ - `POST /api/instances/:id/memory` — add a memory
136
+ - `POST /api/instances/:id/daemon/start` — start the daemon
137
+
138
+ ---
139
+
140
+ ## Architecture
141
+
142
+ ```
143
+ Browser (React + Vite)
144
+ ↕ HTTP/WebSocket
145
+ Studio Server (Express + Socket.IO)
146
+
147
+ Agent Runtime (GoalStore, SkillLoader, MemoryStore, DaemonManager)
148
+
149
+ File System (.agent/) + SQLite (agent.db)
150
+ ```
151
+
152
+ The Studio server reuses the same classes as the CLI — `GoalStore`, `SkillLoader`,
153
+ `CommandLoader`, `ScriptLoader`, `MemoryStore`, `DaemonManager` — so all operations
154
+ are consistent between CLI and UI.
@@ -0,0 +1,118 @@
1
+ # LLM Providers — Configuration & Routing
2
+
3
+ > How the Agent Runtime connects to multiple AI providers with automatic fallback.
4
+
5
+ ---
6
+
7
+ ## Supported Providers
8
+
9
+ | Provider | Module | SDK | Environment Variable |
10
+ |----------|--------|-----|---------------------|
11
+ | **OpenAI** | `openai.ts` | `openai` | `OPENAI_API_KEY` |
12
+ | **Azure OpenAI** | `azure.ts` | `openai` | `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT` |
13
+ | **Anthropic** | `anthropic.ts` | `@anthropic-ai/sdk` | `ANTHROPIC_API_KEY` |
14
+ | **Ollama** | `ollama.ts` | HTTP fetch | — (local, port 11434) |
15
+
16
+ ---
17
+
18
+ ## Configuration
19
+
20
+ Set your preferred provider and model in `agent.config.json` or `.agent/config.json`:
21
+
22
+ ```json
23
+ {
24
+ "llm": {
25
+ "provider": "openai",
26
+ "model": "gpt-4o",
27
+ "temperature": 0.2,
28
+ "maxTokens": 4096
29
+ }
30
+ }
31
+ ```
32
+
33
+ ### Provider-Specific Config
34
+
35
+ **OpenAI / Azure:**
36
+ ```json
37
+ {
38
+ "llm": {
39
+ "provider": "openai",
40
+ "model": "gpt-4o",
41
+ "apiKey": "sk-..."
42
+ }
43
+ }
44
+ ```
45
+
46
+ **Anthropic:**
47
+ ```json
48
+ {
49
+ "llm": {
50
+ "provider": "anthropic",
51
+ "model": "claude-sonnet-4-20250514",
52
+ "apiKey": "sk-ant-..."
53
+ }
54
+ }
55
+ ```
56
+
57
+ **Ollama (local):**
58
+ ```json
59
+ {
60
+ "llm": {
61
+ "provider": "ollama",
62
+ "model": "llama3",
63
+ "baseUrl": "http://localhost:11434"
64
+ }
65
+ }
66
+ ```
67
+
68
+ API keys can also be set via environment variables (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc.).
69
+ Environment variables take precedence over config file values.
70
+
71
+ ---
72
+
73
+ ## LLM Router
74
+
75
+ The **LLM Router** (`src/llm/router.ts`) is the core abstraction that:
76
+
77
+ 1. Selects the correct provider adapter based on config
78
+ 2. Sanitizes tool names for provider compatibility (e.g., dots → underscores for OpenAI)
79
+ 3. Forwards chat requests with the full message history
80
+ 4. Handles tool call serialization for each provider's expected format
81
+
82
+ ### Tool Name Sanitization
83
+
84
+ Different providers have different naming rules. The router automatically transforms:
85
+ - `fs.read` → `fs_read` (for OpenAI/Azure which reject dots)
86
+ - Tool calls in conversation history are also sanitized to maintain consistency
87
+
88
+ ### Message Mapping
89
+
90
+ Each provider adapter maps the internal message format to the provider-specific API:
91
+
92
+ | Internal | OpenAI | Anthropic | Ollama |
93
+ |----------|--------|-----------|--------|
94
+ | `role: 'tool'` | `role: 'tool'` | `role: 'user'` + `tool_result` block | `role: 'tool'` |
95
+ | `toolCalls` on assistant | `tool_calls` array | `tool_use` content blocks | `tool_calls` array |
96
+ | System message | `role: 'system'` | `system` parameter | `role: 'system'` |
97
+
98
+ ---
99
+
100
+ ## Fallback Chain
101
+
102
+ The router supports fallback to local models when cloud providers fail:
103
+
104
+ ```
105
+ openai/gpt-4o → anthropic/claude-sonnet → ollama/llama3
106
+ ```
107
+
108
+ If the primary provider returns an error or times out, the router automatically
109
+ retries with the next provider in the chain.
110
+
111
+ ---
112
+
113
+ ## Adding a New Provider
114
+
115
+ 1. Create `src/llm/providers/my-provider.ts`
116
+ 2. Implement the `LLMProvider` interface with a `chat(request)` method
117
+ 3. Map messages from internal format to provider format
118
+ 4. Register in `src/llm/router.ts`
@@ -0,0 +1,118 @@
1
+ # Policy & Approvals — Permission-Gated Execution
2
+
3
+ > How the Agent Runtime keeps humans in the loop for sensitive operations.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ The Agent Runtime uses a **Policy Engine** to gate tool execution. Every tool action
10
+ passes through a permission check, and high-risk operations require explicit human
11
+ approval before proceeding.
12
+
13
+ ---
14
+
15
+ ## Risk Levels
16
+
17
+ Tools are categorized into risk levels:
18
+
19
+ | Level | Examples | Behavior |
20
+ |-------|----------|----------|
21
+ | **low** | `fs.read`, `project.detect` | Auto-approved, no prompt |
22
+ | **medium** | `fs.write`, `git.status` | Logged, may require approval based on policy |
23
+ | **high** | `cmd.run`, `git.push` | Always requires human approval |
24
+ | **critical** | `fs.delete`, system-level ops | Always requires approval + confirmation |
25
+
26
+ ---
27
+
28
+ ## Approval Flow
29
+
30
+ ### CLI Mode
31
+
32
+ When a tool requires approval in the interactive REPL:
33
+
34
+ ```
35
+ ⚡ cmd.run("npm install express")
36
+ ⚠ This action requires approval.
37
+ Allow? (y/n) ▊
38
+ ```
39
+
40
+ The REPL pauses execution, displays the tool name and arguments, and waits for
41
+ the user to approve (`y`) or deny (`n`).
42
+
43
+ ### Studio Mode (Remote Approval)
44
+
45
+ When running via daemon or in a remote session, approval requests are relayed
46
+ via WebSocket to the Studio UI:
47
+
48
+ ```
49
+ Agent CLI → Socket.IO → Studio Server → Browser UI
50
+
51
+ Approval Button
52
+
53
+ Agent CLI ← Socket.IO ← Studio Server ← User clicks "Allow"
54
+ ```
55
+
56
+ The Studio console shows an approval card with:
57
+ - Tool name and arguments
58
+ - Risk level badge
59
+ - **Allow** / **Deny** buttons
60
+
61
+ ---
62
+
63
+ ## Configuration
64
+
65
+ Customize the policy in `.agent/config.json`:
66
+
67
+ ```json
68
+ {
69
+ "policy": {
70
+ "autoAllow": ["fs.read", "fs.list", "project.detect"],
71
+ "alwaysAsk": ["cmd.run", "fs.delete"],
72
+ "denyList": ["cmd.run:rm -rf /"]
73
+ }
74
+ }
75
+ ```
76
+
77
+ ### Fields
78
+
79
+ | Field | Description |
80
+ |-------|-------------|
81
+ | `autoAllow` | Tools that never require approval |
82
+ | `alwaysAsk` | Tools that always require approval regardless of risk level |
83
+ | `denyList` | Specific tool+args combinations that are always denied |
84
+
85
+ ---
86
+
87
+ ## Audit Trail
88
+
89
+ Every tool execution is logged to the audit system:
90
+
91
+ - **Tool name** and arguments
92
+ - **Approval status** (auto-approved, human-approved, denied)
93
+ - **Timestamp** and **run ID**
94
+ - **Duration** and result
95
+
96
+ Access audit logs via:
97
+ ```bash
98
+ agent memory search "audit"
99
+ # or in Studio → Memory Explorer → search "audit"
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Task-Level Approval
105
+
106
+ Goals can mark individual tasks as requiring approval:
107
+
108
+ ```typescript
109
+ goalStore.addTask(goalId, "Deploy to production", {
110
+ requiresApproval: true,
111
+ skill: "deploy-staging"
112
+ });
113
+ ```
114
+
115
+ These tasks enter a `pending` state until approved via:
116
+ - CLI: `agent goal approve <taskId>`
117
+ - Studio: Goals panel → Approve button
118
+ - API: `POST /api/instances/:id/tasks/:taskId/approve`
@@ -0,0 +1,123 @@
1
+ # Daemon & Background Automation
2
+
3
+ > Autonomous goal execution with scheduling, triggers, and monitoring.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ The **Daemon** is a background worker that processes goals and tasks autonomously
10
+ without human interaction. It picks up queued tasks, executes them using the
11
+ appropriate skills, and handles retries and failures.
12
+
13
+ ---
14
+
15
+ ## Starting the Daemon
16
+
17
+ ### CLI
18
+ ```bash
19
+ agent daemon start # Start background worker
20
+ agent daemon status # Check if running
21
+ agent daemon stop # Stop the worker
22
+ agent daemon logs # View recent logs
23
+ ```
24
+
25
+ ### Studio
26
+ Navigate to **Daemon** in the sidebar → click **Start Daemon**.
27
+
28
+ ### API
29
+ ```bash
30
+ curl -X POST http://localhost:3333/api/instances/:id/daemon/start
31
+ curl http://localhost:3333/api/instances/:id/daemon/status
32
+ ```
33
+
34
+ ---
35
+
36
+ ## How It Works
37
+
38
+ ```
39
+ ┌─────────────┐ ┌──────────────┐ ┌─────────────┐
40
+ │ Goal Store │ ──→ │ Scheduler │ ──→ │ Executor │
41
+ │ (SQLite) │ │ (picks next │ │ (runs task │
42
+ │ │ │ task) │ │ via skill) │
43
+ └─────────────┘ └──────────────┘ └─────────────┘
44
+ ↑ │
45
+ └────────── Results Written Back ────────┘
46
+ ```
47
+
48
+ 1. **Goal Store** holds all goals and tasks in SQLite
49
+ 2. **Scheduler** polls for the next executable task (respecting dependencies)
50
+ 3. **Executor** runs the task using the assigned skill
51
+ 4. Results (success/failure) are written back to the store
52
+ 5. Goal progress is auto-calculated based on task completion
53
+
54
+ ---
55
+
56
+ ## Task Dependencies
57
+
58
+ Tasks can depend on other tasks:
59
+
60
+ ```typescript
61
+ goalStore.addTask(goalId, "Install dependencies", { skill: "npm-install" });
62
+ goalStore.addTask(goalId, "Run tests", {
63
+ skill: "test-runner",
64
+ dependsOn: [1] // Won't start until task 1 completes
65
+ });
66
+ ```
67
+
68
+ The scheduler only picks tasks whose dependencies are all `completed`.
69
+
70
+ ---
71
+
72
+ ## Retry & Failure Handling
73
+
74
+ | Strategy | Behavior |
75
+ |----------|----------|
76
+ | `retry` | Re-execute the task up to `maxRetries` times |
77
+ | `abort` | Stop the entire plan on first failure |
78
+ | `skip` | Mark as failed but continue with remaining tasks |
79
+
80
+ ---
81
+
82
+ ## File Watcher
83
+
84
+ The daemon includes a file watcher (`src/daemon/watcher.ts`) that can trigger
85
+ tasks when files change:
86
+
87
+ ```json
88
+ {
89
+ "daemon": {
90
+ "watch": ["src/**/*.ts"],
91
+ "onFileChange": "lint-and-test"
92
+ }
93
+ }
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Triggers
99
+
100
+ Custom triggers (`src/daemon/triggers.ts`) define when tasks should execute:
101
+
102
+ - **cron** — Schedule tasks on a cron expression
103
+ - **file-change** — React to file system events
104
+ - **webhook** — HTTP POST triggers task execution
105
+ - **manual** — Only execute when explicitly started
106
+
107
+ ---
108
+
109
+ ## Monitoring
110
+
111
+ ### CLI
112
+ ```bash
113
+ agent daemon status # Running | Stopped, PID, uptime
114
+ agent daemon logs # Last 30 lines of daemon.log
115
+ agent goal status 1 # Task-level progress for goal #1
116
+ ```
117
+
118
+ ### Studio
119
+ The Daemon panel provides:
120
+ - Live status indicator (green = running)
121
+ - Start/Stop buttons
122
+ - Color-coded log viewer with auto-refresh
123
+ - PID and uptime display
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@praveencs/agent",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "files": [
5
5
  "dist",
6
6
  "bin",