@ace-sdk/core 1.0.0

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 (86) hide show
  1. package/README.md +54 -0
  2. package/dist/cache/index.d.ts +8 -0
  3. package/dist/cache/index.d.ts.map +1 -0
  4. package/dist/cache/index.js +6 -0
  5. package/dist/cache/index.js.map +1 -0
  6. package/dist/cache/local-cache.d.ts +72 -0
  7. package/dist/cache/local-cache.d.ts.map +1 -0
  8. package/dist/cache/local-cache.js +227 -0
  9. package/dist/cache/local-cache.js.map +1 -0
  10. package/dist/cache/session-storage.d.ts +76 -0
  11. package/dist/cache/session-storage.d.ts.map +1 -0
  12. package/dist/cache/session-storage.js +237 -0
  13. package/dist/cache/session-storage.js.map +1 -0
  14. package/dist/client/ace-client.d.ts +199 -0
  15. package/dist/client/ace-client.d.ts.map +1 -0
  16. package/dist/client/ace-client.js +454 -0
  17. package/dist/client/ace-client.js.map +1 -0
  18. package/dist/client/index.d.ts +6 -0
  19. package/dist/client/index.d.ts.map +1 -0
  20. package/dist/client/index.js +5 -0
  21. package/dist/client/index.js.map +1 -0
  22. package/dist/config/context.d.ts +48 -0
  23. package/dist/config/context.d.ts.map +1 -0
  24. package/dist/config/context.js +147 -0
  25. package/dist/config/context.js.map +1 -0
  26. package/dist/config/helpers.d.ts +79 -0
  27. package/dist/config/helpers.d.ts.map +1 -0
  28. package/dist/config/helpers.js +173 -0
  29. package/dist/config/helpers.js.map +1 -0
  30. package/dist/config/index.d.ts +10 -0
  31. package/dist/config/index.d.ts.map +1 -0
  32. package/dist/config/index.js +9 -0
  33. package/dist/config/index.js.map +1 -0
  34. package/dist/config/loader.d.ts +58 -0
  35. package/dist/config/loader.d.ts.map +1 -0
  36. package/dist/config/loader.js +275 -0
  37. package/dist/config/loader.js.map +1 -0
  38. package/dist/config/migration.d.ts +29 -0
  39. package/dist/config/migration.d.ts.map +1 -0
  40. package/dist/config/migration.js +137 -0
  41. package/dist/config/migration.js.map +1 -0
  42. package/dist/config/xdg.d.ts +62 -0
  43. package/dist/config/xdg.d.ts.map +1 -0
  44. package/dist/config/xdg.js +168 -0
  45. package/dist/config/xdg.js.map +1 -0
  46. package/dist/index.d.ts +32 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +50 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/logger/index.d.ts +6 -0
  51. package/dist/logger/index.d.ts.map +1 -0
  52. package/dist/logger/index.js +5 -0
  53. package/dist/logger/index.js.map +1 -0
  54. package/dist/logger/interface.d.ts +73 -0
  55. package/dist/logger/interface.d.ts.map +1 -0
  56. package/dist/logger/interface.js +11 -0
  57. package/dist/logger/interface.js.map +1 -0
  58. package/dist/logger/noop.d.ts +32 -0
  59. package/dist/logger/noop.d.ts.map +1 -0
  60. package/dist/logger/noop.js +53 -0
  61. package/dist/logger/noop.js.map +1 -0
  62. package/dist/types/config.d.ts +94 -0
  63. package/dist/types/config.d.ts.map +1 -0
  64. package/dist/types/config.js +26 -0
  65. package/dist/types/config.js.map +1 -0
  66. package/dist/types/index.d.ts +8 -0
  67. package/dist/types/index.d.ts.map +1 -0
  68. package/dist/types/index.js +6 -0
  69. package/dist/types/index.js.map +1 -0
  70. package/dist/types/pattern.d.ts +246 -0
  71. package/dist/types/pattern.d.ts.map +1 -0
  72. package/dist/types/pattern.js +22 -0
  73. package/dist/types/pattern.js.map +1 -0
  74. package/dist/utils/code-extractor.d.ts +34 -0
  75. package/dist/utils/code-extractor.d.ts.map +1 -0
  76. package/dist/utils/code-extractor.js +116 -0
  77. package/dist/utils/code-extractor.js.map +1 -0
  78. package/dist/utils/index.d.ts +8 -0
  79. package/dist/utils/index.d.ts.map +1 -0
  80. package/dist/utils/index.js +6 -0
  81. package/dist/utils/index.js.map +1 -0
  82. package/dist/utils/semver.d.ts +41 -0
  83. package/dist/utils/semver.d.ts.map +1 -0
  84. package/dist/utils/semver.js +90 -0
  85. package/dist/utils/semver.js.map +1 -0
  86. package/package.json +58 -0
@@ -0,0 +1,454 @@
1
+ /**
2
+ * ACE Server Client - HTTP REST API client with 3-tier cache
3
+ *
4
+ * Architecture:
5
+ * 1. RAM cache (fastest, lost on restart)
6
+ * 2. SQLite cache (fast, survives restart)
7
+ * 3. Remote server (slow, source of truth)
8
+ *
9
+ * @package @ace-sdk/core
10
+ */
11
+ import { LocalCacheService } from '../cache/local-cache.js';
12
+ export class AceClient {
13
+ config;
14
+ localCache;
15
+ memoryCache; // RAM cache
16
+ logger;
17
+ // Config cache (v3.6.0+) - 1-hour TTL (configurable)
18
+ configCache = { data: null, timestamp: 0 };
19
+ CONFIG_CACHE_TTL = 60 * 60 * 1000; // 60 minutes (1 hour)
20
+ constructor(config, options) {
21
+ this.config = config;
22
+ this.logger = options?.logger;
23
+ // Support both AceConfig (legacy) and AceContext (new)
24
+ const serverUrl = config.serverUrl;
25
+ const apiToken = config.apiToken;
26
+ const projectId = config.projectId;
27
+ const orgId = 'orgId' in config ? config.orgId : this.extractOrgId(apiToken);
28
+ const cacheTtlMinutes = config.cacheTtlMinutes;
29
+ // Initialize local SQLite cache (optional - graceful fallback for Node 25+)
30
+ try {
31
+ const cacheConfig = {
32
+ orgId: orgId || 'default',
33
+ projectId,
34
+ ttlMinutes: cacheTtlMinutes
35
+ };
36
+ this.localCache = new LocalCacheService(cacheConfig, this.logger);
37
+ this.logger?.debug(`SQLite cache enabled (TTL: ${cacheTtlMinutes} minutes)`);
38
+ }
39
+ catch (error) {
40
+ // Graceful fallback for Node.js 25+ (better-sqlite3 not yet supported)
41
+ this.localCache = null;
42
+ this.logger?.debug(`SQLite cache disabled (${error.message})`);
43
+ this.logger?.debug('Using RAM-only cache (degraded performance)');
44
+ if (process.version.startsWith('v25')) {
45
+ this.logger?.debug('Node.js 25 detected - SQLite support coming soon');
46
+ }
47
+ }
48
+ this.logger?.debug(`ACE Server: ${serverUrl}`);
49
+ this.logger?.debug(`API Token: ${apiToken.substring(0, 15)}...`);
50
+ this.logger?.debug(`Project: ${projectId}`);
51
+ if (orgId && orgId !== 'default') {
52
+ this.logger?.debug(`Organization: ${orgId}`);
53
+ }
54
+ }
55
+ /**
56
+ * Extract org_id from API token
57
+ * Format: ace_{base64_with_org_id}
58
+ */
59
+ extractOrgId(apiToken) {
60
+ // Simple extraction - token format varies
61
+ // Fallback to hash if can't extract
62
+ if (!apiToken.startsWith('ace_')) {
63
+ return 'default';
64
+ }
65
+ // For now, use first 8 chars after ace_ as org identifier
66
+ return apiToken.substring(4, 12);
67
+ }
68
+ async request(endpoint, method, body) {
69
+ const url = `${this.config.serverUrl}${endpoint}`;
70
+ // Trace logging: outgoing request
71
+ if (this.logger?.isTrace()) {
72
+ this.logger.trace(`→ ${method} ${endpoint}`);
73
+ if (body) {
74
+ // Truncate large bodies in trace output
75
+ const bodyStr = JSON.stringify(body);
76
+ const truncated = bodyStr.length > 500 ? bodyStr.substring(0, 500) + '...' : bodyStr;
77
+ this.logger.trace(`Request body: ${truncated}`);
78
+ }
79
+ }
80
+ const startTime = Date.now();
81
+ const response = await fetch(url, {
82
+ method,
83
+ headers: {
84
+ 'Content-Type': 'application/json',
85
+ 'Authorization': `Bearer ${this.config.apiToken}`,
86
+ 'X-ACE-Project': this.config.projectId
87
+ },
88
+ body: body ? JSON.stringify(body) : undefined
89
+ });
90
+ const duration = Date.now() - startTime;
91
+ // Trace logging: response status
92
+ if (this.logger?.isTrace()) {
93
+ this.logger.trace(`← ${response.status} ${response.statusText} (${duration}ms)`);
94
+ }
95
+ if (!response.ok) {
96
+ const error = await response.text();
97
+ if (this.logger?.isTrace()) {
98
+ this.logger.trace(`Error response: ${error}`);
99
+ }
100
+ throw new Error(`Server error (${response.status}): ${error}`);
101
+ }
102
+ const result = await response.json();
103
+ // Trace logging: response body
104
+ if (this.logger?.isTrace()) {
105
+ const resultStr = JSON.stringify(result);
106
+ const truncated = resultStr.length > 500 ? resultStr.substring(0, 500) + '...' : resultStr;
107
+ this.logger.trace(`Response body: ${truncated}`);
108
+ }
109
+ return result;
110
+ }
111
+ /**
112
+ * Save structured playbook to server
113
+ * Server endpoint: POST /patterns (saves individual bullets)
114
+ */
115
+ async savePlaybook(playbook) {
116
+ // Flatten playbook into array of bullets
117
+ const allBullets = [
118
+ ...playbook.strategies_and_hard_rules,
119
+ ...playbook.useful_code_snippets,
120
+ ...playbook.troubleshooting_and_pitfalls,
121
+ ...playbook.apis_to_use
122
+ ];
123
+ // Server expects: POST /patterns with array of bullets
124
+ await this.request('/patterns', 'POST', { patterns: allBullets });
125
+ }
126
+ /**
127
+ * Get structured playbook (3-tier cache: RAM → SQLite → Server)
128
+ * Endpoint: GET /playbook
129
+ */
130
+ async getPlaybook(params) {
131
+ const forceRefresh = params?.forceRefresh ?? false;
132
+ const include_metadata = params?.include_metadata ?? true;
133
+ // 1. Check RAM cache (fastest)
134
+ if (!forceRefresh && this.memoryCache) {
135
+ this.logger?.info('Cache hit (RAM)');
136
+ return {
137
+ playbook: this.memoryCache,
138
+ total_bullets: this.countBullets(this.memoryCache),
139
+ metadata: undefined
140
+ };
141
+ }
142
+ // 2. Check SQLite cache (if available and fresh)
143
+ if (!forceRefresh && this.localCache && !this.localCache.needsSync()) {
144
+ const cached = this.localCache.getPlaybook();
145
+ if (cached) {
146
+ this.memoryCache = cached;
147
+ this.logger?.info('Cache hit (SQLite)');
148
+ return {
149
+ playbook: cached,
150
+ total_bullets: this.countBullets(cached),
151
+ metadata: undefined
152
+ };
153
+ }
154
+ }
155
+ // 3. Fetch from server
156
+ this.logger?.info('Fetching playbook from server...');
157
+ const result = await this.request(`/playbook?include_metadata=${include_metadata}`, 'GET');
158
+ const playbook = result.playbook || {
159
+ strategies_and_hard_rules: [],
160
+ useful_code_snippets: [],
161
+ troubleshooting_and_pitfalls: [],
162
+ apis_to_use: []
163
+ };
164
+ // Update caches
165
+ this.memoryCache = playbook;
166
+ if (this.localCache) {
167
+ this.localCache.savePlaybook(playbook);
168
+ }
169
+ return {
170
+ playbook,
171
+ total_bullets: result.total_bullets || this.countBullets(playbook),
172
+ metadata: result.metadata
173
+ };
174
+ }
175
+ /**
176
+ * Count total bullets across all playbook sections
177
+ */
178
+ countBullets(playbook) {
179
+ return (playbook.strategies_and_hard_rules.length +
180
+ playbook.useful_code_snippets.length +
181
+ playbook.troubleshooting_and_pitfalls.length +
182
+ playbook.apis_to_use.length);
183
+ }
184
+ /**
185
+ * Compute embeddings for texts (with SQLite cache if available)
186
+ * Endpoint: POST /embeddings
187
+ */
188
+ async computeEmbeddings(texts) {
189
+ if (texts.length === 0)
190
+ return [];
191
+ const embeddings = [];
192
+ const uncachedTexts = [];
193
+ const uncachedIndices = [];
194
+ // Check cache for each text
195
+ if (this.localCache) {
196
+ for (let i = 0; i < texts.length; i++) {
197
+ const cached = this.localCache.getEmbedding(texts[i]);
198
+ if (cached) {
199
+ embeddings[i] = cached;
200
+ }
201
+ else {
202
+ uncachedTexts.push(texts[i]);
203
+ uncachedIndices.push(i);
204
+ }
205
+ }
206
+ }
207
+ else {
208
+ uncachedTexts.push(...texts);
209
+ uncachedIndices.push(...texts.map((_, i) => i));
210
+ }
211
+ // Compute uncached embeddings from server
212
+ if (uncachedTexts.length > 0) {
213
+ this.logger?.info(`Computing ${uncachedTexts.length} embeddings...`);
214
+ const result = await this.request('/embeddings', 'POST', { texts: uncachedTexts });
215
+ // Fill in results and cache them
216
+ for (let i = 0; i < result.embeddings.length; i++) {
217
+ const embedding = result.embeddings[i];
218
+ const originalIndex = uncachedIndices[i];
219
+ embeddings[originalIndex] = embedding;
220
+ if (this.localCache) {
221
+ this.localCache.cacheEmbedding(uncachedTexts[i], embedding);
222
+ }
223
+ }
224
+ }
225
+ return embeddings;
226
+ }
227
+ /**
228
+ * Semantic search for relevant patterns
229
+ * Endpoint: POST /patterns/search
230
+ */
231
+ async searchPatterns(params) {
232
+ const { query, section, threshold, top_k, include_metadata = true } = params;
233
+ if (threshold === undefined) {
234
+ throw new Error('searchPatterns called without threshold');
235
+ }
236
+ const now = new Date().toISOString();
237
+ const tempId = `temp_search_${Date.now()}`;
238
+ const url = `/patterns/search?include_metadata=${include_metadata}`;
239
+ const body = {
240
+ pattern: {
241
+ id: tempId,
242
+ content: query,
243
+ confidence: 0.8,
244
+ created_at: now,
245
+ section: section || 'general'
246
+ },
247
+ threshold
248
+ };
249
+ if (top_k !== undefined) {
250
+ body.top_k = top_k;
251
+ }
252
+ const result = await this.request(url, 'POST', body);
253
+ return {
254
+ similar_patterns: result.similar_patterns || [],
255
+ count: result.count ?? (result.similar_patterns?.length || 0),
256
+ threshold: result.threshold ?? threshold,
257
+ top_k: result.top_k,
258
+ domains_summary: result.domains_summary,
259
+ metadata: result.metadata
260
+ };
261
+ }
262
+ /**
263
+ * Get top patterns by helpful score
264
+ * Endpoint: GET /patterns/top
265
+ */
266
+ async getTopPatterns(params) {
267
+ const { section, limit = 10, min_helpful = 0 } = params;
268
+ const queryParams = new URLSearchParams();
269
+ if (section)
270
+ queryParams.append('section', section);
271
+ queryParams.append('limit', String(limit));
272
+ queryParams.append('min_helpful', String(min_helpful));
273
+ const result = await this.request(`/patterns/top?${queryParams.toString()}`, 'GET');
274
+ return result.top_patterns || [];
275
+ }
276
+ /**
277
+ * Get playbook analytics
278
+ * Endpoint: GET /analytics
279
+ */
280
+ async getAnalytics() {
281
+ return this.request('/analytics', 'GET');
282
+ }
283
+ /**
284
+ * Clear entire playbook
285
+ * Server endpoint: DELETE /patterns
286
+ */
287
+ async clearPlaybook() {
288
+ await this.request('/patterns?confirm=true', 'DELETE');
289
+ this.invalidateCache();
290
+ }
291
+ /**
292
+ * Apply delta operation (ADD/UPDATE/DELETE)
293
+ * Server endpoint: POST /delta
294
+ */
295
+ async applyDelta(operation) {
296
+ await this.request('/delta', 'POST', operation);
297
+ this.invalidateCache();
298
+ }
299
+ /**
300
+ * Apply multiple delta operations in batch
301
+ */
302
+ async applyDeltas(operations) {
303
+ for (const operation of operations) {
304
+ await this.applyDelta(operation);
305
+ }
306
+ }
307
+ /**
308
+ * Store execution trace for server-side analysis
309
+ * Server endpoint: POST /traces
310
+ */
311
+ async storeExecutionTrace(trace) {
312
+ return this.request('/traces', 'POST', trace);
313
+ }
314
+ /**
315
+ * Bootstrap playbook from extracted code blocks
316
+ * Server endpoint: POST /bootstrap
317
+ */
318
+ async bootstrap(params) {
319
+ return this.request('/bootstrap', 'POST', params);
320
+ }
321
+ /**
322
+ * Initialize playbook from git repository (server-side)
323
+ * Server endpoint: POST /init
324
+ */
325
+ async initializeFromRepo(params) {
326
+ return this.request('/init', 'POST', params);
327
+ }
328
+ /**
329
+ * Get playbook status/statistics
330
+ * Server endpoint: GET /analytics
331
+ */
332
+ async getStatus() {
333
+ return this.getAnalytics();
334
+ }
335
+ /**
336
+ * Invalidate caches (force refresh on next call)
337
+ */
338
+ invalidateCache() {
339
+ this.memoryCache = undefined;
340
+ this.logger?.debug('Cache invalidated');
341
+ }
342
+ /**
343
+ * Get server configuration with caching (v3.6.0+)
344
+ * Server endpoint: GET /api/v1/config
345
+ */
346
+ async getConfig(useCache = true) {
347
+ if (useCache) {
348
+ const now = Date.now();
349
+ const isValid = this.configCache.data &&
350
+ (now - this.configCache.timestamp) < this.CONFIG_CACHE_TTL;
351
+ if (isValid) {
352
+ this.logger?.debug('Config cache hit (RAM)');
353
+ return this.configCache.data;
354
+ }
355
+ }
356
+ this.logger?.info('Fetching config from server...');
357
+ const config = await this.request('/api/v1/config', 'GET');
358
+ this.configCache = {
359
+ data: config,
360
+ timestamp: Date.now()
361
+ };
362
+ return config;
363
+ }
364
+ /**
365
+ * Verify API token and fetch organization info
366
+ * Server endpoint: GET /api/v1/config/verify
367
+ */
368
+ async verifyToken() {
369
+ return this.request('/api/v1/config/verify', 'GET');
370
+ }
371
+ /**
372
+ * Batch retrieve patterns by ID (v3.6.0+)
373
+ * Server endpoint: POST /patterns/batch
374
+ */
375
+ async batchGetPatterns(patternIds) {
376
+ if (patternIds.length === 0) {
377
+ return { patterns: [], found_count: 0, not_found: [] };
378
+ }
379
+ const MAX_BATCH = 50;
380
+ const chunks = [];
381
+ for (let i = 0; i < patternIds.length; i += MAX_BATCH) {
382
+ chunks.push(patternIds.slice(i, i + MAX_BATCH));
383
+ }
384
+ this.logger?.info(`Batch fetching ${patternIds.length} patterns in ${chunks.length} chunk(s)...`);
385
+ const results = await Promise.all(chunks.map(chunk => this.request('/patterns/batch', 'POST', { pattern_ids: chunk })));
386
+ const allPatterns = results.flatMap(r => r.patterns || []);
387
+ const totalFound = results.reduce((sum, r) => sum + (r.found_count || 0), 0);
388
+ const allNotFound = results.flatMap(r => r.not_found || []);
389
+ return {
390
+ patterns: allPatterns,
391
+ found_count: totalFound,
392
+ not_found: allNotFound
393
+ };
394
+ }
395
+ /**
396
+ * Summarize a recorded session
397
+ * Server endpoint: POST /api/v1/summarize
398
+ */
399
+ async summarizeSession(sessionData) {
400
+ return this.request('/api/v1/summarize', 'POST', { session: sessionData });
401
+ }
402
+ /**
403
+ * Clear config cache
404
+ */
405
+ clearConfigCache() {
406
+ this.configCache = { data: null, timestamp: 0 };
407
+ this.logger?.debug('Config cache cleared');
408
+ }
409
+ /**
410
+ * Get local cache instance
411
+ */
412
+ getLocalCache() {
413
+ return this.localCache;
414
+ }
415
+ /**
416
+ * Update server configuration (v3.6.0+)
417
+ * Server endpoint: PUT /api/v1/config?scope=project
418
+ */
419
+ async updateConfig(settings, scope = 'project') {
420
+ try {
421
+ this.logger?.debug(`Updating config (scope=${scope})`);
422
+ const config = await this.request(`/api/v1/config?scope=${scope}`, 'PUT', settings);
423
+ this.configCache = { data: null, timestamp: 0 };
424
+ this.logger?.debug('Config updated successfully');
425
+ return config;
426
+ }
427
+ catch (error) {
428
+ if (error.message?.includes('404') || error.message?.includes('501')) {
429
+ throw new Error('This ACE Server does not support configuration updates. Please upgrade to ACE Server v3.6.0+');
430
+ }
431
+ throw error;
432
+ }
433
+ }
434
+ /**
435
+ * Reset server configuration to defaults (v3.9.0+)
436
+ * Server endpoint: POST /api/v1/config/reset?scope=project
437
+ */
438
+ async resetConfig(scope = 'project') {
439
+ try {
440
+ this.logger?.debug(`Resetting config (scope=${scope})`);
441
+ const result = await this.request(`/api/v1/config/reset?scope=${scope}`, 'POST');
442
+ this.configCache = { data: null, timestamp: 0 };
443
+ this.logger?.debug('Config reset successfully');
444
+ return result;
445
+ }
446
+ catch (error) {
447
+ if (error.message?.includes('404') || error.message?.includes('501')) {
448
+ throw new Error('This ACE Server does not support configuration reset. Please upgrade to ACE Server v3.9.0+');
449
+ }
450
+ throw error;
451
+ }
452
+ }
453
+ }
454
+ //# sourceMappingURL=ace-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ace-client.js","sourceRoot":"","sources":["../../src/client/ace-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,EAAE,iBAAiB,EAAe,MAAM,yBAAyB,CAAC;AAWzE,MAAM,OAAO,SAAS;IAaV;IAZF,UAAU,CAA2B;IACrC,WAAW,CAAsB,CAAC,YAAY;IAC9C,MAAM,CAAsB;IAEpC,qDAAqD;IAC7C,WAAW,GAGf,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACzB,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,sBAAsB;IAEjE,YACU,MAA8B,EACtC,OAA0B;QADlB,WAAM,GAAN,MAAM,CAAwB;QAGtC,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;QAE9B,uDAAuD;QACvD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM,KAAK,GAAG,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC7E,MAAM,eAAe,GAAG,MAAM,CAA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@@
1
+ /**
2
+ * Client exports for @ace-sdk/core
3
+ */
4
+ export { AceClient } from './ace-client.js';
5
+ export type { AceClientOptions } from './ace-client.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Client exports for @ace-sdk/core
3
+ */
4
+ export { AceClient } from './ace-client.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Context Creation and Resolution
3
+ * @package @ace-sdk/core
4
+ */
5
+ import type { AceContext, ServerConfig, ResolvedContext, ResolveContextOptions } from '../types/config.js';
6
+ import { ConfigOverrides } from './loader.js';
7
+ import { ILogger } from '../logger/index.js';
8
+ /**
9
+ * Resolves org and project context using 3-tier precedence:
10
+ *
11
+ * 1. CLI flags (--org, --project) - HIGHEST PRIORITY
12
+ * 2. Environment variables (ACE_ORG_ID, ACE_PROJECT_ID)
13
+ * 3. Error - NO CONTEXT FOUND
14
+ *
15
+ * Note: .claude/settings.json is NOT read by this function. That's Claude Code's job.
16
+ * Claude Code reads .claude/settings.json and sets ACE_ORG_ID/ACE_PROJECT_ID as ENV vars.
17
+ *
18
+ * @param options - CLI flags and working directory
19
+ * @returns Resolved org and project IDs with source
20
+ * @throws Error if no context can be resolved
21
+ */
22
+ export declare function resolveContext(options?: ResolveContextOptions): ResolvedContext;
23
+ /**
24
+ * Validates that an org ID matches the expected format
25
+ */
26
+ export declare function isValidOrgId(orgId: string): boolean;
27
+ /**
28
+ * Validates that a project ID matches the expected format
29
+ */
30
+ export declare function isValidProjectId(projectId: string): boolean;
31
+ /**
32
+ * Create AceContext from CLI flags, environment, and config files
33
+ *
34
+ * This function implements the complete context resolution flow:
35
+ * 1. Resolve org/project using 4-tier precedence (flags > env > .claude/settings.json > error)
36
+ * 2. Load global config to get server URL and tokens
37
+ * 3. Get the correct token for the resolved organization
38
+ * 4. Merge with server-derived runtime settings
39
+ *
40
+ * @param options - CLI flags for org/project override
41
+ * @param serverConfig - Optional server configuration (fetched via ACEServerClient.getConfig())
42
+ * @param configOverrides - Optional config overrides
43
+ * @param logger - Optional logger
44
+ * @returns Complete runtime context with merged settings
45
+ * @throws Error if context cannot be resolved
46
+ */
47
+ export declare function createContext(options?: ResolveContextOptions, serverConfig?: ServerConfig, configOverrides?: ConfigOverrides, logger?: ILogger): Promise<AceContext>;
48
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/config/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,UAAU,EAEV,YAAY,EACZ,eAAe,EACf,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAc,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS7C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,eAAe,CA8DnF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CACjC,OAAO,GAAE,qBAA0B,EACnC,YAAY,CAAC,EAAE,YAAY,EAC3B,eAAe,CAAC,EAAE,eAAe,EACjC,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,UAAU,CAAC,CAkCrB"}