@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,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FileSystemContextOptions } from './types.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* FileSystem Context - Local directory retrieval via MCP protocol
|
|
4
5
|
*
|
|
@@ -9,7 +10,7 @@ import type { FileSystemContextOptions } from "./types";
|
|
|
9
10
|
* This class spawns `auggie --mcp` and communicates with it via the MCP protocol
|
|
10
11
|
* to provide codebase retrieval from a local directory.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
declare class FileSystemContext {
|
|
13
14
|
private readonly auggiePath;
|
|
14
15
|
private readonly directory;
|
|
15
16
|
private readonly debug;
|
|
@@ -84,4 +85,5 @@ export declare class FileSystemContext {
|
|
|
84
85
|
*/
|
|
85
86
|
close(): Promise<void>;
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
|
|
89
|
+
export { FileSystemContext };
|
|
@@ -1,220 +1,198 @@
|
|
|
1
1
|
import { MCPClient } from "@mastra/mcp";
|
|
2
|
-
import { ContextAPIClient } from "./internal/api-client";
|
|
3
|
-
import { chatWithRetry } from "./internal/chat-utils";
|
|
4
|
-
import { resolveCredentials } from "./internal/credentials";
|
|
5
|
-
import { formatSearchPrompt } from "./internal/search-utils";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
import { ContextAPIClient } from "./internal/api-client.js";
|
|
3
|
+
import { chatWithRetry } from "./internal/chat-utils.js";
|
|
4
|
+
import { resolveCredentials } from "./internal/credentials.js";
|
|
5
|
+
import { formatSearchPrompt } from "./internal/search-utils.js";
|
|
6
|
+
class FileSystemContext {
|
|
7
|
+
auggiePath;
|
|
8
|
+
directory;
|
|
9
|
+
debug;
|
|
10
|
+
apiKey;
|
|
11
|
+
apiUrl;
|
|
12
|
+
mcpClient = null;
|
|
13
|
+
apiClient = null;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new FileSystemContext instance
|
|
16
|
+
* @param options Configuration options
|
|
17
|
+
* @param apiKey API key for authentication
|
|
18
|
+
* @param apiUrl API URL for the tenant
|
|
19
|
+
*/
|
|
20
|
+
constructor(options, apiKey, apiUrl) {
|
|
21
|
+
this.auggiePath = options.auggiePath || "auggie";
|
|
22
|
+
this.directory = options.directory;
|
|
23
|
+
this.debug = options.debug ?? false;
|
|
24
|
+
this.apiKey = apiKey;
|
|
25
|
+
this.apiUrl = apiUrl;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create and initialize a new FileSystemContext instance
|
|
29
|
+
*/
|
|
30
|
+
static async create(options) {
|
|
31
|
+
let apiKey;
|
|
32
|
+
let apiUrl;
|
|
33
|
+
try {
|
|
34
|
+
const credentials = await resolveCredentials({});
|
|
35
|
+
apiKey = credentials.apiKey;
|
|
36
|
+
apiUrl = credentials.apiUrl;
|
|
37
|
+
} catch {
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
apiKey = credentials.apiKey;
|
|
43
|
-
apiUrl = credentials.apiUrl;
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// Credentials are optional for FileSystemContext
|
|
47
|
-
// They're only required if searchAndAsk() is called
|
|
48
|
-
}
|
|
49
|
-
const instance = new FileSystemContext(options, apiKey, apiUrl);
|
|
50
|
-
await Promise.resolve(instance.connect());
|
|
51
|
-
return instance;
|
|
39
|
+
const instance = new FileSystemContext(options, apiKey, apiUrl);
|
|
40
|
+
await Promise.resolve(instance.connect());
|
|
41
|
+
return instance;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Log a debug message if debug mode is enabled
|
|
45
|
+
*/
|
|
46
|
+
log(message) {
|
|
47
|
+
if (this.debug) {
|
|
48
|
+
console.log(`[FileSystemContext] ${message}`);
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Connect to Auggie MCP server
|
|
53
|
+
*/
|
|
54
|
+
connect() {
|
|
55
|
+
this.log(`Starting MCP server for directory: ${this.directory}`);
|
|
56
|
+
const command = this.auggiePath.trim();
|
|
57
|
+
if (!command) {
|
|
58
|
+
throw new Error("Invalid auggiePath: cannot be empty");
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (!command) {
|
|
68
|
-
throw new Error("Invalid auggiePath: cannot be empty");
|
|
69
|
-
}
|
|
70
|
-
const args = ["--mcp", "--workspace-root", this.directory];
|
|
71
|
-
// Build environment variables
|
|
72
|
-
const env = {};
|
|
73
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
74
|
-
if (value !== undefined) {
|
|
75
|
-
env[key] = value;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (this.apiKey) {
|
|
79
|
-
env.AUGMENT_API_TOKEN = this.apiKey;
|
|
80
|
-
}
|
|
81
|
-
if (this.apiUrl) {
|
|
82
|
-
env.AUGMENT_API_URL = this.apiUrl;
|
|
83
|
-
}
|
|
84
|
-
// Create MCP client using MCPClient
|
|
85
|
-
this.mcpClient = new MCPClient({
|
|
86
|
-
servers: {
|
|
87
|
-
auggie: {
|
|
88
|
-
command,
|
|
89
|
-
args,
|
|
90
|
-
env,
|
|
91
|
-
logger: this.debug
|
|
92
|
-
? (logMessage) => {
|
|
93
|
-
console.log(`[MCP ${logMessage.level}] ${logMessage.message}`, logMessage.details);
|
|
94
|
-
}
|
|
95
|
-
: undefined,
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
this.log("Connected to Auggie MCP server");
|
|
60
|
+
const args = ["--mcp", "--workspace-root", this.directory];
|
|
61
|
+
const env = {};
|
|
62
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
63
|
+
if (value !== void 0) {
|
|
64
|
+
env[key] = value;
|
|
65
|
+
}
|
|
100
66
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*
|
|
104
|
-
* The results are returned as a formatted string designed for use in LLM prompts.
|
|
105
|
-
* The format includes file paths, line numbers, and code content in a structured,
|
|
106
|
-
* readable format that can be passed directly to LLM APIs like `generate()`.
|
|
107
|
-
*
|
|
108
|
-
* @param query - The search query describing what code you're looking for
|
|
109
|
-
* @returns A formatted string containing the search results, ready for LLM consumption
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* const context = await FileSystemContext.create({ directory: "./my-project" });
|
|
114
|
-
* const results = await context.search("authentication logic");
|
|
115
|
-
* console.log(results); // Formatted string with file paths, line numbers, and code
|
|
116
|
-
*
|
|
117
|
-
* // Use directly with generate API
|
|
118
|
-
* const response = await generate(
|
|
119
|
-
* `Based on this code:\n\n${results}\n\nHow does authentication work?`,
|
|
120
|
-
* { model: "sonnet4.5" }
|
|
121
|
-
* );
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
async search(query) {
|
|
125
|
-
if (!this.mcpClient) {
|
|
126
|
-
throw new Error("MCP client not initialized. Call create() first.");
|
|
127
|
-
}
|
|
128
|
-
this.log(`Searching for: "${query}"`);
|
|
129
|
-
try {
|
|
130
|
-
// Get the tools from the MCP client
|
|
131
|
-
// getTools() returns tools with server name prefix (auggie_codebase-retrieval)
|
|
132
|
-
const tools = await this.mcpClient.getTools();
|
|
133
|
-
const codebaseRetrievalTool = tools["auggie_codebase-retrieval"];
|
|
134
|
-
if (!codebaseRetrievalTool) {
|
|
135
|
-
throw new Error(`codebase-retrieval tool not found. Available tools: ${Object.keys(tools).join(", ")}`);
|
|
136
|
-
}
|
|
137
|
-
// Execute the MCP tool
|
|
138
|
-
//
|
|
139
|
-
// MCP Tool Input Format:
|
|
140
|
-
// Mastra MCP wraps tool parameters in a 'context' property:
|
|
141
|
-
// { context: { param1: value1, param2: value2, ... } }
|
|
142
|
-
//
|
|
143
|
-
// MCP Tool Output Format:
|
|
144
|
-
// MCP tools return results in the Model Context Protocol format:
|
|
145
|
-
// { content: [{ type: "text", text: "..." }, ...] }
|
|
146
|
-
// This allows tools to return multiple content blocks of different types.
|
|
147
|
-
const result = await codebaseRetrievalTool.execute({
|
|
148
|
-
context: {
|
|
149
|
-
information_request: query,
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
// Extract text from MCP result (standard MCP format)
|
|
153
|
-
if (!(result?.content && Array.isArray(result.content))) {
|
|
154
|
-
throw new Error(`Unexpected MCP response format: expected { content: [...] }, got ${JSON.stringify(result)}`);
|
|
155
|
-
}
|
|
156
|
-
const text = result.content
|
|
157
|
-
.filter((item) => item.type === "text")
|
|
158
|
-
.map((item) => item.text || "")
|
|
159
|
-
.join("\n");
|
|
160
|
-
this.log(`Search completed (${text.length} characters)`);
|
|
161
|
-
return text;
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
throw new Error(`Codebase retrieval failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
165
|
-
}
|
|
67
|
+
if (this.apiKey) {
|
|
68
|
+
env.AUGMENT_API_TOKEN = this.apiKey;
|
|
166
69
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
* console.log(answer);
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
async searchAndAsk(searchQuery, prompt) {
|
|
186
|
-
const results = await this.search(searchQuery);
|
|
187
|
-
const llmPrompt = formatSearchPrompt(prompt ?? searchQuery, results);
|
|
188
|
-
// Lazy initialization of API client
|
|
189
|
-
if (!this.apiClient) {
|
|
190
|
-
if (!(this.apiKey && this.apiUrl)) {
|
|
191
|
-
throw new Error("API credentials are required for searchAndAsk(). Provide them via:\n" +
|
|
192
|
-
"1. AUGMENT_API_TOKEN and AUGMENT_API_URL environment variables\n" +
|
|
193
|
-
"2. Run 'auggie login' to create ~/.augment/session.json");
|
|
194
|
-
}
|
|
195
|
-
this.apiClient = new ContextAPIClient({
|
|
196
|
-
apiKey: this.apiKey,
|
|
197
|
-
apiUrl: this.apiUrl,
|
|
198
|
-
debug: this.debug,
|
|
199
|
-
});
|
|
70
|
+
if (this.apiUrl) {
|
|
71
|
+
env.AUGMENT_API_URL = this.apiUrl;
|
|
72
|
+
}
|
|
73
|
+
this.mcpClient = new MCPClient({
|
|
74
|
+
servers: {
|
|
75
|
+
auggie: {
|
|
76
|
+
command,
|
|
77
|
+
args,
|
|
78
|
+
env,
|
|
79
|
+
logger: this.debug ? (logMessage) => {
|
|
80
|
+
console.log(
|
|
81
|
+
`[MCP ${logMessage.level}] ${logMessage.message}`,
|
|
82
|
+
logMessage.details
|
|
83
|
+
);
|
|
84
|
+
} : void 0
|
|
200
85
|
}
|
|
201
|
-
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
this.log("Connected to Auggie MCP server");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Search the codebase using natural language and return formatted results.
|
|
92
|
+
*
|
|
93
|
+
* The results are returned as a formatted string designed for use in LLM prompts.
|
|
94
|
+
* The format includes file paths, line numbers, and code content in a structured,
|
|
95
|
+
* readable format that can be passed directly to LLM APIs like `generate()`.
|
|
96
|
+
*
|
|
97
|
+
* @param query - The search query describing what code you're looking for
|
|
98
|
+
* @returns A formatted string containing the search results, ready for LLM consumption
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const context = await FileSystemContext.create({ directory: "./my-project" });
|
|
103
|
+
* const results = await context.search("authentication logic");
|
|
104
|
+
* console.log(results); // Formatted string with file paths, line numbers, and code
|
|
105
|
+
*
|
|
106
|
+
* // Use directly with generate API
|
|
107
|
+
* const response = await generate(
|
|
108
|
+
* `Based on this code:\n\n${results}\n\nHow does authentication work?`,
|
|
109
|
+
* { model: "sonnet4.5" }
|
|
110
|
+
* );
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
async search(query) {
|
|
114
|
+
if (!this.mcpClient) {
|
|
115
|
+
throw new Error("MCP client not initialized. Call create() first.");
|
|
202
116
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this.mcpClient = null;
|
|
117
|
+
this.log(`Searching for: "${query}"`);
|
|
118
|
+
try {
|
|
119
|
+
const tools = await this.mcpClient.getTools();
|
|
120
|
+
const codebaseRetrievalTool = tools["auggie_codebase-retrieval"];
|
|
121
|
+
if (!codebaseRetrievalTool) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`codebase-retrieval tool not found. Available tools: ${Object.keys(tools).join(", ")}`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
const result = await codebaseRetrievalTool.execute({
|
|
127
|
+
context: {
|
|
128
|
+
information_request: query
|
|
216
129
|
}
|
|
217
|
-
|
|
130
|
+
});
|
|
131
|
+
if (!(result?.content && Array.isArray(result.content))) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
`Unexpected MCP response format: expected { content: [...] }, got ${JSON.stringify(result)}`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const text = result.content.filter((item) => item.type === "text").map((item) => item.text || "").join("\n");
|
|
137
|
+
this.log(`Search completed (${text.length} characters)`);
|
|
138
|
+
return text;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
throw new Error(
|
|
141
|
+
`Codebase retrieval failed: ${error instanceof Error ? error.message : String(error)}`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Search the indexed codebase and ask an LLM a question about the results.
|
|
147
|
+
*
|
|
148
|
+
* This is a convenience method that combines search() with an LLM call to answer
|
|
149
|
+
* questions about your codebase.
|
|
150
|
+
*
|
|
151
|
+
* @param searchQuery - The semantic search query to find relevant code (also used as the prompt if no separate prompt is provided)
|
|
152
|
+
* @param prompt - Optional prompt to ask the LLM about the search results. If not provided, searchQuery is used as the prompt.
|
|
153
|
+
* @returns The LLM's answer to your question
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const answer = await context.searchAndAsk(
|
|
158
|
+
* "How does the authentication flow work?"
|
|
159
|
+
* );
|
|
160
|
+
* console.log(answer);
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
async searchAndAsk(searchQuery, prompt) {
|
|
164
|
+
const results = await this.search(searchQuery);
|
|
165
|
+
const llmPrompt = formatSearchPrompt(prompt ?? searchQuery, results);
|
|
166
|
+
if (!this.apiClient) {
|
|
167
|
+
if (!(this.apiKey && this.apiUrl)) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
"API credentials are required for searchAndAsk(). Provide them via:\n1. AUGMENT_API_TOKEN and AUGMENT_API_URL environment variables\n2. Run 'auggie login' to create ~/.augment/session.json"
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
this.apiClient = new ContextAPIClient({
|
|
173
|
+
apiKey: this.apiKey,
|
|
174
|
+
apiUrl: this.apiUrl,
|
|
175
|
+
debug: this.debug
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return await chatWithRetry(this.apiClient, llmPrompt, this.debug);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Close the MCP connection and cleanup resources
|
|
182
|
+
*/
|
|
183
|
+
async close() {
|
|
184
|
+
this.log("Closing MCP connection");
|
|
185
|
+
if (this.mcpClient) {
|
|
186
|
+
try {
|
|
187
|
+
await this.mcpClient.disconnect();
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error("Error closing MCP client:", error);
|
|
190
|
+
}
|
|
191
|
+
this.mcpClient = null;
|
|
218
192
|
}
|
|
193
|
+
this.log("MCP connection closed");
|
|
194
|
+
}
|
|
219
195
|
}
|
|
220
|
-
|
|
196
|
+
export {
|
|
197
|
+
FileSystemContext
|
|
198
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { Blobs } from '../../types.js';
|
|
2
|
+
import { ContextAPIClient, UploadBlob, FindMissingResult, BatchUploadResult, CheckpointBlobsResult, AgentCodebaseRetrievalResult } from '../api-client.js';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Mock implementation of ContextAPIClient for testing
|
|
3
6
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type MockAPIClientConfig = {
|
|
7
|
+
|
|
8
|
+
type MockAPIClientConfig = {
|
|
7
9
|
/** Blobs that the server knows about (uploaded) */
|
|
8
10
|
knownBlobs?: Set<string>;
|
|
9
11
|
/** Blobs that are indexed (subset of knownBlobs) */
|
|
@@ -16,14 +18,17 @@ export type MockAPIClientConfig = {
|
|
|
16
18
|
shouldFailBatchUpload?: boolean;
|
|
17
19
|
/** Should checkpointBlobs throw an error? */
|
|
18
20
|
shouldFailCheckpoint?: boolean;
|
|
21
|
+
/** Function to transform blob IDs (simulates backend computing different IDs) */
|
|
22
|
+
blobIdTransform?: (blobId: string) => string;
|
|
19
23
|
};
|
|
20
|
-
|
|
21
|
-
private knownBlobs;
|
|
22
|
-
private indexedBlobs;
|
|
23
|
-
private delay;
|
|
24
|
-
private shouldFailFindMissing;
|
|
25
|
-
private shouldFailBatchUpload;
|
|
26
|
-
private shouldFailCheckpoint;
|
|
24
|
+
declare class MockContextAPIClient extends ContextAPIClient {
|
|
25
|
+
private readonly knownBlobs;
|
|
26
|
+
private readonly indexedBlobs;
|
|
27
|
+
private readonly delay;
|
|
28
|
+
private readonly shouldFailFindMissing;
|
|
29
|
+
private readonly shouldFailBatchUpload;
|
|
30
|
+
private readonly shouldFailCheckpoint;
|
|
31
|
+
private readonly blobIdTransform?;
|
|
27
32
|
findMissingCalls: string[][];
|
|
28
33
|
batchUploadCalls: UploadBlob[][];
|
|
29
34
|
checkpointBlobsCalls: Blobs[];
|
|
@@ -46,4 +51,5 @@ export declare class MockContextAPIClient extends ContextAPIClient {
|
|
|
46
51
|
/** Reset all call tracking */
|
|
47
52
|
resetCalls(): void;
|
|
48
53
|
}
|
|
49
|
-
|
|
54
|
+
|
|
55
|
+
export { type MockAPIClientConfig, MockContextAPIClient };
|