@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,98 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import {
|
|
2
|
+
ContextAPIClient
|
|
3
|
+
} from "../api-client.js";
|
|
4
|
+
class MockContextAPIClient extends ContextAPIClient {
|
|
5
|
+
knownBlobs;
|
|
6
|
+
indexedBlobs;
|
|
7
|
+
delay;
|
|
8
|
+
shouldFailFindMissing;
|
|
9
|
+
shouldFailBatchUpload;
|
|
10
|
+
shouldFailCheckpoint;
|
|
11
|
+
blobIdTransform;
|
|
12
|
+
// Track method calls for assertions
|
|
13
|
+
findMissingCalls = [];
|
|
14
|
+
batchUploadCalls = [];
|
|
15
|
+
checkpointBlobsCalls = [];
|
|
16
|
+
agentCodebaseRetrievalCalls = [];
|
|
17
|
+
chatCalls = [];
|
|
18
|
+
constructor(config = {}) {
|
|
19
|
+
super({
|
|
20
|
+
apiKey: "mock-api-key",
|
|
21
|
+
apiUrl: "https://mock.api.augmentcode.com",
|
|
22
|
+
debug: false
|
|
23
|
+
});
|
|
24
|
+
this.knownBlobs = config.knownBlobs || /* @__PURE__ */ new Set();
|
|
25
|
+
this.indexedBlobs = config.indexedBlobs || /* @__PURE__ */ new Set();
|
|
26
|
+
this.delay = config.delay || 0;
|
|
27
|
+
this.shouldFailFindMissing = config.shouldFailFindMissing ?? false;
|
|
28
|
+
this.shouldFailBatchUpload = config.shouldFailBatchUpload ?? false;
|
|
29
|
+
this.shouldFailCheckpoint = config.shouldFailCheckpoint ?? false;
|
|
30
|
+
this.blobIdTransform = config.blobIdTransform;
|
|
31
|
+
}
|
|
32
|
+
createRequestId() {
|
|
33
|
+
return `mock-req-${Date.now()}`;
|
|
34
|
+
}
|
|
35
|
+
async simulateDelay() {
|
|
36
|
+
if (this.delay > 0) {
|
|
37
|
+
await new Promise((resolve) => setTimeout(resolve, this.delay));
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
}
|
|
40
|
+
async findMissing(blobNames) {
|
|
41
|
+
this.findMissingCalls.push([...blobNames]);
|
|
42
|
+
if (this.shouldFailFindMissing) {
|
|
43
|
+
throw new Error("Mock findMissing error");
|
|
28
44
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
await this.simulateDelay();
|
|
46
|
+
const unknownBlobNames = blobNames.filter(
|
|
47
|
+
(name) => !this.knownBlobs.has(name)
|
|
48
|
+
);
|
|
49
|
+
const nonindexedBlobNames = blobNames.filter(
|
|
50
|
+
(name) => this.knownBlobs.has(name) && !this.indexedBlobs.has(name)
|
|
51
|
+
);
|
|
52
|
+
return {
|
|
53
|
+
unknownBlobNames,
|
|
54
|
+
nonindexedBlobNames
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async batchUpload(blobs) {
|
|
58
|
+
this.batchUploadCalls.push([...blobs]);
|
|
59
|
+
if (this.shouldFailBatchUpload) {
|
|
60
|
+
throw new Error("Mock batchUpload error");
|
|
33
61
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const unknownBlobNames = blobNames.filter((name) => !this.knownBlobs.has(name));
|
|
41
|
-
const nonindexedBlobNames = blobNames.filter((name) => this.knownBlobs.has(name) && !this.indexedBlobs.has(name));
|
|
42
|
-
return {
|
|
43
|
-
unknownBlobNames,
|
|
44
|
-
nonindexedBlobNames,
|
|
45
|
-
};
|
|
62
|
+
await this.simulateDelay();
|
|
63
|
+
const blobNames = blobs.map(
|
|
64
|
+
(b) => this.blobIdTransform ? this.blobIdTransform(b.blobName) : b.blobName
|
|
65
|
+
);
|
|
66
|
+
for (const blobName of blobNames) {
|
|
67
|
+
this.knownBlobs.add(blobName);
|
|
46
68
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// Add uploaded blobs to known blobs (but not indexed yet)
|
|
54
|
-
const blobNames = blobs.map((b) => b.blobName);
|
|
55
|
-
for (const blobName of blobNames) {
|
|
56
|
-
this.knownBlobs.add(blobName);
|
|
57
|
-
}
|
|
58
|
-
return { blobNames };
|
|
69
|
+
return { blobNames };
|
|
70
|
+
}
|
|
71
|
+
async checkpointBlobs(blobs) {
|
|
72
|
+
this.checkpointBlobsCalls.push({ ...blobs });
|
|
73
|
+
if (this.shouldFailCheckpoint) {
|
|
74
|
+
throw new Error("Mock checkpointBlobs error");
|
|
59
75
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// Helper methods for test setup
|
|
83
|
-
/** Mark blobs as indexed (simulates backend indexing completion) */
|
|
84
|
-
markAsIndexed(blobNames) {
|
|
85
|
-
for (const blobName of blobNames) {
|
|
86
|
-
this.indexedBlobs.add(blobName);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/** Reset all call tracking */
|
|
90
|
-
resetCalls() {
|
|
91
|
-
this.findMissingCalls = [];
|
|
92
|
-
this.batchUploadCalls = [];
|
|
93
|
-
this.checkpointBlobsCalls = [];
|
|
94
|
-
this.agentCodebaseRetrievalCalls = [];
|
|
95
|
-
this.chatCalls = [];
|
|
76
|
+
await this.simulateDelay();
|
|
77
|
+
return {
|
|
78
|
+
newCheckpointId: `checkpoint-${Date.now()}`
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async agentCodebaseRetrieval(query, blobs, maxOutputLength) {
|
|
82
|
+
this.agentCodebaseRetrievalCalls.push({ query, blobs, maxOutputLength });
|
|
83
|
+
await this.simulateDelay();
|
|
84
|
+
return {
|
|
85
|
+
formattedRetrieval: `Mock search results for: ${query}`
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async chat(prompt) {
|
|
89
|
+
this.chatCalls.push(prompt);
|
|
90
|
+
await this.simulateDelay();
|
|
91
|
+
return `Mock LLM response to: ${prompt}`;
|
|
92
|
+
}
|
|
93
|
+
// Helper methods for test setup
|
|
94
|
+
/** Mark blobs as indexed (simulates backend indexing completion) */
|
|
95
|
+
markAsIndexed(blobNames) {
|
|
96
|
+
for (const blobName of blobNames) {
|
|
97
|
+
this.indexedBlobs.add(blobName);
|
|
96
98
|
}
|
|
99
|
+
}
|
|
100
|
+
/** Reset all call tracking */
|
|
101
|
+
resetCalls() {
|
|
102
|
+
this.findMissingCalls = [];
|
|
103
|
+
this.batchUploadCalls = [];
|
|
104
|
+
this.checkpointBlobsCalls = [];
|
|
105
|
+
this.agentCodebaseRetrievalCalls = [];
|
|
106
|
+
this.chatCalls = [];
|
|
107
|
+
}
|
|
97
108
|
}
|
|
98
|
-
|
|
109
|
+
export {
|
|
110
|
+
MockContextAPIClient
|
|
111
|
+
};
|
|
@@ -1,37 +1,39 @@
|
|
|
1
|
+
import { Blobs } from '../types.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* API client for Context operations
|
|
3
5
|
* Handles both indexing endpoints and LLM chat endpoint
|
|
4
6
|
*/
|
|
5
|
-
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* Error thrown when an API request fails
|
|
8
10
|
* Includes the HTTP status code to enable retry logic for transient failures
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
declare class APIError extends Error {
|
|
11
13
|
readonly status: number;
|
|
12
14
|
readonly statusText: string;
|
|
13
15
|
constructor(status: number, statusText: string, message: string);
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
type UploadBlob = {
|
|
16
18
|
blobName: string;
|
|
17
19
|
pathName: string;
|
|
18
20
|
text: string;
|
|
19
21
|
metadata: string[];
|
|
20
22
|
};
|
|
21
|
-
|
|
23
|
+
type FindMissingResult = {
|
|
22
24
|
unknownBlobNames: string[];
|
|
23
25
|
nonindexedBlobNames: string[];
|
|
24
26
|
};
|
|
25
|
-
|
|
27
|
+
type CheckpointBlobsResult = {
|
|
26
28
|
newCheckpointId: string;
|
|
27
29
|
};
|
|
28
|
-
|
|
30
|
+
type BatchUploadResult = {
|
|
29
31
|
blobNames: string[];
|
|
30
32
|
};
|
|
31
|
-
|
|
33
|
+
type AgentCodebaseRetrievalResult = {
|
|
32
34
|
formattedRetrieval: string;
|
|
33
35
|
};
|
|
34
|
-
|
|
36
|
+
type ContextAPIClientOptions = {
|
|
35
37
|
apiKey: string;
|
|
36
38
|
apiUrl: string;
|
|
37
39
|
debug?: boolean;
|
|
@@ -39,11 +41,11 @@ export type ContextAPIClientOptions = {
|
|
|
39
41
|
/**
|
|
40
42
|
* Get user agent string for Context API requests
|
|
41
43
|
*/
|
|
42
|
-
|
|
44
|
+
declare function getUserAgent(): string;
|
|
43
45
|
/**
|
|
44
46
|
* API client for Context operations
|
|
45
47
|
*/
|
|
46
|
-
|
|
48
|
+
declare class ContextAPIClient {
|
|
47
49
|
private readonly apiKey;
|
|
48
50
|
private readonly apiUrl;
|
|
49
51
|
private readonly sessionId;
|
|
@@ -60,12 +62,9 @@ export declare class ContextAPIClient {
|
|
|
60
62
|
batchUpload(blobs: UploadBlob[]): Promise<BatchUploadResult>;
|
|
61
63
|
checkpointBlobs(blobs: Blobs): Promise<CheckpointBlobsResult>;
|
|
62
64
|
agentCodebaseRetrieval(query: string, blobs: Blobs, maxOutputLength?: number): Promise<AgentCodebaseRetrievalResult>;
|
|
63
|
-
/**
|
|
64
|
-
* Parse a single JSON line from the stream and extract text if present
|
|
65
|
-
*/
|
|
66
|
-
private parseStreamLine;
|
|
67
65
|
/**
|
|
68
66
|
* Parse streaming response and accumulate text chunks
|
|
67
|
+
* Uses a buffer to handle JSON objects that span multiple lines or chunks
|
|
69
68
|
*/
|
|
70
69
|
private parseSSEStream;
|
|
71
70
|
/**
|
|
@@ -76,4 +75,5 @@ export declare class ContextAPIClient {
|
|
|
76
75
|
*/
|
|
77
76
|
chat(prompt: string): Promise<string>;
|
|
78
77
|
}
|
|
79
|
-
|
|
78
|
+
|
|
79
|
+
export { APIError, type AgentCodebaseRetrievalResult, type BatchUploadResult, type CheckpointBlobsResult, ContextAPIClient, type ContextAPIClientOptions, type FindMissingResult, type UploadBlob, getUserAgent };
|