@sandagent/runner-cli 0.1.1 → 0.1.2-beta.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.
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.js ADDED
@@ -0,0 +1,377 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { parseArgs } from "node:util";
5
+
6
+ // src/runner.ts
7
+ import * as fs from "node:fs";
8
+ import * as path from "node:path";
9
+
10
+ // ../../packages/runner-claude/dist/claude-runner.js
11
+ var OPTIONAL_MODULES = {
12
+ "claude-agent-sdk": "@anthropic-ai/claude-agent-sdk"
13
+ };
14
+ function createClaudeRunner(options) {
15
+ return {
16
+ async *run(userInput) {
17
+ const apiKey = process.env.ANTHROPIC_API_KEY;
18
+ if (!apiKey) {
19
+ console.error("[SandAgent] Warning: ANTHROPIC_API_KEY not set. Using mock response.\nTo use the real Claude Agent SDK:\n1. Set ANTHROPIC_API_KEY environment variable\n2. Install the SDK: npm install @anthropic-ai/claude-agent-sdk");
20
+ yield* runMockAgent(options, userInput);
21
+ return;
22
+ }
23
+ const sdk = await loadClaudeAgentSDK();
24
+ if (sdk) {
25
+ yield* runWithClaudeAgentSDK(sdk, options, userInput);
26
+ } else {
27
+ console.error("[SandAgent] Warning: @anthropic-ai/claude-agent-sdk not installed. Using mock response.\nInstall the SDK: npm install @anthropic-ai/claude-agent-sdk");
28
+ yield* runMockAgent(options, userInput);
29
+ }
30
+ }
31
+ };
32
+ }
33
+ async function loadClaudeAgentSDK() {
34
+ try {
35
+ const modulePath = OPTIONAL_MODULES["claude-agent-sdk"];
36
+ const module = await import(
37
+ /* webpackIgnore: true */
38
+ modulePath
39
+ );
40
+ return module;
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
45
+ async function* runWithClaudeAgentSDK(sdk, options, userInput) {
46
+ const sdkOptions = {
47
+ model: options.model,
48
+ systemPrompt: options.systemPrompt,
49
+ maxTurns: options.maxTurns,
50
+ allowedTools: options.allowedTools,
51
+ cwd: options.cwd,
52
+ env: options.env
53
+ };
54
+ try {
55
+ for await (const message of sdk.query({
56
+ prompt: userInput,
57
+ options: sdkOptions
58
+ })) {
59
+ const chunks = convertSDKMessageToAISDKUI(message);
60
+ for (const chunk of chunks) {
61
+ yield chunk;
62
+ }
63
+ }
64
+ yield `d:{"finishReason":"stop"}
65
+ `;
66
+ } catch (error) {
67
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
68
+ yield `3:${JSON.stringify(errorMessage)}
69
+ `;
70
+ yield `d:{"finishReason":"error"}
71
+ `;
72
+ }
73
+ }
74
+ function convertSDKMessageToAISDKUI(message) {
75
+ const chunks = [];
76
+ switch (message.type) {
77
+ case "system":
78
+ if (message.subtype === "init") {
79
+ chunks.push(`0:${JSON.stringify(`[System initialized: ${message.model ?? "unknown model"}]
80
+ `)}
81
+ `);
82
+ }
83
+ break;
84
+ case "assistant":
85
+ const assistantMsg = message;
86
+ if (assistantMsg.message) {
87
+ chunks.push(`0:${JSON.stringify(assistantMsg.message)}
88
+ `);
89
+ }
90
+ break;
91
+ case "tool_use":
92
+ const toolUseMsg = message;
93
+ chunks.push(`9:${JSON.stringify({
94
+ toolCallId: toolUseMsg.tool_use_id,
95
+ toolName: toolUseMsg.tool_name,
96
+ args: toolUseMsg.tool_input
97
+ })}
98
+ `);
99
+ break;
100
+ case "tool_result":
101
+ const toolResultMsg = message;
102
+ chunks.push(`a:${JSON.stringify({
103
+ toolCallId: toolResultMsg.tool_use_id,
104
+ result: toolResultMsg.output
105
+ })}
106
+ `);
107
+ break;
108
+ case "result":
109
+ const resultMsg = message;
110
+ if (resultMsg.is_error && resultMsg.errors) {
111
+ chunks.push(`3:${JSON.stringify(resultMsg.errors.join(", "))}
112
+ `);
113
+ }
114
+ break;
115
+ default:
116
+ break;
117
+ }
118
+ return chunks;
119
+ }
120
+ async function* runMockAgent(options, userInput) {
121
+ const response = `I received your request: "${userInput}"
122
+
123
+ Model: ${options.model}
124
+
125
+ This is a mock response because:
126
+ - ANTHROPIC_API_KEY is not set, OR
127
+ - @anthropic-ai/claude-agent-sdk is not installed
128
+
129
+ To use the real Claude Agent SDK:
130
+ 1. Set ANTHROPIC_API_KEY environment variable
131
+ 2. Install the SDK: npm install @anthropic-ai/claude-agent-sdk
132
+
133
+ Documentation: https://platform.claude.com/docs/en/agent-sdk/typescript-v2-preview`;
134
+ const words = response.split(" ");
135
+ for (const word of words) {
136
+ yield `0:${JSON.stringify(word + " ")}
137
+ `;
138
+ await new Promise((resolve2) => setTimeout(resolve2, 20));
139
+ }
140
+ yield `d:{"finishReason":"stop"}
141
+ `;
142
+ }
143
+
144
+ // src/runner.ts
145
+ function findTemplatesDir() {
146
+ const envPath = process.env.SANDAGENT_TEMPLATES_DIR;
147
+ if (envPath && fs.existsSync(envPath)) {
148
+ return envPath;
149
+ }
150
+ const sandboxPath = "/sandagent/templates";
151
+ if (fs.existsSync(sandboxPath)) {
152
+ return sandboxPath;
153
+ }
154
+ const devPath = path.resolve(__dirname, "../../../templates");
155
+ if (fs.existsSync(devPath)) {
156
+ return devPath;
157
+ }
158
+ return null;
159
+ }
160
+ function loadTemplate(templateName) {
161
+ const templatesDir = findTemplatesDir();
162
+ if (!templatesDir) {
163
+ return {};
164
+ }
165
+ const templateDir = path.join(templatesDir, templateName);
166
+ if (!fs.existsSync(templateDir)) {
167
+ if (templateName !== "default") {
168
+ console.error(
169
+ `Warning: Template "${templateName}" not found, using default`
170
+ );
171
+ return loadTemplate("default");
172
+ }
173
+ return {};
174
+ }
175
+ let systemPrompt;
176
+ let settings;
177
+ const claudeMdPath = path.join(templateDir, "CLAUDE.md");
178
+ if (fs.existsSync(claudeMdPath)) {
179
+ systemPrompt = fs.readFileSync(claudeMdPath, "utf-8");
180
+ }
181
+ const settingsPath = path.join(templateDir, ".claude", "settings.json");
182
+ if (fs.existsSync(settingsPath)) {
183
+ try {
184
+ const settingsContent = fs.readFileSync(settingsPath, "utf-8");
185
+ settings = JSON.parse(settingsContent);
186
+ } catch (error) {
187
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
188
+ console.error(
189
+ `Warning: Failed to parse ${settingsPath}: ${errorMessage}`
190
+ );
191
+ }
192
+ }
193
+ const skillsDir = path.join(templateDir, "skills");
194
+ if (fs.existsSync(skillsDir)) {
195
+ try {
196
+ const skillFiles = fs.readdirSync(skillsDir).filter((f) => f.endsWith(".md"));
197
+ if (skillFiles.length > 0) {
198
+ const skillsContent = skillFiles.map((file) => {
199
+ const content = fs.readFileSync(
200
+ path.join(skillsDir, file),
201
+ "utf-8"
202
+ );
203
+ return `
204
+ ---
205
+
206
+ ${content}`;
207
+ }).join("\n");
208
+ if (systemPrompt) {
209
+ systemPrompt += `
210
+
211
+ ## Skills
212
+ ${skillsContent}`;
213
+ }
214
+ }
215
+ } catch (error) {
216
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
217
+ console.error(
218
+ `Warning: Failed to load skills from ${skillsDir}: ${errorMessage}`
219
+ );
220
+ }
221
+ }
222
+ return { systemPrompt, settings };
223
+ }
224
+ async function runAgent(options) {
225
+ const template = loadTemplate(options.template ?? "default");
226
+ const runnerOptions = {
227
+ model: options.model,
228
+ // Explicit system prompt overrides template
229
+ systemPrompt: options.systemPrompt ?? template.systemPrompt,
230
+ // Explicit maxTurns overrides template
231
+ maxTurns: options.maxTurns ?? template.settings?.max_turns,
232
+ // Explicit allowedTools overrides template
233
+ allowedTools: options.allowedTools ?? template.settings?.allowed_tools
234
+ };
235
+ const runner = createClaudeRunner(runnerOptions);
236
+ for await (const chunk of runner.run(options.userInput)) {
237
+ process.stdout.write(chunk);
238
+ }
239
+ }
240
+
241
+ // src/cli.ts
242
+ function parseCliArgs() {
243
+ const { values, positionals } = parseArgs({
244
+ options: {
245
+ model: {
246
+ type: "string",
247
+ short: "m",
248
+ default: "claude-sonnet-4-20250514"
249
+ },
250
+ cwd: {
251
+ type: "string",
252
+ short: "c",
253
+ default: process.env.SANDAGENT_WORKSPACE ?? process.cwd()
254
+ },
255
+ template: {
256
+ type: "string",
257
+ short: "T",
258
+ default: process.env.SANDAGENT_TEMPLATE ?? "default"
259
+ },
260
+ "system-prompt": {
261
+ type: "string",
262
+ short: "s"
263
+ },
264
+ "max-turns": {
265
+ type: "string",
266
+ short: "t"
267
+ },
268
+ "allowed-tools": {
269
+ type: "string",
270
+ short: "a"
271
+ },
272
+ help: {
273
+ type: "boolean",
274
+ short: "h"
275
+ }
276
+ },
277
+ allowPositionals: true,
278
+ strict: true
279
+ });
280
+ if (values.help) {
281
+ printHelp();
282
+ process.exit(0);
283
+ }
284
+ if (positionals[0] !== "run") {
285
+ console.error('Error: Expected "run" command');
286
+ console.error('Usage: sandagent run [options] -- "<user input>"');
287
+ process.exit(1);
288
+ }
289
+ const dashIndex = process.argv.indexOf("--");
290
+ let userInput = "";
291
+ if (dashIndex !== -1 && dashIndex < process.argv.length - 1) {
292
+ userInput = process.argv.slice(dashIndex + 1).join(" ");
293
+ } else if (positionals.length > 1) {
294
+ userInput = positionals.slice(1).join(" ");
295
+ }
296
+ if (!userInput) {
297
+ console.error("Error: User input is required");
298
+ console.error('Usage: sandagent run [options] -- "<user input>"');
299
+ process.exit(1);
300
+ }
301
+ return {
302
+ model: values.model,
303
+ cwd: values.cwd,
304
+ template: values.template,
305
+ systemPrompt: values["system-prompt"],
306
+ maxTurns: values["max-turns"] ? Number.parseInt(values["max-turns"], 10) : void 0,
307
+ allowedTools: values["allowed-tools"]?.split(",").map((t) => t.trim()),
308
+ userInput
309
+ };
310
+ }
311
+ function printHelp() {
312
+ console.log(`
313
+ \u{1F916} SandAgent Runner CLI
314
+
315
+ Like gemini-cli or claude-code - runs locally in your terminal.
316
+ Streams AI SDK UI messages directly to stdout.
317
+
318
+ Usage:
319
+ sandagent run [options] -- "<user input>"
320
+
321
+ # Or run from a template directory:
322
+ cd templates/coder
323
+ sandagent run -- "Build a REST API"
324
+
325
+ Options:
326
+ -m, --model <model> Model to use (default: claude-sonnet-4-20250514)
327
+ -c, --cwd <path> Working directory (default: current directory)
328
+ -T, --template <name> Template to use (default: default)
329
+ Available: default, coder, analyst, researcher
330
+ -s, --system-prompt <prompt> Custom system prompt (overrides template)
331
+ -t, --max-turns <n> Maximum conversation turns
332
+ -a, --allowed-tools <tools> Comma-separated list of allowed tools
333
+ -h, --help Show this help message
334
+
335
+ Environment Variables:
336
+ ANTHROPIC_API_KEY Anthropic API key (required)
337
+ SANDAGENT_WORKSPACE Default workspace path
338
+ SANDAGENT_TEMPLATE Default template to use
339
+ SANDAGENT_LOG_LEVEL Logging level (debug, info, warn, error)
340
+
341
+ Templates:
342
+ default General-purpose assistant
343
+ coder Optimized for software development
344
+ analyst Optimized for data analysis
345
+ researcher Optimized for research tasks
346
+
347
+ Examples:
348
+ # Run with default template
349
+ sandagent run -- "Create a hello world script"
350
+
351
+ # Run from a template directory (recommended)
352
+ cd templates/coder
353
+ sandagent run -- "Build a REST API with Express"
354
+
355
+ # Use a specific template
356
+ sandagent run --template analyst -- "Analyze sales.csv"
357
+
358
+ # Specify working directory
359
+ sandagent run --cwd ./my-project -- "Fix the bug in main.ts"
360
+ `);
361
+ }
362
+ async function main() {
363
+ const args = parseCliArgs();
364
+ process.chdir(args.cwd);
365
+ await runAgent({
366
+ model: args.model,
367
+ template: args.template,
368
+ userInput: args.userInput,
369
+ systemPrompt: args.systemPrompt,
370
+ maxTurns: args.maxTurns,
371
+ allowedTools: args.allowedTools
372
+ });
373
+ }
374
+ main().catch((error) => {
375
+ console.error("Fatal error:", error.message);
376
+ process.exit(1);
377
+ });
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 usage = { inputTokens: 0, outputTokens: 0 };
120
- let systemMessage;
121
- let messageId;
122
- const sdkOptions = {
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: [SettingSource.project, SettingSource.user],
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
- const queryIterator = sdk.query({
137
- prompt: userInput,
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
- -T, --template <name> Template to use (default: default)
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 template
581
+ # Run with default settings
514
582
  sandagent run -- "Create a hello world script"
515
583
 
516
- # Run from a template directory (recommended)
517
- cd templates/coder
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
- * (e.g., a template directory) and outputs AI SDK UI messages directly.
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
- * (e.g., a template directory) and outputs AI SDK UI messages directly.
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
- -T, --template <name> Template to use (default: default)
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 template
132
+ # Run with default settings
138
133
  sandagent run -- "Create a hello world script"
139
134
 
140
- # Run from a template directory (recommended)
141
- cd templates/coder
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;AACtC,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,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,GAAG;gBACV,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,SAAS;aACrD;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;gBACd,KAAK,EAAE,GAAG;aACX;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,GAAG;aACX;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;aACf;YACD,IAAI,EAAE;gBACJ,IAAI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AI,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.
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CtE"}
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
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAwBlC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAwB;IACrD,sDAAsD;IACtD,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAE9C,oCAAoC;I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,SAAS,EAAE,aAAa,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACvC,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sandagent/runner-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-beta.1",
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": {
@@ -18,6 +18,16 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
+ "scripts": {
22
+ "build": "tsc && pnpm bundle",
23
+ "build:bundle": "tsc && pnpm bundle",
24
+ "bundle": "esbuild src/cli.ts --bundle --platform=node --format=esm --outfile=dist/bundle.mjs",
25
+ "dev": "tsc --watch",
26
+ "clean": "rm -rf dist",
27
+ "typecheck": "tsc --noEmit",
28
+ "lint": "echo 'no lint configured'",
29
+ "test": "vitest run --passWithNoTests"
30
+ },
21
31
  "repository": {
22
32
  "type": "git",
23
33
  "url": "https://github.com/vikadata/sandagent.git",
@@ -26,20 +36,10 @@
26
36
  "license": "Apache-2.0",
27
37
  "dependencies": {},
28
38
  "devDependencies": {
39
+ "@sandagent/runner-claude": "workspace:*",
29
40
  "@types/node": "^20.10.0",
30
41
  "esbuild": "^0.27.2",
31
42
  "typescript": "^5.3.0",
32
- "vitest": "^1.6.1",
33
- "@sandagent/runner-claude": "0.1.0"
34
- },
35
- "scripts": {
36
- "build": "tsc && pnpm bundle",
37
- "build:bundle": "tsc && pnpm bundle",
38
- "bundle": "esbuild src/cli.ts --bundle --platform=node --format=esm --outfile=dist/bundle.mjs",
39
- "dev": "tsc --watch",
40
- "clean": "rm -rf dist",
41
- "typecheck": "tsc --noEmit",
42
- "lint": "echo 'no lint configured'",
43
- "test": "vitest run --passWithNoTests"
43
+ "vitest": "^1.6.1"
44
44
  }
45
- }
45
+ }
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.