@augmentcode/auggie-sdk 0.1.10 → 0.1.12
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 +56 -1
- 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 +82 -22
- package/dist/context/direct-context.js +675 -562
- 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 +14 -11
- package/dist/context/internal/api-client.js +234 -239
- 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 +132 -13
- 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,40 +1,26 @@
|
|
|
1
|
-
import { readSessionFile } from "./session-reader";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @param options - Optional credential options
|
|
11
|
-
* @returns Resolved credentials
|
|
12
|
-
* @throws Error if credentials cannot be resolved
|
|
13
|
-
*/
|
|
14
|
-
export async function resolveCredentials(options = {}) {
|
|
15
|
-
let apiKey = options.apiKey || process.env.AUGMENT_API_TOKEN;
|
|
16
|
-
let apiUrl = options.apiUrl || process.env.AUGMENT_API_URL;
|
|
17
|
-
// If credentials not provided, try session.json
|
|
18
|
-
if (!(apiKey && apiUrl)) {
|
|
19
|
-
const session = await readSessionFile();
|
|
20
|
-
if (session) {
|
|
21
|
-
apiKey = apiKey || session.accessToken;
|
|
22
|
-
apiUrl = apiUrl || session.tenantURL;
|
|
23
|
-
}
|
|
1
|
+
import { readSessionFile } from "./session-reader.js";
|
|
2
|
+
async function resolveCredentials(options = {}) {
|
|
3
|
+
let apiKey = options.apiKey || process.env.AUGMENT_API_TOKEN;
|
|
4
|
+
let apiUrl = options.apiUrl || process.env.AUGMENT_API_URL;
|
|
5
|
+
if (!(apiKey && apiUrl)) {
|
|
6
|
+
const session = await readSessionFile();
|
|
7
|
+
if (session) {
|
|
8
|
+
apiKey = apiKey || session.accessToken;
|
|
9
|
+
apiUrl = apiUrl || session.tenantURL;
|
|
24
10
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return { apiKey, apiUrl };
|
|
11
|
+
}
|
|
12
|
+
if (!apiKey) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
"API key is required. Provide it via:\n1. options.apiKey parameter\n2. AUGMENT_API_TOKEN environment variable\n3. Run 'auggie login' to create ~/.augment/session.json"
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (!apiUrl) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
"API URL is required. Provide it via:\n1. options.apiUrl parameter\n2. AUGMENT_API_URL environment variable\n3. Run 'auggie login' to create ~/.augment/session.json"
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return { apiKey, apiUrl };
|
|
39
23
|
}
|
|
40
|
-
|
|
24
|
+
export {
|
|
25
|
+
resolveCredentials
|
|
26
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Retry utilities with exponential backoff
|
|
3
3
|
* Based on clients/sidecar/libs/src/utils/promise-utils.ts
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
type BackoffParams = {
|
|
6
6
|
initialMS: number;
|
|
7
7
|
mult: number;
|
|
8
8
|
maxMS: number;
|
|
@@ -18,7 +18,7 @@ export type BackoffParams = {
|
|
|
18
18
|
* @param backoffParams Backoff parameters
|
|
19
19
|
* @returns Promise that resolves to the function's return value
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
declare function retryWithBackoff<T>(fn: () => Promise<T>, debug?: boolean, backoffParams?: BackoffParams): Promise<T>;
|
|
22
22
|
/**
|
|
23
23
|
* Retry a chat function with exponential backoff
|
|
24
24
|
* Uses chat-specific retry logic that includes 429 and 529 status codes
|
|
@@ -28,5 +28,6 @@ export declare function retryWithBackoff<T>(fn: () => Promise<T>, debug?: boolea
|
|
|
28
28
|
* @param backoffParams Backoff parameters (defaults to chat-optimized settings)
|
|
29
29
|
* @returns Promise that resolves to the function's return value
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
declare function retryChat<T>(fn: () => Promise<T>, debug?: boolean, backoffParams?: BackoffParams): Promise<T>;
|
|
32
|
+
|
|
33
|
+
export { type BackoffParams, retryChat, retryWithBackoff };
|
|
@@ -1,125 +1,71 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retry utilities with exponential backoff
|
|
3
|
-
* Based on clients/sidecar/libs/src/utils/promise-utils.ts
|
|
4
|
-
*/
|
|
5
1
|
const defaultBackoffParams = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
initialMS: 100,
|
|
3
|
+
mult: 2,
|
|
4
|
+
maxMS: 3e4
|
|
9
5
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Delay for the specified number of milliseconds
|
|
12
|
-
*/
|
|
13
6
|
function delayMs(ms) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
if (ms === 0) {
|
|
8
|
+
return Promise.resolve();
|
|
9
|
+
}
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
setTimeout(resolve, ms);
|
|
12
|
+
});
|
|
20
13
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Check if an error is retriable based on its properties
|
|
23
|
-
* Retriable errors include network errors and server errors (5xx)
|
|
24
|
-
*/
|
|
25
14
|
function isRetriableError(e) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
|
15
|
+
if (e && typeof e === "object" && "status" in e) {
|
|
16
|
+
const status = e.status;
|
|
17
|
+
return status === 499 || status === 503 || status >= 500 && status < 600;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
39
20
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Check if an error is retriable for chat streaming endpoints
|
|
42
|
-
* Chat streams retry additional status codes beyond the default retry logic
|
|
43
|
-
*/
|
|
44
21
|
function isChatRetriableError(e) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// - 499 (cancelled)
|
|
51
|
-
// - 503 (unavailable)
|
|
52
|
-
// - 529 (overloaded)
|
|
53
|
-
// - 5xx (server errors)
|
|
54
|
-
return (status === 429 ||
|
|
55
|
-
status === 499 ||
|
|
56
|
-
status === 503 ||
|
|
57
|
-
status === 529 ||
|
|
58
|
-
(status >= 500 && status < 600));
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
22
|
+
if (e && typeof e === "object" && "status" in e) {
|
|
23
|
+
const status = e.status;
|
|
24
|
+
return status === 429 || status === 499 || status === 503 || status === 529 || status >= 500 && status < 600;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
61
27
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// Calculate backoff delay
|
|
94
|
-
backoffMs =
|
|
95
|
-
backoffMs === 0
|
|
96
|
-
? backoffParams.initialMS
|
|
97
|
-
: Math.min(backoffMs * backoffParams.mult, backoffParams.maxMS);
|
|
98
|
-
if (debug) {
|
|
99
|
-
console.log(`[RetryUtils] Operation failed with error ${e}, retrying in ${backoffMs} ms; retries = ${tries}`);
|
|
100
|
-
}
|
|
101
|
-
// Check if the backoff delay will exceed total time
|
|
102
|
-
if (backoffParams.maxTotalMs !== undefined &&
|
|
103
|
-
Date.now() - startTime + backoffMs > backoffParams.maxTotalMs) {
|
|
104
|
-
throw e;
|
|
105
|
-
}
|
|
106
|
-
await delayMs(backoffMs);
|
|
107
|
-
}
|
|
28
|
+
async function retryWithBackoff(fn, debug = false, backoffParams = defaultBackoffParams) {
|
|
29
|
+
const canRetryFn = backoffParams.canRetry ?? isRetriableError;
|
|
30
|
+
let backoffMs = 0;
|
|
31
|
+
const startTime = Date.now();
|
|
32
|
+
for (let tries = 0; ; tries++) {
|
|
33
|
+
try {
|
|
34
|
+
const ret = await fn();
|
|
35
|
+
if (tries > 0 && debug) {
|
|
36
|
+
console.log(
|
|
37
|
+
`[RetryUtils] Operation succeeded after ${tries} transient failures`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return ret;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
const currTryCount = tries + 1;
|
|
43
|
+
if (backoffParams.maxTries !== void 0 && currTryCount >= backoffParams.maxTries) {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
if (!canRetryFn(e)) {
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
backoffMs = backoffMs === 0 ? backoffParams.initialMS : Math.min(backoffMs * backoffParams.mult, backoffParams.maxMS);
|
|
50
|
+
if (debug) {
|
|
51
|
+
console.log(
|
|
52
|
+
`[RetryUtils] Operation failed with error ${e}, retrying in ${backoffMs} ms; retries = ${tries}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (backoffParams.maxTotalMs !== void 0 && Date.now() - startTime + backoffMs > backoffParams.maxTotalMs) {
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
58
|
+
await delayMs(backoffMs);
|
|
108
59
|
}
|
|
60
|
+
}
|
|
109
61
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* @param debug Whether to log debug messages
|
|
116
|
-
* @param backoffParams Backoff parameters (defaults to chat-optimized settings)
|
|
117
|
-
* @returns Promise that resolves to the function's return value
|
|
118
|
-
*/
|
|
119
|
-
export function retryChat(fn, debug = false, backoffParams = defaultBackoffParams) {
|
|
120
|
-
return retryWithBackoff(fn, debug, {
|
|
121
|
-
...backoffParams,
|
|
122
|
-
canRetry: isChatRetriableError,
|
|
123
|
-
});
|
|
62
|
+
function retryChat(fn, debug = false, backoffParams = defaultBackoffParams) {
|
|
63
|
+
return retryWithBackoff(fn, debug, {
|
|
64
|
+
...backoffParams,
|
|
65
|
+
canRetry: isChatRetriableError
|
|
66
|
+
});
|
|
124
67
|
}
|
|
125
|
-
|
|
68
|
+
export {
|
|
69
|
+
retryChat,
|
|
70
|
+
retryWithBackoff
|
|
71
|
+
};
|
|
@@ -4,5 +4,6 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Format a question and search results into a prompt for the LLM
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
declare function formatSearchPrompt(question: string, results: string): string;
|
|
8
|
+
|
|
9
|
+
export { formatSearchPrompt };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export function formatSearchPrompt(question, results) {
|
|
8
|
-
return `Relevant context:\n${results}\n\n${question}`;
|
|
1
|
+
function formatSearchPrompt(question, results) {
|
|
2
|
+
return `Relevant context:
|
|
3
|
+
${results}
|
|
4
|
+
|
|
5
|
+
${question}`;
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export {
|
|
8
|
+
formatSearchPrompt
|
|
9
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Structure of the session.json file created by `auggie login`
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
type SessionData = {
|
|
8
8
|
accessToken: string;
|
|
9
9
|
tenantURL: string;
|
|
10
10
|
scopes?: string[];
|
|
@@ -13,5 +13,6 @@ export type SessionData = {
|
|
|
13
13
|
* Read session data from ~/.augment/session.json
|
|
14
14
|
* Returns null if the file doesn't exist or can't be read
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
declare function readSessionFile(): Promise<SessionData | null>;
|
|
17
|
+
|
|
18
|
+
export { type SessionData, readSessionFile };
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility for reading Augment session file
|
|
3
|
-
*/
|
|
4
1
|
import { readFile } from "node:fs/promises";
|
|
5
2
|
import { homedir } from "node:os";
|
|
6
3
|
import { join } from "node:path";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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;
|
|
4
|
+
async function readSessionFile() {
|
|
5
|
+
try {
|
|
6
|
+
const sessionPath = join(homedir(), ".augment", "session.json");
|
|
7
|
+
const content = await readFile(sessionPath, "utf-8");
|
|
8
|
+
const data = JSON.parse(content);
|
|
9
|
+
if (!(data.accessToken && data.tenantURL)) {
|
|
10
|
+
return null;
|
|
25
11
|
}
|
|
12
|
+
return data;
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
26
16
|
}
|
|
27
|
-
|
|
17
|
+
export {
|
|
18
|
+
readSessionFile
|
|
19
|
+
};
|
package/dist/context/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents a file with path and contents (source-agnostic)
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
type File = {
|
|
8
8
|
/** Relative path (e.g., "src/main.py") */
|
|
9
9
|
path: string;
|
|
10
10
|
/** File contents as string */
|
|
@@ -13,7 +13,7 @@ export type File = {
|
|
|
13
13
|
/**
|
|
14
14
|
* A single code chunk from the retrieval results
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
type Chunk = {
|
|
17
17
|
/** File path relative to workspace root */
|
|
18
18
|
path: string;
|
|
19
19
|
/** Starting line number (1-based) */
|
|
@@ -26,7 +26,7 @@ export type Chunk = {
|
|
|
26
26
|
/**
|
|
27
27
|
* Result from a codebase search query
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
type SearchResult = {
|
|
30
30
|
/** Formatted retrieval results as markdown text */
|
|
31
31
|
formattedRetrieval: string;
|
|
32
32
|
/** Structured list of code chunks */
|
|
@@ -35,20 +35,28 @@ export type SearchResult = {
|
|
|
35
35
|
/**
|
|
36
36
|
* Blob information for a file
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
type BlobInfo = {
|
|
39
39
|
/** SHA-256 hash of the file path and contents */
|
|
40
40
|
blobName: string;
|
|
41
41
|
/** Relative path from workspace root */
|
|
42
42
|
relativePath: string;
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
-
* Blob entry in persistent state - tuple of [
|
|
45
|
+
* Blob entry in persistent state - tuple of [serverBlobId, path, clientBlobId?]
|
|
46
|
+
*
|
|
47
|
+
* The third element (clientBlobId) is optional for backwards compatibility.
|
|
48
|
+
* When present, it indicates the server computed a different blob ID than the client.
|
|
49
|
+
* When absent, assume clientBlobId === serverBlobId.
|
|
46
50
|
*/
|
|
47
|
-
|
|
51
|
+
type BlobEntry = [
|
|
52
|
+
serverBlobId: string,
|
|
53
|
+
path: string,
|
|
54
|
+
clientBlobId?: string
|
|
55
|
+
];
|
|
48
56
|
/**
|
|
49
57
|
* Blobs payload for API requests
|
|
50
58
|
*/
|
|
51
|
-
|
|
59
|
+
type Blobs = {
|
|
52
60
|
/** Optional checkpoint ID from previous indexing */
|
|
53
61
|
checkpointId?: string;
|
|
54
62
|
/** List of added blob names */
|
|
@@ -59,16 +67,85 @@ export type Blobs = {
|
|
|
59
67
|
/**
|
|
60
68
|
* Result from addToIndex operation
|
|
61
69
|
*/
|
|
62
|
-
|
|
70
|
+
type IndexingResult = {
|
|
63
71
|
/** Paths that were newly uploaded to the backend (queued for indexing) */
|
|
64
72
|
newlyUploaded: string[];
|
|
65
73
|
/** Paths that were already uploaded (content unchanged or already on server) */
|
|
66
74
|
alreadyUploaded: string[];
|
|
67
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Progress information for indexing operations
|
|
78
|
+
*/
|
|
79
|
+
type IndexingProgress = {
|
|
80
|
+
/**
|
|
81
|
+
* Current stage of the indexing operation
|
|
82
|
+
* - 'uploading': Files are being uploaded to the backend
|
|
83
|
+
* - 'indexing': Backend is processing and indexing the uploaded files
|
|
84
|
+
*/
|
|
85
|
+
stage: "uploading" | "indexing";
|
|
86
|
+
/**
|
|
87
|
+
* Number of files uploaded so far
|
|
88
|
+
*/
|
|
89
|
+
uploaded: number;
|
|
90
|
+
/**
|
|
91
|
+
* Number of files indexed so far
|
|
92
|
+
*/
|
|
93
|
+
indexed: number;
|
|
94
|
+
/**
|
|
95
|
+
* Total number of files to upload and index
|
|
96
|
+
*/
|
|
97
|
+
total: number;
|
|
98
|
+
/**
|
|
99
|
+
* Path of the file currently being processed (only available during upload stage)
|
|
100
|
+
*/
|
|
101
|
+
currentFile?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Total bytes uploaded so far (only available during upload stage)
|
|
104
|
+
*/
|
|
105
|
+
bytesUploaded?: number;
|
|
106
|
+
/**
|
|
107
|
+
* When the operation started
|
|
108
|
+
*/
|
|
109
|
+
startedAt: Date;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Options for addToIndex operation
|
|
113
|
+
*/
|
|
114
|
+
type AddToIndexOptions = {
|
|
115
|
+
/**
|
|
116
|
+
* If true (default), waits for the newly added files to be indexed before returning.
|
|
117
|
+
* If false, returns immediately after upload completes (indexing continues asynchronously).
|
|
118
|
+
* Default: true
|
|
119
|
+
*/
|
|
120
|
+
waitForIndexing?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Timeout in milliseconds for the indexing operation when waitForIndexing is true.
|
|
123
|
+
* If the backend does not finish indexing within this time, an error is thrown.
|
|
124
|
+
* Default: undefined (no timeout - waits indefinitely)
|
|
125
|
+
*
|
|
126
|
+
* Set this to a specific value (e.g., 600000 for 10 minutes) if you want to fail fast
|
|
127
|
+
* in case of backend issues or unexpectedly slow indexing.
|
|
128
|
+
*/
|
|
129
|
+
timeout?: number;
|
|
130
|
+
/**
|
|
131
|
+
* Optional callback to receive progress updates during the indexing operation.
|
|
132
|
+
* Called periodically with information about the current stage, files uploaded/indexed, etc.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* await context.addToIndex(files, {
|
|
137
|
+
* onProgress: (progress) => {
|
|
138
|
+
* console.log(`[${progress.stage}] Uploaded: ${progress.uploaded}/${progress.total}, Indexed: ${progress.indexed}/${progress.total}`);
|
|
139
|
+
* }
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
onProgress?: (progress: IndexingProgress) => void;
|
|
144
|
+
};
|
|
68
145
|
/**
|
|
69
146
|
* Options for configuring the Direct Context
|
|
70
147
|
*/
|
|
71
|
-
|
|
148
|
+
type DirectContextOptions = {
|
|
72
149
|
/**
|
|
73
150
|
* API key for authentication
|
|
74
151
|
* Optional - falls back to AUGMENT_API_TOKEN env var, then ~/.augment/session.json
|
|
@@ -87,9 +164,11 @@ export type DirectContextOptions = {
|
|
|
87
164
|
debug?: boolean;
|
|
88
165
|
};
|
|
89
166
|
/**
|
|
90
|
-
*
|
|
167
|
+
* Full state for Direct Context with all blob information
|
|
91
168
|
*/
|
|
92
|
-
|
|
169
|
+
type FullContextState = {
|
|
170
|
+
/** Discriminator for state type */
|
|
171
|
+
mode: "full";
|
|
93
172
|
/** Current checkpoint ID */
|
|
94
173
|
checkpointId?: string;
|
|
95
174
|
/** Array of blob names that have been added (pending checkpoint) */
|
|
@@ -99,10 +178,49 @@ export type DirectContextState = {
|
|
|
99
178
|
/** List of blobs as [blobName, path] tuples */
|
|
100
179
|
blobs: BlobEntry[];
|
|
101
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Lightweight search-only state without blob information
|
|
183
|
+
*
|
|
184
|
+
* This state format is optimized for search-only use cases and reduces
|
|
185
|
+
* storage size for large codebases by excluding the blobs array.
|
|
186
|
+
*
|
|
187
|
+
* Use this when you only need to search the index and don't need to:
|
|
188
|
+
* - Add new files to the index
|
|
189
|
+
* - Remove files from the index
|
|
190
|
+
* - Get the list of indexed paths
|
|
191
|
+
*/
|
|
192
|
+
type SearchOnlyContextState = {
|
|
193
|
+
/** Discriminator for state type */
|
|
194
|
+
mode: "search-only";
|
|
195
|
+
/** Current checkpoint ID */
|
|
196
|
+
checkpointId?: string;
|
|
197
|
+
/** Array of blob names that have been added (pending checkpoint) */
|
|
198
|
+
addedBlobs: string[];
|
|
199
|
+
/** Array of blob names that have been deleted (pending checkpoint) */
|
|
200
|
+
deletedBlobs: string[];
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* State for Direct Context that can be exported/imported
|
|
204
|
+
*
|
|
205
|
+
* Can be either full state (with blobs array) or search-only state (without blobs array).
|
|
206
|
+
* For backwards compatibility, states without a mode field are treated as full state.
|
|
207
|
+
*/
|
|
208
|
+
type DirectContextState = FullContextState | SearchOnlyContextState;
|
|
209
|
+
/**
|
|
210
|
+
* Options for exporting Direct Context state
|
|
211
|
+
*/
|
|
212
|
+
type ExportOptions = {
|
|
213
|
+
/**
|
|
214
|
+
* Export mode:
|
|
215
|
+
* - 'full': Include all blob information (default) - required for addToIndex/removeFromIndex
|
|
216
|
+
* - 'search-only': Exclude blob array for minimal storage - only supports search operations
|
|
217
|
+
*/
|
|
218
|
+
mode?: "full" | "search-only";
|
|
219
|
+
};
|
|
102
220
|
/**
|
|
103
221
|
* Options for FileSystem Context (MCP mode)
|
|
104
222
|
*/
|
|
105
|
-
|
|
223
|
+
type FileSystemContextOptions = {
|
|
106
224
|
/** Path to the workspace directory to index */
|
|
107
225
|
directory: string;
|
|
108
226
|
/** Path to auggie executable (default: "auggie") */
|
|
@@ -110,4 +228,5 @@ export type FileSystemContextOptions = {
|
|
|
110
228
|
/** Enable debug logging */
|
|
111
229
|
debug?: boolean;
|
|
112
230
|
};
|
|
113
|
-
|
|
231
|
+
|
|
232
|
+
export type { AddToIndexOptions, BlobEntry, BlobInfo, Blobs, Chunk, DirectContextOptions, DirectContextState, ExportOptions, File, FileSystemContextOptions, FullContextState, IndexingProgress, IndexingResult, SearchOnlyContextState, SearchResult };
|
package/dist/context/types.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { Auggie,
|
|
2
|
-
export { DirectContext } from
|
|
3
|
-
export { FileSystemContext } from
|
|
4
|
-
export { APIError } from
|
|
5
|
-
export { BlobTooLargeError } from
|
|
6
|
-
export
|
|
7
|
-
|
|
1
|
+
export { Auggie, PredefinedToolType, ToolIdentifier } from './auggie/sdk-acp-client.js';
|
|
2
|
+
export { DirectContext } from './context/direct-context.js';
|
|
3
|
+
export { FileSystemContext } from './context/filesystem-context.js';
|
|
4
|
+
export { APIError } from './context/internal/api-client.js';
|
|
5
|
+
export { BlobTooLargeError } from './context/internal/blob-name-calculator.js';
|
|
6
|
+
export { AddToIndexOptions, BlobEntry, BlobInfo, Blobs, DirectContextOptions, DirectContextState, ExportOptions, File, FileSystemContextOptions, FullContextState, IndexingProgress, IndexingResult, SearchOnlyContextState } from './context/types.js';
|
|
7
|
+
import '@agentclientprotocol/sdk';
|
|
8
|
+
import 'ai';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
|
|
1
|
+
import {
|
|
2
|
+
Auggie
|
|
3
|
+
} from "./auggie/sdk-acp-client.js";
|
|
4
|
+
import { DirectContext } from "./context/direct-context.js";
|
|
5
|
+
import { FileSystemContext } from "./context/filesystem-context.js";
|
|
6
|
+
import { APIError } from "./context/internal/api-client.js";
|
|
7
|
+
import { BlobTooLargeError } from "./context/internal/blob-name-calculator.js";
|
|
8
|
+
export {
|
|
9
|
+
APIError,
|
|
10
|
+
Auggie,
|
|
11
|
+
BlobTooLargeError,
|
|
12
|
+
DirectContext,
|
|
13
|
+
FileSystemContext
|
|
14
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -12,5 +12,6 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @returns The version string from package.json, or "unknown" if it cannot be read
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
declare function getSDKVersion(): string;
|
|
16
|
+
|
|
17
|
+
export { getSDKVersion };
|