@augmentcode/auggie-sdk 0.1.0 → 0.1.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 +50 -2
- package/dist/auggie/sdk-acp-client.d.ts +20 -10
- package/dist/auggie/sdk-acp-client.d.ts.map +1 -1
- package/dist/auggie/sdk-acp-client.js +52 -22
- package/dist/auggie/sdk-acp-client.js.map +1 -1
- package/dist/auggie/sdk-mcp-server.d.ts +4 -4
- package/dist/auggie/sdk-mcp-server.d.ts.map +1 -1
- package/dist/auggie/sdk-mcp-server.js +14 -15
- package/dist/auggie/sdk-mcp-server.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,8 +38,10 @@ import { Auggie } from "@augmentcode/auggie-sdk";
|
|
|
38
38
|
async function main() {
|
|
39
39
|
// Create and initialize Auggie (automatically connects and creates a session)
|
|
40
40
|
const client = await Auggie.create({
|
|
41
|
-
model: "sonnet4.5",
|
|
42
|
-
debug: false,
|
|
41
|
+
model: "sonnet4.5", // Optional: haiku4.5, opus4.1, sonnet4.5, sonnet4
|
|
42
|
+
debug: false, // Optional: enable debug logging
|
|
43
|
+
apiKey: "your-api-key", // Optional: API key for authentication
|
|
44
|
+
apiUrl: "https://api.augmentcode.com", // Optional: API URL
|
|
43
45
|
});
|
|
44
46
|
|
|
45
47
|
try {
|
|
@@ -63,6 +65,45 @@ async function main() {
|
|
|
63
65
|
main();
|
|
64
66
|
```
|
|
65
67
|
|
|
68
|
+
### Authentication
|
|
69
|
+
|
|
70
|
+
There are three ways to authenticate with Auggie:
|
|
71
|
+
|
|
72
|
+
#### 1. Using `auggie login` (Recommended)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
auggie login
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This stores your OAuth session and is automatically used by the SDK.
|
|
79
|
+
|
|
80
|
+
#### 2. Passing API Key Directly
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const client = await Auggie.create({
|
|
84
|
+
apiKey: "your-api-key",
|
|
85
|
+
apiUrl: "https://api.augmentcode.com",
|
|
86
|
+
model: "sonnet4.5",
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### 3. Using Environment Variables
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
export AUGMENT_API_TOKEN="your-api-key"
|
|
94
|
+
export AUGMENT_API_URL="https://api.augmentcode.com"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Then create the client without specifying credentials:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const client = await Auggie.create({
|
|
101
|
+
model: "sonnet4.5",
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Note:** If you pass `apiKey` and `apiUrl` to the constructor, they will override any environment variables.
|
|
106
|
+
|
|
66
107
|
### Using Custom Tools
|
|
67
108
|
|
|
68
109
|
You can provide custom tools to Auggie using the AI SDK tool format:
|
|
@@ -156,6 +197,9 @@ npm run dev "What's the weather in Tokyo?"
|
|
|
156
197
|
|
|
157
198
|
# Run the silent example (no streaming)
|
|
158
199
|
npm run silent "What's the weather in Paris?"
|
|
200
|
+
|
|
201
|
+
# Run with API key authentication
|
|
202
|
+
AUGMENT_API_TOKEN=your-key AUGMENT_API_URL=https://api.augmentcode.com npm run with-api-key "List files"
|
|
159
203
|
```
|
|
160
204
|
|
|
161
205
|
### Custom Auggie Path and Workspace
|
|
@@ -167,6 +211,8 @@ const client = await Auggie.create({
|
|
|
167
211
|
model: "sonnet4.5",
|
|
168
212
|
debug: true,
|
|
169
213
|
allowIndexing: true,
|
|
214
|
+
apiKey: "your-api-key", // Optional
|
|
215
|
+
apiUrl: "https://api.augmentcode.com", // Optional
|
|
170
216
|
});
|
|
171
217
|
```
|
|
172
218
|
|
|
@@ -189,6 +235,8 @@ Creates a new Auggie instance and automatically connects and initializes a sessi
|
|
|
189
235
|
- `model?: "haiku4.5" | "opus4.1" | "sonnet4.5" | "sonnet4"` - Model to use (default: "haiku4.5")
|
|
190
236
|
- `allowIndexing?: boolean` - Allow codebase indexing (default: true)
|
|
191
237
|
- `toolsMap?: Record<string, Tool>` - Custom tools to provide to Auggie (optional)
|
|
238
|
+
- `apiKey?: string` - API key for authentication (optional, sets AUGMENT_API_TOKEN)
|
|
239
|
+
- `apiUrl?: string` - API URL for authentication (optional, sets AUGMENT_API_URL)
|
|
192
240
|
|
|
193
241
|
#### Methods
|
|
194
242
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { type SessionNotification } from "@agentclientprotocol/sdk";
|
|
2
|
+
import type { Tool } from "ai";
|
|
3
3
|
type models = "haiku4.5" | "opus4.1" | "sonnet4.5" | "sonnet4";
|
|
4
4
|
type AuggieOptions = {
|
|
5
5
|
auggiePath?: string;
|
|
6
6
|
workspaceRoot?: string;
|
|
7
|
-
debug?: boolean;
|
|
8
7
|
model?: models;
|
|
9
8
|
allowIndexing?: boolean;
|
|
9
|
+
toolsMap?: Record<string, Tool>;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
apiUrl?: string;
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
12
14
|
* ACP Client for connecting to Auggie as an ACP server
|
|
@@ -18,17 +20,25 @@ type AuggieOptions = {
|
|
|
18
20
|
* 4. Send prompts and receive responses
|
|
19
21
|
*/
|
|
20
22
|
declare class Auggie {
|
|
23
|
+
private static readonly PATH_SPLIT_REGEX;
|
|
21
24
|
private connection;
|
|
22
25
|
private sessionId;
|
|
23
|
-
private auggiePath;
|
|
24
|
-
private workspaceRoot;
|
|
26
|
+
private readonly auggiePath;
|
|
27
|
+
private readonly workspaceRoot;
|
|
25
28
|
private auggieProcess;
|
|
26
29
|
private sessionUpdateCallback;
|
|
27
|
-
private debug;
|
|
30
|
+
private readonly debug;
|
|
28
31
|
private mcpServer;
|
|
29
|
-
private model;
|
|
30
|
-
private allowIndexing;
|
|
31
|
-
|
|
32
|
+
private readonly model;
|
|
33
|
+
private readonly allowIndexing;
|
|
34
|
+
private readonly apiKey;
|
|
35
|
+
private readonly apiUrl;
|
|
36
|
+
private constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Create and initialize a new Auggie instance
|
|
39
|
+
* This static factory method automatically connects and creates a session
|
|
40
|
+
*/
|
|
41
|
+
static create(options?: AuggieOptions): Promise<Auggie>;
|
|
32
42
|
/**
|
|
33
43
|
* Connect to Auggie ACP server
|
|
34
44
|
*/
|
|
@@ -58,7 +68,7 @@ declare class Auggie {
|
|
|
58
68
|
/**
|
|
59
69
|
* Listen for session update events from the agent
|
|
60
70
|
*/
|
|
61
|
-
onSessionUpdate(callback: (update:
|
|
71
|
+
onSessionUpdate(callback: (update: SessionNotification) => void): void;
|
|
62
72
|
/**
|
|
63
73
|
* Cancel the current request
|
|
64
74
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-acp-client.d.ts","sourceRoot":"","sources":["../../src/auggie/sdk-acp-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk-acp-client.d.ts","sourceRoot":"","sources":["../../src/auggie/sdk-acp-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAUL,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAG/B,KAAK,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAE/D,KAAK,aAAa,GAAG;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,C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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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { spawn, ChildProcess } from "node:child_process";
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
3
2
|
import { Readable, Writable } from "node:stream";
|
|
4
|
-
import {} from "
|
|
3
|
+
import { ClientSideConnection, ndJsonStream, PROTOCOL_VERSION, } from "@agentclientprotocol/sdk";
|
|
5
4
|
import { AuggieMCPServer } from "./sdk-mcp-server";
|
|
6
5
|
/**
|
|
7
6
|
* ACP Client for connecting to Auggie as an ACP server
|
|
@@ -13,18 +12,32 @@ import { AuggieMCPServer } from "./sdk-mcp-server";
|
|
|
13
12
|
* 4. Send prompts and receive responses
|
|
14
13
|
*/
|
|
15
14
|
class Auggie {
|
|
16
|
-
constructor({ auggiePath = "auggie", workspaceRoot,
|
|
15
|
+
constructor({ auggiePath = "auggie", workspaceRoot,
|
|
16
|
+
// debug = false,
|
|
17
|
+
model = "haiku4.5", allowIndexing = true, apiKey, apiUrl, } = {}) {
|
|
17
18
|
this.connection = null;
|
|
18
19
|
this.sessionId = null;
|
|
19
20
|
this.workspaceRoot = undefined;
|
|
20
21
|
this.auggieProcess = null;
|
|
21
22
|
this.sessionUpdateCallback = null;
|
|
23
|
+
this.debug = false;
|
|
22
24
|
this.mcpServer = null;
|
|
23
25
|
this.auggiePath = auggiePath;
|
|
24
26
|
this.workspaceRoot = workspaceRoot;
|
|
25
|
-
this.debug = debug;
|
|
26
27
|
this.model = model;
|
|
27
28
|
this.allowIndexing = allowIndexing;
|
|
29
|
+
this.apiKey = apiKey;
|
|
30
|
+
this.apiUrl = apiUrl;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create and initialize a new Auggie instance
|
|
34
|
+
* This static factory method automatically connects and creates a session
|
|
35
|
+
*/
|
|
36
|
+
static async create(options = {}) {
|
|
37
|
+
const instance = new Auggie(options);
|
|
38
|
+
await instance.connect();
|
|
39
|
+
await instance.createSession(options.toolsMap);
|
|
40
|
+
return instance;
|
|
28
41
|
}
|
|
29
42
|
/**
|
|
30
43
|
* Connect to Auggie ACP server
|
|
@@ -41,14 +54,23 @@ class Auggie {
|
|
|
41
54
|
args.push("--workspace-root", this.workspaceRoot);
|
|
42
55
|
}
|
|
43
56
|
// Parse auggiePath to handle cases where it includes arguments (e.g., "node /path/to/file.js")
|
|
44
|
-
const pathParts = this.auggiePath.trim().split(
|
|
57
|
+
const pathParts = this.auggiePath.trim().split(Auggie.PATH_SPLIT_REGEX);
|
|
45
58
|
if (pathParts.length === 0 || !pathParts[0]) {
|
|
46
59
|
throw new Error("Invalid auggiePath: cannot be empty");
|
|
47
60
|
}
|
|
48
61
|
const command = pathParts[0];
|
|
49
62
|
const commandArgs = [...pathParts.slice(1), ...args];
|
|
63
|
+
// Build environment variables for the Auggie process
|
|
64
|
+
const env = { ...process.env };
|
|
65
|
+
if (this.apiKey) {
|
|
66
|
+
env.AUGMENT_API_TOKEN = this.apiKey;
|
|
67
|
+
}
|
|
68
|
+
if (this.apiUrl) {
|
|
69
|
+
env.AUGMENT_API_URL = this.apiUrl;
|
|
70
|
+
}
|
|
50
71
|
this.auggieProcess = spawn(command, commandArgs, {
|
|
51
72
|
stdio: ["pipe", "pipe", "inherit"],
|
|
73
|
+
env,
|
|
52
74
|
});
|
|
53
75
|
// Handle process errors
|
|
54
76
|
this.auggieProcess.on("error", (error) => {
|
|
@@ -61,12 +83,15 @@ class Auggie {
|
|
|
61
83
|
});
|
|
62
84
|
// Create streams for ACP communication
|
|
63
85
|
// Note: Auggie writes to stdout and reads from stdin
|
|
86
|
+
if (!(this.auggieProcess.stdout && this.auggieProcess.stdin)) {
|
|
87
|
+
throw new Error("Failed to create stdio pipes for Auggie process");
|
|
88
|
+
}
|
|
64
89
|
const input = Readable.toWeb(this.auggieProcess.stdout);
|
|
65
90
|
const output = Writable.toWeb(this.auggieProcess.stdin);
|
|
66
91
|
// Create ndjson stream for ACP protocol
|
|
67
|
-
const stream =
|
|
92
|
+
const stream = ndJsonStream(output, input);
|
|
68
93
|
// Create client-side connection with a Client implementation
|
|
69
|
-
this.connection = new
|
|
94
|
+
this.connection = new ClientSideConnection((agent) => this.createClient(agent), stream);
|
|
70
95
|
if (this.debug) {
|
|
71
96
|
console.log("Connected to Auggie ACP server");
|
|
72
97
|
}
|
|
@@ -79,31 +104,32 @@ class Auggie {
|
|
|
79
104
|
createClient(_agent) {
|
|
80
105
|
return {
|
|
81
106
|
// Handle session updates from the agent
|
|
82
|
-
sessionUpdate:
|
|
107
|
+
sessionUpdate: (params) => {
|
|
83
108
|
if (this.sessionUpdateCallback) {
|
|
84
109
|
this.sessionUpdateCallback(params);
|
|
85
110
|
}
|
|
111
|
+
return Promise.resolve();
|
|
86
112
|
},
|
|
87
113
|
// Handle permission requests from the agent
|
|
88
|
-
requestPermission:
|
|
114
|
+
requestPermission: (params) => {
|
|
89
115
|
// For this example, auto-select the first option if available
|
|
90
116
|
// In a real implementation, you'd prompt the user
|
|
91
117
|
if (this.debug)
|
|
92
118
|
console.log("Permission requested:", params);
|
|
93
119
|
if (params.options && params.options.length > 0) {
|
|
94
|
-
return {
|
|
120
|
+
return Promise.resolve({
|
|
95
121
|
outcome: {
|
|
96
122
|
outcome: "selected",
|
|
97
|
-
optionId: params.options?.[0]?.name ||
|
|
123
|
+
optionId: params.options?.[0]?.name || "",
|
|
98
124
|
},
|
|
99
|
-
};
|
|
125
|
+
});
|
|
100
126
|
}
|
|
101
127
|
// If no options, return cancelled
|
|
102
|
-
return {
|
|
128
|
+
return Promise.resolve({
|
|
103
129
|
outcome: {
|
|
104
130
|
outcome: "cancelled",
|
|
105
131
|
},
|
|
106
|
-
};
|
|
132
|
+
});
|
|
107
133
|
},
|
|
108
134
|
};
|
|
109
135
|
}
|
|
@@ -117,7 +143,7 @@ class Auggie {
|
|
|
117
143
|
if (this.debug)
|
|
118
144
|
console.log("Initializing ACP connection...");
|
|
119
145
|
const initResponse = await this.connection.initialize({
|
|
120
|
-
protocolVersion:
|
|
146
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
121
147
|
clientInfo: {
|
|
122
148
|
name: "auggie-sdk-client",
|
|
123
149
|
version: "0.1.0",
|
|
@@ -161,7 +187,7 @@ class Auggie {
|
|
|
161
187
|
this.sessionId = sessionResponse.sessionId;
|
|
162
188
|
if (this.debug) {
|
|
163
189
|
console.log(`Session created: ${this.sessionId}`);
|
|
164
|
-
console.log(
|
|
190
|
+
console.log(" Available modes:", sessionResponse.modes?.availableModes);
|
|
165
191
|
}
|
|
166
192
|
return this.sessionId;
|
|
167
193
|
}
|
|
@@ -172,8 +198,10 @@ class Auggie {
|
|
|
172
198
|
* If false or undefined, returns all agent message chunks (default: false)
|
|
173
199
|
* @returns The accumulated text response from the agent
|
|
174
200
|
*/
|
|
175
|
-
async sendPrompt(prompt, { isAnswerOnly = false } = {
|
|
176
|
-
|
|
201
|
+
async sendPrompt(prompt, { isAnswerOnly = false } = {
|
|
202
|
+
isAnswerOnly: false,
|
|
203
|
+
}) {
|
|
204
|
+
if (!(this.connection && this.sessionId)) {
|
|
177
205
|
throw new Error("Not connected or no session. Call connect() and createSession() first.");
|
|
178
206
|
}
|
|
179
207
|
if (this.debug)
|
|
@@ -194,7 +222,8 @@ class Auggie {
|
|
|
194
222
|
finalResponseText = "";
|
|
195
223
|
}
|
|
196
224
|
// Accumulate text content
|
|
197
|
-
if (update.update.sessionUpdate === "agent_message_chunk" &&
|
|
225
|
+
if (update.update.sessionUpdate === "agent_message_chunk" &&
|
|
226
|
+
update.update.content.type === "text") {
|
|
198
227
|
const textChunk = update.update.content.text;
|
|
199
228
|
accumulatedText += textChunk;
|
|
200
229
|
// If we've seen a tool call, accumulate text for final response
|
|
@@ -252,7 +281,7 @@ class Auggie {
|
|
|
252
281
|
* Cancel the current request
|
|
253
282
|
*/
|
|
254
283
|
async cancel() {
|
|
255
|
-
if (!this.connection
|
|
284
|
+
if (!(this.connection && this.sessionId)) {
|
|
256
285
|
throw new Error("Not connected or no session.");
|
|
257
286
|
}
|
|
258
287
|
if (this.debug)
|
|
@@ -278,7 +307,7 @@ class Auggie {
|
|
|
278
307
|
// Use a short timeout since the connections are already closed
|
|
279
308
|
await Promise.race([
|
|
280
309
|
this.mcpServer.stop(),
|
|
281
|
-
new Promise((resolve) => setTimeout(resolve, 100))
|
|
310
|
+
new Promise((resolve) => setTimeout(resolve, 100)),
|
|
282
311
|
]);
|
|
283
312
|
this.mcpServer = null;
|
|
284
313
|
}
|
|
@@ -302,5 +331,6 @@ class Auggie {
|
|
|
302
331
|
}
|
|
303
332
|
}
|
|
304
333
|
}
|
|
334
|
+
Auggie.PATH_SPLIT_REGEX = /\s+/;
|
|
305
335
|
export { Auggie };
|
|
306
336
|
//# sourceMappingURL=sdk-acp-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-acp-client.js","sourceRoot":"","sources":["../../src/auggie/sdk-acp-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk-acp-client.js","sourceRoot":"","sources":["../../src/auggie/sdk-acp-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAGL,oBAAoB,EAGpB,YAAY,EACZ,gBAAgB,GAIjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAcnD;;;;;;;;GAQG;AACH,MAAM,MAAM;IAiBV,YAAoB,EAClB,UAAU,GAAG,QAAQ,EACrB,aAAa;IACb,iBAAiB;IACjB,KAAK,GAAG,UAAU,EAClB,aAAa,GAAG,IAAI,EAC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C,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;;AAtYuB,uBAAgB,GAAG,KAAK,AAAR,CAAS;AAyYnD,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Tool } from "ai";
|
|
2
2
|
export declare class AuggieMCPServer {
|
|
3
|
-
private server;
|
|
3
|
+
private readonly server;
|
|
4
4
|
private httpServer;
|
|
5
5
|
private PORT;
|
|
6
|
-
private serverPATH;
|
|
7
|
-
private activeSockets;
|
|
6
|
+
private readonly serverPATH;
|
|
7
|
+
private readonly activeSockets;
|
|
8
8
|
constructor(tools: Record<string, Tool>, PORT: number | undefined);
|
|
9
9
|
start(): Promise<string>;
|
|
10
10
|
stop(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-mcp-server.d.ts","sourceRoot":"","sources":["../../src/auggie/sdk-mcp-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk-mcp-server.d.ts","sourceRoot":"","sources":["../../src/auggie/sdk-mcp-server.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAmB,MAAM,IAAI,CAAC;AAyBhD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0B;gBAE5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS;IAkC3D,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IA2CxB,IAAI;CA6BX"}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
+
import { createServer as createHTTPServer, } from "node:http";
|
|
2
|
+
import { createServer } from "node:net";
|
|
1
3
|
import { MCPServer } from "@mastra/mcp";
|
|
2
|
-
import {} from "ai";
|
|
3
|
-
import * as http from "http";
|
|
4
|
-
import * as net from "net";
|
|
5
4
|
/**
|
|
6
5
|
* Find a free port by creating a temporary server on port 0
|
|
7
6
|
* and getting the assigned port number
|
|
8
7
|
*/
|
|
9
|
-
|
|
8
|
+
function findFreePort() {
|
|
10
9
|
return new Promise((resolve, reject) => {
|
|
11
|
-
const server =
|
|
10
|
+
const server = createServer();
|
|
12
11
|
server.unref();
|
|
13
|
-
server.on(
|
|
12
|
+
server.on("error", reject);
|
|
14
13
|
server.listen(0, () => {
|
|
15
14
|
const address = server.address();
|
|
16
|
-
if (address && typeof address !==
|
|
15
|
+
if (address && typeof address !== "string") {
|
|
17
16
|
const port = address.port;
|
|
18
17
|
server.close(() => {
|
|
19
18
|
resolve(port);
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
21
|
else {
|
|
23
|
-
reject(new Error(
|
|
22
|
+
reject(new Error("Failed to get port from server address"));
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
25
|
});
|
|
@@ -62,7 +61,7 @@ export class AuggieMCPServer {
|
|
|
62
61
|
if (this.PORT === undefined) {
|
|
63
62
|
this.PORT = await findFreePort();
|
|
64
63
|
}
|
|
65
|
-
const httpServer =
|
|
64
|
+
const httpServer = createHTTPServer(async (req, res) => {
|
|
66
65
|
await this.server.startHTTP({
|
|
67
66
|
url: new URL(req.url || "", `http://localhost:${this.PORT}`),
|
|
68
67
|
httpPath: this.serverPATH,
|
|
@@ -76,9 +75,9 @@ export class AuggieMCPServer {
|
|
|
76
75
|
// Store the server instance
|
|
77
76
|
this.httpServer = httpServer;
|
|
78
77
|
// Track active connections for faster shutdown
|
|
79
|
-
httpServer.on(
|
|
78
|
+
httpServer.on("connection", (socket) => {
|
|
80
79
|
this.activeSockets.add(socket);
|
|
81
|
-
socket.on(
|
|
80
|
+
socket.on("close", () => {
|
|
82
81
|
this.activeSockets.delete(socket);
|
|
83
82
|
});
|
|
84
83
|
});
|
|
@@ -87,7 +86,7 @@ export class AuggieMCPServer {
|
|
|
87
86
|
httpServer.listen(this.PORT, () => {
|
|
88
87
|
resolve();
|
|
89
88
|
});
|
|
90
|
-
httpServer.on(
|
|
89
|
+
httpServer.on("error", reject);
|
|
91
90
|
});
|
|
92
91
|
const serverURL = new URL(this.serverPATH, `http://localhost:${this.PORT}`);
|
|
93
92
|
return serverURL.toString();
|
|
@@ -97,7 +96,7 @@ export class AuggieMCPServer {
|
|
|
97
96
|
if (this.httpServer) {
|
|
98
97
|
await Promise.race([
|
|
99
98
|
new Promise((resolve, reject) => {
|
|
100
|
-
this.httpServer
|
|
99
|
+
this.httpServer?.close((err) => {
|
|
101
100
|
if (err)
|
|
102
101
|
reject(err);
|
|
103
102
|
else
|
|
@@ -105,7 +104,7 @@ export class AuggieMCPServer {
|
|
|
105
104
|
});
|
|
106
105
|
}),
|
|
107
106
|
// Timeout after 1 second
|
|
108
|
-
new Promise((resolve) => setTimeout(resolve, 1000))
|
|
107
|
+
new Promise((resolve) => setTimeout(resolve, 1000)),
|
|
109
108
|
]);
|
|
110
109
|
// Force close by destroying all connections if still open
|
|
111
110
|
if (this.httpServer.listening) {
|
|
@@ -117,7 +116,7 @@ export class AuggieMCPServer {
|
|
|
117
116
|
await Promise.race([
|
|
118
117
|
this.server.close(),
|
|
119
118
|
// Timeout after 1 second
|
|
120
|
-
new Promise((resolve) => setTimeout(resolve, 1000))
|
|
119
|
+
new Promise((resolve) => setTimeout(resolve, 1000)),
|
|
121
120
|
]);
|
|
122
121
|
}
|
|
123
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-mcp-server.js","sourceRoot":"","sources":["../../src/auggie/sdk-mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk-mcp-server.js","sourceRoot":"","sources":["../../src/auggie/sdk-mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,IAAI,gBAAgB,GAIjC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;GAGG;AACH,SAAS,YAAY;IACnB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAC9B,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE;YACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;gBAC1B,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;oBAChB,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,OAAO,eAAe;IAO1B,YAAY,KAA2B,EAAE,IAAwB;QALzD,eAAU,GAAsB,IAAI,CAAC;QAE5B,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