@augmentcode/auggie-sdk 0.1.6 → 0.1.8

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 (46) hide show
  1. package/dist/auggie/sdk-acp-client.d.ts +0 -102
  2. package/dist/auggie/sdk-acp-client.d.ts.map +1 -1
  3. package/dist/auggie/sdk-acp-client.js +1 -32
  4. package/dist/auggie/sdk-acp-client.js.map +1 -1
  5. package/dist/context/direct-context.d.ts +287 -0
  6. package/dist/context/direct-context.d.ts.map +1 -0
  7. package/dist/context/direct-context.js +624 -0
  8. package/dist/context/direct-context.js.map +1 -0
  9. package/dist/context/filesystem-context.d.ts +84 -0
  10. package/dist/context/filesystem-context.d.ts.map +1 -0
  11. package/dist/context/filesystem-context.js +198 -0
  12. package/dist/context/filesystem-context.js.map +1 -0
  13. package/dist/context/internal/__mocks__/api-client.d.ts +54 -0
  14. package/dist/context/internal/__mocks__/api-client.d.ts.map +1 -0
  15. package/dist/context/internal/__mocks__/api-client.js +96 -0
  16. package/dist/context/internal/__mocks__/api-client.js.map +1 -0
  17. package/dist/context/internal/api-client.d.ts +75 -0
  18. package/dist/context/internal/api-client.d.ts.map +1 -0
  19. package/dist/context/internal/api-client.js +218 -0
  20. package/dist/context/internal/api-client.js.map +1 -0
  21. package/dist/context/internal/blob-name-calculator.d.ts +14 -0
  22. package/dist/context/internal/blob-name-calculator.d.ts.map +1 -0
  23. package/dist/context/internal/blob-name-calculator.js +44 -0
  24. package/dist/context/internal/blob-name-calculator.js.map +1 -0
  25. package/dist/context/internal/retry-utils.d.ts +22 -0
  26. package/dist/context/internal/retry-utils.d.ts.map +1 -0
  27. package/dist/context/internal/retry-utils.js +88 -0
  28. package/dist/context/internal/retry-utils.js.map +1 -0
  29. package/dist/context/internal/search-utils.d.ts +8 -0
  30. package/dist/context/internal/search-utils.d.ts.map +1 -0
  31. package/dist/context/internal/search-utils.js +10 -0
  32. package/dist/context/internal/search-utils.js.map +1 -0
  33. package/dist/context/internal/session-reader.d.ts +17 -0
  34. package/dist/context/internal/session-reader.d.ts.map +1 -0
  35. package/dist/context/internal/session-reader.js +27 -0
  36. package/dist/context/internal/session-reader.js.map +1 -0
  37. package/dist/context/types.d.ts +113 -0
  38. package/dist/context/types.d.ts.map +1 -0
  39. package/dist/context/types.js +5 -0
  40. package/dist/context/types.js.map +1 -0
  41. package/dist/index.d.ts +6 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +7 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/version.js.map +1 -1
  46. package/package.json +2 -1
@@ -0,0 +1,218 @@
1
+ /**
2
+ * API client for Context operations
3
+ * Handles both indexing endpoints and LLM chat endpoint
4
+ */
5
+ import { v4 as uuidv4 } from "uuid";
6
+ import { getSDKVersion } from "../../version";
7
+ /**
8
+ * Error thrown when an API request fails
9
+ * Includes the HTTP status code to enable retry logic for transient failures
10
+ */
11
+ export class APIError extends Error {
12
+ constructor(status, statusText, message) {
13
+ super(message);
14
+ this.name = "APIError";
15
+ this.status = status;
16
+ this.statusText = statusText;
17
+ }
18
+ }
19
+ /**
20
+ * Get user agent string for Context API requests
21
+ */
22
+ export function getUserAgent() {
23
+ return `augment.sdk.context/${getSDKVersion()} (typescript)`;
24
+ }
25
+ /**
26
+ * API client for Context operations
27
+ */
28
+ export class ContextAPIClient {
29
+ constructor(options) {
30
+ this.apiKey = options.apiKey;
31
+ this.apiUrl = options.apiUrl;
32
+ this.sessionId = uuidv4();
33
+ this.debug = options.debug ?? false;
34
+ }
35
+ log(message) {
36
+ if (this.debug) {
37
+ console.log(`[ContextAPI] ${message}`);
38
+ }
39
+ }
40
+ createRequestId() {
41
+ return uuidv4();
42
+ }
43
+ async callApi(endpoint, payload) {
44
+ // Remove trailing slash from apiUrl if present
45
+ const baseUrl = this.apiUrl.endsWith("/")
46
+ ? this.apiUrl.slice(0, -1)
47
+ : this.apiUrl;
48
+ const url = `${baseUrl}/${endpoint}`;
49
+ const requestId = this.createRequestId();
50
+ this.log(`POST ${url}`);
51
+ this.log(`Request ID: ${requestId}`);
52
+ this.log(`Request: ${JSON.stringify(payload, null, 2)}`);
53
+ const response = await fetch(url, {
54
+ method: "POST",
55
+ headers: {
56
+ "Content-Type": "application/json",
57
+ Authorization: `Bearer ${this.apiKey}`,
58
+ "X-Request-Session-Id": this.sessionId,
59
+ "X-Request-Id": requestId,
60
+ "User-Agent": getUserAgent(),
61
+ },
62
+ body: JSON.stringify(payload),
63
+ });
64
+ if (!response.ok) {
65
+ const errorText = await response.text();
66
+ throw new APIError(response.status, response.statusText, `API request failed: ${response.status} ${response.statusText} - ${errorText}`);
67
+ }
68
+ const json = (await response.json());
69
+ this.log(`Response: ${JSON.stringify(json, null, 2)}`);
70
+ return json;
71
+ }
72
+ async findMissing(blobNames) {
73
+ const result = await this.callApi("find-missing", {
74
+ mem_object_names: blobNames,
75
+ });
76
+ return {
77
+ unknownBlobNames: result.unknown_memory_names || [],
78
+ nonindexedBlobNames: result.nonindexed_blob_names || [],
79
+ };
80
+ }
81
+ async batchUpload(blobs) {
82
+ const result = await this.callApi("batch-upload", {
83
+ blobs: blobs.map((blob) => ({
84
+ blob_name: blob.blobName,
85
+ path: blob.pathName,
86
+ content: blob.text,
87
+ })),
88
+ });
89
+ return {
90
+ blobNames: result.blob_names || [],
91
+ };
92
+ }
93
+ async checkpointBlobs(blobs) {
94
+ const result = await this.callApi("checkpoint-blobs", {
95
+ blobs: {
96
+ checkpoint_id: blobs.checkpointId ?? null,
97
+ added_blobs: blobs.addedBlobs,
98
+ deleted_blobs: blobs.deletedBlobs,
99
+ },
100
+ });
101
+ return {
102
+ newCheckpointId: result.new_checkpoint_id,
103
+ };
104
+ }
105
+ async agentCodebaseRetrieval(_requestId, query, blobs, maxOutputLength) {
106
+ const requestBody = {
107
+ information_request: query,
108
+ blobs: {
109
+ checkpoint_id: blobs.checkpointId ?? null,
110
+ added_blobs: blobs.addedBlobs,
111
+ deleted_blobs: blobs.deletedBlobs,
112
+ },
113
+ dialog: [],
114
+ };
115
+ if (maxOutputLength !== undefined) {
116
+ requestBody.max_output_length = maxOutputLength;
117
+ }
118
+ const result = await this.callApi("agents/codebase-retrieval", requestBody);
119
+ return {
120
+ formattedRetrieval: result.formatted_retrieval,
121
+ };
122
+ }
123
+ /**
124
+ * Parse a single JSON line from the stream and extract text if present
125
+ */
126
+ parseStreamLine(line) {
127
+ const trimmed = line.trim();
128
+ if (!trimmed) {
129
+ return null;
130
+ }
131
+ try {
132
+ const parsed = JSON.parse(trimmed);
133
+ if (parsed.text) {
134
+ return parsed.text;
135
+ }
136
+ }
137
+ catch {
138
+ // Skip invalid JSON lines
139
+ this.log(`Failed to parse stream line: ${trimmed}`);
140
+ }
141
+ return null;
142
+ }
143
+ /**
144
+ * Parse streaming response and accumulate text chunks
145
+ */
146
+ async parseSSEStream(body) {
147
+ const reader = body.getReader();
148
+ const decoder = new TextDecoder();
149
+ let accumulatedText = "";
150
+ try {
151
+ while (true) {
152
+ const { done, value } = await reader.read();
153
+ if (done)
154
+ break;
155
+ const chunk = decoder.decode(value, { stream: true });
156
+ const lines = chunk.split("\n");
157
+ for (const line of lines) {
158
+ const text = this.parseStreamLine(line);
159
+ if (text) {
160
+ accumulatedText += text;
161
+ }
162
+ }
163
+ }
164
+ }
165
+ finally {
166
+ reader.releaseLock();
167
+ }
168
+ return accumulatedText;
169
+ }
170
+ /**
171
+ * Call the LLM chat streaming API with a formatted prompt
172
+ *
173
+ * @param prompt - The formatted prompt to send to the LLM
174
+ * @returns The LLM's response text
175
+ */
176
+ async chat(prompt) {
177
+ // Remove trailing slash from apiUrl if present
178
+ const baseUrl = this.apiUrl.endsWith("/")
179
+ ? this.apiUrl.slice(0, -1)
180
+ : this.apiUrl;
181
+ const url = `${baseUrl}/chat-stream`;
182
+ const requestId = this.createRequestId();
183
+ this.log(`POST ${url}`);
184
+ this.log(`Request ID: ${requestId}`);
185
+ // Use simple message format for chat-stream
186
+ const payload = {
187
+ message: prompt,
188
+ chat_history: [],
189
+ conversation_id: this.sessionId,
190
+ };
191
+ this.log(`Request: ${JSON.stringify(payload, null, 2)}`);
192
+ const response = await fetch(url, {
193
+ method: "POST",
194
+ headers: {
195
+ "Content-Type": "application/json",
196
+ Authorization: `Bearer ${this.apiKey}`,
197
+ "X-Request-Session-Id": this.sessionId,
198
+ "X-Request-Id": requestId,
199
+ "conversation-id": this.sessionId,
200
+ "X-Mode": "sdk",
201
+ "User-Agent": getUserAgent(),
202
+ },
203
+ body: JSON.stringify(payload),
204
+ });
205
+ if (!response.ok) {
206
+ const errorText = await response.text();
207
+ throw new APIError(response.status, response.statusText, `API request failed: ${response.status} ${response.statusText} - ${errorText}`);
208
+ }
209
+ // Handle streaming response
210
+ if (!response.body) {
211
+ throw new Error("Response body is null");
212
+ }
213
+ const accumulatedText = await this.parseSSEStream(response.body);
214
+ this.log(`Response: ${accumulatedText}`);
215
+ return accumulatedText;
216
+ }
217
+ }
218
+ //# sourceMappingURL=api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../src/context/internal/api-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAIjC,YAAY,MAAc,EAAE,UAAkB,EAAE,OAAe;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAgCD;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,uBAAuB,aAAa,EAAE,eAAe,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,gBAAg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xC,MAAM,IAAI,QAAQ,CAChB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,UAAU,EACnB,uBAAuB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CAC/E,CAAC;QACJ,CAAC;QAED,4BAA4B;QAC5B,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEjE,IAAI,CAAC,GAAG,CAAC,aAAa,eAAe,EAAE,CAAC,CAAC;QACzC,OAAO,eAAe,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ export declare const blobNamingVersion = 2023102300;
2
+ export declare class BlobTooLargeError extends Error {
3
+ constructor(maxBlobSize: number);
4
+ }
5
+ export declare class BlobNameCalculator {
6
+ private readonly _textEncoder;
7
+ readonly maxBlobSize: number;
8
+ constructor(maxBlobSize: number);
9
+ private _hash;
10
+ calculateOrThrow(path: string, contents: string | Uint8Array, checkFileSize?: boolean): string;
11
+ calculate(path: string, contents: string | Uint8Array): string | undefined;
12
+ calculateNoThrow(path: string, contents: string | Uint8Array): string;
13
+ }
14
+ //# sourceMappingURL=blob-name-calculator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-name-calculator.d.ts","sourceRoot":"","sources":["../../../src/context/internal/blob-name-calculator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,aAAgB,CAAC;AAE/C,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,WAAW,EAAE,MAAM;CAGhC;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAElD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,WAAW,EAAE,MAAM;IAI/B,OAAO,CAAC,KAAK;IAOb,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,UAAU,EAC7B,aAAa,UAAO,GACnB,MAAM;IAeT,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS;IAQ1E,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM;CAGtE"}
@@ -0,0 +1,44 @@
1
+ import { createHash } from "node:crypto";
2
+ export const blobNamingVersion = 2023102300;
3
+ export class BlobTooLargeError extends Error {
4
+ constructor(maxBlobSize) {
5
+ super(`content exceeds maximum size of ${maxBlobSize}`);
6
+ }
7
+ }
8
+ export class BlobNameCalculator {
9
+ constructor(maxBlobSize) {
10
+ this._textEncoder = new TextEncoder();
11
+ this.maxBlobSize = maxBlobSize;
12
+ }
13
+ _hash(path, contents) {
14
+ const hash = createHash("sha256");
15
+ hash.update(path);
16
+ hash.update(contents);
17
+ return hash.digest("hex");
18
+ }
19
+ calculateOrThrow(path, contents, checkFileSize = true) {
20
+ let contentsBytes;
21
+ if (typeof contents === "string") {
22
+ contentsBytes = this._textEncoder.encode(contents);
23
+ }
24
+ else {
25
+ contentsBytes = contents;
26
+ }
27
+ if (checkFileSize && contentsBytes.length > this.maxBlobSize) {
28
+ throw new BlobTooLargeError(this.maxBlobSize);
29
+ }
30
+ return this._hash(path, contentsBytes);
31
+ }
32
+ calculate(path, contents) {
33
+ try {
34
+ return this.calculateOrThrow(path, contents, true);
35
+ }
36
+ catch {
37
+ return;
38
+ }
39
+ }
40
+ calculateNoThrow(path, contents) {
41
+ return this.calculateOrThrow(path, contents, false);
42
+ }
43
+ }
44
+ //# sourceMappingURL=blob-name-calculator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-name-calculator.js","sourceRoot":"","sources":["../../../src/context/internal/blob-name-calculator.ts"],"names":[],"mapp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B,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;IACH,CAAC;IAED,gBAAgB,CAAC,IAAY,EAAE,QAA6B;QAC1D,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Retry utilities with exponential backoff
3
+ * Based on clients/sidecar/libs/src/utils/promise-utils.ts
4
+ */
5
+ export type BackoffParams = {
6
+ initialMS: number;
7
+ mult: number;
8
+ maxMS: number;
9
+ maxTries?: number;
10
+ maxTotalMs?: number;
11
+ canRetry?: (e: unknown) => boolean;
12
+ };
13
+ /**
14
+ * Retry a function with exponential backoff
15
+ *
16
+ * @param fn The function to retry
17
+ * @param debug Whether to log debug messages
18
+ * @param backoffParams Backoff parameters
19
+ * @returns Promise that resolves to the function's return value
20
+ */
21
+ export declare function retryWithBackoff<T>(fn: () => Promise<T>, debug?: boolean, backoffParams?: BackoffParams): Promise<T>;
22
+ //# sourceMappingURL=retry-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-utils.d.ts","sourceRoot":"","sources":["../../../src/context/internal/retry-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;CACpC,CAAC;AA0CF;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,KAAK,UAAQ,EACb,aAAa,GAAE,aAAoC,GAClD,OAAO,CAAC,CAAC,CAAC,CAqDZ"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Retry utilities with exponential backoff
3
+ * Based on clients/sidecar/libs/src/utils/promise-utils.ts
4
+ */
5
+ const defaultBackoffParams = {
6
+ initialMS: 100,
7
+ mult: 2,
8
+ maxMS: 30000,
9
+ };
10
+ /**
11
+ * Delay for the specified number of milliseconds
12
+ */
13
+ function delayMs(ms) {
14
+ if (ms === 0) {
15
+ return Promise.resolve();
16
+ }
17
+ return new Promise((resolve) => {
18
+ setTimeout(resolve, ms);
19
+ });
20
+ }
21
+ /**
22
+ * Check if an error is retriable based on its properties
23
+ * Retriable errors include network errors and server errors (5xx)
24
+ */
25
+ function isRetriableError(e) {
26
+ // Check for HTTP status codes
27
+ if (e && typeof e === "object" && "status" in e) {
28
+ const status = e.status;
29
+ // Match the default VSCode client retry logic:
30
+ // - 499 (cancelled)
31
+ // - 503 (unavailable)
32
+ // - 5xx (unavailable)
33
+ //
34
+ // Note: We do NOT retry 429 or 504 by default
35
+ // (only chat streams retry those)
36
+ return status === 499 || status === 503 || (status >= 500 && status < 600);
37
+ }
38
+ return false;
39
+ }
40
+ /**
41
+ * Retry a function with exponential backoff
42
+ *
43
+ * @param fn The function to retry
44
+ * @param debug Whether to log debug messages
45
+ * @param backoffParams Backoff parameters
46
+ * @returns Promise that resolves to the function's return value
47
+ */
48
+ export async function retryWithBackoff(fn, debug = false, backoffParams = defaultBackoffParams) {
49
+ const canRetryFn = backoffParams.canRetry ?? isRetriableError;
50
+ let backoffMs = 0;
51
+ const startTime = Date.now();
52
+ for (let tries = 0;; tries++) {
53
+ try {
54
+ const ret = await fn();
55
+ if (tries > 0 && debug) {
56
+ console.log(`[RetryUtils] Operation succeeded after ${tries} transient failures`);
57
+ }
58
+ return ret;
59
+ }
60
+ catch (e) {
61
+ const currTryCount = tries + 1;
62
+ // Check if we have exceeded the max number of retries
63
+ if (backoffParams.maxTries !== undefined &&
64
+ currTryCount >= backoffParams.maxTries) {
65
+ throw e;
66
+ }
67
+ // Check if we should retry this error
68
+ if (!canRetryFn(e)) {
69
+ throw e;
70
+ }
71
+ // Calculate backoff delay
72
+ backoffMs =
73
+ backoffMs === 0
74
+ ? backoffParams.initialMS
75
+ : Math.min(backoffMs * backoffParams.mult, backoffParams.maxMS);
76
+ if (debug) {
77
+ console.log(`[RetryUtils] Operation failed with error ${e}, retrying in ${backoffMs} ms; retries = ${tries}`);
78
+ }
79
+ // Check if the backoff delay will exceed total time
80
+ if (backoffParams.maxTotalMs !== undefined &&
81
+ Date.now() - startTime + backoffMs > backoffParams.maxTotalMs) {
82
+ throw e;
83
+ }
84
+ await delayMs(backoffMs);
85
+ }
86
+ }
87
+ }
88
+ //# sourceMappingURL=retry-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-utils.js","sourceRoot":"","sources":["../../../src/context/internal/retry-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,MAAM,oBAAoB,GAAkB;IAC1C,SAAS,EAAE,GAAG;IACd,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,KAAM;CACd,CAAC;AAEF;;GAEG;AACH,SAAS,OAAO,CAAC,EAAU;IACzB,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACb,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,CAAU;IAClC,8BAA8B;IAC9B,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,MAAM,GAAI,CAAwB,CAAC,MAAM,CAAC;QAEhD,+CAA+C;QAC/C,oBAAoB;QACpB,s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I,CAAC,GAAG,CAAC,SAAS,GAAG,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;YAEpE,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CACT,4CAA4C,CAAC,iBAAiB,SAAS,kBAAkB,KAAK,EAAE,CACjG,CAAC;YACJ,CAAC;YAED,oDAAoD;YACpD,IACE,aAAa,CAAC,UAAU,KAAK,SAAS;gBACtC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC,UAAU,EAC7D,CAAC;gBACD,MAAM,CAAC,CAAC;YACV,CAAC;YAED,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared utilities for search functionality across context modes
3
+ */
4
+ /**
5
+ * Format a question and search results into a prompt for the LLM
6
+ */
7
+ export declare function formatSearchPrompt(question: string, results: string): string;
8
+ //# sourceMappingURL=search-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-utils.d.ts","sourceRoot":"","sources":["../../../src/context/internal/search-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5E"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared utilities for search functionality across context modes
3
+ */
4
+ /**
5
+ * Format a question and search results into a prompt for the LLM
6
+ */
7
+ export function formatSearchPrompt(question, results) {
8
+ return `Relevant context:\n${results}\n\n${question}`;
9
+ }
10
+ //# sourceMappingURL=search-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-utils.js","sourceRoot":"","sources":["../../../src/context/internal/search-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,OAAe;IAClE,OAAO,sBAAsB,OAAO,OAAO,QAAQ,EAAE,CAAC;AACxD,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Utility for reading Augment session file
3
+ */
4
+ /**
5
+ * Structure of the session.json file created by `auggie login`
6
+ */
7
+ export type SessionData = {
8
+ accessToken: string;
9
+ tenantURL: string;
10
+ scopes?: string[];
11
+ };
12
+ /**
13
+ * Read session data from ~/.augment/session.json
14
+ * Returns null if the file doesn't exist or can't be read
15
+ */
16
+ export declare function readSessionFile(): Promise<SessionData | null>;
17
+ //# sourceMappingURL=session-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-reader.d.ts","sourceRoot":"","sources":["../../../src/context/internal/session-reader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAgBnE"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Utility for reading Augment session file
3
+ */
4
+ import { readFile } from "node:fs/promises";
5
+ import { homedir } from "node:os";
6
+ import { join } from "node:path";
7
+ /**
8
+ * Read session data from ~/.augment/session.json
9
+ * Returns null if the file doesn't exist or can't be read
10
+ */
11
+ export async function readSessionFile() {
12
+ try {
13
+ const sessionPath = join(homedir(), ".augment", "session.json");
14
+ const content = await readFile(sessionPath, "utf-8");
15
+ const data = JSON.parse(content);
16
+ // Validate required fields
17
+ if (!(data.accessToken && data.tenantURL)) {
18
+ return null;
19
+ }
20
+ return data;
21
+ }
22
+ catch {
23
+ // File doesn't exist or can't be read
24
+ return null;
25
+ }
26
+ }
27
+ //# sourceMappingURL=session-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-reader.js","sourceRoot":"","sources":["../../../src/context/internal/session-reader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAgB,CAAC;QAEhD,2BAA2B;QAC3B,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Types for the Context SDK
3
+ */
4
+ /**
5
+ * Represents a file with path and contents (source-agnostic)
6
+ */
7
+ export type File = {
8
+ /** Relative path (e.g., "src/main.py") */
9
+ path: string;
10
+ /** File contents as string */
11
+ contents: string;
12
+ };
13
+ /**
14
+ * A single code chunk from the retrieval results
15
+ */
16
+ export type Chunk = {
17
+ /** File path relative to workspace root */
18
+ path: string;
19
+ /** Starting line number (1-based) */
20
+ startLine: number;
21
+ /** Ending line number (1-based, inclusive) */
22
+ endLine: number;
23
+ /** The code content */
24
+ contents: string;
25
+ };
26
+ /**
27
+ * Result from a codebase search query
28
+ */
29
+ export type SearchResult = {
30
+ /** Formatted retrieval results as markdown text */
31
+ formattedRetrieval: string;
32
+ /** Structured list of code chunks */
33
+ chunks: Chunk[];
34
+ };
35
+ /**
36
+ * Blob information for a file
37
+ */
38
+ export type BlobInfo = {
39
+ /** SHA-256 hash of the file path and contents */
40
+ blobName: string;
41
+ /** Relative path from workspace root */
42
+ relativePath: string;
43
+ };
44
+ /**
45
+ * Blob entry in persistent state - tuple of [blobName, path]
46
+ */
47
+ export type BlobEntry = [blobName: string, path: string];
48
+ /**
49
+ * Blobs payload for API requests
50
+ */
51
+ export type Blobs = {
52
+ /** Optional checkpoint ID from previous indexing */
53
+ checkpointId?: string;
54
+ /** List of added blob names */
55
+ addedBlobs: string[];
56
+ /** List of deleted blob names */
57
+ deletedBlobs: string[];
58
+ };
59
+ /**
60
+ * Result from addToIndex operation
61
+ */
62
+ export type IndexingResult = {
63
+ /** Paths that were newly uploaded to the backend (queued for indexing) */
64
+ newlyUploaded: string[];
65
+ /** Paths that were already uploaded (content unchanged or already on server) */
66
+ alreadyUploaded: string[];
67
+ };
68
+ /**
69
+ * Options for configuring the Direct Context
70
+ */
71
+ export type DirectContextOptions = {
72
+ /**
73
+ * API key for authentication
74
+ * Optional - falls back to AUGMENT_API_TOKEN env var, then ~/.augment/session.json
75
+ */
76
+ apiKey?: string;
77
+ /**
78
+ * API URL for your Augment tenant (e.g., "https://your-tenant.api.augmentcode.com")
79
+ * Optional - falls back to AUGMENT_API_URL env var, then ~/.augment/session.json
80
+ */
81
+ apiUrl?: string;
82
+ /**
83
+ * Enable debug logging to console.
84
+ * When enabled, logs key operations like uploads, checkpoints, and polling.
85
+ * Default: false
86
+ */
87
+ debug?: boolean;
88
+ };
89
+ /**
90
+ * State for Direct Context that can be exported/imported
91
+ */
92
+ export type DirectContextState = {
93
+ /** Current checkpoint ID */
94
+ checkpointId?: string;
95
+ /** Array of blob names that have been added (pending checkpoint) */
96
+ addedBlobs: string[];
97
+ /** Array of blob names that have been deleted (pending checkpoint) */
98
+ deletedBlobs: string[];
99
+ /** List of blobs as [blobName, path] tuples */
100
+ blobs: BlobEntry[];
101
+ };
102
+ /**
103
+ * Options for FileSystem Context (MCP mode)
104
+ */
105
+ export type FileSystemContextOptions = {
106
+ /** Path to the workspace directory to index */
107
+ directory: string;
108
+ /** Path to auggie executable (default: "auggie") */
109
+ auggiePath?: string;
110
+ /** Enable debug logging */
111
+ debug?: boolean;
112
+ };
113
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,mDAAmD;IACnD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qCAAqC;IACrC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iCAAiC;IACjC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,0EAA0E;IAC1E,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gFAAgF;IAChF,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,4BAA4B;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,sEAAsE;IACtE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the Context SDK
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
- export { Auggie, type PredefinedToolType, type ToolIdentifier, type ToolPermission, type ToolPermissionRule, } from "./auggie/sdk-acp-client";
1
+ export { Auggie, type PredefinedToolType, type ToolIdentifier, } from "./auggie/sdk-acp-client";
2
+ export { DirectContext } from "./context/direct-context";
3
+ export { FileSystemContext } from "./context/filesystem-context";
4
+ export { APIError } from "./context/internal/api-client";
5
+ export { BlobTooLargeError } from "./context/internal/blob-name-calculator";
6
+ export type { BlobEntry, BlobInfo, Blobs, DirectContextOptions, DirectContextState, File, FileSystemContextOptions, IndexingResult, } from "./context/types";
2
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACvB,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,YAAY,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,kBAAkB,EAClB,IAAI,EACJ,wBAAwB,EACxB,cAAc,GACf,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,9 @@
1
+ // ACP Client (existing)
1
2
  export { Auggie, } from "./auggie/sdk-acp-client";
3
+ // Context Modes
4
+ export { DirectContext } from "./context/direct-context";
5
+ export { FileSystemContext } from "./context/filesystem-context";
6
+ // Context Errors
7
+ export { APIError } from "./context/internal/api-client";
8
+ export { BlobTooLargeError } from "./context/internal/blob-name-calculator";
2
9
  //# sourceMappingURL=index.js.map