@newsails/veil-cli 1.0.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 (199) hide show
  1. package/.veil/agents/analyst/AGENT.md +21 -0
  2. package/.veil/agents/analyst/agent.json +23 -0
  3. package/.veil/agents/assistant/AGENT.md +15 -0
  4. package/.veil/agents/assistant/agent.json +19 -0
  5. package/.veil/agents/coder/AGENT.md +18 -0
  6. package/.veil/agents/coder/agent.json +19 -0
  7. package/.veil/agents/hello/AGENT.md +5 -0
  8. package/.veil/agents/hello/agent.json +13 -0
  9. package/.veil/agents/writer/AGENT.md +12 -0
  10. package/.veil/agents/writer/agent.json +17 -0
  11. package/.veil/memory/MEMORY.md +343 -0
  12. package/.veil/memory/agents/analyst/MEMORY.md +55 -0
  13. package/.veil/memory/agents/hello/MEMORY.md +12 -0
  14. package/.veil/runtime.pid +1 -0
  15. package/.veil/settings.json +10 -0
  16. package/.veil-studio/studio.db +0 -0
  17. package/.veil-studio/studio.db-shm +0 -0
  18. package/.veil-studio/studio.db-wal +0 -0
  19. package/PLAN/01-vision.md +26 -0
  20. package/PLAN/02-tech-stack.md +94 -0
  21. package/PLAN/03-agents.md +232 -0
  22. package/PLAN/04-runtime.md +171 -0
  23. package/PLAN/05-tools.md +211 -0
  24. package/PLAN/06-communication.md +243 -0
  25. package/PLAN/07-storage.md +218 -0
  26. package/PLAN/08-api-cli.md +153 -0
  27. package/PLAN/09-permissions.md +108 -0
  28. package/PLAN/10-ably.md +105 -0
  29. package/PLAN/11-file-formats.md +442 -0
  30. package/PLAN/12-folder-structure.md +205 -0
  31. package/PLAN/13-operations.md +212 -0
  32. package/PLAN/README.md +23 -0
  33. package/README.md +128 -0
  34. package/REPORT.md +174 -0
  35. package/TODO.md +45 -0
  36. package/ai-tests/FRONTEND_PROMPT.md +220 -0
  37. package/ai-tests/Research & Planning.md +814 -0
  38. package/ai-tests/prompt-001-basic-api.md +230 -0
  39. package/ai-tests/prompt-002-basic-flows.md +230 -0
  40. package/ai-tests/prompt-003-agent-behaviors.md +220 -0
  41. package/api/middleware.js +60 -0
  42. package/api/routes/agents.js +193 -0
  43. package/api/routes/chat.js +93 -0
  44. package/api/routes/completions.js +122 -0
  45. package/api/routes/daemons.js +80 -0
  46. package/api/routes/memory.js +169 -0
  47. package/api/routes/models.js +40 -0
  48. package/api/routes/remote-methods.js +74 -0
  49. package/api/routes/sessions.js +208 -0
  50. package/api/routes/settings.js +108 -0
  51. package/api/routes/system.js +50 -0
  52. package/api/routes/tasks.js +270 -0
  53. package/api/server.js +120 -0
  54. package/cli/formatter.js +70 -0
  55. package/cli/index.js +443 -0
  56. package/cli/parser.js +113 -0
  57. package/config/config.json +10 -0
  58. package/config/models.json +6826 -0
  59. package/core/agent.js +329 -0
  60. package/core/cancel.js +38 -0
  61. package/core/compaction.js +176 -0
  62. package/core/events.js +13 -0
  63. package/core/loop.js +564 -0
  64. package/core/memory.js +51 -0
  65. package/core/prompt.js +185 -0
  66. package/core/queue.js +96 -0
  67. package/core/registry.js +291 -0
  68. package/core/remote-methods.js +124 -0
  69. package/core/router.js +386 -0
  70. package/core/running-sessions.js +18 -0
  71. package/docs/api/01-system.md +84 -0
  72. package/docs/api/02-agents.md +374 -0
  73. package/docs/api/03-chat.md +269 -0
  74. package/docs/api/04-tasks.md +470 -0
  75. package/docs/api/05-sessions.md +444 -0
  76. package/docs/api/06-daemons.md +142 -0
  77. package/docs/api/07-memory.md +186 -0
  78. package/docs/api/08-settings.md +133 -0
  79. package/docs/api/09-models.md +119 -0
  80. package/docs/api/09-websocket.md +350 -0
  81. package/docs/api/10-completions.md +134 -0
  82. package/docs/api/README.md +116 -0
  83. package/docs/guide/01-quickstart.md +220 -0
  84. package/docs/guide/02-folder-structure.md +185 -0
  85. package/docs/guide/03-configuration.md +252 -0
  86. package/docs/guide/04-agents.md +267 -0
  87. package/docs/guide/05-cli.md +290 -0
  88. package/docs/guide/06-tools.md +643 -0
  89. package/docs/guide/07-permissions.md +236 -0
  90. package/docs/guide/08-memory.md +139 -0
  91. package/docs/guide/09-multi-agent.md +271 -0
  92. package/docs/guide/10-daemons.md +226 -0
  93. package/docs/guide/README.md +53 -0
  94. package/docs/index.html +623 -0
  95. package/examples/README.md +151 -0
  96. package/examples/agents/assistant/AGENT.md +31 -0
  97. package/examples/agents/assistant/SOUL.md +9 -0
  98. package/examples/agents/assistant/agent.json +74 -0
  99. package/examples/agents/hello/AGENT.md +15 -0
  100. package/examples/agents/hello/agent.json +14 -0
  101. package/examples/agents/monitor/AGENT.md +51 -0
  102. package/examples/agents/monitor/agent.json +33 -0
  103. package/examples/agents/monitor/heartbeats/monitor.md +24 -0
  104. package/examples/agents/orchestrator/AGENT.md +70 -0
  105. package/examples/agents/orchestrator/agent.json +30 -0
  106. package/examples/agents/researcher/AGENT.md +52 -0
  107. package/examples/agents/researcher/agent.json +49 -0
  108. package/examples/agents/researcher/skills/web-research.md +28 -0
  109. package/examples/skills/code-review.md +72 -0
  110. package/examples/skills/summarise.md +59 -0
  111. package/examples/skills/web-research.md +42 -0
  112. package/examples/tools/word-count/index.js +27 -0
  113. package/examples/tools/word-count/tool.json +18 -0
  114. package/infrastructure/database.js +563 -0
  115. package/infrastructure/scheduler.js +122 -0
  116. package/llm/client.js +206 -0
  117. package/migrations/001-initial.sql +121 -0
  118. package/migrations/002-debuggability.sql +13 -0
  119. package/migrations/003-drop-orphaned-columns.sql +72 -0
  120. package/migrations/004-session-message-token-fields.sql +78 -0
  121. package/migrations/005-session-thinking.sql +5 -0
  122. package/package.json +30 -0
  123. package/schemas/agent.json +143 -0
  124. package/schemas/settings.json +111 -0
  125. package/scripts/fetch-models.js +93 -0
  126. package/session-debug-scenario.md +248 -0
  127. package/settings/fields.js +52 -0
  128. package/system-prompts/base-core.md +7 -0
  129. package/system-prompts/environment.md +13 -0
  130. package/system-prompts/reminders/anti-drift.md +6 -0
  131. package/system-prompts/reminders/stall-recovery.md +10 -0
  132. package/system-prompts/safety-rules.md +25 -0
  133. package/system-prompts/task-heuristics.md +27 -0
  134. package/test/client.js +71 -0
  135. package/test/integration/01-health.test.js +25 -0
  136. package/test/integration/02-agents.test.js +80 -0
  137. package/test/integration/03-chat-hello.test.js +48 -0
  138. package/test/integration/04-chat-multiturn.test.js +61 -0
  139. package/test/integration/05-chat-writer.test.js +48 -0
  140. package/test/integration/06-task-basic.test.js +68 -0
  141. package/test/integration/07-task-tools.test.js +74 -0
  142. package/test/integration/08-task-code-analysis.test.js +69 -0
  143. package/test/integration/09-memory-analyst.test.js +63 -0
  144. package/test/integration/10-task-advanced.test.js +85 -0
  145. package/test/integration/11-sessions-advanced.test.js +84 -0
  146. package/test/integration/12-assistant-chat-tools.test.js +75 -0
  147. package/test/integration/13-edge-cases.test.js +99 -0
  148. package/test/integration/14-cancel.test.js +62 -0
  149. package/test/integration/15-debug.test.js +106 -0
  150. package/test/integration/16-memory-api.test.js +83 -0
  151. package/test/integration/17-settings-api.test.js +41 -0
  152. package/test/integration/18-tool-search-activation.test.js +119 -0
  153. package/test/results/.gitkeep +0 -0
  154. package/test/runner.js +206 -0
  155. package/test/smoke.js +216 -0
  156. package/tools/agent_message.js +85 -0
  157. package/tools/agent_send.js +80 -0
  158. package/tools/agent_spawn.js +44 -0
  159. package/tools/bash.js +49 -0
  160. package/tools/edit_file.js +41 -0
  161. package/tools/glob.js +64 -0
  162. package/tools/grep.js +82 -0
  163. package/tools/list_dir.js +63 -0
  164. package/tools/log_write.js +31 -0
  165. package/tools/memory_read.js +38 -0
  166. package/tools/memory_search.js +65 -0
  167. package/tools/memory_write.js +42 -0
  168. package/tools/read_file.js +48 -0
  169. package/tools/sleep.js +22 -0
  170. package/tools/task_create.js +41 -0
  171. package/tools/task_respond.js +37 -0
  172. package/tools/task_spawn.js +64 -0
  173. package/tools/task_status.js +39 -0
  174. package/tools/task_subscribe.js +37 -0
  175. package/tools/todo_read.js +26 -0
  176. package/tools/todo_write.js +38 -0
  177. package/tools/tool_activate.js +24 -0
  178. package/tools/tool_search.js +24 -0
  179. package/tools/web_fetch.js +50 -0
  180. package/tools/web_search.js +52 -0
  181. package/tools/write_file.js +28 -0
  182. package/ui/api.js +190 -0
  183. package/ui/app.js +281 -0
  184. package/ui/index.html +382 -0
  185. package/ui/views/agents.js +377 -0
  186. package/ui/views/chat.js +610 -0
  187. package/ui/views/connection.js +96 -0
  188. package/ui/views/daemons.js +129 -0
  189. package/ui/views/feed.js +194 -0
  190. package/ui/views/memory.js +263 -0
  191. package/ui/views/models.js +146 -0
  192. package/ui/views/sessions.js +314 -0
  193. package/ui/views/settings.js +142 -0
  194. package/ui/views/tasks.js +415 -0
  195. package/utils/context.js +49 -0
  196. package/utils/id.js +16 -0
  197. package/utils/models.js +88 -0
  198. package/utils/paths.js +213 -0
  199. package/utils/settings.js +172 -0
@@ -0,0 +1,220 @@
1
+ # Quickstart
2
+
3
+ Get VeilCLI running and talk to your first agent in under 5 minutes.
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ - **Node.js ≥ 18.3.0** — check with `node --version`
10
+ - An **OpenAI-compatible API key** — [OpenRouter](https://openrouter.ai) works out of the box
11
+
12
+ ---
13
+
14
+ ## Step 1 — Install
15
+
16
+ ```bash
17
+ npm install -g @newsails/veil-cli
18
+ ```
19
+
20
+ Verify:
21
+ ```bash
22
+ veil --version
23
+ # VeilCLI v0.1.0
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Step 2 — Create a Workspace
29
+
30
+ A workspace is any directory with a `.veil/` folder.
31
+
32
+ ```bash
33
+ mkdir ~/my-workspace && cd ~/my-workspace
34
+ mkdir -p .veil/agents/hello
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Step 3 — Configure Auth
40
+
41
+ ```bash
42
+ # Save your API key to the project workspace
43
+ veil login --key sk-or-v1-YOUR_KEY_HERE
44
+
45
+ # Or save it globally (shared across all workspaces)
46
+ veil login --key sk-or-v1-YOUR_KEY_HERE --global
47
+ ```
48
+
49
+ This writes to `.veil/auth.json`:
50
+ ```json
51
+ {
52
+ "models": {
53
+ "main": {
54
+ "base_url": "https://openrouter.ai/api/v1",
55
+ "api_key": "sk-or-v1-...",
56
+ "model": ""
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ You also need to specify the model. Edit `.veil/auth.json`:
63
+ ```json
64
+ {
65
+ "models": {
66
+ "main": {
67
+ "base_url": "https://openrouter.ai/api/v1",
68
+ "api_key": "sk-or-v1-YOUR_KEY",
69
+ "model": "moonshotai/kimi-k2.5"
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ Any [OpenRouter model slug](https://openrouter.ai/models) works. Popular choices:
76
+ - `moonshotai/kimi-k2.5` — fast, capable, tool-calling
77
+ - `anthropic/claude-3.5-sonnet` — excellent reasoning
78
+ - `google/gemini-2.0-flash-001` — very fast
79
+ - `meta-llama/llama-3.3-70b-instruct` — open model
80
+
81
+ ---
82
+
83
+ ## Step 4 — Create Your First Agent
84
+
85
+ Create `.veil/agents/hello/agent.json`:
86
+
87
+ ```json
88
+ {
89
+ "name": "hello",
90
+ "description": "A friendly conversational agent",
91
+ "model": "moonshotai/kimi-k2.5",
92
+ "temperature": 0.7,
93
+ "reasoning": "medium",
94
+ "memory": { "enabled": false },
95
+ "modes": {
96
+ "chat": { "enabled": true },
97
+ "task": { "enabled": true }
98
+ }
99
+ }
100
+ ```
101
+
102
+ Create `.veil/agents/hello/AGENT.md`:
103
+
104
+ ```markdown
105
+ You are Hello, a friendly and concise assistant.
106
+
107
+ Be helpful, clear, and direct. Keep responses short unless asked for detail.
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Step 5 — Start the Server
113
+
114
+ ```bash
115
+ cd ~/my-workspace
116
+ veil start
117
+ # VeilCLI v0.1.0 started on port 5050
118
+ # Project: /home/user/my-workspace
119
+ # Agents: 1 | PID: 12345
120
+ ```
121
+
122
+ Options:
123
+ ```bash
124
+ veil start --port 5051 # custom port
125
+ veil start --folder /other/dir # different workspace
126
+ veil start --secret mytoken # require auth header
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Step 6 — Chat!
132
+
133
+ ```bash
134
+ # Check health
135
+ curl http://localhost:5050/health
136
+
137
+ # Send a chat message
138
+ curl -X POST http://localhost:5050/agents/hello/chat \
139
+ -H "Content-Type: application/json" \
140
+ -d '{"message": "What is 2 + 2?"}'
141
+ ```
142
+
143
+ Response:
144
+ ```json
145
+ {
146
+ "sessionId": "sess_4f3a1b9c2d8e7f01",
147
+ "message": {
148
+ "role": "assistant",
149
+ "content": "2 + 2 = 4."
150
+ },
151
+ "tokenUsage": { "input": 120, "output": 8, "cache": 0 }
152
+ }
153
+ ```
154
+
155
+ Continue the conversation by passing `sessionId` back:
156
+ ```bash
157
+ curl -X POST http://localhost:5050/agents/hello/chat \
158
+ -H "Content-Type: application/json" \
159
+ -d '{"message": "And multiply that by 3?", "sessionId": "sess_4f3a1b9c2d8e7f01"}'
160
+ ```
161
+
162
+ ---
163
+
164
+ ## Step 7 — Run a Task
165
+
166
+ Tasks run asynchronously. Great for anything that needs multiple LLM steps or tool use.
167
+
168
+ First, give your agent tools by updating `agent.json`:
169
+ ```json
170
+ {
171
+ "name": "hello",
172
+ "model": "moonshotai/kimi-k2.5",
173
+ "modes": {
174
+ "chat": { "enabled": true },
175
+ "task": {
176
+ "enabled": true,
177
+ "permissions": {
178
+ "allow": ["read_file", "list_dir", "bash"]
179
+ }
180
+ }
181
+ }
182
+ }
183
+ ```
184
+
185
+ Then run a task:
186
+ ```bash
187
+ # Create task (returns immediately)
188
+ curl -X POST http://localhost:5050/agents/hello/task \
189
+ -H "Content-Type: application/json" \
190
+ -d '{"input": "How many files are in the current directory?"}'
191
+
192
+ # Poll until done
193
+ curl http://localhost:5050/tasks/task_c0ab38d8377cdd47
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Interactive CLI Client
199
+
200
+ If you have the `connect.js` TUI client, you can explore everything interactively:
201
+
202
+ ```bash
203
+ node /path/to/VeilCli_TESTS/cli-app/connect.js
204
+ ```
205
+
206
+ Or jump straight to a chat session:
207
+ ```bash
208
+ node connect.js chat hello
209
+ ```
210
+
211
+ See [the connect.js README](../guide/05-cli.md#interactive-tui-client) for full usage.
212
+
213
+ ---
214
+
215
+ ## What's Next
216
+
217
+ - [Folder Structure](02-folder-structure.md) — understand every file in `.veil/`
218
+ - [Configuration](03-configuration.md) — all settings explained
219
+ - [Agent Configuration](04-agents.md) — full `agent.json` reference
220
+ - [Built-in Tools](06-tools.md) — what your agents can do
@@ -0,0 +1,185 @@
1
+ # Folder Structure
2
+
3
+ Every VeilCLI workspace is a directory with a `.veil/` subfolder. Here is the complete layout:
4
+
5
+ ---
6
+
7
+ ## Workspace Layout
8
+
9
+ ```
10
+ my-workspace/
11
+ └── .veil/
12
+ ├── auth.json ← API keys and model config
13
+ ├── settings.json ← Server and runtime settings
14
+ ├── settings.local.json ← Local overrides (gitignore this)
15
+ ├── data.db ← SQLite database (sessions, tasks, messages)
16
+ ├── runtime.pid ← PID of the running server
17
+
18
+ ├── agents/
19
+ │ └── <agent-name>/
20
+ │ ├── agent.json ← Agent configuration (required)
21
+ │ ├── AGENT.md ← System prompt / personality (required)
22
+ │ ├── SOUL.md ← Optional extra identity layer
23
+ │ └── tools/ ← Optional custom tools for this agent
24
+ │ └── my_tool.js
25
+
26
+ ├── memory/
27
+ │ ├── MEMORY.md ← Project-level (global) memory
28
+ │ └── agents/
29
+ │ └── <agent-name>/
30
+ │ └── MEMORY.md ← Per-agent memory
31
+
32
+ └── heartbeats/
33
+ └── <agent-name>.md ← Daemon agent instructions (read each tick)
34
+ ```
35
+
36
+ ---
37
+
38
+ ## File Descriptions
39
+
40
+ ### `auth.json`
41
+
42
+ Stores API credentials. Separated from `settings.json` so you can gitignore it independently.
43
+
44
+ ```json
45
+ {
46
+ "models": {
47
+ "main": {
48
+ "base_url": "https://openrouter.ai/api/v1",
49
+ "api_key": "sk-or-v1-...",
50
+ "model": "moonshotai/kimi-k2.5"
51
+ },
52
+ "compact": null,
53
+ "title": null
54
+ }
55
+ }
56
+ ```
57
+
58
+ Model roles:
59
+ - **`main`** — used for all agent LLM calls (required)
60
+ - **`compact`** — used for context compaction summaries (falls back to `main`)
61
+ - **`title`** — used to generate task/session titles (falls back to `main`)
62
+
63
+ ---
64
+
65
+ ### `settings.json`
66
+
67
+ Runtime configuration. See [Configuration Reference](03-configuration.md) for all fields.
68
+
69
+ ```json
70
+ {
71
+ "port": 5050,
72
+ "maxIterations": 20,
73
+ "maxDurationSeconds": 120,
74
+ "permissions": {
75
+ "allow": [],
76
+ "deny": [],
77
+ "ask": []
78
+ }
79
+ }
80
+ ```
81
+
82
+ ---
83
+
84
+ ### `settings.local.json`
85
+
86
+ Same format as `settings.json`. Applied last (highest priority among file layers). Useful for developer overrides that should not be committed. Add to `.gitignore`.
87
+
88
+ ---
89
+
90
+ ### `data.db`
91
+
92
+ SQLite database file. Contains all sessions, messages, tasks, task events, todos, agent messages, and task subscriptions. Created automatically on first run.
93
+
94
+ **Do not edit manually.** If you need to reset state, stop the server and delete this file — it will be recreated.
95
+
96
+ ---
97
+
98
+ ### `runtime.pid`
99
+
100
+ Contains the process ID of the running server. Written by `veil start`, removed by `veil stop` / graceful shutdown. If it exists but the process is gone, it is a stale PID file and can be deleted.
101
+
102
+ ---
103
+
104
+ ### `agents/<name>/agent.json`
105
+
106
+ Agent configuration. JSON Schema-validated on load. See [Agent Configuration](04-agents.md).
107
+
108
+ ---
109
+
110
+ ### `agents/<name>/AGENT.md`
111
+
112
+ The agent's system prompt. Loaded and injected into every conversation for this agent. Supports variables:
113
+
114
+ | Variable | Resolves to |
115
+ |----------|-------------|
116
+ | `$AGENT_FOLDER` | Absolute path to the agent's folder |
117
+ | `$PROJECT_ROOT` | Absolute path to the workspace root |
118
+
119
+ Example:
120
+ ```markdown
121
+ You are Analyst, a code analysis agent.
122
+
123
+ Your working directory is $PROJECT_ROOT.
124
+ Your files are in $AGENT_FOLDER.
125
+ ```
126
+
127
+ ---
128
+
129
+ ### `agents/<name>/SOUL.md`
130
+
131
+ Optional. An additional identity/personality layer merged into the system prompt after `AGENT.md`. Useful for separating static capabilities from dynamic persona.
132
+
133
+ ---
134
+
135
+ ### `agents/<name>/tools/`
136
+
137
+ Optional directory for agent-specific custom tools. Each file must export `{ schema, execute }` following the same pattern as the built-in tools. These tools are available only to this agent.
138
+
139
+ ---
140
+
141
+ ### `memory/MEMORY.md`
142
+
143
+ Project-level shared memory. Written by agents using `memory_write` with `scope: "global"`. Injected into the system prompt of agents that have memory enabled.
144
+
145
+ ---
146
+
147
+ ### `memory/agents/<name>/MEMORY.md`
148
+
149
+ Per-agent memory. Written by agents using `memory_write` with `scope: "agent"` (default). Only injected for that agent.
150
+
151
+ ---
152
+
153
+ ### `heartbeats/<agent-name>.md`
154
+
155
+ Instructions file for daemon agents. Read at the start of each scheduled tick and used as the agent's task input for that run. If the file doesn't exist, a default instruction is used.
156
+
157
+ ---
158
+
159
+ ## Global Config
160
+
161
+ VeilCLI also reads from a global config directory at `~/.veil/`:
162
+
163
+ ```
164
+ ~/.veil/
165
+ ├── auth.json ← Global API keys (overridden by project auth.json)
166
+ └── settings.json ← Global defaults (overridden by project settings.json)
167
+ ```
168
+
169
+ The global config is useful for sharing an API key across multiple workspaces without duplicating it. See [Settings Layers](03-configuration.md#settings-layers).
170
+
171
+ ---
172
+
173
+ ## What to Gitignore
174
+
175
+ Add these to `.gitignore` in your workspace:
176
+
177
+ ```gitignore
178
+ .veil/data.db
179
+ .veil/runtime.pid
180
+ .veil/auth.json
181
+ .veil/settings.local.json
182
+ .veil/memory/
183
+ ```
184
+
185
+ Keep `agents/`, `settings.json`, and `heartbeats/` in version control.
@@ -0,0 +1,252 @@
1
+ # Configuration Reference
2
+
3
+ VeilCLI uses two config files per workspace: `auth.json` for credentials and `settings.json` for everything else.
4
+
5
+ ---
6
+
7
+ ## Settings Layers
8
+
9
+ Settings are loaded and merged in this order (each layer overrides the previous):
10
+
11
+ ```
12
+ 1. Built-in defaults
13
+ 2. ~/.veil/settings.json (global settings)
14
+ 3. ~/.veil/auth.json (global credentials)
15
+ 4. .veil/settings.json (project settings)
16
+ 5. .veil/auth.json (project credentials)
17
+ 6. .veil/settings.local.json (local overrides, gitignored)
18
+ 7. CLI flags (--port, --secret, etc.)
19
+ ```
20
+
21
+ This means you can set a default model in `~/.veil/auth.json` and override it per-project in `.veil/auth.json`.
22
+
23
+ ---
24
+
25
+ ## `auth.json`
26
+
27
+ Stores API credentials. Keep this out of version control.
28
+
29
+ ```json
30
+ {
31
+ "models": {
32
+ "main": {
33
+ "base_url": "https://openrouter.ai/api/v1",
34
+ "api_key": "sk-or-v1-...",
35
+ "model": "moonshotai/kimi-k2.5"
36
+ },
37
+ "compact": {
38
+ "base_url": "https://openrouter.ai/api/v1",
39
+ "api_key": "sk-or-v1-...",
40
+ "model": "google/gemini-flash-1.5-8b"
41
+ },
42
+ "title": null
43
+ }
44
+ }
45
+ ```
46
+
47
+ ### Model roles
48
+
49
+ | Role | Purpose | Fallback |
50
+ |------|---------|----------|
51
+ | `main` | All agent LLM calls | — (required) |
52
+ | `compact` | Context compaction summaries | Falls back to `main` |
53
+ | `title` | Generate task/session titles | Falls back to `main` |
54
+
55
+ ### Model config fields
56
+
57
+ | Field | Type | Description |
58
+ |-------|------|-------------|
59
+ | `base_url` | string | API base URL (default: `https://openrouter.ai/api/v1`) |
60
+ | `api_key` | string | API key |
61
+ | `model` | string | Model identifier string, e.g. `moonshotai/kimi-k2.5` |
62
+ | `temperature` | number | Override temperature (0–2) |
63
+ | `reasoning` | string | Override reasoning mode: "minimal", "low", "medium", "high" |
64
+ | `maxTokens` | integer | Override max output tokens |
65
+
66
+ ### Shortcut: `veil login`
67
+
68
+ ```bash
69
+ veil login --key sk-or-v1-... # writes to .veil/auth.json
70
+ veil login --key sk-or-v1-... --global # writes to ~/.veil/auth.json
71
+ ```
72
+
73
+ ---
74
+
75
+ ## `settings.json`
76
+
77
+ Full runtime configuration. All fields are optional — omitting any field uses the default.
78
+
79
+ ### Top-level fields
80
+
81
+ | Field | Type | Default | Description |
82
+ |-------|------|---------|-------------|
83
+ | `port` | integer | `5050` | HTTP server port |
84
+ | `secret` | string \| null | `null` | If set, all API requests must include `X-Veil-Secret: <secret>` |
85
+ | `maxIterations` | integer | `20` | Default max LLM loop iterations per task/chat turn |
86
+ | `maxDurationSeconds` | integer | `120` | Default max wall-clock seconds per task |
87
+ | `maxConcurrentTasks` | integer | `10` | Max tasks running in parallel |
88
+ | `maxSubAgentDepth` | integer | `5` | Max depth of nested `agent_spawn` calls |
89
+
90
+ ### `models`
91
+
92
+ Can also be specified in `settings.json` (alongside or instead of `auth.json`):
93
+
94
+ ```json
95
+ {
96
+ "models": {
97
+ "main": { "base_url": "...", "api_key": "...", "model": "..." }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### `permissions`
103
+
104
+ Global tool permission policy applied to all agents (unless overridden per-agent or per-mode).
105
+
106
+ ```json
107
+ {
108
+ "permissions": {
109
+ "allow": ["*"],
110
+ "deny": ["bash"],
111
+ "ask": ["write_file"]
112
+ }
113
+ }
114
+ ```
115
+
116
+ | Field | Type | Description |
117
+ |-------|------|-------------|
118
+ | `allow` | string[] | Tools explicitly allowed. Use `["*"]` to allow all. |
119
+ | `deny` | string[] | Tools explicitly denied. Takes priority over `allow`. |
120
+ | `ask` | string[] | Tools that require human approval before executing. Settings-level only. |
121
+
122
+ See [Permissions](07-permissions.md) for the full layering explanation.
123
+
124
+ ### `hooks`
125
+
126
+ Shell commands to run before/after every tool execution:
127
+
128
+ ```json
129
+ {
130
+ "hooks": {
131
+ "PreToolUse": "/path/to/pre-hook.sh",
132
+ "PostToolUse": "/path/to/post-hook.sh"
133
+ }
134
+ }
135
+ ```
136
+
137
+ The hook receives tool name and input as environment variables. Set to `null` to disable.
138
+
139
+ ### `compaction`
140
+
141
+ Controls automatic context window management:
142
+
143
+ ```json
144
+ {
145
+ "compaction": {
146
+ "threshold": 0.8,
147
+ "observationMaskingTurns": 10
148
+ }
149
+ }
150
+ ```
151
+
152
+ | Field | Type | Default | Description |
153
+ |-------|------|---------|-------------|
154
+ | `threshold` | number | `0.8` | Fraction of context window (0.1–1.0) that triggers compaction |
155
+ | `observationMaskingTurns` | integer | `10` | Number of recent turns to keep tool results visible; older ones are masked |
156
+
157
+ See [Memory & Compaction](08-memory.md).
158
+
159
+ ### `memory`
160
+
161
+ ```json
162
+ {
163
+ "memory": {
164
+ "enabled": true,
165
+ "maxLines": 500
166
+ }
167
+ }
168
+ ```
169
+
170
+ | Field | Type | Default | Description |
171
+ |-------|------|---------|-------------|
172
+ | `enabled` | boolean | `true` | Whether memory files are injected into system prompts |
173
+ | `maxLines` | integer | `500` | Max lines to read from a memory file |
174
+
175
+ ### `storage.retention`
176
+
177
+ Controls how long sessions and tasks are kept in SQLite:
178
+
179
+ ```json
180
+ {
181
+ "storage": {
182
+ "retention": {
183
+ "sessions": { "maxAgeDays": 90, "maxCount": 10000 },
184
+ "tasks": { "maxAgeDays": 30, "maxCount": 5000 }
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ ### `mcpServers`
191
+
192
+ Configuration for Model Context Protocol (MCP) servers:
193
+
194
+ ```json
195
+ {
196
+ "mcpServers": {
197
+ "my-mcp": {
198
+ "command": "npx",
199
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
200
+ }
201
+ }
202
+ }
203
+ ```
204
+
205
+ MCP tools are available to agents that list the server name in their `modes.<mode>.mcpServers` array (whitelist-only).
206
+
207
+ ### `ably`
208
+
209
+ Enable Ably for remote API access (e.g. from external clients over the internet):
210
+
211
+ ```json
212
+ {
213
+ "ably": {
214
+ "enabled": true,
215
+ "key": "xVLya.AblyKey"
216
+ }
217
+ }
218
+ ```
219
+
220
+ ---
221
+
222
+ ## Complete Example
223
+
224
+ ```json
225
+ {
226
+ "port": 5051,
227
+ "secret": "my-dev-secret",
228
+ "maxIterations": 25,
229
+ "maxDurationSeconds": 180,
230
+ "maxConcurrentTasks": 5,
231
+ "maxSubAgentDepth": 3,
232
+ "permissions": {
233
+ "allow": ["read_file", "list_dir", "bash", "web_search", "web_fetch"],
234
+ "deny": [],
235
+ "ask": ["write_file", "edit_file"]
236
+ },
237
+ "compaction": {
238
+ "threshold": 0.75,
239
+ "observationMaskingTurns": 8
240
+ },
241
+ "memory": {
242
+ "enabled": true,
243
+ "maxLines": 300
244
+ },
245
+ "storage": {
246
+ "retention": {
247
+ "sessions": { "maxAgeDays": 30, "maxCount": 5000 },
248
+ "tasks": { "maxAgeDays": 14, "maxCount": 2000 }
249
+ }
250
+ }
251
+ }
252
+ ```