@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,98 +1,111 @@
1
- /**
2
- * Mock implementation of ContextAPIClient for testing
3
- */
4
- import { ContextAPIClient, } from "../api-client";
5
- export class MockContextAPIClient extends ContextAPIClient {
6
- constructor(config = {}) {
7
- // Call parent constructor with dummy credentials
8
- super({
9
- apiKey: "mock-api-key",
10
- apiUrl: "https://mock.api.augmentcode.com",
11
- debug: false,
12
- });
13
- // Track method calls for assertions
14
- this.findMissingCalls = [];
15
- this.batchUploadCalls = [];
16
- this.checkpointBlobsCalls = [];
17
- this.agentCodebaseRetrievalCalls = [];
18
- this.chatCalls = [];
19
- this.knownBlobs = config.knownBlobs || new Set();
20
- this.indexedBlobs = config.indexedBlobs || new Set();
21
- this.delay = config.delay || 0;
22
- this.shouldFailFindMissing = config.shouldFailFindMissing ?? false;
23
- this.shouldFailBatchUpload = config.shouldFailBatchUpload ?? false;
24
- this.shouldFailCheckpoint = config.shouldFailCheckpoint ?? false;
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
- createRequestId() {
27
- return `mock-req-${Date.now()}`;
39
+ }
40
+ async findMissing(blobNames) {
41
+ this.findMissingCalls.push([...blobNames]);
42
+ if (this.shouldFailFindMissing) {
43
+ throw new Error("Mock findMissing error");
28
44
  }
29
- async simulateDelay() {
30
- if (this.delay > 0) {
31
- await new Promise((resolve) => setTimeout(resolve, this.delay));
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
- async findMissing(blobNames) {
35
- this.findMissingCalls.push([...blobNames]);
36
- if (this.shouldFailFindMissing) {
37
- throw new Error("Mock findMissing error");
38
- }
39
- await this.simulateDelay();
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
- async batchUpload(blobs) {
48
- this.batchUploadCalls.push([...blobs]);
49
- if (this.shouldFailBatchUpload) {
50
- throw new Error("Mock batchUpload error");
51
- }
52
- await this.simulateDelay();
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
- async checkpointBlobs(blobs) {
61
- this.checkpointBlobsCalls.push({ ...blobs });
62
- if (this.shouldFailCheckpoint) {
63
- throw new Error("Mock checkpointBlobs error");
64
- }
65
- await this.simulateDelay();
66
- return {
67
- newCheckpointId: `checkpoint-${Date.now()}`,
68
- };
69
- }
70
- async agentCodebaseRetrieval(query, blobs, maxOutputLength) {
71
- this.agentCodebaseRetrievalCalls.push({ query, blobs, maxOutputLength });
72
- await this.simulateDelay();
73
- return {
74
- formattedRetrieval: `Mock search results for: ${query}`,
75
- };
76
- }
77
- async chat(prompt) {
78
- this.chatCalls.push(prompt);
79
- await this.simulateDelay();
80
- return `Mock LLM response to: ${prompt}`;
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
- //# sourceMappingURL=api-client.js.map
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
- import type { Blobs } from "../types";
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
- export declare class APIError extends Error {
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
- export type UploadBlob = {
17
+ type UploadBlob = {
16
18
  blobName: string;
17
19
  pathName: string;
18
20
  text: string;
19
21
  metadata: string[];
20
22
  };
21
- export type FindMissingResult = {
23
+ type FindMissingResult = {
22
24
  unknownBlobNames: string[];
23
25
  nonindexedBlobNames: string[];
24
26
  };
25
- export type CheckpointBlobsResult = {
27
+ type CheckpointBlobsResult = {
26
28
  newCheckpointId: string;
27
29
  };
28
- export type BatchUploadResult = {
30
+ type BatchUploadResult = {
29
31
  blobNames: string[];
30
32
  };
31
- export type AgentCodebaseRetrievalResult = {
33
+ type AgentCodebaseRetrievalResult = {
32
34
  formattedRetrieval: string;
33
35
  };
34
- export type ContextAPIClientOptions = {
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
- export declare function getUserAgent(): string;
44
+ declare function getUserAgent(): string;
43
45
  /**
44
46
  * API client for Context operations
45
47
  */
46
- export declare class ContextAPIClient {
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
- //# sourceMappingURL=api-client.d.ts.map
78
+
79
+ export { APIError, type AgentCodebaseRetrievalResult, type BatchUploadResult, type CheckpointBlobsResult, ContextAPIClient, type ContextAPIClientOptions, type FindMissingResult, type UploadBlob, getUserAgent };