@augmentcode/auggie-sdk 0.1.0
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 +395 -0
- package/dist/auggie/sdk-acp-client.d.ts +76 -0
- package/dist/auggie/sdk-acp-client.d.ts.map +1 -0
- package/dist/auggie/sdk-acp-client.js +306 -0
- package/dist/auggie/sdk-acp-client.js.map +1 -0
- package/dist/auggie/sdk-mcp-server.d.ts +12 -0
- package/dist/auggie/sdk-mcp-server.d.ts.map +1 -0
- package/dist/auggie/sdk-mcp-server.js +124 -0
- package/dist/auggie/sdk-mcp-server.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
# Auggie SDK
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for connecting to Auggie as an ACP (Agent Client Protocol) server with support for custom tools via MCP (Model Context Protocol).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This SDK provides a simple way to:
|
|
8
|
+
1. Launch Auggie in ACP mode
|
|
9
|
+
2. Establish a bidirectional communication channel
|
|
10
|
+
3. Initialize sessions with custom tools
|
|
11
|
+
4. Send prompts and receive responses
|
|
12
|
+
5. Handle session updates and permission requests
|
|
13
|
+
6. Integrate custom tools using the AI SDK tool format
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### From tarball (recommended for distribution)
|
|
18
|
+
```bash
|
|
19
|
+
npm install /path/to/augmentcode-auggie-sdk-0.1.0.tgz
|
|
20
|
+
# or
|
|
21
|
+
pnpm add /path/to/augmentcode-auggie-sdk-0.1.0.tgz
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### From local directory (for development)
|
|
25
|
+
```bash
|
|
26
|
+
npm install /path/to/auggie-sdk
|
|
27
|
+
# or
|
|
28
|
+
pnpm add /path/to/auggie-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Basic Example
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { Auggie } from "@augmentcode/auggie-sdk";
|
|
37
|
+
|
|
38
|
+
async function main() {
|
|
39
|
+
// Create and initialize Auggie (automatically connects and creates a session)
|
|
40
|
+
const client = await Auggie.create({
|
|
41
|
+
model: "sonnet4.5", // Optional: haiku4.5, opus4.1, sonnet4.5, sonnet4
|
|
42
|
+
debug: false, // Optional: enable debug logging
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
// Listen for session updates
|
|
47
|
+
client.onSessionUpdate((update) => {
|
|
48
|
+
console.log("Received update:", update);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Send a prompt
|
|
52
|
+
const response = await client.sendPrompt("What files are in the current directory?");
|
|
53
|
+
console.log("Response:", response);
|
|
54
|
+
|
|
55
|
+
// Close the connection
|
|
56
|
+
await client.close();
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error("Error:", error);
|
|
59
|
+
await client.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
main();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Using Custom Tools
|
|
67
|
+
|
|
68
|
+
You can provide custom tools to Auggie using the AI SDK tool format:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { Auggie } from "@augmentcode/auggie-sdk";
|
|
72
|
+
import { tool } from "ai";
|
|
73
|
+
import z from "zod";
|
|
74
|
+
|
|
75
|
+
const weatherTool = tool({
|
|
76
|
+
name: "get_weather",
|
|
77
|
+
description: "Get the weather in a location",
|
|
78
|
+
inputSchema: z.object({
|
|
79
|
+
location: z.string().describe("The location to get the weather for"),
|
|
80
|
+
}),
|
|
81
|
+
execute: async ({ location }) => {
|
|
82
|
+
// Your tool implementation
|
|
83
|
+
return `The weather in ${location} is sunny.`;
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
async function main() {
|
|
88
|
+
// Pass tools when creating the instance
|
|
89
|
+
const client = await Auggie.create({
|
|
90
|
+
model: "sonnet4.5",
|
|
91
|
+
toolsMap: { weather_tool: weatherTool }
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const response = await client.sendPrompt("What's the weather in San Francisco?");
|
|
96
|
+
console.log(response);
|
|
97
|
+
|
|
98
|
+
await client.close();
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error("Error:", error);
|
|
101
|
+
await client.close();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
main();
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Getting Only the Final Response
|
|
109
|
+
|
|
110
|
+
When the agent uses tools (like file operations, web searches, etc.), you can choose to get only the final answer after all tool executions complete:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Get all agent responses (default behavior)
|
|
114
|
+
const fullResponse = await client.sendPrompt("List all TypeScript files in this project");
|
|
115
|
+
|
|
116
|
+
// Get only the final response after tool calls
|
|
117
|
+
const finalAnswer = await client.sendPrompt(
|
|
118
|
+
"List all TypeScript files in this project",
|
|
119
|
+
{ isAnswerOnly: true }
|
|
120
|
+
);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This is useful when you want to:
|
|
124
|
+
- Display only the final answer to users, hiding intermediate thinking
|
|
125
|
+
- Process only the conclusive response in automated workflows
|
|
126
|
+
- Reduce token usage by ignoring intermediate agent messages
|
|
127
|
+
|
|
128
|
+
### Streaming Session Updates
|
|
129
|
+
|
|
130
|
+
You can listen to real-time updates from the agent:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
client.onSessionUpdate((event) => {
|
|
134
|
+
switch (event.update.sessionUpdate) {
|
|
135
|
+
case "agent_message_chunk":
|
|
136
|
+
if (event.update.content.type === "text") {
|
|
137
|
+
process.stdout.write(event.update.content.text);
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case "tool_call":
|
|
141
|
+
console.log("Tool called:", event.update.title);
|
|
142
|
+
console.log("Input:", event.update.rawInput);
|
|
143
|
+
break;
|
|
144
|
+
case "tool_call_update":
|
|
145
|
+
console.log("Tool output:", event.update.rawOutput);
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Running the Examples
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Run the dev example with streaming output
|
|
155
|
+
npm run dev "What's the weather in Tokyo?"
|
|
156
|
+
|
|
157
|
+
# Run the silent example (no streaming)
|
|
158
|
+
npm run silent "What's the weather in Paris?"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Custom Auggie Path and Workspace
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const client = await Auggie.create({
|
|
165
|
+
auggiePath: "/path/to/auggie",
|
|
166
|
+
workspaceRoot: "/path/to/workspace",
|
|
167
|
+
model: "sonnet4.5",
|
|
168
|
+
debug: true,
|
|
169
|
+
allowIndexing: true,
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## API Reference
|
|
174
|
+
|
|
175
|
+
### `Auggie`
|
|
176
|
+
|
|
177
|
+
#### Static Factory Method
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
static async create(options?: AuggieOptions): Promise<Auggie>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Creates a new Auggie instance and automatically connects and initializes a session.
|
|
184
|
+
|
|
185
|
+
**Options:**
|
|
186
|
+
- `auggiePath?: string` - Path to the Auggie executable (default: "auggie")
|
|
187
|
+
- `workspaceRoot?: string` - Working directory for the Auggie process (default: `process.cwd()`)
|
|
188
|
+
- `debug?: boolean` - Enable debug logging (default: false)
|
|
189
|
+
- `model?: "haiku4.5" | "opus4.1" | "sonnet4.5" | "sonnet4"` - Model to use (default: "haiku4.5")
|
|
190
|
+
- `allowIndexing?: boolean` - Allow codebase indexing (default: true)
|
|
191
|
+
- `toolsMap?: Record<string, Tool>` - Custom tools to provide to Auggie (optional)
|
|
192
|
+
|
|
193
|
+
#### Methods
|
|
194
|
+
|
|
195
|
+
##### `connect(): Promise<void>`
|
|
196
|
+
|
|
197
|
+
Launches Auggie in ACP mode and establishes a connection. (Called automatically by `create()`)
|
|
198
|
+
|
|
199
|
+
##### `createSession(toolsMap?: Record<string, Tool>): Promise<string>`
|
|
200
|
+
|
|
201
|
+
Creates a new session. (Called automatically by `create()`)
|
|
202
|
+
|
|
203
|
+
Creates a new conversation session with the agent.
|
|
204
|
+
|
|
205
|
+
- `toolsMap`: Optional map of tool names to AI SDK Tool objects
|
|
206
|
+
- Returns: Session ID
|
|
207
|
+
|
|
208
|
+
When tools are provided, an MCP server is automatically started and connected to the session.
|
|
209
|
+
|
|
210
|
+
##### `sendPrompt(prompt: string, options?: { isAnswerOnly?: boolean }): Promise<string>`
|
|
211
|
+
|
|
212
|
+
Sends a prompt to the agent and waits for completion.
|
|
213
|
+
|
|
214
|
+
- `prompt`: The text prompt to send
|
|
215
|
+
- `options.isAnswerOnly`: Optional boolean (default: `false`). When set to `true`, returns only the final response after all tool calls complete. When `false` or omitted, returns all agent message chunks including any intermediate responses.
|
|
216
|
+
- Returns: The accumulated text response from the agent
|
|
217
|
+
|
|
218
|
+
##### `onSessionUpdate(callback: (update: SessionNotification) => void): void`
|
|
219
|
+
|
|
220
|
+
Registers a callback to receive session updates from the agent.
|
|
221
|
+
|
|
222
|
+
- `callback`: Function to handle session updates
|
|
223
|
+
|
|
224
|
+
##### `cancel(): Promise<void>`
|
|
225
|
+
|
|
226
|
+
Cancels the current ongoing request.
|
|
227
|
+
|
|
228
|
+
##### `close(): Promise<void>`
|
|
229
|
+
|
|
230
|
+
Closes the connection, stops the MCP server (if running), and terminates the Auggie process.
|
|
231
|
+
|
|
232
|
+
## How It Works
|
|
233
|
+
|
|
234
|
+
### ACP Protocol
|
|
235
|
+
|
|
236
|
+
The Agent Client Protocol (ACP) is a standardized protocol for communication between code editors and AI coding agents. This SDK implements the client side of the protocol.
|
|
237
|
+
|
|
238
|
+
### MCP Integration
|
|
239
|
+
|
|
240
|
+
When you provide custom tools, the SDK automatically:
|
|
241
|
+
1. Starts a local MCP (Model Context Protocol) server
|
|
242
|
+
2. Wraps your AI SDK tools to work with Mastra's MCP implementation
|
|
243
|
+
3. Registers the MCP server with the Auggie session
|
|
244
|
+
4. Handles tool execution requests from Auggie
|
|
245
|
+
5. Cleans up the MCP server when the session closes
|
|
246
|
+
|
|
247
|
+
### Connection Flow
|
|
248
|
+
|
|
249
|
+
1. **Launch**: Spawns Auggie with the `--acp` flag and optional parameters
|
|
250
|
+
2. **Streams**: Creates bidirectional streams using stdio
|
|
251
|
+
3. **Initialize**: Negotiates protocol version and capabilities
|
|
252
|
+
4. **MCP Setup**: If tools are provided, starts an MCP server on a free port
|
|
253
|
+
5. **Session**: Creates a conversation session with MCP server configuration
|
|
254
|
+
6. **Prompt**: Sends prompts and receives responses
|
|
255
|
+
7. **Updates**: Receives real-time updates via callbacks
|
|
256
|
+
8. **Cleanup**: Closes connections and terminates processes
|
|
257
|
+
|
|
258
|
+
### Client Implementation
|
|
259
|
+
|
|
260
|
+
The SDK implements the `Client` interface required by ACP:
|
|
261
|
+
|
|
262
|
+
- `sessionUpdate`: Handles real-time updates from the agent
|
|
263
|
+
- `requestPermission`: Handles permission requests (auto-selects first option)
|
|
264
|
+
|
|
265
|
+
## Examples
|
|
266
|
+
|
|
267
|
+
### Complete Example with Tools and Streaming
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
import { Auggie } from "@augmentcode/auggie-sdk";
|
|
271
|
+
import { tool } from "ai";
|
|
272
|
+
import z from "zod";
|
|
273
|
+
|
|
274
|
+
const weatherTool = tool({
|
|
275
|
+
name: "get_weather",
|
|
276
|
+
description: "Get the weather in a location",
|
|
277
|
+
inputSchema: z.object({
|
|
278
|
+
location: z.string().describe("The location to get the weather for"),
|
|
279
|
+
}),
|
|
280
|
+
execute: async ({ location }) => {
|
|
281
|
+
console.log(`Weather tool called for: ${location}`);
|
|
282
|
+
return `The weather in ${location} is sunny.`;
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
async function main() {
|
|
287
|
+
const client = await Auggie.create({
|
|
288
|
+
model: "sonnet4.5",
|
|
289
|
+
debug: true,
|
|
290
|
+
toolsMap: { weather_tool: weatherTool }
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
try {
|
|
294
|
+
// Stream updates in real-time
|
|
295
|
+
client.onSessionUpdate((event) => {
|
|
296
|
+
switch (event.update.sessionUpdate) {
|
|
297
|
+
case "agent_message_chunk":
|
|
298
|
+
if (event.update.content.type === "text") {
|
|
299
|
+
process.stdout.write(event.update.content.text);
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
case "tool_call":
|
|
303
|
+
console.log(`\nTool: ${event.update.title}`);
|
|
304
|
+
console.log("Input:", event.update.rawInput);
|
|
305
|
+
break;
|
|
306
|
+
case "tool_call_update":
|
|
307
|
+
console.log("Output:", event.update.rawOutput);
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
const response = await client.sendPrompt(
|
|
313
|
+
"What's the weather in Tokyo?",
|
|
314
|
+
{ isAnswerOnly: true }
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
console.log("\nFinal answer:", response);
|
|
318
|
+
} catch (error) {
|
|
319
|
+
console.error("Error:", error);
|
|
320
|
+
} finally {
|
|
321
|
+
await client.close();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
main();
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Error Handling
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
try {
|
|
332
|
+
const client = await Auggie.create();
|
|
333
|
+
await client.sendPrompt("Hello!");
|
|
334
|
+
await client.close();
|
|
335
|
+
} catch (error) {
|
|
336
|
+
if (error instanceof Error) {
|
|
337
|
+
console.error("Error:", error.message);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Requirements
|
|
343
|
+
|
|
344
|
+
- Node.js 18+
|
|
345
|
+
- Auggie CLI installed and accessible in PATH (or provide custom path)
|
|
346
|
+
- Auggie must be authenticated (`auggie login`)
|
|
347
|
+
|
|
348
|
+
## Building the Package
|
|
349
|
+
|
|
350
|
+
To build the TypeScript SDK:
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
npm run build
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
This compiles the TypeScript source to JavaScript in the `dist/` directory with:
|
|
357
|
+
- ES2020 module format
|
|
358
|
+
- Type declaration files (`.d.ts`)
|
|
359
|
+
- Source maps for debugging
|
|
360
|
+
|
|
361
|
+
To create a distributable tarball:
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
npm pack
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
This creates `augmentcode-auggie-sdk-0.1.0.tgz` which can be shared and installed.
|
|
368
|
+
|
|
369
|
+
## Launching Auggie as ACP Server
|
|
370
|
+
|
|
371
|
+
To launch Auggie in ACP mode manually:
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
auggie --acp
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
This starts Auggie in ACP server mode, communicating via stdio using newline-delimited JSON (ndjson).
|
|
378
|
+
|
|
379
|
+
### Available CLI Options
|
|
380
|
+
|
|
381
|
+
- `--acp`: Enable ACP mode
|
|
382
|
+
- `--model <model>`: Specify model (haiku4.5, opus4.1, sonnet4.5, sonnet4)
|
|
383
|
+
- `--workspace-root <path>`: Set workspace directory
|
|
384
|
+
- `--allow-indexing`: Enable codebase indexing
|
|
385
|
+
|
|
386
|
+
## References
|
|
387
|
+
|
|
388
|
+
- [Agent Client Protocol Documentation](https://agentclientprotocol.com/)
|
|
389
|
+
- [ACP TypeScript SDK](https://github.com/agentclientprotocol/typescript-sdk)
|
|
390
|
+
- [AI SDK Documentation](https://sdk.vercel.ai/docs)
|
|
391
|
+
- [Mastra MCP Documentation](https://mastra.ai/docs/mcp)
|
|
392
|
+
|
|
393
|
+
## License
|
|
394
|
+
|
|
395
|
+
See the main repository license.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as acp from "@agentclientprotocol/sdk";
|
|
2
|
+
import { type Tool } from "ai";
|
|
3
|
+
type models = "haiku4.5" | "opus4.1" | "sonnet4.5" | "sonnet4";
|
|
4
|
+
type AuggieOptions = {
|
|
5
|
+
auggiePath?: string;
|
|
6
|
+
workspaceRoot?: string;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
model?: models;
|
|
9
|
+
allowIndexing?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* ACP Client for connecting to Auggie as an ACP server
|
|
13
|
+
*
|
|
14
|
+
* This client demonstrates how to:
|
|
15
|
+
* 1. Launch Auggie in ACP mode
|
|
16
|
+
* 2. Establish a bidirectional communication channel
|
|
17
|
+
* 3. Initialize a session
|
|
18
|
+
* 4. Send prompts and receive responses
|
|
19
|
+
*/
|
|
20
|
+
declare class Auggie {
|
|
21
|
+
private connection;
|
|
22
|
+
private sessionId;
|
|
23
|
+
private auggiePath;
|
|
24
|
+
private workspaceRoot;
|
|
25
|
+
private auggieProcess;
|
|
26
|
+
private sessionUpdateCallback;
|
|
27
|
+
private debug;
|
|
28
|
+
private mcpServer;
|
|
29
|
+
private model;
|
|
30
|
+
private allowIndexing;
|
|
31
|
+
constructor({ auggiePath, workspaceRoot, debug, model, allowIndexing }?: AuggieOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Connect to Auggie ACP server
|
|
34
|
+
*/
|
|
35
|
+
connect(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a Client implementation to handle agent requests
|
|
38
|
+
*/
|
|
39
|
+
private createClient;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize the ACP connection
|
|
42
|
+
*/
|
|
43
|
+
private initialize;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new session
|
|
46
|
+
*/
|
|
47
|
+
createSession(toolsMap?: Record<string, Tool>): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Send a prompt to the agent and accumulate the text response
|
|
50
|
+
* @param prompt - The text prompt to send to the agent
|
|
51
|
+
* @param isAnswerOnly - If true, returns only the final response after all tool calls complete.
|
|
52
|
+
* If false or undefined, returns all agent message chunks (default: false)
|
|
53
|
+
* @returns The accumulated text response from the agent
|
|
54
|
+
*/
|
|
55
|
+
sendPrompt(prompt: string, { isAnswerOnly }?: {
|
|
56
|
+
isAnswerOnly?: boolean;
|
|
57
|
+
} | undefined): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Listen for session update events from the agent
|
|
60
|
+
*/
|
|
61
|
+
onSessionUpdate(callback: (update: acp.SessionNotification) => void): void;
|
|
62
|
+
/**
|
|
63
|
+
* Cancel the current request
|
|
64
|
+
*/
|
|
65
|
+
cancel(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Close the connection and kill the Auggie process
|
|
68
|
+
*/
|
|
69
|
+
close(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Kill the Auggie process if it's still running
|
|
72
|
+
*/
|
|
73
|
+
private killProcess;
|
|
74
|
+
}
|
|
75
|
+
export { Auggie };
|
|
76
|
+
//# sourceMappingURL=sdk-acp-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-acp-client.d.ts","sourceRoot":"","sources":["../../src/auggie/sdk-acp-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC;AAG/B,KAAK,MAAM,G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;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAc7B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B5B;;OAEG;IACH,OAAO,CAAC,WAAW;CAOpB;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import * as acp from "@agentclientprotocol/sdk";
|
|
2
|
+
import { spawn, ChildProcess } from "node:child_process";
|
|
3
|
+
import { Readable, Writable } from "node:stream";
|
|
4
|
+
import {} from "ai";
|
|
5
|
+
import { AuggieMCPServer } from "./sdk-mcp-server";
|
|
6
|
+
/**
|
|
7
|
+
* ACP Client for connecting to Auggie as an ACP server
|
|
8
|
+
*
|
|
9
|
+
* This client demonstrates how to:
|
|
10
|
+
* 1. Launch Auggie in ACP mode
|
|
11
|
+
* 2. Establish a bidirectional communication channel
|
|
12
|
+
* 3. Initialize a session
|
|
13
|
+
* 4. Send prompts and receive responses
|
|
14
|
+
*/
|
|
15
|
+
class Auggie {
|
|
16
|
+
constructor({ auggiePath = "auggie", workspaceRoot, debug = false, model = "haiku4.5", allowIndexing = true } = {}) {
|
|
17
|
+
this.connection = null;
|
|
18
|
+
this.sessionId = null;
|
|
19
|
+
this.workspaceRoot = undefined;
|
|
20
|
+
this.auggieProcess = null;
|
|
21
|
+
this.sessionUpdateCallback = null;
|
|
22
|
+
this.mcpServer = null;
|
|
23
|
+
this.auggiePath = auggiePath;
|
|
24
|
+
this.workspaceRoot = workspaceRoot;
|
|
25
|
+
this.debug = debug;
|
|
26
|
+
this.model = model;
|
|
27
|
+
this.allowIndexing = allowIndexing;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Connect to Auggie ACP server
|
|
31
|
+
*/
|
|
32
|
+
async connect() {
|
|
33
|
+
const args = ["--acp"];
|
|
34
|
+
if (this.model) {
|
|
35
|
+
args.push("--model", this.model);
|
|
36
|
+
}
|
|
37
|
+
if (this.allowIndexing) {
|
|
38
|
+
args.push("--allow-indexing");
|
|
39
|
+
}
|
|
40
|
+
if (this.workspaceRoot) {
|
|
41
|
+
args.push("--workspace-root", this.workspaceRoot);
|
|
42
|
+
}
|
|
43
|
+
// Parse auggiePath to handle cases where it includes arguments (e.g., "node /path/to/file.js")
|
|
44
|
+
const pathParts = this.auggiePath.trim().split(/\s+/);
|
|
45
|
+
if (pathParts.length === 0 || !pathParts[0]) {
|
|
46
|
+
throw new Error("Invalid auggiePath: cannot be empty");
|
|
47
|
+
}
|
|
48
|
+
const command = pathParts[0];
|
|
49
|
+
const commandArgs = [...pathParts.slice(1), ...args];
|
|
50
|
+
this.auggieProcess = spawn(command, commandArgs, {
|
|
51
|
+
stdio: ["pipe", "pipe", "inherit"],
|
|
52
|
+
});
|
|
53
|
+
// Handle process errors
|
|
54
|
+
this.auggieProcess.on("error", (error) => {
|
|
55
|
+
console.error("Failed to start Auggie process:", error);
|
|
56
|
+
throw error;
|
|
57
|
+
});
|
|
58
|
+
this.auggieProcess.on("exit", (code, signal) => {
|
|
59
|
+
if (this.debug)
|
|
60
|
+
console.log(`Auggie process exited with code ${code} and signal ${signal}`);
|
|
61
|
+
});
|
|
62
|
+
// Create streams for ACP communication
|
|
63
|
+
// Note: Auggie writes to stdout and reads from stdin
|
|
64
|
+
const input = Readable.toWeb(this.auggieProcess.stdout);
|
|
65
|
+
const output = Writable.toWeb(this.auggieProcess.stdin);
|
|
66
|
+
// Create ndjson stream for ACP protocol
|
|
67
|
+
const stream = acp.ndJsonStream(output, input);
|
|
68
|
+
// Create client-side connection with a Client implementation
|
|
69
|
+
this.connection = new acp.ClientSideConnection((agent) => this.createClient(agent), stream);
|
|
70
|
+
if (this.debug) {
|
|
71
|
+
console.log("Connected to Auggie ACP server");
|
|
72
|
+
}
|
|
73
|
+
// Initialize the connection
|
|
74
|
+
await this.initialize();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a Client implementation to handle agent requests
|
|
78
|
+
*/
|
|
79
|
+
createClient(_agent) {
|
|
80
|
+
return {
|
|
81
|
+
// Handle session updates from the agent
|
|
82
|
+
sessionUpdate: async (params) => {
|
|
83
|
+
if (this.sessionUpdateCallback) {
|
|
84
|
+
this.sessionUpdateCallback(params);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
// Handle permission requests from the agent
|
|
88
|
+
requestPermission: async (params) => {
|
|
89
|
+
// For this example, auto-select the first option if available
|
|
90
|
+
// In a real implementation, you'd prompt the user
|
|
91
|
+
if (this.debug)
|
|
92
|
+
console.log("Permission requested:", params);
|
|
93
|
+
if (params.options && params.options.length > 0) {
|
|
94
|
+
return {
|
|
95
|
+
outcome: {
|
|
96
|
+
outcome: "selected",
|
|
97
|
+
optionId: params.options?.[0]?.name || '',
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// If no options, return cancelled
|
|
102
|
+
return {
|
|
103
|
+
outcome: {
|
|
104
|
+
outcome: "cancelled",
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Initialize the ACP connection
|
|
112
|
+
*/
|
|
113
|
+
async initialize() {
|
|
114
|
+
if (!this.connection) {
|
|
115
|
+
throw new Error("Not connected. Call connect() first.");
|
|
116
|
+
}
|
|
117
|
+
if (this.debug)
|
|
118
|
+
console.log("Initializing ACP connection...");
|
|
119
|
+
const initResponse = await this.connection.initialize({
|
|
120
|
+
protocolVersion: acp.PROTOCOL_VERSION,
|
|
121
|
+
clientInfo: {
|
|
122
|
+
name: "auggie-sdk-client",
|
|
123
|
+
version: "0.1.0",
|
|
124
|
+
},
|
|
125
|
+
clientCapabilities: {},
|
|
126
|
+
});
|
|
127
|
+
if (this.debug)
|
|
128
|
+
console.log("Initialized:", JSON.stringify(initResponse, null, 2));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Create a new session
|
|
132
|
+
*/
|
|
133
|
+
async createSession(toolsMap) {
|
|
134
|
+
if (!this.connection) {
|
|
135
|
+
throw new Error("Not connected. Call connect() first.");
|
|
136
|
+
}
|
|
137
|
+
if (this.debug)
|
|
138
|
+
console.log("Creating new session...");
|
|
139
|
+
// Build MCP servers array for the session
|
|
140
|
+
const mcpServers = [];
|
|
141
|
+
// If tools are provided, create and start an MCP server
|
|
142
|
+
if (toolsMap && Object.keys(toolsMap).length > 0) {
|
|
143
|
+
if (this.debug)
|
|
144
|
+
console.log("Starting MCP server with provided tools...");
|
|
145
|
+
this.mcpServer = new AuggieMCPServer(toolsMap, undefined);
|
|
146
|
+
const serverUrl = await this.mcpServer.start();
|
|
147
|
+
if (this.debug)
|
|
148
|
+
console.log(`MCP server started at: ${serverUrl}`);
|
|
149
|
+
// Add the MCP server to the session configuration
|
|
150
|
+
mcpServers.push({
|
|
151
|
+
type: "http",
|
|
152
|
+
name: "custom_tool",
|
|
153
|
+
url: serverUrl,
|
|
154
|
+
headers: [],
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const sessionResponse = await this.connection.newSession({
|
|
158
|
+
cwd: this.workspaceRoot ? this.workspaceRoot : process.cwd(),
|
|
159
|
+
mcpServers,
|
|
160
|
+
});
|
|
161
|
+
this.sessionId = sessionResponse.sessionId;
|
|
162
|
+
if (this.debug) {
|
|
163
|
+
console.log(`Session created: ${this.sessionId}`);
|
|
164
|
+
console.log(` Available modes:`, sessionResponse.modes?.availableModes);
|
|
165
|
+
}
|
|
166
|
+
return this.sessionId;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Send a prompt to the agent and accumulate the text response
|
|
170
|
+
* @param prompt - The text prompt to send to the agent
|
|
171
|
+
* @param isAnswerOnly - If true, returns only the final response after all tool calls complete.
|
|
172
|
+
* If false or undefined, returns all agent message chunks (default: false)
|
|
173
|
+
* @returns The accumulated text response from the agent
|
|
174
|
+
*/
|
|
175
|
+
async sendPrompt(prompt, { isAnswerOnly = false } = { isAnswerOnly: false }) {
|
|
176
|
+
if (!this.connection || !this.sessionId) {
|
|
177
|
+
throw new Error("Not connected or no session. Call connect() and createSession() first.");
|
|
178
|
+
}
|
|
179
|
+
if (this.debug)
|
|
180
|
+
console.log(`\nSending prompt: "${prompt}"`);
|
|
181
|
+
// Accumulator for text responses
|
|
182
|
+
let accumulatedText = "";
|
|
183
|
+
// Track the final response separately (text after the last tool call)
|
|
184
|
+
let finalResponseText = "";
|
|
185
|
+
// Track if we've seen a tool call
|
|
186
|
+
let hasSeenToolCall = false;
|
|
187
|
+
// Temporary callback to accumulate text
|
|
188
|
+
const originalCallback = this.sessionUpdateCallback;
|
|
189
|
+
const accumulatorCallback = (update) => {
|
|
190
|
+
// Track tool calls to know when to start capturing final response
|
|
191
|
+
if (update.update.sessionUpdate === "tool_call") {
|
|
192
|
+
hasSeenToolCall = true;
|
|
193
|
+
// Reset final response text when a new tool call starts
|
|
194
|
+
finalResponseText = "";
|
|
195
|
+
}
|
|
196
|
+
// Accumulate text content
|
|
197
|
+
if (update.update.sessionUpdate === "agent_message_chunk" && update.update.content.type === "text") {
|
|
198
|
+
const textChunk = update.update.content.text;
|
|
199
|
+
accumulatedText += textChunk;
|
|
200
|
+
// If we've seen a tool call, accumulate text for final response
|
|
201
|
+
// This captures the agent's response after tool execution
|
|
202
|
+
if (hasSeenToolCall) {
|
|
203
|
+
finalResponseText += textChunk;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// Also call the original callback if it exists
|
|
207
|
+
if (originalCallback) {
|
|
208
|
+
originalCallback(update);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
// Temporarily replace the callback
|
|
212
|
+
this.sessionUpdateCallback = accumulatorCallback;
|
|
213
|
+
try {
|
|
214
|
+
// Build content blocks
|
|
215
|
+
const content = [
|
|
216
|
+
{
|
|
217
|
+
type: "text",
|
|
218
|
+
text: prompt,
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
// Send the prompt and wait for response
|
|
222
|
+
const response = await this.connection.prompt({
|
|
223
|
+
sessionId: this.sessionId,
|
|
224
|
+
prompt: content,
|
|
225
|
+
});
|
|
226
|
+
if (this.debug)
|
|
227
|
+
console.log("Prompt completed with stop reason:", response.stopReason);
|
|
228
|
+
// Restore original callback
|
|
229
|
+
this.sessionUpdateCallback = originalCallback;
|
|
230
|
+
// Return final response if requested and we had tool calls, otherwise return all text
|
|
231
|
+
if (isAnswerOnly && hasSeenToolCall) {
|
|
232
|
+
return finalResponseText;
|
|
233
|
+
}
|
|
234
|
+
return accumulatedText;
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
console.error("Error during prompt:", error);
|
|
238
|
+
// Restore original callback before closing
|
|
239
|
+
this.sessionUpdateCallback = originalCallback;
|
|
240
|
+
// Kill the process on error
|
|
241
|
+
await this.close();
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Listen for session update events from the agent
|
|
247
|
+
*/
|
|
248
|
+
onSessionUpdate(callback) {
|
|
249
|
+
this.sessionUpdateCallback = callback;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Cancel the current request
|
|
253
|
+
*/
|
|
254
|
+
async cancel() {
|
|
255
|
+
if (!this.connection || !this.sessionId) {
|
|
256
|
+
throw new Error("Not connected or no session.");
|
|
257
|
+
}
|
|
258
|
+
if (this.debug)
|
|
259
|
+
console.log(" Cancelling current request...");
|
|
260
|
+
await this.connection.cancel({
|
|
261
|
+
sessionId: this.sessionId,
|
|
262
|
+
});
|
|
263
|
+
if (this.debug)
|
|
264
|
+
console.log(" Request cancelled");
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Close the connection and kill the Auggie process
|
|
268
|
+
*/
|
|
269
|
+
async close() {
|
|
270
|
+
if (this.debug)
|
|
271
|
+
console.log(" Closing connection...");
|
|
272
|
+
// Kill the Auggie process first - this will naturally close all MCP connections
|
|
273
|
+
this.killProcess();
|
|
274
|
+
// Stop the MCP server (should be fast since Auggie is already killed)
|
|
275
|
+
if (this.mcpServer) {
|
|
276
|
+
if (this.debug)
|
|
277
|
+
console.log(" Stopping MCP server...");
|
|
278
|
+
// Use a short timeout since the connections are already closed
|
|
279
|
+
await Promise.race([
|
|
280
|
+
this.mcpServer.stop(),
|
|
281
|
+
new Promise((resolve) => setTimeout(resolve, 100))
|
|
282
|
+
]);
|
|
283
|
+
this.mcpServer = null;
|
|
284
|
+
}
|
|
285
|
+
// Clean up connection state
|
|
286
|
+
if (this.connection) {
|
|
287
|
+
this.connection = null;
|
|
288
|
+
this.sessionId = null;
|
|
289
|
+
}
|
|
290
|
+
if (this.debug)
|
|
291
|
+
console.log(" Connection closed");
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Kill the Auggie process if it's still running
|
|
295
|
+
*/
|
|
296
|
+
killProcess() {
|
|
297
|
+
if (this.auggieProcess && !this.auggieProcess.killed) {
|
|
298
|
+
if (this.debug)
|
|
299
|
+
console.log(" Killing Auggie process...");
|
|
300
|
+
// Use SIGKILL for immediate termination
|
|
301
|
+
this.auggieProcess.kill("SIGKILL");
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
export { Auggie };
|
|
306
|
+
//# sourceMappingURL=sdk-acp-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-acp-client.js","sourceRoot":"","sources":["../../src/auggie/sdk-acp-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAa,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAiBnD;;;;;;;;GAQG;AACH,MAAM,MAAM;IAWV,YAAY,EAAE,UA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AAS,CAAC,IAAI,EAAE;gBACrB,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;aACzD,CAAC,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,4BAA4B;QAC5B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACK,WAAW;QACjB,IAAI,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YACrD,IAAI,IAAI,CAAC,KAAK;gBAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;YAC1D,wCAAwC;YACxC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;CACF;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Tool } from "ai";
|
|
2
|
+
export declare class AuggieMCPServer {
|
|
3
|
+
private server;
|
|
4
|
+
private httpServer;
|
|
5
|
+
private PORT;
|
|
6
|
+
private serverPATH;
|
|
7
|
+
private activeSockets;
|
|
8
|
+
constructor(tools: Record<string, Tool>, PORT: number | undefined);
|
|
9
|
+
start(): Promise<string>;
|
|
10
|
+
stop(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=sdk-mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-mcp-server.d.ts","sourceRoot":"","sources":["../../src/auggie/sdk-mcp-server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC;AA2B/B,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,aAAa,CAAwC;gBAEjD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS;IA+B3D,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAyCxB,IAAI;CA6BX"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { MCPServer } from "@mastra/mcp";
|
|
2
|
+
import {} from "ai";
|
|
3
|
+
import * as http from "http";
|
|
4
|
+
import * as net from "net";
|
|
5
|
+
/**
|
|
6
|
+
* Find a free port by creating a temporary server on port 0
|
|
7
|
+
* and getting the assigned port number
|
|
8
|
+
*/
|
|
9
|
+
async function findFreePort() {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const server = net.createServer();
|
|
12
|
+
server.unref();
|
|
13
|
+
server.on('error', reject);
|
|
14
|
+
server.listen(0, () => {
|
|
15
|
+
const address = server.address();
|
|
16
|
+
if (address && typeof address !== 'string') {
|
|
17
|
+
const port = address.port;
|
|
18
|
+
server.close(() => {
|
|
19
|
+
resolve(port);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
reject(new Error('Failed to get port from server address'));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export class AuggieMCPServer {
|
|
29
|
+
constructor(tools, PORT) {
|
|
30
|
+
this.httpServer = null;
|
|
31
|
+
this.serverPATH = "/mcp";
|
|
32
|
+
this.activeSockets = new Set();
|
|
33
|
+
// Wrap AI SDK tools to match Mastra's expected signature
|
|
34
|
+
// Mastra wraps the actual tool parameters in a 'context' property
|
|
35
|
+
// AI SDK tools expect: execute({ param1, param2 })
|
|
36
|
+
// Mastra passes: execute({ context: { param1, param2 }, runtimeContext, ... }, mcpContext)
|
|
37
|
+
const wrappedTools = {};
|
|
38
|
+
for (const [name, tool] of Object.entries(tools)) {
|
|
39
|
+
wrappedTools[name] = {
|
|
40
|
+
...tool,
|
|
41
|
+
execute: async (args, mcpContext) => {
|
|
42
|
+
// Extract the actual tool parameters from the 'context' property
|
|
43
|
+
const toolParams = args?.context || args;
|
|
44
|
+
// Call the original AI SDK tool's execute with the unwrapped parameters
|
|
45
|
+
// AI SDK tools may expect (params, options) signature
|
|
46
|
+
if (tool.execute) {
|
|
47
|
+
return await tool.execute(toolParams, mcpContext);
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Tool ${name} does not have an execute function`);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
this.server = new MCPServer({
|
|
54
|
+
name: "auggie-mcp",
|
|
55
|
+
version: "1.0.0",
|
|
56
|
+
tools: wrappedTools,
|
|
57
|
+
});
|
|
58
|
+
this.PORT = PORT;
|
|
59
|
+
}
|
|
60
|
+
async start() {
|
|
61
|
+
// If PORT is undefined, find a free port
|
|
62
|
+
if (this.PORT === undefined) {
|
|
63
|
+
this.PORT = await findFreePort();
|
|
64
|
+
}
|
|
65
|
+
const httpServer = http.createServer(async (req, res) => {
|
|
66
|
+
await this.server.startHTTP({
|
|
67
|
+
url: new URL(req.url || "", `http://localhost:${this.PORT}`),
|
|
68
|
+
httpPath: this.serverPATH,
|
|
69
|
+
req,
|
|
70
|
+
res,
|
|
71
|
+
options: {
|
|
72
|
+
sessionIdGenerator: undefined,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
// Store the server instance
|
|
77
|
+
this.httpServer = httpServer;
|
|
78
|
+
// Track active connections for faster shutdown
|
|
79
|
+
httpServer.on('connection', (socket) => {
|
|
80
|
+
this.activeSockets.add(socket);
|
|
81
|
+
socket.on('close', () => {
|
|
82
|
+
this.activeSockets.delete(socket);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
// Wait for the server to start listening before returning
|
|
86
|
+
await new Promise((resolve, reject) => {
|
|
87
|
+
httpServer.listen(this.PORT, () => {
|
|
88
|
+
resolve();
|
|
89
|
+
});
|
|
90
|
+
httpServer.on('error', reject);
|
|
91
|
+
});
|
|
92
|
+
const serverURL = new URL(this.serverPATH, `http://localhost:${this.PORT}`);
|
|
93
|
+
return serverURL.toString();
|
|
94
|
+
}
|
|
95
|
+
async stop() {
|
|
96
|
+
// Close the HTTP server first with a timeout
|
|
97
|
+
if (this.httpServer) {
|
|
98
|
+
await Promise.race([
|
|
99
|
+
new Promise((resolve, reject) => {
|
|
100
|
+
this.httpServer.close((err) => {
|
|
101
|
+
if (err)
|
|
102
|
+
reject(err);
|
|
103
|
+
else
|
|
104
|
+
resolve();
|
|
105
|
+
});
|
|
106
|
+
}),
|
|
107
|
+
// Timeout after 1 second
|
|
108
|
+
new Promise((resolve) => setTimeout(resolve, 1000))
|
|
109
|
+
]);
|
|
110
|
+
// Force close by destroying all connections if still open
|
|
111
|
+
if (this.httpServer.listening) {
|
|
112
|
+
this.httpServer.closeAllConnections?.();
|
|
113
|
+
}
|
|
114
|
+
this.httpServer = null;
|
|
115
|
+
}
|
|
116
|
+
// Then close the MCP server with a timeout
|
|
117
|
+
await Promise.race([
|
|
118
|
+
this.server.close(),
|
|
119
|
+
// Timeout after 1 second
|
|
120
|
+
new Promise((resolve) => setTimeout(resolve, 1000))
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=sdk-mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-mcp-server.js","sourceRoot":"","sources":["../../src/auggie/sdk-mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAa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AO,EAAE,IAAI,CAAC,CAAC;aAC1D,CAAC,CAAC;YAEH,0DAA0D;YAC1D,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;gBAC9B,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,EAAE,CAAC;YAC1C,CAAC;YAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;QAED,2CAA2C;QAC3C,MAAM,OAAO,CAAC,IAAI,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;YACnB,yBAAyB;YACzB,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SAC1D,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@augmentcode/auggie-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for Auggie",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc --project tsconfig.build.json",
|
|
20
|
+
"dev": "bun ./examples/dev.ts",
|
|
21
|
+
"silent": "bun ./examples/silent.ts",
|
|
22
|
+
"prepare": "husky"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@biomejs/biome": "2.3.4",
|
|
26
|
+
"@types/bun": "latest",
|
|
27
|
+
"husky": "^9.1.7",
|
|
28
|
+
"ultracite": "6.3.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"typescript": "^5"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@agentclientprotocol/sdk": "^0.5.1",
|
|
35
|
+
"@mastra/mcp": "^0.14.1",
|
|
36
|
+
"ai": "^5.0.86",
|
|
37
|
+
"zod": "^4.1.12"
|
|
38
|
+
}
|
|
39
|
+
}
|