@agent-smith/cli 0.0.115 → 0.0.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +274 -34
- package/dist/cli.js +4 -8
- package/dist/cmd/{clicmds/aliases.d.ts → aliases.d.ts} +1 -1
- package/dist/cmd/{clicmds/aliases.js → aliases.js} +1 -26
- package/dist/cmd/{clicmds/base.js → base.js} +21 -17
- package/dist/cmd/build.d.ts +9 -0
- package/dist/cmd/build.js +59 -0
- package/dist/cmd/callbacks.d.ts +11 -0
- package/dist/cmd/callbacks.js +90 -0
- package/dist/cmd/cmds.d.ts +8 -9
- package/dist/cmd/cmds.js +134 -103
- package/dist/cmd/features.d.ts +6 -0
- package/dist/cmd/features.js +57 -0
- package/dist/cmd/{sys/read_cmds.d.ts → read_cmds.d.ts} +1 -1
- package/dist/cmd/{sys/read_cmds.js → read_cmds.js} +1 -1
- package/dist/cmd/user_cmds.d.ts +3 -0
- package/dist/cmd/user_cmds.js +23 -0
- package/dist/index.js +11 -11
- package/dist/main.d.ts +3 -38
- package/dist/main.js +3 -37
- package/dist/state.d.ts +6 -0
- package/dist/state.js +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +50 -0
- package/package.json +10 -20
- package/dist/cmd/clicmds/cmds.d.ts +0 -7
- package/dist/cmd/clicmds/cmds.js +0 -135
- package/dist/cmd/clicmds/updateconf.d.ts +0 -3
- package/dist/cmd/clicmds/updateconf.js +0 -74
- package/dist/cmd/lib/actions/cmd.d.ts +0 -6
- package/dist/cmd/lib/actions/cmd.js +0 -154
- package/dist/cmd/lib/actions/read.d.ts +0 -3
- package/dist/cmd/lib/actions/read.js +0 -17
- package/dist/cmd/lib/adaptaters/cmd.d.ts +0 -2
- package/dist/cmd/lib/adaptaters/cmd.js +0 -39
- package/dist/cmd/lib/agents/cmd.d.ts +0 -3
- package/dist/cmd/lib/agents/cmd.js +0 -11
- package/dist/cmd/lib/mcp.d.ts +0 -16
- package/dist/cmd/lib/mcp.js +0 -105
- package/dist/cmd/lib/options_parsers.d.ts +0 -7
- package/dist/cmd/lib/options_parsers.js +0 -52
- package/dist/cmd/lib/tasks/cmd.d.ts +0 -4
- package/dist/cmd/lib/tasks/cmd.js +0 -419
- package/dist/cmd/lib/tasks/conf.d.ts +0 -6
- package/dist/cmd/lib/tasks/conf.js +0 -131
- package/dist/cmd/lib/tasks/read.d.ts +0 -14
- package/dist/cmd/lib/tasks/read.js +0 -186
- package/dist/cmd/lib/tasks/utils.d.ts +0 -8
- package/dist/cmd/lib/tasks/utils.js +0 -48
- package/dist/cmd/lib/tools.d.ts +0 -15
- package/dist/cmd/lib/tools.js +0 -147
- package/dist/cmd/lib/utils.d.ts +0 -3
- package/dist/cmd/lib/utils.js +0 -54
- package/dist/cmd/lib/workflows/cmd.d.ts +0 -3
- package/dist/cmd/lib/workflows/cmd.js +0 -230
- package/dist/cmd/lib/workflows/read.d.ts +0 -6
- package/dist/cmd/lib/workflows/read.js +0 -61
- package/dist/cmd/sys/clipboard.d.ts +0 -3
- package/dist/cmd/sys/clipboard.js +0 -33
- package/dist/cmd/sys/delete_file.d.ts +0 -2
- package/dist/cmd/sys/delete_file.js +0 -10
- package/dist/cmd/sys/dirs.d.ts +0 -2
- package/dist/cmd/sys/dirs.js +0 -9
- package/dist/cmd/sys/execute.d.ts +0 -13
- package/dist/cmd/sys/execute.js +0 -48
- package/dist/cmd/sys/read.d.ts +0 -3
- package/dist/cmd/sys/read.js +0 -21
- package/dist/cmd/sys/read_conf.d.ts +0 -6
- package/dist/cmd/sys/read_conf.js +0 -12
- package/dist/cmd/sys/read_features.d.ts +0 -3
- package/dist/cmd/sys/read_features.js +0 -112
- package/dist/cmd/sys/read_task.d.ts +0 -6
- package/dist/cmd/sys/read_task.js +0 -23
- package/dist/cmd/sys/read_yml_file.d.ts +0 -5
- package/dist/cmd/sys/read_yml_file.js +0 -11
- package/dist/cmd/sys/run_python.d.ts +0 -6
- package/dist/cmd/sys/run_python.js +0 -39
- package/dist/conf.d.ts +0 -14
- package/dist/conf.js +0 -166
- package/dist/const.d.ts +0 -3
- package/dist/const.js +0 -24
- package/dist/db/db.d.ts +0 -4
- package/dist/db/db.js +0 -23
- package/dist/db/read.d.ts +0 -34
- package/dist/db/read.js +0 -128
- package/dist/db/schemas.d.ts +0 -2
- package/dist/db/schemas.js +0 -105
- package/dist/db/write.d.ts +0 -15
- package/dist/db/write.js +0 -376
- package/dist/interfaces.d.ts +0 -165
- package/dist/interfaces.js +0 -1
- package/dist/state/backends.d.ts +0 -7
- package/dist/state/backends.js +0 -159
- package/dist/state/chat.d.ts +0 -7
- package/dist/state/chat.js +0 -10
- package/dist/state/features.d.ts +0 -8
- package/dist/state/features.js +0 -35
- package/dist/state/plugins.d.ts +0 -6
- package/dist/state/plugins.js +0 -27
- package/dist/state/state.d.ts +0 -20
- package/dist/state/state.js +0 -80
- package/dist/state/tasks.d.ts +0 -6
- package/dist/state/tasks.js +0 -28
- package/dist/utils/perf.d.ts +0 -9
- package/dist/utils/perf.js +0 -63
- package/dist/utils/text.d.ts +0 -6
- package/dist/utils/text.js +0 -41
- package/dist/utils/user_msgs.d.ts +0 -5
- package/dist/utils/user_msgs.js +0 -19
- /package/dist/cmd/{clicmds/base.d.ts → base.d.ts} +0 -0
- /package/dist/{cmd/options.d.ts → options.d.ts} +0 -0
- /package/dist/{cmd/options.js → options.js} +0 -0
- /package/dist/{cmd/lib/user_msgs.d.ts → user_msgs.d.ts} +0 -0
- /package/dist/{cmd/lib/user_msgs.js → user_msgs.js} +0 -0
package/README.md
CHANGED
|
@@ -1,82 +1,322 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://www.npmjs.com/package/@agent-smith/cli)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @agent-smith/cli — Terminal REPL for Agent Smith
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A command-line interface built with Commander.js for interacting with AI agents, executing workflows and actions, managing configuration, and running inference. Part of the [Agent Smith toolkit](https://github.com/lynxai-team/agent-smith).
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Features
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- 🚀 **Interactive REPL** — Chat mode for conversational agent interaction
|
|
10
|
+
- ⚡ **One-shot Commands** — Run agents, workflows, and actions from the terminal
|
|
11
|
+
- 🔧 **Dynamic Commands** — Auto-generated commands from database features (agents, actions, workflows, aliases)
|
|
12
|
+
- 🎛️ **Configuration Management** — YAML-based config with SQLite backend for backends, plugins, and feature paths
|
|
13
|
+
- 🌐 **Multi-Backend Support** — Llama.cpp, Koboldcpp, Ollama, OpenRouter, and any OpenAI-compatible API
|
|
14
|
+
- 📋 **I/O Flexibility** — Clipboard input/output, file input, markdown output modes
|
|
15
|
+
- 🔍 **Inference Control** — Fine-grained control over model parameters (temperature, top_k, top_p, min_p, etc.)
|
|
16
|
+
- 🔄 **Hot-Reloadable Features** — Add agents and tools without restarting the CLI
|
|
17
|
+
|
|
18
|
+
## Documentation
|
|
19
|
+
|
|
20
|
+
### For AI Agents
|
|
21
|
+
|
|
22
|
+
- [Codebase Summary](.agents/documentation/codebase-summary.md) — Architecture, key files, and patterns for the CLI package
|
|
23
|
+
- [Overview](https://raw.githubusercontent.com/lynxai-team/agent-smith/refs/heads/main/docsite/public/doc/terminal_client/2.overview.md) — Terminal client principles and feature types
|
|
24
|
+
- [Install](https://raw.githubusercontent.com/lynxai-team/agent-smith/refs/heads/main/docsite/public/doc/terminal_client/1.install.md) — Installation and quickstart
|
|
25
|
+
- [Config](https://raw.githubusercontent.com/lynxai-team/agent-smith/refs/heads/main/docsite/public/doc/terminal_client/3.config.md) — Configuration file format and backend setup
|
|
26
|
+
- [Agents](https://raw.githubusercontent.com/lynxai-team/agent-smith/refs/heads/main/docsite/public/doc/terminal_client/agents/1.overview.md) — Agent YAML definitions and tool calling
|
|
27
|
+
- [Tasks](https://raw.githubusercontent.com/lynxai-team/agent-smith/refs/heads/main/docsite/public/doc/terminal_client/4.tasks.md) — Running agents with variables and parameters
|
|
28
|
+
- [Actions](https://raw.githubusercontent.com/lynxai-team/agent-smith/refs/heads/main/docsite/public/doc/terminal_client/6.actions.md) — Custom tool scripts (JS, Python, YAML)
|
|
29
|
+
- [Workflows](https://raw.githubusercontent.com/lynxai-team/agent-smith/refs/heads/main/docsite/public/doc/terminal_client/7.workflows.md) — Chaining actions and agents in pipelines
|
|
30
|
+
- [Commands](https://raw.githubusercontent.com/lynxai-team/agent-smith/refs/heads/main/docsite/public/doc/terminal_client/8.commands.md) — Custom terminal commands
|
|
31
|
+
|
|
32
|
+
### For Humans
|
|
33
|
+
|
|
34
|
+
- [Quickstart Guide](https://lynxai-team.github.io/agent-smith/terminal_client/quickstart) — Get up and running in minutes
|
|
35
|
+
- [Terminal Client Overview](https://lynxai-team.github.io/agent-smith/terminal_client/overview) — Principles and feature types
|
|
36
|
+
- [Installation](https://lynxai-team.github.io/agent-smith/terminal_client/install) — Install and initial configuration
|
|
37
|
+
- [Configuration](https://lynxai-team.github.io/agent-smith/terminal_client/config) — Config file format, backends, and plugins
|
|
38
|
+
- [Agent Definitions](https://lynxai-team.github.io/agent-smith/terminal_client/agents/overview) — Declaring agents with YAML
|
|
39
|
+
- [Tasks & Variables](https://lynxai-team.github.io/agent-smith/terminal_client/tasks) — Parameterized agent execution
|
|
40
|
+
- [Actions](https://lynxai-team.github.io/agent-smith/terminal_client/actions) — Writing custom tools
|
|
41
|
+
- [Workflows](https://lynxai-team.github.io/agent-smith/terminal_client/workflows) — Building multi-step pipelines
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
10
44
|
|
|
11
45
|
```bash
|
|
12
46
|
npm i -g @agent-smith/cli
|
|
13
47
|
```
|
|
14
48
|
|
|
15
|
-
|
|
49
|
+
This installs the `lm` command globally.
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### 1. Configure Your Backend
|
|
54
|
+
|
|
55
|
+
Create a config file at `~/.config/agent-smith/config.yml`:
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
backends:
|
|
59
|
+
default: "llamacpp"
|
|
60
|
+
llamacpp:
|
|
61
|
+
type: "openai"
|
|
62
|
+
url: "http://localhost:8080/v1"
|
|
63
|
+
openrouter:
|
|
64
|
+
type: "openai"
|
|
65
|
+
url: "https://openrouter.ai/api/v1"
|
|
66
|
+
apiKey: "$OPENROUTER_API_KEY"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Sync Configuration
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
lm conf ~/.config/agent-smith/config.yml
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This processes the YAML config and populates the SQLite database at `~/.config/agent-smith/config.db`.
|
|
76
|
+
|
|
77
|
+
### 3. Run a Quick Query
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
lm q list the planets of the solar system
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
With a specific model:
|
|
16
84
|
|
|
17
|
-
|
|
85
|
+
```bash
|
|
86
|
+
lm q list the planets of the solar system -m gemma4b
|
|
87
|
+
```
|
|
18
88
|
|
|
19
|
-
|
|
89
|
+
### 4. Enter Interactive Chat Mode
|
|
20
90
|
|
|
21
91
|
```bash
|
|
22
|
-
|
|
92
|
+
lm
|
|
23
93
|
```
|
|
24
94
|
|
|
25
|
-
|
|
95
|
+
Then type your queries interactively. Use `exit` to quit.
|
|
96
|
+
|
|
97
|
+
## Usage
|
|
26
98
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
99
|
+
### Listing Agents
|
|
100
|
+
|
|
101
|
+
List all registered agents:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
lm agents
|
|
32
105
|
```
|
|
33
106
|
|
|
34
|
-
|
|
107
|
+
View an agent definition:
|
|
35
108
|
|
|
36
109
|
```bash
|
|
37
|
-
lm
|
|
110
|
+
lm agent myagent
|
|
38
111
|
```
|
|
39
112
|
|
|
40
|
-
###
|
|
113
|
+
### Running Agents
|
|
41
114
|
|
|
42
|
-
Run
|
|
115
|
+
Run a specific agent with a prompt:
|
|
43
116
|
|
|
44
117
|
```bash
|
|
45
|
-
lm
|
|
118
|
+
lm myagent "Explain quantum computing"
|
|
46
119
|
```
|
|
47
120
|
|
|
48
|
-
|
|
121
|
+
With variables (if the agent requires them):
|
|
49
122
|
|
|
50
|
-
|
|
123
|
+
```bash
|
|
124
|
+
lm myagent "Analyze this code" --workspace /path/to/project
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Using Different Backends
|
|
128
|
+
|
|
129
|
+
Change the default backend:
|
|
51
130
|
|
|
52
131
|
```bash
|
|
53
|
-
lm
|
|
132
|
+
lm backend openrouter
|
|
54
133
|
```
|
|
55
134
|
|
|
56
|
-
|
|
135
|
+
Use a specific backend for one execution:
|
|
57
136
|
|
|
58
|
-
|
|
137
|
+
```bash
|
|
138
|
+
lm myagent "Hello" -b llamacpp
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
List available backends:
|
|
59
142
|
|
|
60
143
|
```bash
|
|
61
|
-
lm
|
|
144
|
+
lm backends
|
|
62
145
|
```
|
|
63
146
|
|
|
64
|
-
|
|
147
|
+
### Inference Parameters
|
|
148
|
+
|
|
149
|
+
Control model behavior with command-line options:
|
|
65
150
|
|
|
66
151
|
```bash
|
|
67
|
-
lm
|
|
152
|
+
lm q "Write a poem" \
|
|
153
|
+
--model qwen4b \
|
|
154
|
+
--temperature 0.7 \
|
|
155
|
+
--top_k 20 \
|
|
156
|
+
--top_p 0.95 \
|
|
157
|
+
--max_tokens 1024
|
|
68
158
|
```
|
|
69
159
|
|
|
70
|
-
###
|
|
160
|
+
### Input/Output Modes
|
|
71
161
|
|
|
72
|
-
|
|
162
|
+
**Clipboard input:**
|
|
163
|
+
```bash
|
|
164
|
+
lm q "Summarize this" --clipboard-input
|
|
165
|
+
```
|
|
73
166
|
|
|
167
|
+
**File input:**
|
|
74
168
|
```bash
|
|
75
|
-
lm
|
|
169
|
+
lm q "Analyze" --input-file
|
|
76
170
|
```
|
|
77
171
|
|
|
78
|
-
|
|
172
|
+
**Markdown output:**
|
|
173
|
+
```bash
|
|
174
|
+
lm q "Generate a report" --markdown-output
|
|
175
|
+
```
|
|
79
176
|
|
|
177
|
+
**Clipboard output:**
|
|
80
178
|
```bash
|
|
81
|
-
lm
|
|
82
|
-
```
|
|
179
|
+
lm q "Generate code" --clipboard-output
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Chat Mode for Tasks
|
|
183
|
+
|
|
184
|
+
Enable chat mode for multi-turn task execution:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
lm myagent "Start a project" -c
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Verbose and Debug Modes
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
lm q "Hello" --verbose # Show detailed execution info
|
|
194
|
+
lm q "Hello" --debug # Show debug-level output
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Complete Example
|
|
198
|
+
|
|
199
|
+
Here's a full workflow: configuring backends, creating an agent, and running it with custom parameters.
|
|
200
|
+
|
|
201
|
+
### Step 1: Create Features Directory
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
mkdir -p ~/my-agents/features/agents
|
|
205
|
+
mkdir -p ~/my-agents/features/actions
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Step 2: Configure Features Path
|
|
209
|
+
|
|
210
|
+
Update `~/.config/agent-smith/config.yml`:
|
|
211
|
+
|
|
212
|
+
```yaml
|
|
213
|
+
features:
|
|
214
|
+
- ~/my-agents/features
|
|
215
|
+
backends:
|
|
216
|
+
default: "llamacpp"
|
|
217
|
+
llamacpp:
|
|
218
|
+
type: "openai"
|
|
219
|
+
url: "http://localhost:8080/v1"
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Step 3: Create an Agent
|
|
223
|
+
|
|
224
|
+
Create `~/my-agents/features/agents/shell-demo.yml`:
|
|
225
|
+
|
|
226
|
+
```yaml
|
|
227
|
+
name: shell-demo
|
|
228
|
+
description: A demo agent with shell tool access
|
|
229
|
+
prompt: |-
|
|
230
|
+
{prompt}
|
|
231
|
+
model: qwen4b
|
|
232
|
+
inferParams:
|
|
233
|
+
min_p: 0
|
|
234
|
+
top_k: 20
|
|
235
|
+
top_p: 0.95
|
|
236
|
+
temperature: 0.4
|
|
237
|
+
toolsList:
|
|
238
|
+
- shell
|
|
239
|
+
variables:
|
|
240
|
+
required:
|
|
241
|
+
workspace:
|
|
242
|
+
description: The local directory path where to operate
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Step 4: Register and Run
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Register the new agent
|
|
249
|
+
lm update
|
|
250
|
+
|
|
251
|
+
# Run with a prompt and variable
|
|
252
|
+
lm shell-demo "List files in the current directory" --workspace /path/to/dir
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## API Reference
|
|
256
|
+
|
|
257
|
+
### CLI Entry Point
|
|
258
|
+
|
|
259
|
+
The package exports utility functions for integration:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import {
|
|
263
|
+
displayOptions,
|
|
264
|
+
ioOptions,
|
|
265
|
+
inferenceOptions,
|
|
266
|
+
allOptions,
|
|
267
|
+
parseCommandArgs
|
|
268
|
+
} from "@agent-smith/cli";
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Options
|
|
272
|
+
|
|
273
|
+
| Export | Type | Description |
|
|
274
|
+
|--------|------|-------------|
|
|
275
|
+
| `displayOptions` | `Option[]` | CLI display options (`--verbose`, `--debug`) |
|
|
276
|
+
| `ioOptions` | `Option[]` | I/O mode options (clipboard, file, markdown) |
|
|
277
|
+
| `inferenceOptions` | `Option[]` | Inference parameter options (model, temperature, etc.) |
|
|
278
|
+
| `allOptions` | `Option[]` | Combined options array |
|
|
279
|
+
| `parseCommandArgs` | `Function` | Parse command-line arguments for Commander.js |
|
|
280
|
+
|
|
281
|
+
### Inference Options
|
|
282
|
+
|
|
283
|
+
| Option | Short | Description |
|
|
284
|
+
|--------|-------|-------------|
|
|
285
|
+
| `--model <name>` | `-m` | Model name to use |
|
|
286
|
+
| `--ctx` | `-x` | Context window size |
|
|
287
|
+
| `--template <template>` | `--tpl` | Template to use |
|
|
288
|
+
| `--max_tokens <number>` | `--mt` | Maximum tokens to generate |
|
|
289
|
+
| `--top_k <number>` | `-k` | Limit results to top K |
|
|
290
|
+
| `--top_p <number>` | `-p` | Cumulative probability filter |
|
|
291
|
+
| `--min_p <number>` | `--mp` | Minimum token probability |
|
|
292
|
+
| `--temperature <number>` | `-t` | Sampling randomness |
|
|
293
|
+
| `--repeat_penalty <number>` | `-r` | Penalty for repeated tokens |
|
|
294
|
+
| `--backend <name>` | `-b` | Backend to use (must be registered) |
|
|
295
|
+
| `--mcp [args...]` | — | MCP server arguments |
|
|
296
|
+
|
|
297
|
+
### I/O Options
|
|
298
|
+
|
|
299
|
+
| Option | Short | Description |
|
|
300
|
+
|--------|-------|-------------|
|
|
301
|
+
| `--input-file` | `--if` | Use promptfile input mode |
|
|
302
|
+
| `--clipboard-input` | `--ic` | Use clipboard input mode |
|
|
303
|
+
| `--manual-input` | `--im` | Manual input (default) |
|
|
304
|
+
| `--clipboard-output` | `--oc` | Output to clipboard |
|
|
305
|
+
| `--markdown-output` | `--omd` | Markdown output format |
|
|
306
|
+
| `--text-output` | `--otxt` | Text output (default) |
|
|
307
|
+
|
|
308
|
+
## Important Notes
|
|
309
|
+
|
|
310
|
+
- **Node.js Required**: This package runs in Node.js environments only — it is not a browser library.
|
|
311
|
+
- **Global Installation**: Designed for global installation via `npm i -g`. The `lm` binary is available system-wide.
|
|
312
|
+
- **SQLite Database**: Configuration and features are stored in SQLite at `~/.config/agent-smith/config.db`.
|
|
313
|
+
- **Dependencies**: Requires `@agent-smith/core` for feature execution and database operations.
|
|
314
|
+
- **Backend Compatibility**: Supports any server with an OpenAI-compatible API (Llama.cpp, Ollama, Koboldcpp, OpenRouter, etc.).
|
|
315
|
+
- **Related Packages**:
|
|
316
|
+
- `@agent-smith/core` — Runtime engine for feature execution
|
|
317
|
+
- `@agent-smith/agent` — Agent inference loop
|
|
318
|
+
- `@agent-smith/wscli` — WebSocket client for server communication
|
|
319
|
+
|
|
320
|
+
## License
|
|
321
|
+
|
|
322
|
+
MIT
|
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { input } from '@inquirer/prompts';
|
|
2
|
-
import { chat } from './cmd/cmds.js';
|
|
3
|
-
import { isChatMode } from './state/state.js';
|
|
4
|
-
import { Agent } from '@agent-smith/agent';
|
|
5
|
-
import { backend } from './state/backends.js';
|
|
6
2
|
async function query(program) {
|
|
7
3
|
const data = { message: "$", default: "" };
|
|
8
4
|
const q = await input(data);
|
|
9
5
|
//console.log("QUERY", q);
|
|
10
6
|
const args = q.split(" ");
|
|
11
7
|
await program.parseAsync(args, { from: "user" });
|
|
12
|
-
if (isChatMode.value) {
|
|
13
|
-
const agent = new Agent(backend.value
|
|
14
|
-
await chat(
|
|
15
|
-
}
|
|
8
|
+
/*if (isChatMode.value) {
|
|
9
|
+
const agent = new Agent({ lm: state.backend.value!, name: "chat" })
|
|
10
|
+
await chat({}, agent, [])
|
|
11
|
+
}*/
|
|
16
12
|
await query(program);
|
|
17
13
|
}
|
|
18
14
|
export { query };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { AliasType, FeatureSpec, FeatureType } from "
|
|
2
|
+
import type { AliasType, FeatureSpec, FeatureType } from "@agent-smith/types";
|
|
3
3
|
declare function initCommandsFromAliases(program: Command, aliases: {
|
|
4
4
|
name: string;
|
|
5
5
|
type: AliasType;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { allOptions } from "../options.js";
|
|
2
|
-
import {
|
|
3
|
-
import { executeWorkflowCmd } from "../lib/workflows/cmd.js";
|
|
4
|
-
import { executeAgentCmd } from "../lib/agents/cmd.js";
|
|
2
|
+
import { executeWorkflowCmd, executeAgentCmd } from "./features.js";
|
|
5
3
|
function initCommandsFromAliases(program, aliases, features) {
|
|
6
4
|
aliases.forEach((alias) => {
|
|
7
5
|
//console.log("A", alias)
|
|
@@ -29,29 +27,6 @@ function initCommandsFromAliases(program, aliases, features) {
|
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
break;
|
|
32
|
-
case "task":
|
|
33
|
-
const tcmd = program.command(`${alias.name} [prompt_and_vars...]`)
|
|
34
|
-
.description("task: " + alias.name)
|
|
35
|
-
.action(async (...args) => {
|
|
36
|
-
await executeTaskCmd(alias.name, args);
|
|
37
|
-
});
|
|
38
|
-
allOptions.forEach(o => tcmd.addOption(o));
|
|
39
|
-
//console.log("TVARS", alias.name, features.task[alias.name]?.variables)
|
|
40
|
-
if (features.task[alias.name]?.variables) {
|
|
41
|
-
const rtv = features.task[alias.name].variables?.required;
|
|
42
|
-
if (rtv) {
|
|
43
|
-
for (const name of Object.keys(rtv)) {
|
|
44
|
-
tcmd.option(`--${name} <value>`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const otv = features.task[alias.name].variables?.optional;
|
|
48
|
-
if (otv) {
|
|
49
|
-
for (const name of Object.keys(otv)) {
|
|
50
|
-
tcmd.option(`--${name} <value>`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
30
|
/*case "action":
|
|
56
31
|
const acmd = program.command(`${alias.name} [args...]`)
|
|
57
32
|
.description("action: " + alias.name)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Option } from "commander";
|
|
2
|
-
import {
|
|
3
|
-
import { parseCommandArgs } from "../
|
|
4
|
-
import {
|
|
5
|
-
import { updateConfCmd, updateFeaturesCmd } from "./updateconf.js";
|
|
2
|
+
import { conf, state } from "@agent-smith/core";
|
|
3
|
+
import { parseCommandArgs } from "../utils.js";
|
|
4
|
+
import { processAgentCmd, processAgentsCmd, recreateDbCmd, resetDbCmd } from "./cmds.js";
|
|
6
5
|
import { displayOptions, inferenceOptions } from "../options.js";
|
|
7
6
|
function initBaseCommands(program) {
|
|
8
7
|
/*program.command("ping")
|
|
@@ -11,50 +10,55 @@ function initBaseCommands(program) {
|
|
|
11
10
|
program.command("exit")
|
|
12
11
|
.description("exit the cli")
|
|
13
12
|
.action(() => process.exit(0));
|
|
14
|
-
const
|
|
15
|
-
.description("list all the
|
|
13
|
+
const agentsCmd = program.command("agents")
|
|
14
|
+
.description("list all the agents")
|
|
16
15
|
.action(async (...args) => {
|
|
17
16
|
const ca = parseCommandArgs(args);
|
|
18
|
-
await
|
|
17
|
+
await processAgentsCmd(ca.args, ca.options);
|
|
19
18
|
});
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
.description("
|
|
19
|
+
agentsCmd.addOption(new Option("-c, --conf", "output the agents config"));
|
|
20
|
+
const agentCmd = program.command("agent <agent>")
|
|
21
|
+
.description("view an agent")
|
|
23
22
|
.action(async (...args) => {
|
|
24
23
|
const ca = parseCommandArgs(args);
|
|
25
|
-
await
|
|
24
|
+
await processAgentCmd(ca.args, ca.options);
|
|
26
25
|
});
|
|
27
|
-
inferenceOptions.forEach(o =>
|
|
28
|
-
|
|
26
|
+
inferenceOptions.forEach(o => agentCmd.addOption(o));
|
|
27
|
+
agentCmd.addOption(new Option("--reset", "reset the task config to the original"));
|
|
29
28
|
program.command("backend <name>")
|
|
30
29
|
.description("set the default backend")
|
|
31
30
|
.action(async (...args) => {
|
|
32
31
|
const ca = parseCommandArgs(args);
|
|
33
|
-
await setBackend(ca.args[0]);
|
|
32
|
+
await state.setBackend(ca.args[0]);
|
|
34
33
|
});
|
|
35
34
|
program.command("backends")
|
|
36
35
|
.description("list the available backends")
|
|
37
36
|
.action(async (...args) => {
|
|
38
|
-
await listBackends();
|
|
37
|
+
await state.listBackends();
|
|
39
38
|
});
|
|
40
39
|
const updateCmd = program.command("update")
|
|
41
40
|
.description("update the available features: run this after adding a new feature")
|
|
42
41
|
.action(async (...args) => {
|
|
43
42
|
const ca = parseCommandArgs(args);
|
|
44
|
-
await updateFeaturesCmd(ca.options);
|
|
43
|
+
await conf.updateFeaturesCmd(ca.options);
|
|
45
44
|
});
|
|
46
45
|
displayOptions.forEach(o => updateCmd.addOption(o));
|
|
47
46
|
program.command("conf <path>")
|
|
48
47
|
.description("process config file")
|
|
49
48
|
.action(async (...args) => {
|
|
50
49
|
const ca = parseCommandArgs(args);
|
|
51
|
-
await updateConfCmd(ca.args);
|
|
50
|
+
await conf.updateConfCmd(ca.args);
|
|
52
51
|
});
|
|
53
52
|
program.command("reset")
|
|
54
53
|
.description("reset the config database")
|
|
55
54
|
.action(async (...args) => {
|
|
56
55
|
await resetDbCmd();
|
|
57
56
|
});
|
|
57
|
+
program.command("regendb")
|
|
58
|
+
.description("regenerate the database from the current registered config file")
|
|
59
|
+
.action(async (...args) => {
|
|
60
|
+
await recreateDbCmd();
|
|
61
|
+
});
|
|
58
62
|
return program;
|
|
59
63
|
}
|
|
60
64
|
export { initBaseCommands };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentInferenceOptions } from "@agent-smith/types";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { type McpClient } from "@agent-smith/core";
|
|
4
|
+
import type { Agent } from "@agent-smith/agent";
|
|
5
|
+
declare const program: Command;
|
|
6
|
+
declare function chat(options: AgentInferenceOptions, agent: Agent, mcpServers: Array<McpClient>): Promise<void>;
|
|
7
|
+
declare function buildCmds(): Promise<Command>;
|
|
8
|
+
declare function parseCmd(program: Command): Promise<void>;
|
|
9
|
+
export { buildCmds, chat, parseCmd, program };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { input } from "@inquirer/prompts";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { query } from "../cli.js";
|
|
4
|
+
import { db } from "@agent-smith/core";
|
|
5
|
+
import { isChatMode, runMode, chatInferenceParams } from "../state.js";
|
|
6
|
+
import { initBaseCommands } from "./base.js";
|
|
7
|
+
import { initCommandsFromAliases } from "./aliases.js";
|
|
8
|
+
import { initUserCmds } from "./cmds.js";
|
|
9
|
+
const program = new Command();
|
|
10
|
+
async function chat(options, agent, mcpServers) {
|
|
11
|
+
//console.log("CHAT AGENT", agent);
|
|
12
|
+
const data = { message: '>', default: "" };
|
|
13
|
+
const prompt = await input(data);
|
|
14
|
+
if (prompt == "/q") {
|
|
15
|
+
isChatMode.value = false;
|
|
16
|
+
if (runMode.value == "cmd") {
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
mcpServers.forEach(async (s) => await s.stop());
|
|
21
|
+
await query(program);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//console.log("CHAT HIST", agent.history);
|
|
25
|
+
//options.history = undefined;
|
|
26
|
+
//console.log("RUN W PROMPT", prompt);
|
|
27
|
+
options.params = chatInferenceParams;
|
|
28
|
+
await agent.run(prompt, options);
|
|
29
|
+
console.log();
|
|
30
|
+
await chat(options, agent, mcpServers);
|
|
31
|
+
}
|
|
32
|
+
async function buildCmds() {
|
|
33
|
+
//program.allowUnknownOption(true);
|
|
34
|
+
//const perf = usePerfTimer();
|
|
35
|
+
initBaseCommands(program);
|
|
36
|
+
//perf.measure("initBaseCommands");
|
|
37
|
+
const aliases = db.readAliases();
|
|
38
|
+
//perf.measure("readAliases");
|
|
39
|
+
const feats = db.readFeatures();
|
|
40
|
+
//perf.measure("readFeatures");
|
|
41
|
+
initCommandsFromAliases(program, aliases, feats);
|
|
42
|
+
//perf.measure("initCommandsFromAliases");
|
|
43
|
+
await initUserCmds(feats.cmd, program);
|
|
44
|
+
//perf.measure("initUserCmds");
|
|
45
|
+
//perf.measure("cmds for each");
|
|
46
|
+
//perf.final("buildCmds");
|
|
47
|
+
return program;
|
|
48
|
+
}
|
|
49
|
+
async function parseCmd(program) {
|
|
50
|
+
program.name('Agent Smith terminal client');
|
|
51
|
+
program.description('Terminal agents toolkit');
|
|
52
|
+
await program.parseAsync();
|
|
53
|
+
//console.log("CMD END");
|
|
54
|
+
//exit(0)
|
|
55
|
+
/*if (isChatMode.value) {
|
|
56
|
+
await chat(program)
|
|
57
|
+
}*/
|
|
58
|
+
}
|
|
59
|
+
export { buildCmds, chat, parseCmd, program };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentInferenceOptions, ToolCallSpec } from "@agent-smith/types";
|
|
2
|
+
declare const useInferenceCallbacks: (agentName: string, options: AgentInferenceOptions) => {
|
|
3
|
+
onToken: (t: string, from: string) => void;
|
|
4
|
+
onStartThinking: (from: string) => void;
|
|
5
|
+
onEndThinking: (from: string) => void;
|
|
6
|
+
onThinkingToken: (t: string, from: string) => void;
|
|
7
|
+
onToolCallInProgress: (tc: Array<ToolCallSpec>, from: string) => void;
|
|
8
|
+
onToolCall: (tc: ToolCallSpec, type: string, from: string) => void;
|
|
9
|
+
onToolCallEnd: (tc: ToolCallSpec, tr: any, type: string, from: string) => void;
|
|
10
|
+
};
|
|
11
|
+
export { useInferenceCallbacks, };
|