@sourcegraph/amp-sdk 0.1.0-3e67faf1b0e66cf0d3bf2985979efbcac0554a79

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/LICENSE.md ADDED
@@ -0,0 +1 @@
1
+ © Sourcegraph Inc. All rights reserved. Use of Amp is subject to Amp's [Terms of Service](https://ampcode.com/terms).
package/README.md ADDED
@@ -0,0 +1,367 @@
1
+ # Amp TypeScript SDK
2
+
3
+ Use the Amp SDK to programmatically deploy the Amp agent anywhere you run TypeScript. Execute Amp CLI commands programmatically with full type safety, streaming responses, and complete control over your AI coding agent workflows.
4
+
5
+ ## Why use the Amp SDK?
6
+
7
+ The Amp TypeScript SDK brings the Amp agent directly into your applications with simple, reliable functionality:
8
+
9
+ - **Stream Inputs**: Send prompts and messages incrementally to the Amp agent
10
+ - **Stream Outputs**: Receive structured JSON responses (system, assistant, result) as the agent executes tasks
11
+ - **Multi-turn Conversations**: Maintain back-and-forth interactions across multiple executions
12
+ - **Thread Continuity**: Continue an existing thread (latest or by ID) to build stateful agent workflows
13
+ - **Programmatic Settings**: Configure working directories, settings, and tools without user prompts — ideal for automation
14
+ - **MCP Integration**: Extend Amp with custom Model Context Protocol servers and tools
15
+ - **Custom Tools**: Define and use custom tools to extend Amp's functionality with Toolboxes
16
+
17
+ ## What can you build?
18
+
19
+ The Amp SDK enables a wide range of AI-powered applications:
20
+
21
+ ### Development Tools
22
+
23
+ - **Code Review Agent**: Automated pull request analysis and feedback
24
+ - **Documentation Generator**: Create and maintain project documentation
25
+ - **Test Automation**: Generate and execute test suites
26
+ - **Migration Assistant**: Help upgrade codebases and refactor legacy code
27
+
28
+ ### Workflow Automation
29
+
30
+ - **CI/CD Integration**: Smart build and deployment pipelines
31
+ - **Issue Triage**: Automatically categorize and prioritize bug reports
32
+ - **Code Quality Monitoring**: Continuous analysis of code health metrics
33
+ - **Release Management**: Automated changelog generation and version bumping
34
+
35
+ ## Quick Start
36
+
37
+ ### Installation
38
+
39
+ Install the Amp SDK using `npm` or `yarn`:
40
+
41
+ ```bash
42
+ # npm
43
+ npm install @sourcegraph/amp-sdk
44
+
45
+ # yarn
46
+ yarn add @sourcegraph/amp-sdk
47
+ ```
48
+
49
+ Once installed, add your API key to the environment. You can access your API key at [ampcode.com/settings](https://ampcode.com/settings).
50
+
51
+ ```bash
52
+ export AMP_API_KEY=sgamp_your_api_key_here
53
+ ```
54
+
55
+ ### Your First Amp Command
56
+
57
+ Now that you have the SDK installed and your API key set up, you can start using Amp with the `execute()` function:
58
+
59
+ ```typescript
60
+ import { execute } from '@sourcegraph/amp-sdk'
61
+
62
+ // Simple execution - get the final result
63
+ for await (const message of execute({ prompt: 'What files are in this directory?' })) {
64
+ if (message.type === 'result' && !message.is_error) {
65
+ console.log('Result:', message.result)
66
+ break
67
+ }
68
+ }
69
+ ```
70
+
71
+ The `execute()` function only requires that you provide a `prompt` to get started. The SDK streams messages as the agent works, letting you handle responses and integrate them directly into your application.
72
+
73
+ ## Core Concepts
74
+
75
+ ### Message Streaming
76
+
77
+ The SDK streams different types of messages as your agent executes:
78
+
79
+ ```typescript
80
+ for await (const message of execute({ prompt: 'Run tests' })) {
81
+ if (message.type === 'system') {
82
+ // Session info, available tools, MCP servers
83
+ console.log('Available tools:', message.tools)
84
+ } else if (message.type === 'assistant') {
85
+ // AI responses and tool usage
86
+ console.log('Assistant is working...')
87
+ } else if (message.type === 'result') {
88
+ // Final result (success or error)
89
+ console.log('Done:', message.result)
90
+ }
91
+ }
92
+ ```
93
+
94
+ ### Simple Result Extraction
95
+
96
+ When you just need the final result without handling streaming:
97
+
98
+ ```typescript
99
+ async function getResult(prompt: string): Promise<string> {
100
+ for await (const message of execute({ prompt, options: { dangerouslyAllowAll: true } })) {
101
+ if (message.type === 'result') {
102
+ if (message.is_error) {
103
+ throw new Error(message.error)
104
+ }
105
+ return message.result
106
+ }
107
+ }
108
+ throw new Error('No result received')
109
+ }
110
+
111
+ // Usage
112
+ try {
113
+ const result = await getResult('List all TypeScript files in this project')
114
+ console.log('Found files:', result)
115
+ } catch (error) {
116
+ console.error('Failed:', error.message)
117
+ }
118
+ ```
119
+
120
+ ### Thread Continuity
121
+
122
+ Continue conversations across multiple interactions:
123
+
124
+ ```typescript
125
+ // Continue the most recent conversation
126
+ for await (const message of execute({
127
+ prompt: 'What was the last error you found?',
128
+ options: { continue: true },
129
+ })) {
130
+ if (message.type === 'result') {
131
+ console.log(message.result)
132
+ }
133
+ }
134
+
135
+ // Continue a specific thread by ID
136
+ for await (const message of execute({
137
+ prompt: 'Can you update that code we discussed?',
138
+ options: { continue: 'T-abc123-def456' },
139
+ })) {
140
+ if (message.type === 'result') {
141
+ console.log(message.result)
142
+ }
143
+ }
144
+ ```
145
+
146
+ ## Common Configuration
147
+
148
+ ### Skip Permission Prompts
149
+
150
+ For automation scenarios, bypass permission prompts:
151
+
152
+ ```typescript
153
+ const options = {
154
+ dangerouslyAllowAll: true, // Skip permission prompts
155
+ }
156
+
157
+ for await (const message of execute({
158
+ prompt: 'Make changes without asking for permission',
159
+ options,
160
+ })) {
161
+ // Handle messages...
162
+ }
163
+ ```
164
+
165
+ ### Working Directory
166
+
167
+ Specify where Amp should run:
168
+
169
+ ```typescript
170
+ for await (const message of execute({
171
+ prompt: 'Refactor the auth module',
172
+ options: { cwd: './my-project' },
173
+ })) {
174
+ // Process messages...
175
+ }
176
+ ```
177
+
178
+ ### Enable Debug Logging
179
+
180
+ See what's happening under the hood:
181
+
182
+ ```typescript
183
+ for await (const message of execute({
184
+ prompt: 'Analyze this project',
185
+ options: {
186
+ logLevel: 'debug', // Shows CLI command in console
187
+ logFile: './amp-debug.log', // Optional: write logs to file
188
+ },
189
+ })) {
190
+ // Process messages
191
+ }
192
+ ```
193
+
194
+ ## Advanced Usage
195
+
196
+ ### Interactive Progress Tracking
197
+
198
+ For building user interfaces that show real-time progress:
199
+
200
+ ```typescript
201
+ async function executeWithProgress(prompt: string) {
202
+ console.log('Starting task...')
203
+
204
+ for await (const message of execute({ prompt })) {
205
+ if (message.type === 'system' && message.subtype === 'init') {
206
+ console.log('Tools available:', message.tools.join(', '))
207
+ } else if (message.type === 'assistant') {
208
+ // Show tool usage or assistant responses
209
+ const content = message.message.content[0]
210
+ if (content.type === 'tool_use') {
211
+ console.log(`Using ${content.name}...`)
212
+ } else if (content.type === 'text') {
213
+ console.log('Assistant:', content.text.slice(0, 100) + '...')
214
+ }
215
+ } else if (message.type === 'result') {
216
+ if (message.is_error) {
217
+ console.log('Failed:', message.error)
218
+ } else {
219
+ console.log('Completed successfully!')
220
+ console.log(message.result)
221
+ }
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ ### Cancellation and Timeouts
228
+
229
+ Handle long-running operations gracefully:
230
+
231
+ ```typescript
232
+ async function executeWithTimeout(prompt: string, timeoutMs = 30000) {
233
+ const signal = AbortSignal.timeout(timeoutMs)
234
+
235
+ try {
236
+ for await (const message of execute({
237
+ prompt,
238
+ signal,
239
+ options: { dangerouslyAllowAll: true },
240
+ })) {
241
+ if (message.type === 'result') {
242
+ return message.result
243
+ }
244
+ }
245
+ } catch (error) {
246
+ if (error.message.includes('aborted')) {
247
+ throw new Error(`Operation timed out after ${timeoutMs}ms`)
248
+ }
249
+ throw error
250
+ }
251
+ }
252
+ ```
253
+
254
+ ### MCP (Model Context Protocol) Integration
255
+
256
+ Extend Amp's capabilities with custom tools and data sources:
257
+
258
+ ```typescript
259
+ import { execute, type MCPConfig } from '@sourcegraph/amp-sdk'
260
+
261
+ const mcpConfig: MCPConfig = {
262
+ playwright: {
263
+ command: 'npx',
264
+ args: ['-y', '@playwright/mcp@latest', '--headless'],
265
+ env: { NODE_ENV: 'production' },
266
+ },
267
+ database: {
268
+ command: 'node',
269
+ args: ['./custom-mcp-server.js'],
270
+ env: { DB_CONNECTION_STRING: process.env.DATABASE_URL },
271
+ },
272
+ }
273
+
274
+ for await (const message of execute({
275
+ prompt: 'Test the login flow on staging environment',
276
+ options: { mcpConfig, dangerouslyAllowAll: true },
277
+ })) {
278
+ if (message.type === 'system') {
279
+ console.log(
280
+ 'MCP Servers:',
281
+ message.mcp_servers.map((s) => `${s.name}: ${s.status}`),
282
+ )
283
+ }
284
+ // Handle other messages...
285
+ }
286
+ ```
287
+
288
+ To find out more about extending Amp with MCP servers, visit the [MCP Configuration](https://ampcode.com/manual#mcp) section of the manual.
289
+
290
+ ### Multi-turn Conversations
291
+
292
+ Build streaming conversations using async generators:
293
+
294
+ ```typescript
295
+ import { execute, createUserMessage } from '@sourcegraph/amp-sdk'
296
+
297
+ async function* generateMessages() {
298
+ yield createUserMessage('Start analyzing the codebase')
299
+
300
+ // Wait for some condition or user input
301
+ await new Promise((resolve) => setTimeout(resolve, 1000))
302
+
303
+ yield createUserMessage('Now focus on the authentication module')
304
+ }
305
+
306
+ for await (const message of execute({
307
+ prompt: generateMessages(),
308
+ })) {
309
+ if (message.type === 'result') {
310
+ console.log(message.result)
311
+ }
312
+ }
313
+ ```
314
+
315
+ ### Settings File Configuration
316
+
317
+ Configure Amp's behavior with a settings file, like the `settings.json`. You can provide Amp with a custom settings file you have saved in your project:
318
+
319
+ ```typescript
320
+ import { execute } from '@sourcegraph/amp-sdk'
321
+
322
+ // Use a custom settings file
323
+ for await (const message of execute({
324
+ prompt: 'Deploy the application',
325
+ options: {
326
+ settingsFile: './settings.json',
327
+ logLevel: 'debug',
328
+ },
329
+ })) {
330
+ // Handle messages...
331
+ }
332
+ ```
333
+
334
+ Example `settings.json`:
335
+
336
+ ```json
337
+ {
338
+ "amp.mcpServers": {
339
+ "playwright": {
340
+ "command": "npx",
341
+ "args": ["-y", "@playwright/mcp@latest", "--headless", "--isolated"]
342
+ }
343
+ },
344
+ "amp.todos.enabled": false,
345
+ "amp.commands.allowlist": ["npx", "node", "npm"],
346
+ "amp.tools.disable": ["mermaid", "mcp__playwright__browser_resize"]
347
+ }
348
+ ```
349
+
350
+ To find all available settings, see the [Configuration Settings](https://ampcode.com/manual#configuration).
351
+
352
+ ### Custom Tools
353
+
354
+ Extend Amp's capabilities with custom toolbox scripts:
355
+
356
+ ```typescript
357
+ for await (const message of execute({
358
+ prompt: 'Use my custom deployment scripts',
359
+ options: {
360
+ toolbox: '/usr/repository-path/toolbox', // Path to toolbox scripts
361
+ },
362
+ })) {
363
+ // Handle messages...
364
+ }
365
+ ```
366
+
367
+ To find out more about Amp Toolboxes, see the [Toolboxes](https://ampcode.com/manual#toolboxes) section of the Amp documentation.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Amp TypeScript SDK
3
+ *
4
+ * This SDK provides a TypeScript interface to the Amp CLI, allowing you to
5
+ * run Amp programmatically in Node.js applications. It wraps the Amp CLI
6
+ * with the --stream-json flag to provide structured output.
7
+ */
8
+ import { type ExecuteOptions, type StreamMessage, type UserInputMessage } from './types.js';
9
+ /**
10
+ * Execute a command with Amp CLI and return an async iterator of messages
11
+ *
12
+ * @param options Execute configuration including prompt and options
13
+ * @returns Async iterator of stream messages from Amp CLI
14
+ */
15
+ export declare function execute(options: ExecuteOptions): AsyncIterable<StreamMessage>;
16
+ /**
17
+ * Helper function to create streaming input messages
18
+ */
19
+ export declare function createUserMessage(text: string): UserInputMessage;
20
+ export * from './types.js';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAErB,MAAM,YAAY,CAAA;AASnB;;;;;GAKG;AACH,wBAAuB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAAC,aAAa,CAAC,CA0EpF;AAmRD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAQhE;AAMD,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,325 @@
1
+ /**
2
+ * Amp TypeScript SDK
3
+ *
4
+ * This SDK provides a TypeScript interface to the Amp CLI, allowing you to
5
+ * run Amp programmatically in Node.js applications. It wraps the Amp CLI
6
+ * with the --stream-json flag to provide structured output.
7
+ */
8
+ import { spawn } from 'node:child_process';
9
+ import fs from 'node:fs';
10
+ import { createRequire } from 'node:module';
11
+ import path from 'node:path';
12
+ import { createInterface } from 'node:readline';
13
+ import { AmpOptionsSchema, UserInputMessageSchema, } from './types.js';
14
+ // Platform detection
15
+ const isWindows = process.platform === 'win32';
16
+ // ============================================================================
17
+ // Main Execute Function
18
+ // ============================================================================
19
+ /**
20
+ * Execute a command with Amp CLI and return an async iterator of messages
21
+ *
22
+ * @param options Execute configuration including prompt and options
23
+ * @returns Async iterator of stream messages from Amp CLI
24
+ */
25
+ export async function* execute(options) {
26
+ const { prompt, options: ampOptions = {}, signal } = options;
27
+ // Validate options
28
+ const validatedOptions = AmpOptionsSchema.parse(ampOptions);
29
+ // Handle different prompt types
30
+ const isStreamingInput = typeof prompt !== 'string' && Symbol.asyncIterator in prompt;
31
+ // Build CLI arguments
32
+ const args = buildCliArgs(validatedOptions);
33
+ // Add flag for streaming input if needed
34
+ if (isStreamingInput) {
35
+ args.push('--stream-json-input');
36
+ }
37
+ // Log the full CLI command for debugging (only in debug mode)
38
+ if (process.env.AMP_DEBUG || validatedOptions.logLevel === 'debug') {
39
+ const ampCommand = findAmpCommand();
40
+ console.debug(`Executing Amp CLI: ${ampCommand.command} ${[...ampCommand.args, ...args].join(' ')}`);
41
+ }
42
+ // Build environment variables
43
+ const env = buildEnvironmentVariables(validatedOptions);
44
+ // Spawn Amp CLI process
45
+ const ampProcess = spawnAmpCli(args, {
46
+ env,
47
+ cwd: validatedOptions.cwd,
48
+ signal,
49
+ });
50
+ try {
51
+ // Handle input via stdin
52
+ if (isStreamingInput) {
53
+ handleStreamingInput(ampProcess, prompt);
54
+ }
55
+ else if (typeof prompt === 'string' && prompt) {
56
+ handleStringInput(ampProcess, prompt);
57
+ }
58
+ // Process output stream
59
+ yield* processOutputStream(ampProcess.stdout);
60
+ // Wait for process to complete and check exit code
61
+ const { exitCode, stderr, signal: processSignal } = await waitForProcess(ampProcess, signal);
62
+ // Handle exit code properly - null indicates signal termination
63
+ if (exitCode === null) {
64
+ // Process was killed by signal
65
+ if (signal?.aborted) {
66
+ // Expected termination due to AbortController
67
+ throw new Error('Amp CLI process was aborted');
68
+ }
69
+ else if (processSignal) {
70
+ // Killed by system signal
71
+ throw new Error(`Amp CLI process was killed by signal ${processSignal}`);
72
+ }
73
+ else {
74
+ // Unexpected null exit code
75
+ throw new Error('Amp CLI process terminated unexpectedly');
76
+ }
77
+ }
78
+ else if (exitCode !== 0) {
79
+ // Normal exit with error code
80
+ const errorDetails = stderr ? `: ${stderr}` : '';
81
+ throw new Error(`Amp CLI process exited with code ${exitCode}${errorDetails}`);
82
+ }
83
+ }
84
+ catch (error) {
85
+ // Clean up process on error
86
+ if (!ampProcess.killed) {
87
+ ampProcess.kill(isWindows ? 'SIGKILL' : 'SIGTERM');
88
+ }
89
+ throw error;
90
+ }
91
+ }
92
+ // ============================================================================
93
+ // Environment Variable Management
94
+ // ============================================================================
95
+ /**
96
+ * Build environment variables for the Amp CLI process
97
+ * Combines system environment variables with user-provided options
98
+ */
99
+ function buildEnvironmentVariables(options) {
100
+ const env = {
101
+ ...process.env,
102
+ };
103
+ // Set AMP_TOOLBOX if toolbox option is provided
104
+ if (options.toolbox) {
105
+ env.AMP_TOOLBOX = options.toolbox;
106
+ }
107
+ // User-provided env variables override system ones
108
+ if (options.env) {
109
+ Object.assign(env, options.env);
110
+ }
111
+ return env;
112
+ }
113
+ // ============================================================================
114
+ // CLI Process Management
115
+ // ============================================================================
116
+ function spawnAmpCli(args, options) {
117
+ const { env, cwd, signal } = options;
118
+ // Find amp executable
119
+ const ampCommand = findAmpCommand();
120
+ const childProcess = spawn(ampCommand.command, [...ampCommand.args, ...args], {
121
+ cwd: cwd || process.cwd(),
122
+ env: env || process.env,
123
+ stdio: ['pipe', 'pipe', 'pipe'],
124
+ signal,
125
+ });
126
+ // Add error handler immediately to prevent unhandled error events
127
+ childProcess.on('error', () => {
128
+ // Error will be handled by waitForProcess
129
+ });
130
+ return childProcess;
131
+ }
132
+ function findAmpCommand() {
133
+ // Try to find the local CLI (npm already resolved the correct version)
134
+ try {
135
+ const require = createRequire(import.meta.url);
136
+ const pkgJsonPath = require.resolve('@sourcegraph/amp/package.json');
137
+ const pkgJsonRaw = fs.readFileSync(pkgJsonPath, 'utf8');
138
+ const pkgJson = JSON.parse(pkgJsonRaw);
139
+ if (pkgJson.bin?.amp) {
140
+ const binPath = path.join(path.dirname(pkgJsonPath), pkgJson.bin.amp);
141
+ return {
142
+ command: 'node',
143
+ args: [binPath],
144
+ };
145
+ }
146
+ throw new Error('Local @sourcegraph/amp package found but no bin entry for Amp CLI');
147
+ }
148
+ catch (error) {
149
+ if (error instanceof Error && error.message.includes('Local @sourcegraph/amp')) {
150
+ throw error;
151
+ }
152
+ throw new Error('Could not find local @sourcegraph/amp package. Make sure it is installed.');
153
+ }
154
+ }
155
+ function buildCliArgs(options) {
156
+ const args = [];
157
+ // Handle continue option first as it changes the base command structure
158
+ if (typeof options.continue === 'string') {
159
+ args.push('threads', 'continue', options.continue);
160
+ }
161
+ else if (options.continue === true) {
162
+ args.push('threads', 'continue');
163
+ }
164
+ // Add execute and stream-json flags
165
+ args.push('--execute', '--stream-json');
166
+ // Optional flags
167
+ if (options.dangerouslyAllowAll) {
168
+ args.push('--dangerously-allow-all');
169
+ }
170
+ if (options.visibility) {
171
+ args.push('--visibility', options.visibility);
172
+ }
173
+ if (options.settingsFile) {
174
+ args.push('--settings-file', options.settingsFile);
175
+ }
176
+ if (options.logLevel) {
177
+ args.push('--log-level', options.logLevel);
178
+ }
179
+ if (options.logFile) {
180
+ args.push('--log-file', options.logFile);
181
+ }
182
+ if (options.mcpConfig) {
183
+ const mcpConfigValue = typeof options.mcpConfig === 'string'
184
+ ? options.mcpConfig
185
+ : JSON.stringify(options.mcpConfig);
186
+ args.push('--mcp-config', mcpConfigValue);
187
+ }
188
+ return args;
189
+ }
190
+ // ============================================================================
191
+ // Stream Processing
192
+ // ============================================================================
193
+ async function* processOutputStream(stdout) {
194
+ if (!stdout) {
195
+ throw new Error('No stdout stream available from Amp CLI process');
196
+ }
197
+ const readline = createInterface({
198
+ input: stdout,
199
+ crlfDelay: Number.POSITIVE_INFINITY,
200
+ });
201
+ try {
202
+ for await (const line of readline) {
203
+ if (!line.trim())
204
+ continue;
205
+ try {
206
+ const message = JSON.parse(line);
207
+ yield message;
208
+ }
209
+ catch (parseError) {
210
+ throw new Error(`Failed to parse JSON response, raw line: ${line}`);
211
+ }
212
+ }
213
+ }
214
+ finally {
215
+ readline.close();
216
+ }
217
+ }
218
+ async function handleStreamingInput(process, prompt, signal) {
219
+ if (!process.stdin) {
220
+ throw new Error('No stdin stream available for Amp CLI process');
221
+ }
222
+ // Check if already aborted before starting
223
+ signal?.throwIfAborted();
224
+ try {
225
+ for await (const message of prompt) {
226
+ // Check for abort before processing each message
227
+ signal?.throwIfAborted();
228
+ // Validate message format
229
+ const validatedMessage = UserInputMessageSchema.parse(message);
230
+ // Send the complete JSON message
231
+ const jsonMessage = JSON.stringify(validatedMessage) + '\n';
232
+ if (!process.stdin.write(jsonMessage)) {
233
+ // Wait for drain if buffer is full, but allow cancellation during wait
234
+ await new Promise((resolve, reject) => {
235
+ const onAbort = () => reject(signal?.reason || new Error('Aborted'));
236
+ signal?.addEventListener('abort', onAbort, { once: true });
237
+ process.stdin.once('drain', () => {
238
+ // Clean up abort listener when drain completes
239
+ signal?.removeEventListener('abort', onAbort);
240
+ resolve();
241
+ });
242
+ });
243
+ }
244
+ }
245
+ }
246
+ finally {
247
+ // Close stdin to signal end of input
248
+ process.stdin.end();
249
+ }
250
+ }
251
+ function handleStringInput(process, prompt) {
252
+ if (!process.stdin) {
253
+ throw new Error('No stdin stream available for Amp CLI process');
254
+ }
255
+ // Write the prompt to stdin and close it
256
+ process.stdin.write(prompt + '\n');
257
+ process.stdin.end();
258
+ }
259
+ function waitForProcess(process, signal) {
260
+ return new Promise((resolve, reject) => {
261
+ let resolved = false;
262
+ let stderrData = '';
263
+ const cleanup = () => {
264
+ resolved = true;
265
+ };
266
+ // Capture stderr output
267
+ if (process.stderr) {
268
+ process.stderr.on('data', (data) => {
269
+ stderrData += data.toString();
270
+ });
271
+ }
272
+ process.on('exit', (code, processSignal) => {
273
+ if (!resolved) {
274
+ cleanup();
275
+ resolve({ exitCode: code, stderr: stderrData, signal: processSignal });
276
+ }
277
+ });
278
+ process.on('error', (error) => {
279
+ if (!resolved) {
280
+ cleanup();
281
+ reject(error);
282
+ }
283
+ });
284
+ // Handle abort signal
285
+ if (signal?.aborted) {
286
+ if (!resolved) {
287
+ cleanup();
288
+ reject(new Error('Operation was aborted'));
289
+ }
290
+ }
291
+ else if (signal) {
292
+ const abortHandler = () => {
293
+ if (!resolved) {
294
+ cleanup();
295
+ reject(new Error('Operation was aborted'));
296
+ }
297
+ };
298
+ signal.addEventListener('abort', abortHandler);
299
+ // Clean up listener
300
+ process.on('exit', () => {
301
+ signal.removeEventListener('abort', abortHandler);
302
+ });
303
+ }
304
+ });
305
+ }
306
+ // ============================================================================
307
+ // Utility Functions
308
+ // ============================================================================
309
+ /**
310
+ * Helper function to create streaming input messages
311
+ */
312
+ export function createUserMessage(text) {
313
+ return {
314
+ type: 'user',
315
+ message: {
316
+ role: 'user',
317
+ content: [{ type: 'text', text }],
318
+ },
319
+ };
320
+ }
321
+ // ============================================================================
322
+ // Re-export types for convenience
323
+ // ============================================================================
324
+ export * from './types.js';
325
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,aAAa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AAQ,EAAE,CAAC;oBACf,OAAO,EAAE,CAAA;oBACT,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAA;gBAC3C,CAAC;YACF,CAAC,CAAA;YACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;YAE9C,oBAAoB;YACpB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;gBACvB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;YAClD,CAAC,CAAC,CAAA;QACH,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC7C,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE;YACR,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SACjC;KACD,CAAA;AACF,CAAC;AAED,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAE/E,cAAc,YAAY,CAAA"}
@@ -0,0 +1,249 @@
1
+ /**
2
+ * TypeScript SDK types for Amp CLI
3
+ *
4
+ * These types are compatible with the Amp CLI --stream-json output.
5
+ */
6
+ import { z } from 'zod';
7
+ /** Text content block containing plain text */
8
+ export interface TextContent {
9
+ type: 'text';
10
+ text: string;
11
+ }
12
+ /** Tool use content block representing a tool call request */
13
+ export interface ToolUseContent {
14
+ type: 'tool_use';
15
+ id: string;
16
+ name: string;
17
+ input: Record<string, unknown>;
18
+ }
19
+ /** Tool result content block containing the result of a tool execution */
20
+ export interface ToolResultContent {
21
+ type: 'tool_result';
22
+ tool_use_id: string;
23
+ content: string;
24
+ is_error: boolean;
25
+ }
26
+ /** Token usage information for API calls */
27
+ export interface Usage {
28
+ input_tokens: number;
29
+ cache_creation_input_tokens?: number;
30
+ cache_read_input_tokens?: number;
31
+ output_tokens: number;
32
+ service_tier?: string;
33
+ }
34
+ /** Base interface for all message types */
35
+ interface BaseMessage {
36
+ type: 'system' | 'assistant' | 'user' | 'result';
37
+ session_id: string;
38
+ }
39
+ /** System initialization message containing session info and available tools */
40
+ export interface SystemMessage extends BaseMessage {
41
+ type: 'system';
42
+ subtype: 'init';
43
+ cwd: string;
44
+ tools: string[];
45
+ mcp_servers: {
46
+ name: string;
47
+ status: 'connected' | 'connecting' | 'connection-failed' | 'disabled';
48
+ }[];
49
+ }
50
+ /** AI assistant response message with text and tool usage */
51
+ export interface AssistantMessage extends BaseMessage {
52
+ type: 'assistant';
53
+ message: {
54
+ id: string;
55
+ type: 'message';
56
+ role: 'assistant';
57
+ model: string;
58
+ content: Array<TextContent | ToolUseContent>;
59
+ stop_reason: 'end_turn' | 'tool_use' | 'max_tokens' | null;
60
+ stop_sequence: string | null;
61
+ usage?: Usage;
62
+ };
63
+ parent_tool_use_id: string | null;
64
+ }
65
+ /** User input message containing text or tool results */
66
+ export interface UserMessage extends BaseMessage {
67
+ type: 'user';
68
+ message: {
69
+ role: 'user';
70
+ content: Array<TextContent | ToolResultContent>;
71
+ };
72
+ parent_tool_use_id: string | null;
73
+ }
74
+ /** Base interface for result messages */
75
+ interface BaseResultMessage extends BaseMessage {
76
+ type: 'result';
77
+ duration_ms: number;
78
+ num_turns: number;
79
+ usage?: Usage;
80
+ permission_denials?: string[];
81
+ }
82
+ /** Successful execution result message */
83
+ export interface ResultMessage extends BaseResultMessage {
84
+ subtype: 'success';
85
+ is_error: false;
86
+ result: string;
87
+ }
88
+ /** Error result message indicating execution failure */
89
+ export interface ErrorResultMessage extends BaseResultMessage {
90
+ subtype: 'error_during_execution' | 'error_max_turns';
91
+ is_error: true;
92
+ error: string;
93
+ }
94
+ export type StreamMessage = SystemMessage | AssistantMessage | UserMessage | ResultMessage | ErrorResultMessage;
95
+ export declare const UserInputMessageSchema: z.ZodObject<{
96
+ type: z.ZodLiteral<"user">;
97
+ message: z.ZodObject<{
98
+ role: z.ZodLiteral<"user">;
99
+ content: z.ZodArray<z.ZodObject<{
100
+ type: z.ZodLiteral<"text">;
101
+ text: z.ZodString;
102
+ }, "strip", z.ZodTypeAny, {
103
+ text: string;
104
+ type: "text";
105
+ }, {
106
+ text: string;
107
+ type: "text";
108
+ }>, "many">;
109
+ }, "strip", z.ZodTypeAny, {
110
+ role: "user";
111
+ content: {
112
+ text: string;
113
+ type: "text";
114
+ }[];
115
+ }, {
116
+ role: "user";
117
+ content: {
118
+ text: string;
119
+ type: "text";
120
+ }[];
121
+ }>;
122
+ }, "strip", z.ZodTypeAny, {
123
+ message: {
124
+ role: "user";
125
+ content: {
126
+ text: string;
127
+ type: "text";
128
+ }[];
129
+ };
130
+ type: "user";
131
+ }, {
132
+ message: {
133
+ role: "user";
134
+ content: {
135
+ text: string;
136
+ type: "text";
137
+ }[];
138
+ };
139
+ type: "user";
140
+ }>;
141
+ export declare const MCPServerSchema: z.ZodObject<{
142
+ command: z.ZodString;
143
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
144
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
145
+ disabled: z.ZodOptional<z.ZodBoolean>;
146
+ }, "strip", z.ZodTypeAny, {
147
+ command: string;
148
+ disabled?: boolean | undefined;
149
+ args?: string[] | undefined;
150
+ env?: Record<string, string> | undefined;
151
+ }, {
152
+ command: string;
153
+ disabled?: boolean | undefined;
154
+ args?: string[] | undefined;
155
+ env?: Record<string, string> | undefined;
156
+ }>;
157
+ export declare const MCPConfigSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
158
+ command: z.ZodString;
159
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
160
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
161
+ disabled: z.ZodOptional<z.ZodBoolean>;
162
+ }, "strip", z.ZodTypeAny, {
163
+ command: string;
164
+ disabled?: boolean | undefined;
165
+ args?: string[] | undefined;
166
+ env?: Record<string, string> | undefined;
167
+ }, {
168
+ command: string;
169
+ disabled?: boolean | undefined;
170
+ args?: string[] | undefined;
171
+ env?: Record<string, string> | undefined;
172
+ }>>;
173
+ export declare const AmpOptionsSchema: z.ZodObject<{
174
+ cwd: z.ZodOptional<z.ZodString>;
175
+ dangerouslyAllowAll: z.ZodOptional<z.ZodBoolean>;
176
+ visibility: z.ZodOptional<z.ZodDefault<z.ZodEnum<["private", "public", "workspace", "group"]>>>;
177
+ settingsFile: z.ZodOptional<z.ZodString>;
178
+ logLevel: z.ZodOptional<z.ZodEnum<["debug", "info", "warn", "error", "audit"]>>;
179
+ logFile: z.ZodOptional<z.ZodString>;
180
+ mcpConfig: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
181
+ command: z.ZodString;
182
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
183
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
184
+ disabled: z.ZodOptional<z.ZodBoolean>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ command: string;
187
+ disabled?: boolean | undefined;
188
+ args?: string[] | undefined;
189
+ env?: Record<string, string> | undefined;
190
+ }, {
191
+ command: string;
192
+ disabled?: boolean | undefined;
193
+ args?: string[] | undefined;
194
+ env?: Record<string, string> | undefined;
195
+ }>>]>>;
196
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
197
+ continue: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
198
+ toolbox: z.ZodOptional<z.ZodString>;
199
+ }, "strict", z.ZodTypeAny, {
200
+ env?: Record<string, string> | undefined;
201
+ cwd?: string | undefined;
202
+ dangerouslyAllowAll?: boolean | undefined;
203
+ visibility?: "private" | "public" | "workspace" | "group" | undefined;
204
+ settingsFile?: string | undefined;
205
+ logLevel?: "debug" | "info" | "warn" | "error" | "audit" | undefined;
206
+ logFile?: string | undefined;
207
+ mcpConfig?: string | Record<string, {
208
+ command: string;
209
+ disabled?: boolean | undefined;
210
+ args?: string[] | undefined;
211
+ env?: Record<string, string> | undefined;
212
+ }> | undefined;
213
+ continue?: string | boolean | undefined;
214
+ toolbox?: string | undefined;
215
+ }, {
216
+ env?: Record<string, string> | undefined;
217
+ cwd?: string | undefined;
218
+ dangerouslyAllowAll?: boolean | undefined;
219
+ visibility?: "private" | "public" | "workspace" | "group" | undefined;
220
+ settingsFile?: string | undefined;
221
+ logLevel?: "debug" | "info" | "warn" | "error" | "audit" | undefined;
222
+ logFile?: string | undefined;
223
+ mcpConfig?: string | Record<string, {
224
+ command: string;
225
+ disabled?: boolean | undefined;
226
+ args?: string[] | undefined;
227
+ env?: Record<string, string> | undefined;
228
+ }> | undefined;
229
+ continue?: string | boolean | undefined;
230
+ toolbox?: string | undefined;
231
+ }>;
232
+ /** User input message for streaming conversations */
233
+ export type UserInputMessage = z.infer<typeof UserInputMessageSchema>;
234
+ /** MCP server configuration */
235
+ export type MCPServer = z.infer<typeof MCPServerSchema>;
236
+ /** MCP configuration object */
237
+ export type MCPConfig = z.infer<typeof MCPConfigSchema>;
238
+ /** Configuration options for Amp CLI execution */
239
+ export type AmpOptions = z.infer<typeof AmpOptionsSchema>;
240
+ /** Input type for prompts - either a string or streaming user messages */
241
+ type PromptInput = string | AsyncIterable<UserInputMessage>;
242
+ /** Options for executing Amp CLI commands */
243
+ export interface ExecuteOptions {
244
+ prompt: PromptInput;
245
+ options?: AmpOptions;
246
+ signal?: AbortSignal;
247
+ }
248
+ export {};
249
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,+CAA+C;AAC/C,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWjC,CAAA;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAQ1B,CAAA;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;GAEgC,CAAA;AAE5D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCnB,CAAA;AAMV,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAErE,+BAA+B;AAC/B,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,+BAA+B;AAC/B,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,kDAAkD;AAClD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAMzD,0EAA0E;AAC1E,KAAK,WAAW,GAAG,MAAM,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAA;AAE3D,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,WAAW,CAAA;IACnB,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,MAAM,CAAC,EAAE,WAAW,CAAA;CACpB"}
package/dist/types.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * TypeScript SDK types for Amp CLI
3
+ *
4
+ * These types are compatible with the Amp CLI --stream-json output.
5
+ */
6
+ import { z } from 'zod';
7
+ // ============================================================================
8
+ // Validation Schemas (defined to derive interfaces from)
9
+ // ============================================================================
10
+ export const UserInputMessageSchema = z.object({
11
+ type: z.literal('user'),
12
+ message: z.object({
13
+ role: z.literal('user'),
14
+ content: z.array(z.object({
15
+ type: z.literal('text'),
16
+ text: z.string(),
17
+ })),
18
+ }),
19
+ });
20
+ export const MCPServerSchema = z.object({
21
+ command: z.string().describe('Command to run the MCP server'),
22
+ args: z.array(z.string()).describe('Arguments for the MCP server command').optional(),
23
+ env: z
24
+ .record(z.string(), z.string())
25
+ .describe('Environment variables for the server')
26
+ .optional(),
27
+ disabled: z.boolean().describe('Whether the server is disabled').optional(),
28
+ });
29
+ export const MCPConfigSchema = z
30
+ .record(z.string(), MCPServerSchema)
31
+ .describe('MCP server configurations keyed by server name');
32
+ export const AmpOptionsSchema = z
33
+ .object({
34
+ cwd: z.string().describe('Current working directory').optional(),
35
+ dangerouslyAllowAll: z
36
+ .boolean()
37
+ .describe('Allow all tool usage without asking for permission')
38
+ .optional(),
39
+ visibility: z
40
+ .enum(['private', 'public', 'workspace', 'group'])
41
+ .describe('Visibility level for new threads')
42
+ .default('workspace')
43
+ .optional(),
44
+ settingsFile: z.string().describe('Settings file path').optional(),
45
+ logLevel: z
46
+ .enum(['debug', 'info', 'warn', 'error', 'audit'])
47
+ .describe('Log level')
48
+ .optional(),
49
+ logFile: z.string().describe('Log file path').optional(),
50
+ mcpConfig: z
51
+ .union([z.string(), MCPConfigSchema])
52
+ .describe('MCP server configuration as JSON string, path to JSON file, or config object')
53
+ .optional(),
54
+ env: z
55
+ .record(z.string(), z.string())
56
+ .describe('Additional environment variables')
57
+ .optional(),
58
+ continue: z
59
+ .union([z.boolean(), z.string()])
60
+ .describe('Continue the most recent thread (true) or a specific thread by ID (string)')
61
+ .optional(),
62
+ toolbox: z.string().describe('Folder path with toolbox scripts').optional(),
63
+ })
64
+ .strict();
65
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAuHvB,+EAA+E;AAC/E,yDAAyD;AACzD,+EAA+E;AAE/E,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,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,59 @@
1
+ {
2
+ "name": "@sourcegraph/amp-sdk",
3
+ "version": "0.1.0-3e67faf1b0e66cf0d3bf2985979efbcac0554a79",
4
+ "description": "TypeScript SDK for Amp CLI - Build custom AI agents with Amp's capabilities",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "pnpm exec tsc -b",
20
+ "dev": "pnpm exec tsc -b --watch",
21
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
22
+ "examples:basic": "pnpm run build && bun run examples/basic-usage.ts",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "prepack": "bun run scripts/pre-pack.ts",
26
+ "postpack": "bun run scripts/post-pack.ts"
27
+ },
28
+ "keywords": [
29
+ "ai",
30
+ "agent",
31
+ "amp",
32
+ "sourcegraph",
33
+ "cli",
34
+ "typescript",
35
+ "sdk",
36
+ "automation"
37
+ ],
38
+ "author": {
39
+ "name": "The Amp Team at Sourcegraph",
40
+ "email": "amp-devs@sourcegraph.com"
41
+ },
42
+ "license": "SEE LICENSE IN LICENSE.md",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/sourcegraph/amp.git",
46
+ "directory": "sdk/typescript"
47
+ },
48
+ "homepage": "https://ampcode.com/",
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "engines": {
53
+ "node": ">=18"
54
+ },
55
+ "dependencies": {
56
+ "@sourcegraph/amp": "0.0.1759502872-g3e67fa",
57
+ "zod": "^3.23.8"
58
+ }
59
+ }