@augmentcode/auggie-sdk 0.1.9 → 0.1.11
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/dist/auggie/sdk-acp-client.d.ts +7 -6
- package/dist/auggie/sdk-acp-client.js +299 -332
- package/dist/auggie/sdk-mcp-server.d.ts +5 -3
- package/dist/auggie/sdk-mcp-server.js +102 -112
- package/dist/context/direct-context.d.ts +19 -15
- package/dist/context/direct-context.js +556 -567
- package/dist/context/filesystem-context.d.ts +5 -3
- package/dist/context/filesystem-context.js +187 -209
- package/dist/context/internal/__mocks__/api-client.d.ts +17 -11
- package/dist/context/internal/__mocks__/api-client.js +104 -91
- package/dist/context/internal/api-client.d.ts +15 -15
- package/dist/context/internal/api-client.js +233 -224
- package/dist/context/internal/blob-name-calculator.d.ts +5 -4
- package/dist/context/internal/blob-name-calculator.js +41 -38
- package/dist/context/internal/chat-utils.d.ts +6 -3
- package/dist/context/internal/chat-utils.js +5 -18
- package/dist/context/internal/credentials.d.ts +5 -4
- package/dist/context/internal/credentials.js +24 -38
- package/dist/context/internal/retry-utils.d.ts +5 -4
- package/dist/context/internal/retry-utils.js +60 -114
- package/dist/context/internal/search-utils.d.ts +3 -2
- package/dist/context/internal/search-utils.js +8 -9
- package/dist/context/internal/session-reader.d.ts +4 -3
- package/dist/context/internal/session-reader.js +14 -22
- package/dist/context/types.d.ts +17 -12
- package/dist/context/types.js +0 -5
- package/dist/index.d.ts +8 -7
- package/dist/index.js +14 -9
- package/dist/version.d.ts +3 -2
- package/dist/version.js +24 -38
- package/package.json +3 -2
- package/dist/auggie/sdk-acp-client.d.ts.map +0 -1
- package/dist/auggie/sdk-acp-client.js.map +0 -1
- package/dist/auggie/sdk-mcp-server.d.ts.map +0 -1
- package/dist/auggie/sdk-mcp-server.js.map +0 -1
- package/dist/context/direct-context.d.ts.map +0 -1
- package/dist/context/direct-context.js.map +0 -1
- package/dist/context/filesystem-context.d.ts.map +0 -1
- package/dist/context/filesystem-context.js.map +0 -1
- package/dist/context/internal/__mocks__/api-client.d.ts.map +0 -1
- package/dist/context/internal/__mocks__/api-client.js.map +0 -1
- package/dist/context/internal/api-client.d.ts.map +0 -1
- package/dist/context/internal/api-client.js.map +0 -1
- package/dist/context/internal/blob-name-calculator.d.ts.map +0 -1
- package/dist/context/internal/blob-name-calculator.js.map +0 -1
- package/dist/context/internal/chat-utils.d.ts.map +0 -1
- package/dist/context/internal/chat-utils.js.map +0 -1
- package/dist/context/internal/credentials.d.ts.map +0 -1
- package/dist/context/internal/credentials.js.map +0 -1
- package/dist/context/internal/retry-utils.d.ts.map +0 -1
- package/dist/context/internal/retry-utils.js.map +0 -1
- package/dist/context/internal/search-utils.d.ts.map +0 -1
- package/dist/context/internal/search-utils.js.map +0 -1
- package/dist/context/internal/session-reader.d.ts.map +0 -1
- package/dist/context/internal/session-reader.js.map +0 -1
- package/dist/context/types.d.ts.map +0 -1
- package/dist/context/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Tool } from 'ai';
|
|
2
|
+
|
|
3
|
+
declare class AuggieMCPServer {
|
|
3
4
|
private readonly server;
|
|
4
5
|
private httpServer;
|
|
5
6
|
private PORT;
|
|
@@ -9,4 +10,5 @@ export declare class AuggieMCPServer {
|
|
|
9
10
|
start(): Promise<string>;
|
|
10
11
|
stop(): Promise<void>;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
export { AuggieMCPServer };
|
|
@@ -1,123 +1,113 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createServer as createHTTPServer
|
|
3
|
+
} from "node:http";
|
|
2
4
|
import { createServer } from "node:net";
|
|
3
5
|
import { MCPServer } from "@mastra/mcp";
|
|
4
|
-
/**
|
|
5
|
-
* Find a free port by creating a temporary server on port 0
|
|
6
|
-
* and getting the assigned port number
|
|
7
|
-
*/
|
|
8
6
|
function findFreePort() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
reject(new Error("Failed to get port from server address"));
|
|
23
|
-
}
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const server = createServer();
|
|
9
|
+
server.unref();
|
|
10
|
+
server.on("error", reject);
|
|
11
|
+
server.listen(0, () => {
|
|
12
|
+
const address = server.address();
|
|
13
|
+
if (address && typeof address !== "string") {
|
|
14
|
+
const port = address.port;
|
|
15
|
+
server.close(() => {
|
|
16
|
+
resolve(port);
|
|
24
17
|
});
|
|
18
|
+
} else {
|
|
19
|
+
reject(new Error("Failed to get port from server address"));
|
|
20
|
+
}
|
|
25
21
|
});
|
|
22
|
+
});
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
throw new Error(`Tool ${name} does not have an execute function`);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
24
|
+
class AuggieMCPServer {
|
|
25
|
+
server;
|
|
26
|
+
httpServer = null;
|
|
27
|
+
PORT;
|
|
28
|
+
serverPATH = "/mcp";
|
|
29
|
+
activeSockets = /* @__PURE__ */ new Set();
|
|
30
|
+
constructor(tools, PORT) {
|
|
31
|
+
const wrappedTools = {};
|
|
32
|
+
for (const [name, tool] of Object.entries(tools)) {
|
|
33
|
+
wrappedTools[name] = {
|
|
34
|
+
...tool,
|
|
35
|
+
execute: async (args, mcpContext) => {
|
|
36
|
+
const toolParams = args?.context || args;
|
|
37
|
+
if (tool.execute) {
|
|
38
|
+
return await tool.execute(
|
|
39
|
+
toolParams,
|
|
40
|
+
mcpContext
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`Tool ${name} does not have an execute function`);
|
|
51
44
|
}
|
|
52
|
-
|
|
53
|
-
name: "auggie-mcp",
|
|
54
|
-
version: "1.0.0",
|
|
55
|
-
tools: wrappedTools,
|
|
56
|
-
});
|
|
57
|
-
this.PORT = PORT;
|
|
45
|
+
};
|
|
58
46
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
res,
|
|
70
|
-
options: {
|
|
71
|
-
sessionIdGenerator: undefined,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
// Store the server instance
|
|
76
|
-
this.httpServer = httpServer;
|
|
77
|
-
// Track active connections for faster shutdown
|
|
78
|
-
httpServer.on("connection", (socket) => {
|
|
79
|
-
this.activeSockets.add(socket);
|
|
80
|
-
socket.on("close", () => {
|
|
81
|
-
this.activeSockets.delete(socket);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
// Wait for the server to start listening before returning
|
|
85
|
-
await new Promise((resolve, reject) => {
|
|
86
|
-
httpServer.listen(this.PORT, () => {
|
|
87
|
-
resolve();
|
|
88
|
-
});
|
|
89
|
-
httpServer.on("error", reject);
|
|
90
|
-
});
|
|
91
|
-
const serverURL = new URL(this.serverPATH, `http://localhost:${this.PORT}`);
|
|
92
|
-
return serverURL.toString();
|
|
47
|
+
this.server = new MCPServer({
|
|
48
|
+
name: "auggie-mcp",
|
|
49
|
+
version: "1.0.0",
|
|
50
|
+
tools: wrappedTools
|
|
51
|
+
});
|
|
52
|
+
this.PORT = PORT;
|
|
53
|
+
}
|
|
54
|
+
async start() {
|
|
55
|
+
if (this.PORT === void 0) {
|
|
56
|
+
this.PORT = await findFreePort();
|
|
93
57
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
58
|
+
const httpServer = createHTTPServer(
|
|
59
|
+
async (req, res) => {
|
|
60
|
+
await this.server.startHTTP({
|
|
61
|
+
url: new URL(req.url || "", `http://localhost:${this.PORT}`),
|
|
62
|
+
httpPath: this.serverPATH,
|
|
63
|
+
req,
|
|
64
|
+
res,
|
|
65
|
+
options: {
|
|
66
|
+
sessionIdGenerator: void 0
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
this.httpServer = httpServer;
|
|
72
|
+
httpServer.on("connection", (socket) => {
|
|
73
|
+
this.activeSockets.add(socket);
|
|
74
|
+
socket.on("close", () => {
|
|
75
|
+
this.activeSockets.delete(socket);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
await new Promise((resolve, reject) => {
|
|
79
|
+
httpServer.listen(this.PORT, () => {
|
|
80
|
+
resolve();
|
|
81
|
+
});
|
|
82
|
+
httpServer.on("error", reject);
|
|
83
|
+
});
|
|
84
|
+
const serverURL = new URL(this.serverPATH, `http://localhost:${this.PORT}`);
|
|
85
|
+
return serverURL.toString();
|
|
86
|
+
}
|
|
87
|
+
async stop() {
|
|
88
|
+
if (this.httpServer) {
|
|
89
|
+
await Promise.race([
|
|
90
|
+
new Promise((resolve, reject) => {
|
|
91
|
+
this.httpServer?.close((err) => {
|
|
92
|
+
if (err) reject(err);
|
|
93
|
+
else resolve();
|
|
94
|
+
});
|
|
95
|
+
}),
|
|
96
|
+
// Timeout after 1 second
|
|
97
|
+
new Promise((resolve) => setTimeout(resolve, 1e3))
|
|
98
|
+
]);
|
|
99
|
+
if (this.httpServer.listening) {
|
|
100
|
+
this.httpServer.closeAllConnections?.();
|
|
101
|
+
}
|
|
102
|
+
this.httpServer = null;
|
|
121
103
|
}
|
|
104
|
+
await Promise.race([
|
|
105
|
+
this.server.close(),
|
|
106
|
+
// Timeout after 1 second
|
|
107
|
+
new Promise((resolve) => setTimeout(resolve, 1e3))
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
122
110
|
}
|
|
123
|
-
|
|
111
|
+
export {
|
|
112
|
+
AuggieMCPServer
|
|
113
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DirectContextOptions, DirectContextState, File, IndexingResult } from './types.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Direct Context - API-based indexing with import/export state
|
|
4
5
|
*
|
|
@@ -58,7 +59,7 @@ import type { DirectContextOptions, DirectContextState, File, IndexingResult } f
|
|
|
58
59
|
* const context = await DirectContext.importFromFile("state.json");
|
|
59
60
|
* ```
|
|
60
61
|
*/
|
|
61
|
-
|
|
62
|
+
declare class DirectContext {
|
|
62
63
|
private static readonly MAX_FILE_SIZE_BYTES;
|
|
63
64
|
private static readonly MAX_BATCH_UPLOAD_SIZE;
|
|
64
65
|
private static readonly MAX_BATCH_CONTENT_BYTES;
|
|
@@ -70,18 +71,23 @@ export declare class DirectContext {
|
|
|
70
71
|
/**
|
|
71
72
|
* State management:
|
|
72
73
|
*
|
|
73
|
-
* blobMap: Tracks all files that have been uploaded (path ->
|
|
74
|
+
* blobMap: Tracks all files that have been uploaded (path -> serverBlobId).
|
|
74
75
|
* This includes both indexed and non-indexed blobs.
|
|
75
76
|
* Also, includes both checkpointed and non-checkpointed blobs.
|
|
77
|
+
* The server blob ID is the authoritative identifier.
|
|
78
|
+
*
|
|
79
|
+
* clientBlobMap: Tracks client-computed blob IDs (path -> clientBlobId).
|
|
80
|
+
* Used for detecting unchanged files on the client side.
|
|
81
|
+
* May differ from serverBlobId due to encoding differences.
|
|
76
82
|
*
|
|
77
83
|
* checkpointId: The current checkpoint ID from the backend.
|
|
78
84
|
* Checkpoints are named snapshots of the blob set for performance.
|
|
79
85
|
* Updated after each successful checkpoint operation.
|
|
80
86
|
*
|
|
81
|
-
* pendingAdded: Blob
|
|
87
|
+
* pendingAdded: Blob IDs that have been uploaded but not yet checkpointed.
|
|
82
88
|
* Accumulated until CHECKPOINT_THRESHOLD is reached.
|
|
83
89
|
*
|
|
84
|
-
* pendingDeleted: Blob
|
|
90
|
+
* pendingDeleted: Blob IDs that have been removed but not yet checkpointed.
|
|
85
91
|
* Accumulated until CHECKPOINT_THRESHOLD is reached.
|
|
86
92
|
*
|
|
87
93
|
* Note: Checkpointing and indexing are independent operations.
|
|
@@ -89,6 +95,7 @@ export declare class DirectContext {
|
|
|
89
95
|
* both, or neither.
|
|
90
96
|
*/
|
|
91
97
|
private readonly blobMap;
|
|
98
|
+
private readonly clientBlobMap;
|
|
92
99
|
private checkpointId?;
|
|
93
100
|
private pendingAdded;
|
|
94
101
|
private pendingDeleted;
|
|
@@ -157,16 +164,16 @@ export declare class DirectContext {
|
|
|
157
164
|
waitForIndexing?: boolean;
|
|
158
165
|
}): Promise<IndexingResult>;
|
|
159
166
|
/**
|
|
160
|
-
*
|
|
167
|
+
* Find blobs that are missing or not yet indexed on the backend (detailed result)
|
|
168
|
+
* Batches requests in chunks of 1000
|
|
161
169
|
*
|
|
162
170
|
* @param blobNames - Array of blob names to check
|
|
163
|
-
* @
|
|
164
|
-
* If false, only returns blobs that need to be uploaded.
|
|
165
|
-
* @returns Array of blob names that are either missing or not indexed (depending on flag)
|
|
171
|
+
* @returns Object with unknownBlobNames and nonindexedBlobNames arrays
|
|
166
172
|
*/
|
|
167
|
-
private
|
|
173
|
+
private findMissingBlobsDetailed;
|
|
168
174
|
/**
|
|
169
175
|
* Upload files in batches respecting backend limits
|
|
176
|
+
* Returns a map of client-computed blob IDs to backend-returned blob IDs
|
|
170
177
|
*/
|
|
171
178
|
private batchUploadFiles;
|
|
172
179
|
/**
|
|
@@ -182,10 +189,6 @@ export declare class DirectContext {
|
|
|
182
189
|
* Handle replacing an existing blob (track deletion of old blob)
|
|
183
190
|
*/
|
|
184
191
|
private handleBlobReplacement;
|
|
185
|
-
/**
|
|
186
|
-
* Categorize files into newly uploaded vs already on server based on server response
|
|
187
|
-
*/
|
|
188
|
-
private categorizeFiles;
|
|
189
192
|
/**
|
|
190
193
|
* Internal implementation of addToIndex
|
|
191
194
|
*/
|
|
@@ -280,4 +283,5 @@ export declare class DirectContext {
|
|
|
280
283
|
*/
|
|
281
284
|
exportToFile(filePath: string): Promise<void>;
|
|
282
285
|
}
|
|
283
|
-
|
|
286
|
+
|
|
287
|
+
export { DirectContext };
|