@sandagent/runner-cli 0.1.0 → 0.1.2
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 +118 -0
- package/dist/bundle.mjs +108 -44
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +20 -29
- package/dist/cli.js.map +1 -1
- package/dist/runner.d.ts +3 -13
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +1 -0
- package/dist/runner.js.map +1 -1
- package/package.json +5 -6
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# @sandagent/runner-cli
|
|
2
|
+
|
|
3
|
+
SandAgent Runner CLI - A command-line interface for running AI agents locally in your terminal.
|
|
4
|
+
|
|
5
|
+
Like gemini-cli or claude-code, this tool runs locally and streams AI SDK UI messages directly to stdout.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @sandagent/runner-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
sandagent run [options] -- "<user input>"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Basic Examples
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Simple task
|
|
23
|
+
sandagent run -- "Create a hello world script"
|
|
24
|
+
|
|
25
|
+
# With custom system prompt
|
|
26
|
+
sandagent run --system-prompt "You are a coding assistant" -- "Build a REST API with Express"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Options
|
|
30
|
+
|
|
31
|
+
| Option | Short | Description | Default |
|
|
32
|
+
|--------|-------|-------------|---------|
|
|
33
|
+
| `--model <model>` | `-m` | Model to use | `claude-sonnet-4-20250514` |
|
|
34
|
+
| `--cwd <path>` | `-c` | Working directory | Current directory |
|
|
35
|
+
| `--system-prompt <prompt>` | `-s` | Custom system prompt | - |
|
|
36
|
+
| `--max-turns <n>` | `-t` | Maximum conversation turns | - |
|
|
37
|
+
| `--allowed-tools <tools>` | `-a` | Comma-separated list of allowed tools | - |
|
|
38
|
+
| `--resume <session-id>` | `-r` | Resume a previous session | - |
|
|
39
|
+
| `--output-format <format>` | `-o` | Output format: `stream` or `json` | `stream` |
|
|
40
|
+
| `--help` | `-h` | Show help message | - |
|
|
41
|
+
|
|
42
|
+
## Output Formats
|
|
43
|
+
|
|
44
|
+
### Stream Format (Default)
|
|
45
|
+
|
|
46
|
+
Outputs Server-Sent Events (SSE) using the AI SDK UI Stream Protocol. Ideal for real-time UI streaming.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
sandagent run -- "Calculate 2+2"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Output:**
|
|
53
|
+
```
|
|
54
|
+
data: {"type":"start","messageId":"msg_123"}
|
|
55
|
+
data: {"type":"text-delta","id":"text_1","delta":"The answer is 4."}
|
|
56
|
+
data: [DONE]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### JSON Format
|
|
60
|
+
|
|
61
|
+
Outputs a structured JSON object with complete message content and metadata. Ideal for API integration and automation.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
sandagent run --output-format json -- "Calculate 2+2"
|
|
65
|
+
# or
|
|
66
|
+
sandagent run -o json -- "Calculate 2+2"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Environment Variables
|
|
70
|
+
|
|
71
|
+
| Variable | Description | Required |
|
|
72
|
+
|----------|-------------|----------|
|
|
73
|
+
| `ANTHROPIC_API_KEY` | Anthropic API key | Yes |
|
|
74
|
+
| `SANDAGENT_WORKSPACE` | Default workspace path | No |
|
|
75
|
+
| `SANDAGENT_LOG_LEVEL` | Logging level (debug, info, warn, error) | No |
|
|
76
|
+
|
|
77
|
+
## Advanced Examples
|
|
78
|
+
|
|
79
|
+
### Specify Working Directory
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
sandagent run --cwd ./my-project -- "Fix the bug in main.ts"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### JSON Output for Automation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Save result to file
|
|
89
|
+
sandagent run -o json -- "Generate UUID" > result.json
|
|
90
|
+
|
|
91
|
+
# Parse with jq
|
|
92
|
+
sandagent run -o json -- "What is 2+2?" | jq '.content[0].text'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Combined Options
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
sandagent run \
|
|
99
|
+
-o json \
|
|
100
|
+
-m claude-sonnet-4-20250514 \
|
|
101
|
+
--system-prompt "You are a helpful coding assistant" \
|
|
102
|
+
--max-turns 10 \
|
|
103
|
+
-- "Build a REST API"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Architecture
|
|
107
|
+
|
|
108
|
+
The CLI is designed to:
|
|
109
|
+
1. Execute in a specific working directory
|
|
110
|
+
2. Load settings from `.claude/settings.json` and `CLAUDE.md` in the project
|
|
111
|
+
3. Stream AI SDK UI messages directly to stdout
|
|
112
|
+
4. Support both SSE stream and JSON output formats
|
|
113
|
+
|
|
114
|
+
## Related Documentation
|
|
115
|
+
|
|
116
|
+
- [Claude Agent SDK](https://platform.claude.com/docs/agent-sdk/typescript)
|
|
117
|
+
- [AI SDK UI Stream Protocol](https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol)
|
|
118
|
+
|
package/dist/bundle.mjs
CHANGED
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
5
|
|
|
6
6
|
// ../../packages/runner-claude/dist/claude-runner.js
|
|
7
|
-
var SettingSource;
|
|
8
|
-
(function(SettingSource2) {
|
|
9
|
-
SettingSource2["user"] = "user";
|
|
10
|
-
SettingSource2["project"] = "project";
|
|
11
|
-
})(SettingSource || (SettingSource = {}));
|
|
12
7
|
function createCanUseToolCallback(claudeOptions) {
|
|
13
8
|
return async (toolName, input, options) => {
|
|
14
9
|
const { toolUseID } = options;
|
|
@@ -116,10 +111,25 @@ async function loadClaudeAgentSDK() {
|
|
|
116
111
|
}
|
|
117
112
|
}
|
|
118
113
|
async function* runWithClaudeAgentSDK(sdk, options, userInput, signal) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
const outputFormat = options.outputFormat || "stream-json";
|
|
115
|
+
switch (outputFormat) {
|
|
116
|
+
case "text":
|
|
117
|
+
yield* runWithTextOutput(sdk, options, userInput, signal);
|
|
118
|
+
break;
|
|
119
|
+
case "json":
|
|
120
|
+
yield* runWithJSONOutput(sdk, options, userInput, signal);
|
|
121
|
+
break;
|
|
122
|
+
case "stream-json":
|
|
123
|
+
yield* runWithStreamJSONOutput(sdk, options, userInput, signal);
|
|
124
|
+
break;
|
|
125
|
+
// case "stream":
|
|
126
|
+
default:
|
|
127
|
+
yield* runWithAISDKUIOutput(sdk, options, userInput, signal);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function createSDKOptions(options) {
|
|
132
|
+
return {
|
|
123
133
|
model: options.model,
|
|
124
134
|
systemPrompt: options.systemPrompt,
|
|
125
135
|
maxTurns: options.maxTurns,
|
|
@@ -127,16 +137,14 @@ async function* runWithClaudeAgentSDK(sdk, options, userInput, signal) {
|
|
|
127
137
|
cwd: options.cwd,
|
|
128
138
|
env: options.env,
|
|
129
139
|
resume: options.resume,
|
|
130
|
-
settingSources: [
|
|
140
|
+
settingSources: ["project", "user"],
|
|
131
141
|
canUseTool: createCanUseToolCallback(options),
|
|
132
142
|
// Bypass all permission checks for automated execution
|
|
133
143
|
permissionMode: "bypassPermissions",
|
|
134
144
|
allowDangerouslySkipPermissions: true
|
|
135
145
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
options: sdkOptions
|
|
139
|
-
});
|
|
146
|
+
}
|
|
147
|
+
function setupAbortHandler(queryIterator, signal) {
|
|
140
148
|
const abortHandler = async () => {
|
|
141
149
|
console.error("[ClaudeRunner] Operation aborted, calling query.interrupt()");
|
|
142
150
|
await queryIterator.interrupt();
|
|
@@ -150,6 +158,70 @@ async function* runWithClaudeAgentSDK(sdk, options, userInput, signal) {
|
|
|
150
158
|
} else {
|
|
151
159
|
console.error("[ClaudeRunner] No signal provided");
|
|
152
160
|
}
|
|
161
|
+
return abortHandler;
|
|
162
|
+
}
|
|
163
|
+
async function* runWithTextOutput(sdk, options, userInput, signal) {
|
|
164
|
+
const sdkOptions = createSDKOptions(options);
|
|
165
|
+
const queryIterator = sdk.query({ prompt: userInput, options: sdkOptions });
|
|
166
|
+
const abortHandler = setupAbortHandler(queryIterator, signal);
|
|
167
|
+
try {
|
|
168
|
+
let resultText = "";
|
|
169
|
+
for await (const message of queryIterator) {
|
|
170
|
+
if (message.type === "result") {
|
|
171
|
+
const resultMsg = message;
|
|
172
|
+
if (resultMsg.subtype === "success") {
|
|
173
|
+
resultText = resultMsg.result || "";
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
yield resultText;
|
|
178
|
+
} finally {
|
|
179
|
+
if (signal) {
|
|
180
|
+
signal.removeEventListener("abort", abortHandler);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function* runWithJSONOutput(sdk, options, userInput, signal) {
|
|
185
|
+
const sdkOptions = createSDKOptions(options);
|
|
186
|
+
const queryIterator = sdk.query({ prompt: userInput, options: sdkOptions });
|
|
187
|
+
const abortHandler = setupAbortHandler(queryIterator, signal);
|
|
188
|
+
try {
|
|
189
|
+
let resultMessage = null;
|
|
190
|
+
for await (const message of queryIterator) {
|
|
191
|
+
if (message.type === "result") {
|
|
192
|
+
resultMessage = message;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (resultMessage) {
|
|
196
|
+
yield JSON.stringify(resultMessage) + "\n";
|
|
197
|
+
}
|
|
198
|
+
} finally {
|
|
199
|
+
if (signal) {
|
|
200
|
+
signal.removeEventListener("abort", abortHandler);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async function* runWithStreamJSONOutput(sdk, options, userInput, signal) {
|
|
205
|
+
const sdkOptions = createSDKOptions(options);
|
|
206
|
+
const queryIterator = sdk.query({ prompt: userInput, options: sdkOptions });
|
|
207
|
+
const abortHandler = setupAbortHandler(queryIterator, signal);
|
|
208
|
+
try {
|
|
209
|
+
for await (const message of queryIterator) {
|
|
210
|
+
yield JSON.stringify(message) + "\n";
|
|
211
|
+
}
|
|
212
|
+
} finally {
|
|
213
|
+
if (signal) {
|
|
214
|
+
signal.removeEventListener("abort", abortHandler);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async function* runWithAISDKUIOutput(sdk, options, userInput, signal) {
|
|
219
|
+
const usage = { inputTokens: 0, outputTokens: 0 };
|
|
220
|
+
let systemMessage;
|
|
221
|
+
let messageId;
|
|
222
|
+
const sdkOptions = createSDKOptions(options);
|
|
223
|
+
const queryIterator = sdk.query({ prompt: userInput, options: sdkOptions });
|
|
224
|
+
const abortHandler = setupAbortHandler(queryIterator, signal);
|
|
153
225
|
try {
|
|
154
226
|
for await (const message of queryIterator) {
|
|
155
227
|
if (message.type === "system" && message.subtype === "init") {
|
|
@@ -378,7 +450,8 @@ async function runAgent(options) {
|
|
|
378
450
|
maxTurns: options.maxTurns,
|
|
379
451
|
allowedTools: options.allowedTools,
|
|
380
452
|
resume: options.resume,
|
|
381
|
-
approvalDir: options.approvalDir
|
|
453
|
+
approvalDir: options.approvalDir,
|
|
454
|
+
outputFormat: options.outputFormat
|
|
382
455
|
};
|
|
383
456
|
const runner = createClaudeRunner(runnerOptions);
|
|
384
457
|
for await (const chunk of runner.run(
|
|
@@ -407,11 +480,6 @@ function parseCliArgs() {
|
|
|
407
480
|
short: "c",
|
|
408
481
|
default: process.env.SANDAGENT_WORKSPACE ?? process.cwd()
|
|
409
482
|
},
|
|
410
|
-
template: {
|
|
411
|
-
type: "string",
|
|
412
|
-
short: "T",
|
|
413
|
-
default: process.env.SANDAGENT_TEMPLATE ?? "default"
|
|
414
|
-
},
|
|
415
483
|
"system-prompt": {
|
|
416
484
|
type: "string",
|
|
417
485
|
short: "s"
|
|
@@ -431,6 +499,10 @@ function parseCliArgs() {
|
|
|
431
499
|
"approval-dir": {
|
|
432
500
|
type: "string"
|
|
433
501
|
},
|
|
502
|
+
"output-format": {
|
|
503
|
+
type: "string",
|
|
504
|
+
short: "o"
|
|
505
|
+
},
|
|
434
506
|
help: {
|
|
435
507
|
type: "boolean",
|
|
436
508
|
short: "h"
|
|
@@ -460,15 +532,22 @@ function parseCliArgs() {
|
|
|
460
532
|
console.error('Usage: sandagent run [options] -- "<user input>"');
|
|
461
533
|
process.exit(1);
|
|
462
534
|
}
|
|
535
|
+
const outputFormat = values["output-format"];
|
|
536
|
+
if (outputFormat && !["text", "json", "stream-json", "stream"].includes(outputFormat)) {
|
|
537
|
+
console.error(
|
|
538
|
+
'Error: --output-format must be one of: "text", "json", "stream-json", "stream"'
|
|
539
|
+
);
|
|
540
|
+
process.exit(1);
|
|
541
|
+
}
|
|
463
542
|
return {
|
|
464
543
|
model: values.model,
|
|
465
544
|
cwd: values.cwd,
|
|
466
|
-
template: values.template,
|
|
467
545
|
systemPrompt: values["system-prompt"],
|
|
468
546
|
maxTurns: values["max-turns"] ? Number.parseInt(values["max-turns"], 10) : void 0,
|
|
469
547
|
allowedTools: values["allowed-tools"]?.split(",").map((t) => t.trim()),
|
|
470
548
|
resume: values.resume,
|
|
471
549
|
approvalDir: values["approval-dir"],
|
|
550
|
+
outputFormat: outputFormat ?? "stream",
|
|
472
551
|
userInput
|
|
473
552
|
};
|
|
474
553
|
}
|
|
@@ -482,43 +561,28 @@ Streams AI SDK UI messages directly to stdout.
|
|
|
482
561
|
Usage:
|
|
483
562
|
sandagent run [options] -- "<user input>"
|
|
484
563
|
|
|
485
|
-
# Or run from a template directory:
|
|
486
|
-
cd templates/coder
|
|
487
|
-
sandagent run -- "Build a REST API"
|
|
488
|
-
|
|
489
564
|
Options:
|
|
490
565
|
-m, --model <model> Model to use (default: claude-sonnet-4-20250514)
|
|
491
566
|
-c, --cwd <path> Working directory (default: current directory)
|
|
492
|
-
-
|
|
493
|
-
Available: default, coder, analyst, researcher
|
|
494
|
-
-s, --system-prompt <prompt> Custom system prompt (overrides template)
|
|
567
|
+
-s, --system-prompt <prompt> Custom system prompt
|
|
495
568
|
-t, --max-turns <n> Maximum conversation turns
|
|
496
569
|
-a, --allowed-tools <tools> Comma-separated list of allowed tools
|
|
497
570
|
-r, --resume <session-id> Resume a previous session
|
|
571
|
+
-o, --output-format <format> Output format (default: stream)
|
|
572
|
+
Available: text, json(single result), stream-json(realtime streaming), stream(ai sdk ui sse format)
|
|
498
573
|
-h, --help Show this help message
|
|
499
574
|
|
|
500
575
|
Environment Variables:
|
|
501
576
|
ANTHROPIC_API_KEY Anthropic API key (required)
|
|
502
577
|
SANDAGENT_WORKSPACE Default workspace path
|
|
503
|
-
SANDAGENT_TEMPLATE Default template to use
|
|
504
578
|
SANDAGENT_LOG_LEVEL Logging level (debug, info, warn, error)
|
|
505
579
|
|
|
506
|
-
Templates:
|
|
507
|
-
default General-purpose assistant
|
|
508
|
-
coder Optimized for software development
|
|
509
|
-
analyst Optimized for data analysis
|
|
510
|
-
researcher Optimized for research tasks
|
|
511
|
-
|
|
512
580
|
Examples:
|
|
513
|
-
# Run with default
|
|
581
|
+
# Run with default settings
|
|
514
582
|
sandagent run -- "Create a hello world script"
|
|
515
583
|
|
|
516
|
-
# Run
|
|
517
|
-
|
|
518
|
-
sandagent run -- "Build a REST API with Express"
|
|
519
|
-
|
|
520
|
-
# Use a specific template
|
|
521
|
-
sandagent run --template analyst -- "Analyze sales.csv"
|
|
584
|
+
# Run with custom system prompt
|
|
585
|
+
sandagent run --system-prompt "You are a coding assistant" -- "Build a REST API with Express"
|
|
522
586
|
|
|
523
587
|
# Specify working directory
|
|
524
588
|
sandagent run --cwd ./my-project -- "Fix the bug in main.ts"
|
|
@@ -529,13 +593,13 @@ async function main() {
|
|
|
529
593
|
process.chdir(args.cwd);
|
|
530
594
|
await runAgent({
|
|
531
595
|
model: args.model,
|
|
532
|
-
template: args.template,
|
|
533
596
|
userInput: args.userInput,
|
|
534
597
|
systemPrompt: args.systemPrompt,
|
|
535
598
|
maxTurns: args.maxTurns,
|
|
536
599
|
allowedTools: args.allowedTools,
|
|
537
600
|
resume: args.resume,
|
|
538
|
-
approvalDir: args.approvalDir
|
|
601
|
+
approvalDir: args.approvalDir,
|
|
602
|
+
outputFormat: args.outputFormat
|
|
539
603
|
});
|
|
540
604
|
}
|
|
541
605
|
main().catch((error) => {
|
package/dist/cli.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* sandagent run [options] -- "<user input>"
|
|
10
10
|
*
|
|
11
11
|
* The CLI is designed to be executed in a specific working directory
|
|
12
|
-
*
|
|
12
|
+
* and outputs AI SDK UI messages directly.
|
|
13
13
|
*/
|
|
14
14
|
export {};
|
|
15
15
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* sandagent run [options] -- "<user input>"
|
|
10
10
|
*
|
|
11
11
|
* The CLI is designed to be executed in a specific working directory
|
|
12
|
-
*
|
|
12
|
+
* and outputs AI SDK UI messages directly.
|
|
13
13
|
*/
|
|
14
14
|
import { parseArgs } from "node:util";
|
|
15
15
|
import { runAgent } from "./runner.js";
|
|
@@ -26,11 +26,6 @@ function parseCliArgs() {
|
|
|
26
26
|
short: "c",
|
|
27
27
|
default: process.env.SANDAGENT_WORKSPACE ?? process.cwd(),
|
|
28
28
|
},
|
|
29
|
-
template: {
|
|
30
|
-
type: "string",
|
|
31
|
-
short: "T",
|
|
32
|
-
default: process.env.SANDAGENT_TEMPLATE ?? "default",
|
|
33
|
-
},
|
|
34
29
|
"system-prompt": {
|
|
35
30
|
type: "string",
|
|
36
31
|
short: "s",
|
|
@@ -50,6 +45,10 @@ function parseCliArgs() {
|
|
|
50
45
|
"approval-dir": {
|
|
51
46
|
type: "string",
|
|
52
47
|
},
|
|
48
|
+
"output-format": {
|
|
49
|
+
type: "string",
|
|
50
|
+
short: "o",
|
|
51
|
+
},
|
|
53
52
|
help: {
|
|
54
53
|
type: "boolean",
|
|
55
54
|
short: "h",
|
|
@@ -82,10 +81,16 @@ function parseCliArgs() {
|
|
|
82
81
|
console.error('Usage: sandagent run [options] -- "<user input>"');
|
|
83
82
|
process.exit(1);
|
|
84
83
|
}
|
|
84
|
+
// Validate output-format
|
|
85
|
+
const outputFormat = values["output-format"];
|
|
86
|
+
if (outputFormat &&
|
|
87
|
+
!["text", "json", "stream-json", "stream"].includes(outputFormat)) {
|
|
88
|
+
console.error('Error: --output-format must be one of: "text", "json", "stream-json", "stream"');
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
85
91
|
return {
|
|
86
92
|
model: values.model,
|
|
87
93
|
cwd: values.cwd,
|
|
88
|
-
template: values.template,
|
|
89
94
|
systemPrompt: values["system-prompt"],
|
|
90
95
|
maxTurns: values["max-turns"]
|
|
91
96
|
? Number.parseInt(values["max-turns"], 10)
|
|
@@ -93,6 +98,7 @@ function parseCliArgs() {
|
|
|
93
98
|
allowedTools: values["allowed-tools"]?.split(",").map((t) => t.trim()),
|
|
94
99
|
resume: values.resume,
|
|
95
100
|
approvalDir: values["approval-dir"],
|
|
101
|
+
outputFormat: outputFormat ?? "stream",
|
|
96
102
|
userInput,
|
|
97
103
|
};
|
|
98
104
|
}
|
|
@@ -106,43 +112,28 @@ Streams AI SDK UI messages directly to stdout.
|
|
|
106
112
|
Usage:
|
|
107
113
|
sandagent run [options] -- "<user input>"
|
|
108
114
|
|
|
109
|
-
# Or run from a template directory:
|
|
110
|
-
cd templates/coder
|
|
111
|
-
sandagent run -- "Build a REST API"
|
|
112
|
-
|
|
113
115
|
Options:
|
|
114
116
|
-m, --model <model> Model to use (default: claude-sonnet-4-20250514)
|
|
115
117
|
-c, --cwd <path> Working directory (default: current directory)
|
|
116
|
-
-
|
|
117
|
-
Available: default, coder, analyst, researcher
|
|
118
|
-
-s, --system-prompt <prompt> Custom system prompt (overrides template)
|
|
118
|
+
-s, --system-prompt <prompt> Custom system prompt
|
|
119
119
|
-t, --max-turns <n> Maximum conversation turns
|
|
120
120
|
-a, --allowed-tools <tools> Comma-separated list of allowed tools
|
|
121
121
|
-r, --resume <session-id> Resume a previous session
|
|
122
|
+
-o, --output-format <format> Output format (default: stream)
|
|
123
|
+
Available: text, json(single result), stream-json(realtime streaming), stream(ai sdk ui sse format)
|
|
122
124
|
-h, --help Show this help message
|
|
123
125
|
|
|
124
126
|
Environment Variables:
|
|
125
127
|
ANTHROPIC_API_KEY Anthropic API key (required)
|
|
126
128
|
SANDAGENT_WORKSPACE Default workspace path
|
|
127
|
-
SANDAGENT_TEMPLATE Default template to use
|
|
128
129
|
SANDAGENT_LOG_LEVEL Logging level (debug, info, warn, error)
|
|
129
130
|
|
|
130
|
-
Templates:
|
|
131
|
-
default General-purpose assistant
|
|
132
|
-
coder Optimized for software development
|
|
133
|
-
analyst Optimized for data analysis
|
|
134
|
-
researcher Optimized for research tasks
|
|
135
|
-
|
|
136
131
|
Examples:
|
|
137
|
-
# Run with default
|
|
132
|
+
# Run with default settings
|
|
138
133
|
sandagent run -- "Create a hello world script"
|
|
139
134
|
|
|
140
|
-
# Run
|
|
141
|
-
|
|
142
|
-
sandagent run -- "Build a REST API with Express"
|
|
143
|
-
|
|
144
|
-
# Use a specific template
|
|
145
|
-
sandagent run --template analyst -- "Analyze sales.csv"
|
|
135
|
+
# Run with custom system prompt
|
|
136
|
+
sandagent run --system-prompt "You are a coding assistant" -- "Build a REST API with Express"
|
|
146
137
|
|
|
147
138
|
# Specify working directory
|
|
148
139
|
sandagent run --cwd ./my-project -- "Fix the bug in main.ts"
|
|
@@ -155,13 +146,13 @@ async function main() {
|
|
|
155
146
|
// Run the agent and stream output to stdout
|
|
156
147
|
await runAgent({
|
|
157
148
|
model: args.model,
|
|
158
|
-
template: args.template,
|
|
159
149
|
userInput: args.userInput,
|
|
160
150
|
systemPrompt: args.systemPrompt,
|
|
161
151
|
maxTurns: args.maxTurns,
|
|
162
152
|
allowedTools: args.allowedTools,
|
|
163
153
|
resume: args.resume,
|
|
164
154
|
approvalDir: args.approvalDir,
|
|
155
|
+
outputFormat: args.outputFormat,
|
|
165
156
|
});
|
|
166
157
|
}
|
|
167
158
|
main().catch((error) => {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAcvC,SAAS,YAAY;IACnB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;QACxC,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,GAAG;gBACV,OAAO,EAAE,0BAA0B;aACpC;YACD,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,GAAG;gBACV,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,EAAE;aAC1D;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,GAAG;aACX;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,GAAG;aACX;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gB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I;IACjB,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAE5B,4CAA4C;IAC5C,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAExB,4CAA4C;IAC5C,MAAM,QAAQ,CAAC;QACb,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,kCAAkC;IAClC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
+
import { type BaseRunnerOptions } from "@sandagent/runner-claude";
|
|
1
2
|
/**
|
|
2
3
|
* Options for running the agent
|
|
4
|
+
* Extends BaseRunnerOptions with CLI-specific fields
|
|
3
5
|
*/
|
|
4
|
-
export interface RunAgentOptions {
|
|
5
|
-
/** Model to use */
|
|
6
|
-
model: string;
|
|
6
|
+
export interface RunAgentOptions extends BaseRunnerOptions {
|
|
7
7
|
/** User input/task */
|
|
8
8
|
userInput: string;
|
|
9
9
|
/** Template to use (e.g., "default", "coder", "analyst", "researcher") */
|
|
10
10
|
template?: string;
|
|
11
|
-
/** Custom system prompt (overrides template) */
|
|
12
|
-
systemPrompt?: string;
|
|
13
|
-
/** Maximum conversation turns */
|
|
14
|
-
maxTurns?: number;
|
|
15
|
-
/** Allowed tools */
|
|
16
|
-
allowedTools?: string[];
|
|
17
|
-
/** Resume session ID for multi-turn conversation */
|
|
18
|
-
resume?: string;
|
|
19
|
-
/** Approval file directory for tool approval flow (e.g., "/sandagent/approvals") */
|
|
20
|
-
approvalDir?: string;
|
|
21
11
|
}
|
|
22
12
|
/**
|
|
23
13
|
* Run the agent and stream AI SDK UI messages to stdout.
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CtE"}
|
package/dist/runner.js
CHANGED
|
@@ -32,6 +32,7 @@ export async function runAgent(options) {
|
|
|
32
32
|
allowedTools: options.allowedTools,
|
|
33
33
|
resume: options.resume,
|
|
34
34
|
approvalDir: options.approvalDir,
|
|
35
|
+
outputFormat: options.outputFormat,
|
|
35
36
|
};
|
|
36
37
|
const runner = createClaudeRunner(runnerOptions);
|
|
37
38
|
// Stream AI SDK UI messages to stdout
|
package/dist/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,O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OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACvC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandagent/runner-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "SandAgent Runner CLI - Like gemini-cli or claude-code, runs in your local terminal with AI SDK UI streaming",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"sandagent": "./dist/
|
|
7
|
+
"sandagent": "./dist/bundle.mjs"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"module": "./dist/index.js",
|
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
"directory": "apps/runner-cli"
|
|
25
25
|
},
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@sandagent/runner-claude": "0.1.0"
|
|
29
|
-
},
|
|
27
|
+
"dependencies": {},
|
|
30
28
|
"devDependencies": {
|
|
31
29
|
"@types/node": "^20.10.0",
|
|
32
30
|
"esbuild": "^0.27.2",
|
|
33
31
|
"typescript": "^5.3.0",
|
|
34
|
-
"vitest": "^1.6.1"
|
|
32
|
+
"vitest": "^1.6.1",
|
|
33
|
+
"@sandagent/runner-claude": "0.1.0"
|
|
35
34
|
},
|
|
36
35
|
"scripts": {
|
|
37
36
|
"build": "tsc && pnpm bundle",
|