@augmentcode/auggie-sdk 0.1.14 → 0.1.15

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.
@@ -25,6 +25,12 @@ interface AugmentLanguageModelConfig {
25
25
  apiUrl: string;
26
26
  /** Enable debug logging */
27
27
  debug?: boolean;
28
+ /**
29
+ * Custom User-Agent string to use instead of the default SDK User-Agent.
30
+ * If not provided, defaults to "augment.sdk.ai/{version} (typescript)".
31
+ * Example: "context-connectors/0.1.3 via:cli-agent"
32
+ */
33
+ clientUserAgent?: string;
28
34
  }
29
35
  /** Resolved credentials for Augment API (re-export for convenience) */
30
36
  type AugmentCredentials = ResolvedCredentials;
@@ -86,6 +92,7 @@ declare class AugmentLanguageModel implements LanguageModelV2 {
86
92
  private readonly apiUrl;
87
93
  private readonly sessionId;
88
94
  private readonly debug;
95
+ private readonly userAgent;
89
96
  constructor(modelId: string, config: AugmentLanguageModelConfig);
90
97
  private log;
91
98
  private getHeaders;
@@ -1,4 +1,5 @@
1
1
  import { v4 as uuidv4 } from "uuid";
2
+ import { getSDKVersion } from "../version.js";
2
3
  import { resolveCredentials } from "../context/internal/credentials.js";
3
4
  async function resolveAugmentCredentials() {
4
5
  return resolveCredentials();
@@ -233,12 +234,14 @@ class AugmentLanguageModel {
233
234
  apiUrl;
234
235
  sessionId;
235
236
  debug;
237
+ userAgent;
236
238
  constructor(modelId, config) {
237
239
  this.modelId = modelId;
238
240
  this.apiKey = config.apiKey;
239
241
  this.apiUrl = config.apiUrl.endsWith("/") ? config.apiUrl.slice(0, -1) : config.apiUrl;
240
242
  this.sessionId = uuidv4();
241
243
  this.debug = config.debug ?? false;
244
+ this.userAgent = config.clientUserAgent?.trim() || `augment.sdk.ai/${getSDKVersion()} (typescript)`;
242
245
  }
243
246
  log(message) {
244
247
  if (this.debug) {
@@ -253,7 +256,7 @@ class AugmentLanguageModel {
253
256
  "X-Request-Id": requestId,
254
257
  "conversation-id": this.sessionId,
255
258
  "X-Mode": "sdk",
256
- "User-Agent": "auggie-sdk/1.0.0 (typescript)"
259
+ "User-Agent": this.userAgent
257
260
  };
258
261
  }
259
262
  buildPayload(options) {
@@ -68,7 +68,7 @@ class DirectContext {
68
68
  */
69
69
  static async create(options = {}) {
70
70
  const { apiKey, apiUrl } = await resolveCredentials(options);
71
- return new DirectContext(apiKey, apiUrl, options.debug ?? false);
71
+ return new DirectContext(apiKey, apiUrl, options.debug ?? false, options.clientUserAgent);
72
72
  }
73
73
  /**
74
74
  * Import a DirectContext instance from a saved state object
@@ -79,7 +79,7 @@ class DirectContext {
79
79
  */
80
80
  static async import(state, options = {}) {
81
81
  const { apiKey, apiUrl } = await resolveCredentials(options);
82
- const instance = new DirectContext(apiKey, apiUrl, options.debug ?? false);
82
+ const instance = new DirectContext(apiKey, apiUrl, options.debug ?? false, options.clientUserAgent);
83
83
  await instance.doImport(state);
84
84
  return instance;
85
85
  }
@@ -101,12 +101,13 @@ class DirectContext {
101
101
  * @param apiUrl API URL for the tenant
102
102
  * @param debug Enable debug logging
103
103
  */
104
- constructor(apiKey, apiUrl, debug) {
104
+ constructor(apiKey, apiUrl, debug, clientUserAgent) {
105
105
  this.debug = debug;
106
106
  this.apiClient = new ContextAPIClient({
107
107
  apiKey,
108
108
  apiUrl,
109
- debug
109
+ debug,
110
+ clientUserAgent
110
111
  });
111
112
  this.blobCalculator = new BlobNameCalculator(
112
113
  DirectContext.MAX_FILE_SIZE_BYTES
@@ -16,6 +16,7 @@ declare class FileSystemContext {
16
16
  private readonly debug;
17
17
  private readonly apiKey;
18
18
  private readonly apiUrl;
19
+ private readonly clientUserAgent;
19
20
  private mcpClient;
20
21
  private apiClient;
21
22
  /**
@@ -9,6 +9,7 @@ class FileSystemContext {
9
9
  debug;
10
10
  apiKey;
11
11
  apiUrl;
12
+ clientUserAgent;
12
13
  mcpClient = null;
13
14
  apiClient = null;
14
15
  /**
@@ -23,6 +24,7 @@ class FileSystemContext {
23
24
  this.debug = options.debug ?? false;
24
25
  this.apiKey = apiKey;
25
26
  this.apiUrl = apiUrl;
27
+ this.clientUserAgent = options.clientUserAgent;
26
28
  }
27
29
  /**
28
30
  * Create and initialize a new FileSystemContext instance
@@ -172,7 +174,8 @@ class FileSystemContext {
172
174
  this.apiClient = new ContextAPIClient({
173
175
  apiKey: this.apiKey,
174
176
  apiUrl: this.apiUrl,
175
- debug: this.debug
177
+ debug: this.debug,
178
+ clientUserAgent: this.clientUserAgent
176
179
  });
177
180
  }
178
181
  return await chatWithRetry(this.apiClient, llmPrompt, this.debug);
@@ -37,11 +37,13 @@ type ContextAPIClientOptions = {
37
37
  apiKey: string;
38
38
  apiUrl: string;
39
39
  debug?: boolean;
40
+ /**
41
+ * Custom User-Agent string to use instead of the default SDK User-Agent.
42
+ * If not provided, defaults to "augment.sdk.context/{version} (typescript)".
43
+ * Example: "context-connectors/0.1.3 via:cli-search"
44
+ */
45
+ clientUserAgent?: string;
40
46
  };
41
- /**
42
- * Get user agent string for Context API requests
43
- */
44
- declare function getUserAgent(): string;
45
47
  /**
46
48
  * API client for Context operations
47
49
  */
@@ -50,6 +52,7 @@ declare class ContextAPIClient {
50
52
  private readonly apiUrl;
51
53
  private readonly sessionId;
52
54
  private readonly debug;
55
+ private readonly userAgent;
53
56
  constructor(options: ContextAPIClientOptions);
54
57
  private log;
55
58
  createRequestId(): string;
@@ -76,4 +79,4 @@ declare class ContextAPIClient {
76
79
  chat(prompt: string): Promise<string>;
77
80
  }
78
81
 
79
- export { APIError, type AgentCodebaseRetrievalResult, type BatchUploadResult, type CheckpointBlobsResult, ContextAPIClient, type ContextAPIClientOptions, type FindMissingResult, type UploadBlob, getUserAgent };
82
+ export { APIError, type AgentCodebaseRetrievalResult, type BatchUploadResult, type CheckpointBlobsResult, ContextAPIClient, type ContextAPIClientOptions, type FindMissingResult, type UploadBlob };
@@ -11,19 +11,18 @@ class APIError extends Error {
11
11
  this.statusText = statusText;
12
12
  }
13
13
  }
14
- function getUserAgent() {
15
- return `augment.sdk.context/${getSDKVersion()} (typescript)`;
16
- }
17
14
  class ContextAPIClient {
18
15
  apiKey;
19
16
  apiUrl;
20
17
  sessionId;
21
18
  debug;
19
+ userAgent;
22
20
  constructor(options) {
23
21
  this.apiKey = options.apiKey;
24
22
  this.apiUrl = options.apiUrl;
25
23
  this.sessionId = uuidv4();
26
24
  this.debug = options.debug ?? false;
25
+ this.userAgent = options.clientUserAgent?.trim() || `augment.sdk.context/${getSDKVersion()} (typescript)`;
27
26
  }
28
27
  log(message) {
29
28
  if (this.debug) {
@@ -46,7 +45,7 @@ class ContextAPIClient {
46
45
  Authorization: `Bearer ${this.apiKey}`,
47
46
  "X-Request-Session-Id": this.sessionId,
48
47
  "X-Request-Id": requestId,
49
- "User-Agent": getUserAgent()
48
+ "User-Agent": this.userAgent
50
49
  },
51
50
  body: JSON.stringify(payload)
52
51
  });
@@ -219,7 +218,7 @@ class ContextAPIClient {
219
218
  "X-Request-Id": requestId,
220
219
  "conversation-id": this.sessionId,
221
220
  "X-Mode": "sdk",
222
- "User-Agent": getUserAgent()
221
+ "User-Agent": this.userAgent
223
222
  },
224
223
  body: JSON.stringify(payload)
225
224
  });
@@ -242,6 +241,5 @@ class ContextAPIClient {
242
241
  }
243
242
  export {
244
243
  APIError,
245
- ContextAPIClient,
246
- getUserAgent
244
+ ContextAPIClient
247
245
  };
@@ -162,6 +162,12 @@ type DirectContextOptions = {
162
162
  * Default: false
163
163
  */
164
164
  debug?: boolean;
165
+ /**
166
+ * Custom User-Agent string to use instead of the default SDK User-Agent.
167
+ * If not provided, defaults to "augment.sdk.context/{version} (typescript)".
168
+ * Example: "context-connectors/0.1.3 via:cli-search"
169
+ */
170
+ clientUserAgent?: string;
165
171
  };
166
172
  /**
167
173
  * Full state for Direct Context with all blob information
@@ -227,6 +233,12 @@ type FileSystemContextOptions = {
227
233
  auggiePath?: string;
228
234
  /** Enable debug logging */
229
235
  debug?: boolean;
236
+ /**
237
+ * Custom User-Agent string to use instead of the default SDK User-Agent.
238
+ * If not provided, defaults to "augment.sdk.context/{version} (typescript)".
239
+ * Example: "context-connectors/0.1.3 via:mcp"
240
+ */
241
+ clientUserAgent?: string;
230
242
  };
231
243
 
232
244
  export type { AddToIndexOptions, BlobEntry, BlobInfo, Blobs, Chunk, DirectContextOptions, DirectContextState, ExportOptions, File, FileSystemContextOptions, FullContextState, IndexingProgress, IndexingResult, SearchOnlyContextState, SearchResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augmentcode/auggie-sdk",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "TypeScript SDK for Auggie",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",