@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.
Files changed (61) hide show
  1. package/dist/auggie/sdk-acp-client.d.ts +7 -6
  2. package/dist/auggie/sdk-acp-client.js +299 -332
  3. package/dist/auggie/sdk-mcp-server.d.ts +5 -3
  4. package/dist/auggie/sdk-mcp-server.js +102 -112
  5. package/dist/context/direct-context.d.ts +19 -15
  6. package/dist/context/direct-context.js +556 -567
  7. package/dist/context/filesystem-context.d.ts +5 -3
  8. package/dist/context/filesystem-context.js +187 -209
  9. package/dist/context/internal/__mocks__/api-client.d.ts +17 -11
  10. package/dist/context/internal/__mocks__/api-client.js +104 -91
  11. package/dist/context/internal/api-client.d.ts +15 -15
  12. package/dist/context/internal/api-client.js +233 -224
  13. package/dist/context/internal/blob-name-calculator.d.ts +5 -4
  14. package/dist/context/internal/blob-name-calculator.js +41 -38
  15. package/dist/context/internal/chat-utils.d.ts +6 -3
  16. package/dist/context/internal/chat-utils.js +5 -18
  17. package/dist/context/internal/credentials.d.ts +5 -4
  18. package/dist/context/internal/credentials.js +24 -38
  19. package/dist/context/internal/retry-utils.d.ts +5 -4
  20. package/dist/context/internal/retry-utils.js +60 -114
  21. package/dist/context/internal/search-utils.d.ts +3 -2
  22. package/dist/context/internal/search-utils.js +8 -9
  23. package/dist/context/internal/session-reader.d.ts +4 -3
  24. package/dist/context/internal/session-reader.js +14 -22
  25. package/dist/context/types.d.ts +17 -12
  26. package/dist/context/types.js +0 -5
  27. package/dist/index.d.ts +8 -7
  28. package/dist/index.js +14 -9
  29. package/dist/version.d.ts +3 -2
  30. package/dist/version.js +24 -38
  31. package/package.json +3 -2
  32. package/dist/auggie/sdk-acp-client.d.ts.map +0 -1
  33. package/dist/auggie/sdk-acp-client.js.map +0 -1
  34. package/dist/auggie/sdk-mcp-server.d.ts.map +0 -1
  35. package/dist/auggie/sdk-mcp-server.js.map +0 -1
  36. package/dist/context/direct-context.d.ts.map +0 -1
  37. package/dist/context/direct-context.js.map +0 -1
  38. package/dist/context/filesystem-context.d.ts.map +0 -1
  39. package/dist/context/filesystem-context.js.map +0 -1
  40. package/dist/context/internal/__mocks__/api-client.d.ts.map +0 -1
  41. package/dist/context/internal/__mocks__/api-client.js.map +0 -1
  42. package/dist/context/internal/api-client.d.ts.map +0 -1
  43. package/dist/context/internal/api-client.js.map +0 -1
  44. package/dist/context/internal/blob-name-calculator.d.ts.map +0 -1
  45. package/dist/context/internal/blob-name-calculator.js.map +0 -1
  46. package/dist/context/internal/chat-utils.d.ts.map +0 -1
  47. package/dist/context/internal/chat-utils.js.map +0 -1
  48. package/dist/context/internal/credentials.d.ts.map +0 -1
  49. package/dist/context/internal/credentials.js.map +0 -1
  50. package/dist/context/internal/retry-utils.d.ts.map +0 -1
  51. package/dist/context/internal/retry-utils.js.map +0 -1
  52. package/dist/context/internal/search-utils.d.ts.map +0 -1
  53. package/dist/context/internal/search-utils.js.map +0 -1
  54. package/dist/context/internal/session-reader.d.ts.map +0 -1
  55. package/dist/context/internal/session-reader.js.map +0 -1
  56. package/dist/context/types.d.ts.map +0 -1
  57. package/dist/context/types.js.map +0 -1
  58. package/dist/index.d.ts.map +0 -1
  59. package/dist/index.js.map +0 -1
  60. package/dist/version.d.ts.map +0 -1
  61. package/dist/version.js.map +0 -1
@@ -1,355 +1,322 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { existsSync } from "node:fs";
3
3
  import { Readable, Writable } from "node:stream";
4
- import { ClientSideConnection, ndJsonStream, PROTOCOL_VERSION, } from "@agentclientprotocol/sdk";
5
- import { getSDKVersion } from "../version";
6
- import { AuggieMCPServer } from "./sdk-mcp-server";
7
- /**
8
- * ACP Client for connecting to Auggie as an ACP server
9
- *
10
- * This client demonstrates how to:
11
- * 1. Launch Auggie in ACP mode
12
- * 2. Establish a bidirectional communication channel
13
- * 3. Initialize a session
14
- * 4. Send prompts and receive responses
15
- */
4
+ import {
5
+ ClientSideConnection,
6
+ ndJsonStream,
7
+ PROTOCOL_VERSION
8
+ } from "@agentclientprotocol/sdk";
9
+ import { getSDKVersion } from "../version.js";
10
+ import { AuggieMCPServer } from "./sdk-mcp-server.js";
16
11
  class Auggie {
17
- constructor({ auggiePath = "auggie", workspaceRoot, model = "haiku4.5", allowIndexing = true, apiKey, apiUrl = process.env.AUGMENT_API_URL || "https://api.augmentcode.com", rules, excludedTools, } = {}) {
18
- this.connection = null;
19
- this.sessionId = null;
20
- this.workspaceRoot = undefined;
21
- this.auggieProcess = null;
22
- this.sessionUpdateCallback = null;
23
- this.debug = false;
24
- this.mcpServer = null;
25
- this.auggiePath = auggiePath;
26
- this.workspaceRoot = workspaceRoot;
27
- this.model = model;
28
- this.allowIndexing = allowIndexing;
29
- this.apiKey = apiKey;
30
- this.apiUrl = apiUrl;
31
- this.rules = rules;
32
- this.excludedTools = excludedTools;
12
+ static PATH_SPLIT_REGEX = /\s+/;
13
+ connection = null;
14
+ sessionId = null;
15
+ auggiePath;
16
+ workspaceRoot = void 0;
17
+ auggieProcess = null;
18
+ sessionUpdateCallback = null;
19
+ debug = false;
20
+ mcpServer = null;
21
+ model;
22
+ allowIndexing;
23
+ apiKey;
24
+ apiUrl;
25
+ rules;
26
+ excludedTools;
27
+ constructor({
28
+ auggiePath = "auggie",
29
+ workspaceRoot,
30
+ model = "haiku4.5",
31
+ allowIndexing = true,
32
+ apiKey,
33
+ apiUrl = process.env.AUGMENT_API_URL || "https://api.augmentcode.com",
34
+ rules,
35
+ excludedTools
36
+ } = {}) {
37
+ this.auggiePath = auggiePath;
38
+ this.workspaceRoot = workspaceRoot;
39
+ this.model = model;
40
+ this.allowIndexing = allowIndexing;
41
+ this.apiKey = apiKey;
42
+ this.apiUrl = apiUrl;
43
+ this.rules = rules;
44
+ this.excludedTools = excludedTools;
45
+ }
46
+ /**
47
+ * Create and initialize a new Auggie instance
48
+ * This static factory method automatically connects and creates a session
49
+ */
50
+ static async create(options = {}) {
51
+ const instance = new Auggie(options);
52
+ await instance.connect();
53
+ const tools = options.tools || options.toolsMap;
54
+ await instance.createSession(tools);
55
+ return instance;
56
+ }
57
+ /**
58
+ * Connect to Auggie ACP server
59
+ */
60
+ async connect() {
61
+ const args = ["--acp", "--log-level=debug"];
62
+ if (this.model) {
63
+ args.push("--model", this.model);
33
64
  }
34
- /**
35
- * Create and initialize a new Auggie instance
36
- * This static factory method automatically connects and creates a session
37
- */
38
- static async create(options = {}) {
39
- const instance = new Auggie(options);
40
- await instance.connect();
41
- // Support both 'tools' and 'toolsMap' for backwards compatibility
42
- const tools = options.tools || options.toolsMap;
43
- await instance.createSession(tools);
44
- return instance;
65
+ if (this.allowIndexing) {
66
+ args.push("--allow-indexing");
45
67
  }
46
- /**
47
- * Connect to Auggie ACP server
48
- */
49
- async connect() {
50
- const args = ["--acp", "--log-level=debug"];
51
- if (this.model) {
52
- args.push("--model", this.model);
53
- }
54
- if (this.allowIndexing) {
55
- args.push("--allow-indexing");
56
- }
57
- if (this.workspaceRoot) {
58
- args.push("--workspace-root", this.workspaceRoot);
68
+ if (this.workspaceRoot) {
69
+ args.push("--workspace-root", this.workspaceRoot);
70
+ }
71
+ if (this.rules && this.rules.length > 0) {
72
+ for (const rulePath of this.rules) {
73
+ if (!existsSync(rulePath)) {
74
+ throw new Error(`Rule file does not exist: ${rulePath}`);
59
75
  }
60
- if (this.rules && this.rules.length > 0) {
61
- // Validate that all rule files exist before proceeding
62
- for (const rulePath of this.rules) {
63
- if (!existsSync(rulePath)) {
64
- throw new Error(`Rule file does not exist: ${rulePath}`);
65
- }
66
- args.push("--rules", rulePath);
67
- }
76
+ args.push("--rules", rulePath);
77
+ }
78
+ }
79
+ if (this.excludedTools && this.excludedTools.length > 0) {
80
+ for (const tool of this.excludedTools) {
81
+ args.push("--remove-tool", tool);
82
+ }
83
+ }
84
+ const pathParts = this.auggiePath.trim().split(Auggie.PATH_SPLIT_REGEX);
85
+ if (pathParts.length === 0 || !pathParts[0]) {
86
+ throw new Error("Invalid auggiePath: cannot be empty");
87
+ }
88
+ const command = pathParts[0];
89
+ const commandArgs = [...pathParts.slice(1), ...args];
90
+ const env = { ...process.env };
91
+ if (this.apiKey) {
92
+ env.AUGMENT_API_TOKEN = this.apiKey;
93
+ }
94
+ if (this.apiUrl) {
95
+ env.AUGMENT_API_URL = this.apiUrl;
96
+ }
97
+ this.auggieProcess = spawn(command, commandArgs, {
98
+ stdio: ["pipe", "pipe", "inherit"],
99
+ env
100
+ });
101
+ this.auggieProcess.on("error", (error) => {
102
+ console.error("Failed to start Auggie process:", error);
103
+ throw error;
104
+ });
105
+ this.auggieProcess.on("exit", (code, signal) => {
106
+ if (this.debug)
107
+ console.log(
108
+ `Auggie process exited with code ${code} and signal ${signal}`
109
+ );
110
+ });
111
+ if (!(this.auggieProcess.stdout && this.auggieProcess.stdin)) {
112
+ throw new Error("Failed to create stdio pipes for Auggie process");
113
+ }
114
+ const input = Readable.toWeb(
115
+ this.auggieProcess.stdout
116
+ );
117
+ const output = Writable.toWeb(this.auggieProcess.stdin);
118
+ const stream = ndJsonStream(output, input);
119
+ this.connection = new ClientSideConnection(
120
+ (agent) => this.createClient(agent),
121
+ stream
122
+ );
123
+ if (this.debug) {
124
+ console.log("Connected to Auggie ACP server");
125
+ }
126
+ await this.initializeConnection();
127
+ }
128
+ /**
129
+ * Create a Client implementation to handle agent requests
130
+ */
131
+ createClient(_agent) {
132
+ return {
133
+ // Handle session updates from the agent
134
+ sessionUpdate: (params) => {
135
+ if (this.sessionUpdateCallback) {
136
+ this.sessionUpdateCallback(params);
68
137
  }
69
- if (this.excludedTools && this.excludedTools.length > 0) {
70
- // Add each excluded tool as a separate --remove-tool argument
71
- for (const tool of this.excludedTools) {
72
- args.push("--remove-tool", tool);
138
+ return Promise.resolve();
139
+ },
140
+ // Handle permission requests from the agent
141
+ requestPermission: (params) => {
142
+ if (this.debug) console.log("Permission requested:", params);
143
+ if (params.options && params.options.length > 0) {
144
+ return Promise.resolve({
145
+ outcome: {
146
+ outcome: "selected",
147
+ optionId: params.options?.[0]?.name || ""
73
148
  }
149
+ });
74
150
  }
75
- // Parse auggiePath to handle cases where it includes arguments (e.g., "node /path/to/file.js")
76
- const pathParts = this.auggiePath.trim().split(Auggie.PATH_SPLIT_REGEX);
77
- if (pathParts.length === 0 || !pathParts[0]) {
78
- throw new Error("Invalid auggiePath: cannot be empty");
79
- }
80
- const command = pathParts[0];
81
- const commandArgs = [...pathParts.slice(1), ...args];
82
- // Build environment variables for the Auggie process
83
- const env = { ...process.env };
84
- if (this.apiKey) {
85
- env.AUGMENT_API_TOKEN = this.apiKey;
86
- }
87
- if (this.apiUrl) {
88
- env.AUGMENT_API_URL = this.apiUrl;
89
- }
90
- this.auggieProcess = spawn(command, commandArgs, {
91
- stdio: ["pipe", "pipe", "inherit"],
92
- env,
151
+ return Promise.resolve({
152
+ outcome: {
153
+ outcome: "cancelled"
154
+ }
93
155
  });
94
- // Handle process errors
95
- this.auggieProcess.on("error", (error) => {
96
- console.error("Failed to start Auggie process:", error);
97
- throw error;
98
- });
99
- this.auggieProcess.on("exit", (code, signal) => {
100
- if (this.debug)
101
- console.log(`Auggie process exited with code ${code} and signal ${signal}`);
102
- });
103
- // Create streams for ACP communication
104
- // Note: Auggie writes to stdout and reads from stdin
105
- if (!(this.auggieProcess.stdout && this.auggieProcess.stdin)) {
106
- throw new Error("Failed to create stdio pipes for Auggie process");
107
- }
108
- const input = Readable.toWeb(this.auggieProcess.stdout);
109
- const output = Writable.toWeb(this.auggieProcess.stdin);
110
- // Create ndjson stream for ACP protocol
111
- const stream = ndJsonStream(output, input);
112
- // Create client-side connection with a Client implementation
113
- this.connection = new ClientSideConnection((agent) => this.createClient(agent), stream);
114
- if (this.debug) {
115
- console.log("Connected to Auggie ACP server");
116
- }
117
- // Initialize the connection
118
- await this.initializeConnection();
156
+ }
157
+ };
158
+ }
159
+ /**
160
+ * Initialize the ACP connection
161
+ */
162
+ async initializeConnection() {
163
+ if (!this.connection) {
164
+ throw new Error("Not connected. Call connect() first.");
119
165
  }
120
- /**
121
- * Create a Client implementation to handle agent requests
122
- */
123
- createClient(_agent) {
124
- return {
125
- // Handle session updates from the agent
126
- sessionUpdate: (params) => {
127
- if (this.sessionUpdateCallback) {
128
- this.sessionUpdateCallback(params);
129
- }
130
- return Promise.resolve();
131
- },
132
- // Handle permission requests from the agent
133
- requestPermission: (params) => {
134
- // For this example, auto-select the first option if available
135
- // In a real implementation, you'd prompt the user
136
- if (this.debug)
137
- console.log("Permission requested:", params);
138
- if (params.options && params.options.length > 0) {
139
- return Promise.resolve({
140
- outcome: {
141
- outcome: "selected",
142
- optionId: params.options?.[0]?.name || "",
143
- },
144
- });
145
- }
146
- // If no options, return cancelled
147
- return Promise.resolve({
148
- outcome: {
149
- outcome: "cancelled",
150
- },
151
- });
152
- },
153
- };
166
+ if (this.debug) console.log("Initializing ACP connection...");
167
+ const initResponse = await this.connection.initialize({
168
+ protocolVersion: PROTOCOL_VERSION,
169
+ clientInfo: {
170
+ name: "auggie-sdk-typescript",
171
+ version: getSDKVersion()
172
+ },
173
+ clientCapabilities: {}
174
+ });
175
+ if (this.debug)
176
+ console.log("Initialized:", JSON.stringify(initResponse, null, 2));
177
+ }
178
+ /**
179
+ * Create a new session
180
+ */
181
+ async createSession(tools) {
182
+ if (!this.connection) {
183
+ throw new Error("Not connected. Call connect() first.");
154
184
  }
155
- /**
156
- * Initialize the ACP connection
157
- */
158
- async initializeConnection() {
159
- if (!this.connection) {
160
- throw new Error("Not connected. Call connect() first.");
161
- }
162
- if (this.debug)
163
- console.log("Initializing ACP connection...");
164
- const initResponse = await this.connection.initialize({
165
- protocolVersion: PROTOCOL_VERSION,
166
- clientInfo: {
167
- name: "auggie-sdk-typescript",
168
- version: getSDKVersion(),
169
- },
170
- clientCapabilities: {},
171
- });
172
- if (this.debug)
173
- console.log("Initialized:", JSON.stringify(initResponse, null, 2));
185
+ if (this.debug) console.log("Creating new session...");
186
+ const mcpServers = [];
187
+ if (tools && Object.keys(tools).length > 0) {
188
+ if (this.debug) console.log("Starting MCP server with provided tools...");
189
+ this.mcpServer = new AuggieMCPServer(tools, void 0);
190
+ const serverUrl = await this.mcpServer.start();
191
+ if (this.debug) console.log(`MCP server started at: ${serverUrl}`);
192
+ mcpServers.push({
193
+ type: "http",
194
+ name: "auggie_sdk",
195
+ url: serverUrl,
196
+ headers: []
197
+ });
174
198
  }
175
- /**
176
- * Create a new session
177
- */
178
- async createSession(tools) {
179
- if (!this.connection) {
180
- throw new Error("Not connected. Call connect() first.");
181
- }
182
- if (this.debug)
183
- console.log("Creating new session...");
184
- // Build MCP servers array for the session
185
- const mcpServers = [];
186
- // If tools are provided, create and start an MCP server
187
- if (tools && Object.keys(tools).length > 0) {
188
- if (this.debug)
189
- console.log("Starting MCP server with provided tools...");
190
- this.mcpServer = new AuggieMCPServer(tools, undefined);
191
- const serverUrl = await this.mcpServer.start();
192
- if (this.debug)
193
- console.log(`MCP server started at: ${serverUrl}`);
194
- // Add the MCP server to the session configuration
195
- mcpServers.push({
196
- type: "http",
197
- name: "auggie_sdk",
198
- url: serverUrl,
199
- headers: [],
200
- });
201
- }
202
- const sessionResponse = await this.connection.newSession({
203
- cwd: this.workspaceRoot ? this.workspaceRoot : process.cwd(),
204
- mcpServers,
205
- });
206
- this.sessionId = sessionResponse.sessionId;
207
- if (this.debug) {
208
- console.log(`Session created: ${this.sessionId}`);
209
- console.log(" Available modes:", sessionResponse.modes?.availableModes);
210
- }
211
- return this.sessionId;
199
+ const sessionResponse = await this.connection.newSession({
200
+ cwd: this.workspaceRoot ? this.workspaceRoot : process.cwd(),
201
+ mcpServers
202
+ });
203
+ this.sessionId = sessionResponse.sessionId;
204
+ if (this.debug) {
205
+ console.log(`Session created: ${this.sessionId}`);
206
+ console.log(" Available modes:", sessionResponse.modes?.availableModes);
212
207
  }
213
- /**
214
- * Send a prompt to the agent and accumulate the text response
215
- * @param message - The text prompt to send to the agent
216
- * @param isAnswerOnly - If true, returns only the final response after all tool calls complete.
217
- * If false or undefined, returns all agent message chunks (default: false)
218
- * @returns The accumulated text response from the agent
219
- */
220
- async prompt(message, { isAnswerOnly = false } = {
221
- isAnswerOnly: false,
222
- }) {
223
- if (!(this.connection && this.sessionId)) {
224
- throw new Error("Not connected or no session. Initialization failed.");
225
- }
226
- if (this.debug)
227
- console.log(`\nSending prompt: "${message}"`);
228
- // Accumulator for text responses
229
- let accumulatedText = "";
230
- // Track the final response separately (text after the last tool call)
231
- let finalResponseText = "";
232
- // Track if we've seen a tool call
233
- let hasSeenToolCall = false;
234
- // Temporary callback to accumulate text
235
- const originalCallback = this.sessionUpdateCallback;
236
- const accumulatorCallback = (update) => {
237
- // Track tool calls to know when to start capturing final response
238
- if (update.update.sessionUpdate === "tool_call") {
239
- hasSeenToolCall = true;
240
- // Reset final response text when a new tool call starts
241
- finalResponseText = "";
242
- }
243
- // Accumulate text content
244
- if (update.update.sessionUpdate === "agent_message_chunk" &&
245
- update.update.content.type === "text") {
246
- const textChunk = update.update.content.text;
247
- accumulatedText += textChunk;
248
- // If we've seen a tool call, accumulate text for final response
249
- // This captures the agent's response after tool execution
250
- if (hasSeenToolCall) {
251
- finalResponseText += textChunk;
252
- }
253
- }
254
- // Also call the original callback if it exists
255
- if (originalCallback) {
256
- originalCallback(update);
257
- }
258
- };
259
- // Temporarily replace the callback
260
- this.sessionUpdateCallback = accumulatorCallback;
261
- try {
262
- // Build content blocks
263
- const content = [
264
- {
265
- type: "text",
266
- text: message,
267
- },
268
- ];
269
- // Send the prompt and wait for response
270
- const response = await this.connection.prompt({
271
- sessionId: this.sessionId,
272
- prompt: content,
273
- });
274
- if (this.debug)
275
- console.log("Prompt completed with stop reason:", response.stopReason);
276
- // Restore original callback
277
- this.sessionUpdateCallback = originalCallback;
278
- // Return final response if requested and we had tool calls, otherwise return all text
279
- if (isAnswerOnly && hasSeenToolCall) {
280
- return finalResponseText;
281
- }
282
- return accumulatedText;
208
+ return this.sessionId;
209
+ }
210
+ /**
211
+ * Send a prompt to the agent and accumulate the text response
212
+ * @param message - The text prompt to send to the agent
213
+ * @param isAnswerOnly - If true, returns only the final response after all tool calls complete.
214
+ * If false or undefined, returns all agent message chunks (default: false)
215
+ * @returns The accumulated text response from the agent
216
+ */
217
+ async prompt(message, { isAnswerOnly = false } = {
218
+ isAnswerOnly: false
219
+ }) {
220
+ if (!(this.connection && this.sessionId)) {
221
+ throw new Error("Not connected or no session. Initialization failed.");
222
+ }
223
+ if (this.debug) console.log(`
224
+ Sending prompt: "${message}"`);
225
+ let accumulatedText = "";
226
+ let finalResponseText = "";
227
+ let hasSeenToolCall = false;
228
+ const originalCallback = this.sessionUpdateCallback;
229
+ const accumulatorCallback = (update) => {
230
+ if (update.update.sessionUpdate === "tool_call") {
231
+ hasSeenToolCall = true;
232
+ finalResponseText = "";
233
+ }
234
+ if (update.update.sessionUpdate === "agent_message_chunk" && update.update.content.type === "text") {
235
+ const textChunk = update.update.content.text;
236
+ accumulatedText += textChunk;
237
+ if (hasSeenToolCall) {
238
+ finalResponseText += textChunk;
283
239
  }
284
- catch (error) {
285
- console.error("Error during prompt:", error);
286
- // Restore original callback before closing
287
- this.sessionUpdateCallback = originalCallback;
288
- // Kill the process on error
289
- await this.close();
290
- throw error;
240
+ }
241
+ if (originalCallback) {
242
+ originalCallback(update);
243
+ }
244
+ };
245
+ this.sessionUpdateCallback = accumulatorCallback;
246
+ try {
247
+ const content = [
248
+ {
249
+ type: "text",
250
+ text: message
291
251
  }
252
+ ];
253
+ const response = await this.connection.prompt({
254
+ sessionId: this.sessionId,
255
+ prompt: content
256
+ });
257
+ if (this.debug)
258
+ console.log("Prompt completed with stop reason:", response.stopReason);
259
+ this.sessionUpdateCallback = originalCallback;
260
+ if (isAnswerOnly && hasSeenToolCall) {
261
+ return finalResponseText;
262
+ }
263
+ return accumulatedText;
264
+ } catch (error) {
265
+ console.error("Error during prompt:", error);
266
+ this.sessionUpdateCallback = originalCallback;
267
+ await this.close();
268
+ throw error;
292
269
  }
293
- /**
294
- * Listen for session update events from the agent
295
- */
296
- onSessionUpdate(callback) {
297
- this.sessionUpdateCallback = callback;
270
+ }
271
+ /**
272
+ * Listen for session update events from the agent
273
+ */
274
+ onSessionUpdate(callback) {
275
+ this.sessionUpdateCallback = callback;
276
+ }
277
+ /**
278
+ * Cancel the current request
279
+ */
280
+ async cancel() {
281
+ if (!(this.connection && this.sessionId)) {
282
+ throw new Error("Not connected or no session.");
298
283
  }
299
- /**
300
- * Cancel the current request
301
- */
302
- async cancel() {
303
- if (!(this.connection && this.sessionId)) {
304
- throw new Error("Not connected or no session.");
305
- }
306
- if (this.debug)
307
- console.log(" Cancelling current request...");
308
- await this.connection.cancel({
309
- sessionId: this.sessionId,
310
- });
311
- if (this.debug)
312
- console.log(" Request cancelled");
284
+ if (this.debug) console.log(" Cancelling current request...");
285
+ await this.connection.cancel({
286
+ sessionId: this.sessionId
287
+ });
288
+ if (this.debug) console.log(" Request cancelled");
289
+ }
290
+ /**
291
+ * Close the connection and kill the Auggie process
292
+ */
293
+ async close() {
294
+ if (this.debug) console.log(" Closing connection...");
295
+ this.killProcess();
296
+ if (this.mcpServer) {
297
+ if (this.debug) console.log(" Stopping MCP server...");
298
+ await Promise.race([
299
+ this.mcpServer.stop(),
300
+ new Promise((resolve) => setTimeout(resolve, 100))
301
+ ]);
302
+ this.mcpServer = null;
313
303
  }
314
- /**
315
- * Close the connection and kill the Auggie process
316
- */
317
- async close() {
318
- if (this.debug)
319
- console.log(" Closing connection...");
320
- // Kill the Auggie process first - this will naturally close all MCP connections
321
- this.killProcess();
322
- // Stop the MCP server (should be fast since Auggie is already killed)
323
- if (this.mcpServer) {
324
- if (this.debug)
325
- console.log(" Stopping MCP server...");
326
- // Use a short timeout since the connections are already closed
327
- await Promise.race([
328
- this.mcpServer.stop(),
329
- new Promise((resolve) => setTimeout(resolve, 100)),
330
- ]);
331
- this.mcpServer = null;
332
- }
333
- // Clean up connection state
334
- if (this.connection) {
335
- this.connection = null;
336
- this.sessionId = null;
337
- }
338
- if (this.debug)
339
- console.log(" Connection closed");
304
+ if (this.connection) {
305
+ this.connection = null;
306
+ this.sessionId = null;
340
307
  }
341
- /**
342
- * Kill the Auggie process if it's still running
343
- */
344
- killProcess() {
345
- if (this.auggieProcess && !this.auggieProcess.killed) {
346
- if (this.debug)
347
- console.log(" Killing Auggie process...");
348
- // Use SIGKILL for immediate termination
349
- this.auggieProcess.kill("SIGKILL");
350
- }
308
+ if (this.debug) console.log(" Connection closed");
309
+ }
310
+ /**
311
+ * Kill the Auggie process if it's still running
312
+ */
313
+ killProcess() {
314
+ if (this.auggieProcess && !this.auggieProcess.killed) {
315
+ if (this.debug) console.log(" Killing Auggie process...");
316
+ this.auggieProcess.kill("SIGKILL");
351
317
  }
318
+ }
352
319
  }
353
- Auggie.PATH_SPLIT_REGEX = /\s+/;
354
- export { Auggie };
355
- //# sourceMappingURL=sdk-acp-client.js.map
320
+ export {
321
+ Auggie
322
+ };