@x12i/ai-profiles 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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/dist/buildResolvedProfile.d.ts +13 -0
  4. package/dist/buildResolvedProfile.d.ts.map +1 -0
  5. package/dist/buildResolvedProfile.js +70 -0
  6. package/dist/buildResolvedProfile.js.map +1 -0
  7. package/dist/constants.d.ts +9 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +19 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/data/models-profiles.json +611 -0
  12. package/dist/data/profiles-shortcuts.json +86 -0
  13. package/dist/errors.d.ts +7 -0
  14. package/dist/errors.d.ts.map +1 -0
  15. package/dist/errors.js +11 -0
  16. package/dist/errors.js.map +1 -0
  17. package/dist/index.d.ts +6 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +4 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/listAIProfiles.d.ts +3 -0
  22. package/dist/listAIProfiles.d.ts.map +1 -0
  23. package/dist/listAIProfiles.js +37 -0
  24. package/dist/listAIProfiles.js.map +1 -0
  25. package/dist/loader/combineRegistry.d.ts +3 -0
  26. package/dist/loader/combineRegistry.d.ts.map +1 -0
  27. package/dist/loader/combineRegistry.js +14 -0
  28. package/dist/loader/combineRegistry.js.map +1 -0
  29. package/dist/loader/fetchJson.d.ts +2 -0
  30. package/dist/loader/fetchJson.d.ts.map +1 -0
  31. package/dist/loader/fetchJson.js +29 -0
  32. package/dist/loader/fetchJson.js.map +1 -0
  33. package/dist/loader/loadAIProfilesRegistry.d.ts +4 -0
  34. package/dist/loader/loadAIProfilesRegistry.d.ts.map +1 -0
  35. package/dist/loader/loadAIProfilesRegistry.js +68 -0
  36. package/dist/loader/loadAIProfilesRegistry.js.map +1 -0
  37. package/dist/loader/loadBundledRegistry.d.ts +3 -0
  38. package/dist/loader/loadBundledRegistry.d.ts.map +1 -0
  39. package/dist/loader/loadBundledRegistry.js +22 -0
  40. package/dist/loader/loadBundledRegistry.js.map +1 -0
  41. package/dist/loader/loadRemoteRegistry.d.ts +3 -0
  42. package/dist/loader/loadRemoteRegistry.d.ts.map +1 -0
  43. package/dist/loader/loadRemoteRegistry.js +27 -0
  44. package/dist/loader/loadRemoteRegistry.js.map +1 -0
  45. package/dist/loader/memoryCache.d.ts +13 -0
  46. package/dist/loader/memoryCache.d.ts.map +1 -0
  47. package/dist/loader/memoryCache.js +17 -0
  48. package/dist/loader/memoryCache.js.map +1 -0
  49. package/dist/normalizeKey.d.ts +2 -0
  50. package/dist/normalizeKey.d.ts.map +1 -0
  51. package/dist/normalizeKey.js +4 -0
  52. package/dist/normalizeKey.js.map +1 -0
  53. package/dist/resolveAIProfile.d.ts +3 -0
  54. package/dist/resolveAIProfile.d.ts.map +1 -0
  55. package/dist/resolveAIProfile.js +53 -0
  56. package/dist/resolveAIProfile.js.map +1 -0
  57. package/dist/types.d.ts +151 -0
  58. package/dist/types.d.ts.map +1 -0
  59. package/dist/types.js +2 -0
  60. package/dist/types.js.map +1 -0
  61. package/dist/validation/validateModelsProfilesJson.d.ts +4 -0
  62. package/dist/validation/validateModelsProfilesJson.d.ts.map +1 -0
  63. package/dist/validation/validateModelsProfilesJson.js +93 -0
  64. package/dist/validation/validateModelsProfilesJson.js.map +1 -0
  65. package/package.json +65 -0
@@ -0,0 +1,7 @@
1
+ export type AIProfilesErrorCode = "UNKNOWN_PROFILE" | "UNKNOWN_SHORTCUT" | "UNKNOWN_CHOICE" | "REMOTE_FETCH_FAILED" | "REMOTE_JSON_INVALID" | "BUNDLED_JSON_INVALID" | "REGISTRY_SCHEMA_UNSUPPORTED" | "REGISTRY_VALIDATION_FAILED";
2
+ export declare class AIProfilesError extends Error {
3
+ code: AIProfilesErrorCode;
4
+ details?: Record<string, unknown> | undefined;
5
+ constructor(code: AIProfilesErrorCode, message: string, details?: Record<string, unknown> | undefined);
6
+ }
7
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAC3B,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,6BAA6B,GAC7B,4BAA4B,CAAC;AAEjC,qBAAa,eAAgB,SAAQ,KAAK;IAE/B,IAAI,EAAE,mBAAmB;IAEzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFjC,IAAI,EAAE,mBAAmB,EAChC,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAK3C"}
package/dist/errors.js ADDED
@@ -0,0 +1,11 @@
1
+ export class AIProfilesError extends Error {
2
+ code;
3
+ details;
4
+ constructor(code, message, details) {
5
+ super(message);
6
+ this.code = code;
7
+ this.details = details;
8
+ this.name = "AIProfilesError";
9
+ }
10
+ }
11
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAE/B;IAEA;IAHT,YACS,IAAyB,EAChC,OAAe,EACR,OAAiC;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAqB;QAEzB,YAAO,GAAP,OAAO,CAA0B;QAGxC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export { listAIProfiles } from "./listAIProfiles.js";
2
+ export { resolveAIProfile } from "./resolveAIProfile.js";
3
+ export type { AIProfilesRegistry, AIProfileDefinition, AIProfileChoice, AIProfileShortcut, AIProfileSummary, ResolvedAIProfile, ListAIProfilesOptions, ResolveAIProfileOptions, AIProvider, AIModelPricing, AIRuntimeDefaults, AIProfileWarning, RegistrySourceMode, } from "./types.js";
4
+ export { AIProfilesError } from "./errors.js";
5
+ export type { AIProfilesErrorCode } from "./errors.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { listAIProfiles } from "./listAIProfiles.js";
2
+ export { resolveAIProfile } from "./resolveAIProfile.js";
3
+ export { AIProfilesError } from "./errors.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAkBzD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AIProfileSummary, ListAIProfilesOptions } from "./types.js";
2
+ export declare function listAIProfiles(options?: ListAIProfilesOptions): Promise<AIProfileSummary[]>;
3
+ //# sourceMappingURL=listAIProfiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listAIProfiles.d.ts","sourceRoot":"","sources":["../src/listAIProfiles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE1E,wBAAsB,cAAc,CAClC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAuC7B"}
@@ -0,0 +1,37 @@
1
+ import { loadAIProfilesRegistryWithWarnings } from "./loader/loadAIProfilesRegistry.js";
2
+ export async function listAIProfiles(options = {}) {
3
+ const { registry } = await loadAIProfilesRegistryWithWarnings({
4
+ source: options.source,
5
+ refresh: options.refresh,
6
+ });
7
+ return Object.values(registry.profiles)
8
+ .filter((profile) => {
9
+ if (!options.includeDeprecated && profile.status === "deprecated") {
10
+ return false;
11
+ }
12
+ if (!options.includeExperimental && profile.status === "experimental") {
13
+ return false;
14
+ }
15
+ if (options.category && profile.category !== options.category) {
16
+ return false;
17
+ }
18
+ return true;
19
+ })
20
+ .map((profile) => {
21
+ const defaultChoice = profile.choices[profile.defaultChoice];
22
+ return {
23
+ profile: profile.profile,
24
+ displayName: profile.displayName,
25
+ description: profile.description,
26
+ category: profile.category,
27
+ aliases: profile.aliases ?? [],
28
+ defaultChoice: profile.defaultChoice,
29
+ choices: Object.keys(profile.choices),
30
+ defaultProvider: defaultChoice.provider,
31
+ defaultModelId: defaultChoice.modelId,
32
+ source: registry.source,
33
+ registryVersion: registry.version,
34
+ };
35
+ });
36
+ }
37
+ //# sourceMappingURL=listAIProfiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listAIProfiles.js","sourceRoot":"","sources":["../src/listAIProfiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAGxF,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAiC,EAAE;IAEnC,MAAM,EAAE,QAAQ,EAAE,GAAG,MA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CAAC;AACP,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AIProfilesRegistry, ModelsProfilesJson, ProfilesShortcutsJson } from "../types.js";
2
+ export declare function combineRegistry(modelsProfiles: ModelsProfilesJson, shortcuts: ProfilesShortcutsJson, source: "remote" | "bundled"): AIProfilesRegistry;
3
+ //# sourceMappingURL=combineRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combineRegistry.d.ts","sourceRoot":"","sources":["../../src/loader/combineRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAErB,wBAAgB,eAAe,CAC7B,cAAc,EAAE,kBAAkB,EAClC,SAAS,EAAE,qBAAqB,EAChC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAC3B,kBAAkB,CAapB"}
@@ -0,0 +1,14 @@
1
+ export function combineRegistry(modelsProfiles, shortcuts, source) {
2
+ const loadedAt = new Date().toISOString();
3
+ return {
4
+ version: modelsProfiles.version,
5
+ generatedAt: modelsProfiles.generatedAt ?? shortcuts.generatedAt,
6
+ currency: modelsProfiles.currency,
7
+ pricingUnit: modelsProfiles.pricingUnit,
8
+ profiles: modelsProfiles.profiles,
9
+ shortcuts: shortcuts.shortcuts,
10
+ source,
11
+ loadedAt,
12
+ };
13
+ }
14
+ //# sourceMappingURL=combineRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combineRegistry.js","sourceRoot":"","sources":["../../src/loader/combineRegistry.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,eAAe,CAC7B,cAAkC,EAClC,SAAgC,EAChC,MAA4B;IAE5B,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE1C,OAAO;QACL,OAAO,EAAE,cAAc,CAAC,OAAO;QAC/B,WAAW,EAAE,cAAc,CAAC,WAAW,IAAI,SAAS,CAAC,WAAW;QAChE,QAAQ,EAAE,cAAc,CAAC,QAAQ;QACjC,WAAW,EAAE,cAAc,CAAC,WAAW;QACvC,QAAQ,EAAE,cAAc,CAAC,QAAQ;QACjC,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function fetchJson(url: string): Promise<unknown>;
2
+ //# sourceMappingURL=fetchJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchJson.d.ts","sourceRoot":"","sources":["../../src/loader/fetchJson.ts"],"names":[],"mappings":"AAGA,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqC7D"}
@@ -0,0 +1,29 @@
1
+ import { DEFAULT_FETCH_TIMEOUT_MS } from "../constants.js";
2
+ import { AIProfilesError } from "../errors.js";
3
+ export async function fetchJson(url) {
4
+ const controller = new AbortController();
5
+ const timeout = setTimeout(() => controller.abort(), DEFAULT_FETCH_TIMEOUT_MS);
6
+ try {
7
+ const response = await fetch(url, {
8
+ signal: controller.signal,
9
+ headers: {
10
+ Accept: "application/json",
11
+ },
12
+ });
13
+ if (!response.ok) {
14
+ throw new AIProfilesError("REMOTE_FETCH_FAILED", `Failed to fetch ${url}: HTTP ${response.status}`, { url, status: response.status });
15
+ }
16
+ return await response.json();
17
+ }
18
+ catch (error) {
19
+ if (error instanceof AIProfilesError) {
20
+ throw error;
21
+ }
22
+ const message = error instanceof Error ? error.message : "Unknown fetch error";
23
+ throw new AIProfilesError("REMOTE_FETCH_FAILED", `Failed to fetch ${url}: ${message}`, { url, cause: message });
24
+ }
25
+ finally {
26
+ clearTimeout(timeout);
27
+ }
28
+ }
29
+ //# sourceMappingURL=fetchJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchJson.js","sourceRoot":"","sources":["../../src/loader/fetchJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iB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"../types.js";
2
+ export declare function loadAIProfilesRegistry(options?: LoadRegistryOptions): Promise<AIProfilesRegistry>;
3
+ export declare function loadAIProfilesRegistryWithWarnings(options?: LoadRegistryOptions): Promise<LoadRegistryResult>;
4
+ //# sourceMappingURL=loadAIProfilesRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadAIProfilesRegistry.d.ts","sourceRoot":"","sources":["../../src/loader/loadAIProfilesRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AA0BrB,wBAAsB,sBAAsB,CAC1C,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAG7B;AAED,wBAAsB,kCAAkC,CACtD,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAwD7B"}
@@ -0,0 +1,68 @@
1
+ import { DEFAULT_CACHE_TTL_MS } from "../constants.js";
2
+ import { loadBundledRegistry } from "./loadBundledRegistry.js";
3
+ import { loadRemoteRegistry } from "./loadRemoteRegistry.js";
4
+ import { getMemoryCache, isCacheValid, setMemoryCache, } from "./memoryCache.js";
5
+ function cacheAndReturn(registry, source) {
6
+ const now = Date.now();
7
+ const cache = {
8
+ registry,
9
+ loadedAt: now,
10
+ expiresAt: now + DEFAULT_CACHE_TTL_MS,
11
+ source,
12
+ };
13
+ setMemoryCache(cache);
14
+ return registry;
15
+ }
16
+ export async function loadAIProfilesRegistry(options = {}) {
17
+ const result = await loadAIProfilesRegistryWithWarnings(options);
18
+ return result.registry;
19
+ }
20
+ export async function loadAIProfilesRegistryWithWarnings(options = {}) {
21
+ const source = options.source ?? "auto";
22
+ const refresh = options.refresh ?? false;
23
+ const warnings = [];
24
+ const existingCache = getMemoryCache();
25
+ if (!refresh && isCacheValid(existingCache)) {
26
+ return { registry: existingCache.registry, warnings };
27
+ }
28
+ if (source === "bundled") {
29
+ return {
30
+ registry: cacheAndReturn(loadBundledRegistry(), "bundled"),
31
+ warnings,
32
+ };
33
+ }
34
+ if (source === "remote") {
35
+ return {
36
+ registry: cacheAndReturn(await loadRemoteRegistry(), "remote"),
37
+ warnings,
38
+ };
39
+ }
40
+ const shouldAttemptRefresh = refresh || !existingCache || !isCacheValid(existingCache);
41
+ if (shouldAttemptRefresh) {
42
+ try {
43
+ return {
44
+ registry: cacheAndReturn(await loadRemoteRegistry(), "remote"),
45
+ warnings,
46
+ };
47
+ }
48
+ catch {
49
+ if (existingCache) {
50
+ warnings.push({
51
+ code: "REMOTE_REFRESH_FAILED_USING_CACHE",
52
+ message: "Remote registry refresh failed. Using previously cached registry.",
53
+ });
54
+ return { registry: existingCache.registry, warnings };
55
+ }
56
+ warnings.push({
57
+ code: "USING_BUNDLED_FALLBACK",
58
+ message: "Remote registry could not be loaded. Using bundled registry.",
59
+ });
60
+ return {
61
+ registry: cacheAndReturn(loadBundledRegistry(), "bundled"),
62
+ warnings,
63
+ };
64
+ }
65
+ }
66
+ return { registry: existingCache.registry, warnings };
67
+ }
68
+ //# sourceMappingURL=loadAIProfilesRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadAIProfilesRegistry.js","sourceRoot":"","sources":["../../src/loader/loadAIProfilesRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAOvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAE1B,SAAS,cAAc,CACrB,QAA4B,EAC5B,MAA4B;IAE5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,KAAK,GAAwB;QACjC,QAAQ;QACR,QAAQ,EAAE,GAAG;QACb,SAAS,EAAE,GA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,CAAC;gBAC9D,QAAQ;aACT,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,aAAa,EAAE,CAAC;gBAClB,QAAQ,CAAC,IAAI,CAAC;oBACZ,IAAI,EAAE,mCAAmC;oBACzC,OAAO,EACL,mEAAmE;iBACtE,CAAC,CAAC;gBACH,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC;YACxD,CAAC;YAED,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,wBAAwB;gBAC9B,OAAO,EAAE,8DAA8D;aACxE,CAAC,CAAC;YAEH,OAAO;gBACL,QAAQ,EAAE,cAAc,CAAC,mBAAmB,EAAE,EAAE,SAAS,CAAC;gBAC1D,QAAQ;aACT,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,aAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC;AACzD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AIProfilesRegistry } from "../types.js";
2
+ export declare function loadBundledRegistry(): AIProfilesRegistry;
3
+ //# sourceMappingURL=loadBundledRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadBundledRegistry.d.ts","sourceRoot":"","sources":["../../src/loader/loadBundledRegistry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAOtD,wBAAgB,mBAAmB,IAAI,kBAAkB,CAuBxD"}
@@ -0,0 +1,22 @@
1
+ import bundledModelsProfiles from "../data/models-profiles.json" with { type: "json" };
2
+ import bundledProfilesShortcuts from "../data/profiles-shortcuts.json" with { type: "json" };
3
+ import { AIProfilesError } from "../errors.js";
4
+ import { validateModelsProfilesJson, validateProfilesShortcutsJson, } from "../validation/validateModelsProfilesJson.js";
5
+ import { combineRegistry } from "./combineRegistry.js";
6
+ export function loadBundledRegistry() {
7
+ try {
8
+ const modelsProfiles = validateModelsProfilesJson(bundledModelsProfiles);
9
+ const shortcuts = validateProfilesShortcutsJson(bundledProfilesShortcuts, modelsProfiles.profiles);
10
+ return combineRegistry(modelsProfiles, shortcuts, "bundled");
11
+ }
12
+ catch (error) {
13
+ if (error instanceof AIProfilesError) {
14
+ throw new AIProfilesError(error.code === "REGISTRY_SCHEMA_UNSUPPORTED" ||
15
+ error.code === "REGISTRY_VALIDATION_FAILED"
16
+ ? "BUNDLED_JSON_INVALID"
17
+ : error.code, error.message, error.details);
18
+ }
19
+ throw error;
20
+ }
21
+ }
22
+ //# sourceMappingURL=loadBundledRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadBundledRegistry.js","sourceRoot":"","sources":["../../src/loader/loadBundledRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,8BAA8B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACvF,OAAO,wBAAwB,MAAM,iCAAiC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC;QACH,MAAM,cAAc,GAAG,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;QACzE,MAAM,SAAS,GAAG,6BAA6B,CAC7C,wBAAwB,EACxB,cAAc,CAAC,QAAQ,CACxB,CAAC;QAEF,OAAO,eAAe,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;YACrC,MAAM,IAAI,eAAe,CACvB,KAAK,CAAC,IAAI,KAAK,6BAA6B;gBAC1C,KAAK,CAAC,IAAI,KAAK,4BAA4B;gBAC3C,CAAC,CAAC,sBAAsB;gBACxB,CAAC,CAAC,KAAK,CAAC,IAAI,EACd,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,CACd,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AIProfilesRegistry } from "../types.js";
2
+ export declare function loadRemoteRegistry(): Promise<AIProfilesRegistry>;
3
+ //# sourceMappingURL=loadRemoteRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadRemoteRegistry.d.ts","sourceRoot":"","sources":["../../src/loader/loadRemoteRegistry.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAQtD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAgCtE"}
@@ -0,0 +1,27 @@
1
+ import { REMOTE_MODELS_PROFILES_URL, REMOTE_PROFILES_SHORTCUTS_URL, } from "../constants.js";
2
+ import { AIProfilesError } from "../errors.js";
3
+ import { validateModelsProfilesJson, validateProfilesShortcutsJson, } from "../validation/validateModelsProfilesJson.js";
4
+ import { combineRegistry } from "./combineRegistry.js";
5
+ import { fetchJson } from "./fetchJson.js";
6
+ export async function loadRemoteRegistry() {
7
+ try {
8
+ const [modelsProfilesRaw, shortcutsRaw] = await Promise.all([
9
+ fetchJson(REMOTE_MODELS_PROFILES_URL),
10
+ fetchJson(REMOTE_PROFILES_SHORTCUTS_URL),
11
+ ]);
12
+ const modelsProfiles = validateModelsProfilesJson(modelsProfilesRaw);
13
+ const shortcuts = validateProfilesShortcutsJson(shortcutsRaw, modelsProfiles.profiles);
14
+ return combineRegistry(modelsProfiles, shortcuts, "remote");
15
+ }
16
+ catch (error) {
17
+ if (error instanceof AIProfilesError) {
18
+ if (error.code === "REGISTRY_SCHEMA_UNSUPPORTED" ||
19
+ error.code === "REGISTRY_VALIDATION_FAILED") {
20
+ throw new AIProfilesError("REMOTE_JSON_INVALID", error.message, error.details);
21
+ }
22
+ throw error;
23
+ }
24
+ throw error;
25
+ }
26
+ }
27
+ //# sourceMappingURL=loadRemoteRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadRemoteRegistry.js","sourceRoot":"","sources":["../../src/loader/loadRemoteRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,IAAI,CAAC;QACH,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC1D,SAAS,CAAC,0BAA0B,CAAC;YACrC,SAAS,CAAC,6BAA6B,CAAC;SACzC,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,0BAA0B,CAAC,iBAAiB,CAAC,CAAC;QACrE,MAAM,SAAS,GAAG,6BAA6B,CAC7C,YAAY,EACZ,cAAc,CAAC,QAAQ,CACxB,CAAC;QAEF,OAAO,eAAe,CAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;YACrC,IACE,KAAK,CAAC,IAAI,KAAK,6BAA6B;gBAC5C,KAAK,CAAC,IAAI,KAAK,4BAA4B,EAC3C,CAAC;gBACD,MAAM,IAAI,eAAe,CACvB,qBAAqB,EACrB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,CACd,CAAC;YACJ,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { AIProfilesRegistry } from "../types.js";
2
+ export interface RegistryMemoryCache {
3
+ registry: AIProfilesRegistry;
4
+ loadedAt: number;
5
+ expiresAt: number;
6
+ source: "remote" | "bundled";
7
+ }
8
+ export declare function getMemoryCache(): RegistryMemoryCache | null;
9
+ export declare function setMemoryCache(cache: RegistryMemoryCache): void;
10
+ export declare function clearMemoryCache(): void;
11
+ export declare function isCacheValid(cache: RegistryMemoryCache | null): boolean;
12
+ export declare function isCacheExpired(cache: RegistryMemoryCache | null): boolean;
13
+ //# sourceMappingURL=memoryCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryCache.d.ts","sourceRoot":"","sources":["../../src/loader/memoryCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B;AAID,wBAAgB,cAAc,IAAI,mBAAmB,GAAG,IAAI,CAE3D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAE/D;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,GAAG,OAAO,CAEvE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,GAAG,OAAO,CAEzE"}
@@ -0,0 +1,17 @@
1
+ let memoryCache = null;
2
+ export function getMemoryCache() {
3
+ return memoryCache;
4
+ }
5
+ export function setMemoryCache(cache) {
6
+ memoryCache = cache;
7
+ }
8
+ export function clearMemoryCache() {
9
+ memoryCache = null;
10
+ }
11
+ export function isCacheValid(cache) {
12
+ return !!cache && Date.now() < cache.expiresAt;
13
+ }
14
+ export function isCacheExpired(cache) {
15
+ return !!cache && Date.now() >= cache.expiresAt;
16
+ }
17
+ //# sourceMappingURL=memoryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryCache.js","sourceRoot":"","sources":["../../src/loader/memoryCache.ts"],"names":[],"mappings":"AASA,IAAI,WAAW,GAA+B,IAAI,CAAC;AAEnD,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAiC;IAC5D,OAAO,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAiC;IAC9D,OAAO,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,SAAS,CAAC;AAClD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function normalizeKey(value: string): string;
2
+ //# sourceMappingURL=normalizeKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeKey.d.ts","sourceRoot":"","sources":["../src/normalizeKey.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -0,0 +1,4 @@
1
+ export function normalizeKey(value) {
2
+ return value.trim().toLowerCase();
3
+ }
4
+ //# sourceMappingURL=normalizeKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeKey.js","sourceRoot":"","sources":["../src/normalizeKey.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ResolveAIProfileOptions, ResolvedAIProfile } from "./types.js";
2
+ export declare function resolveAIProfile(input: string, options?: ResolveAIProfileOptions): Promise<ResolvedAIProfile>;
3
+ //# sourceMappingURL=resolveAIProfile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAIProfile.d.ts","sourceRoot":"","sources":["../src/resolveAIProfile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE7E,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,iBAAiB,CAAC,CAmE5B"}
@@ -0,0 +1,53 @@
1
+ import { buildResolvedProfile } from "./buildResolvedProfile.js";
2
+ import { AIProfilesError } from "./errors.js";
3
+ import { loadAIProfilesRegistryWithWarnings } from "./loader/loadAIProfilesRegistry.js";
4
+ import { normalizeKey } from "./normalizeKey.js";
5
+ export async function resolveAIProfile(input, options = {}) {
6
+ const { registry, warnings } = await loadAIProfilesRegistryWithWarnings({
7
+ source: options.source,
8
+ refresh: options.refresh,
9
+ });
10
+ const key = normalizeKey(input);
11
+ const directProfile = registry.profiles[key];
12
+ const shortcut = registry.shortcuts[key];
13
+ let profileKey;
14
+ let choiceKey;
15
+ let matchedShortcut = shortcut;
16
+ if (directProfile) {
17
+ profileKey = key;
18
+ choiceKey = options.choice ?? directProfile.defaultChoice;
19
+ matchedShortcut = undefined;
20
+ }
21
+ else if (shortcut) {
22
+ profileKey = shortcut.profile;
23
+ choiceKey = options.choice ?? shortcut.choice;
24
+ }
25
+ else {
26
+ throw new AIProfilesError("UNKNOWN_PROFILE", `Unknown AI profile or shortcut: ${input}`, { input });
27
+ }
28
+ const profile = registry.profiles[profileKey];
29
+ if (!profile) {
30
+ throw new AIProfilesError("UNKNOWN_PROFILE", `Unknown AI profile: ${profileKey}`, { input, profile: profileKey });
31
+ }
32
+ const finalChoiceKey = choiceKey ?? profile.defaultChoice;
33
+ const choice = profile.choices[finalChoiceKey];
34
+ if (!choice) {
35
+ if (options.allowFallbackToDefaultChoice) {
36
+ return resolveAIProfile(profileKey, {
37
+ ...options,
38
+ choice: profile.defaultChoice,
39
+ });
40
+ }
41
+ throw new AIProfilesError("UNKNOWN_CHOICE", `Unknown choice '${finalChoiceKey}' for AI profile '${profileKey}'`, { input, profile: profileKey, choice: finalChoiceKey });
42
+ }
43
+ return buildResolvedProfile({
44
+ input,
45
+ shortcutKey: matchedShortcut ? key : undefined,
46
+ profile,
47
+ choice,
48
+ shortcut: matchedShortcut,
49
+ registry,
50
+ loaderWarnings: warnings,
51
+ });
52
+ }
53
+ //# sourceMappingURL=resolveAIProfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAIProfile.js","sourceRoot":"","sources":["../src/resolveAIProfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAa,EACb,UAAmC,EAAE;IAErC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,kCAAkC,CAAC;QACtE,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAEhC,MAAM,aAAa,GAAG,QAAQ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M,IAAI,eAAe,CACvB,gBAAgB,EAChB,mBAAmB,cAAc,qBAAqB,UAAU,GAAG,EACnE,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,CACvD,CAAC;IACJ,CAAC;IAED,OAAO,oBAAoB,CAAC;QAC1B,KAAK;QACL,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QAC9C,OAAO;QACP,MAAM;QACN,QAAQ,EAAE,eAAe;QACzB,QAAQ;QACR,cAAc,EAAE,QAAQ;KACzB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,151 @@
1
+ export type AIProvider = "openai" | "anthropic" | "google" | "deepseek" | "mistral" | "groq" | "xai" | "local" | "custom";
2
+ export interface AIModelPricing {
3
+ input?: number;
4
+ cachedInput?: number;
5
+ output?: number;
6
+ batchInput?: number;
7
+ batchCachedInput?: number;
8
+ batchOutput?: number;
9
+ cacheWrite5m?: number;
10
+ cacheWrite1h?: number;
11
+ cacheHit?: number;
12
+ inputBelow200k?: number;
13
+ inputAbove200k?: number;
14
+ outputBelow200k?: number;
15
+ outputAbove200k?: number;
16
+ notes?: string;
17
+ }
18
+ export interface AIRuntimeDefaults {
19
+ reasoningEffort?: "minimal" | "low" | "medium" | "high" | "max";
20
+ outputMode?: "text" | "json" | "schema";
21
+ temperature?: number;
22
+ toolPolicy?: "none" | "read-only" | "write-with-approval" | "write-allowed";
23
+ executionMode?: "sync" | "batch" | "offline";
24
+ requireCitations?: boolean;
25
+ allowWeb?: boolean;
26
+ allowFileSearch?: boolean;
27
+ allowCodeExecution?: boolean;
28
+ humanReview?: "none" | "before-write" | "before-final";
29
+ }
30
+ export interface AIProfileChoice {
31
+ choice: string;
32
+ displayName: string;
33
+ description: string;
34
+ provider: AIProvider;
35
+ modelId: string;
36
+ pricing?: AIModelPricing;
37
+ runtime?: AIRuntimeDefaults;
38
+ reason?: string;
39
+ status?: "active" | "experimental" | "deprecated";
40
+ metadata?: Record<string, unknown>;
41
+ }
42
+ export interface AIProfileDefinition {
43
+ profile: string;
44
+ displayName: string;
45
+ description: string;
46
+ category: string;
47
+ aliases?: string[];
48
+ defaultChoice: string;
49
+ choices: Record<string, AIProfileChoice>;
50
+ status?: "active" | "experimental" | "deprecated";
51
+ runtime?: AIRuntimeDefaults;
52
+ metadata?: Record<string, unknown>;
53
+ }
54
+ export interface AIProfileShortcut {
55
+ profile: string;
56
+ choice?: string;
57
+ description?: string;
58
+ }
59
+ export interface ModelsProfilesJson {
60
+ schema: "x12i.ai-profiles.models-profiles";
61
+ version: string;
62
+ generatedAt?: string;
63
+ currency: "USD";
64
+ pricingUnit: "1M_tokens";
65
+ profiles: Record<string, AIProfileDefinition>;
66
+ }
67
+ export interface ProfilesShortcutsJson {
68
+ schema: "x12i.ai-profiles.shortcuts";
69
+ version: string;
70
+ generatedAt?: string;
71
+ shortcuts: Record<string, AIProfileShortcut>;
72
+ }
73
+ export type RegistrySourceMode = "auto" | "remote" | "bundled";
74
+ export interface AIProfilesRegistry {
75
+ version: string;
76
+ generatedAt?: string;
77
+ currency: "USD";
78
+ pricingUnit: "1M_tokens";
79
+ profiles: Record<string, AIProfileDefinition>;
80
+ shortcuts: Record<string, AIProfileShortcut>;
81
+ source: "remote" | "bundled";
82
+ loadedAt: string;
83
+ }
84
+ export interface AIProfileSummary {
85
+ profile: string;
86
+ displayName: string;
87
+ description: string;
88
+ category: string;
89
+ defaultChoice: string;
90
+ choices: string[];
91
+ aliases: string[];
92
+ defaultProvider: AIProvider;
93
+ defaultModelId: string;
94
+ source: "remote" | "bundled";
95
+ registryVersion: string;
96
+ }
97
+ export interface AIProfileWarning {
98
+ code: "USING_BUNDLED_FALLBACK" | "PROFILE_DEPRECATED" | "CHOICE_DEPRECATED" | "PRICING_MISSING" | "REMOTE_REFRESH_FAILED_USING_CACHE";
99
+ message: string;
100
+ }
101
+ export interface ResolvedAIProfile {
102
+ input: string;
103
+ profile: string;
104
+ profileDisplayName: string;
105
+ profileDescription: string;
106
+ category: string;
107
+ choice: string;
108
+ choiceDisplayName: string;
109
+ choiceDescription: string;
110
+ provider: AIProvider;
111
+ modelId: string;
112
+ pricing?: AIModelPricing & {
113
+ currency: "USD";
114
+ unit: "1M_tokens";
115
+ };
116
+ runtime: Required<AIRuntimeDefaults>;
117
+ reason?: string;
118
+ source: "remote" | "bundled";
119
+ registryVersion: string;
120
+ loadedAt: string;
121
+ expiresAt: string;
122
+ shortcut?: {
123
+ key: string;
124
+ profile: string;
125
+ choice?: string;
126
+ };
127
+ warnings?: AIProfileWarning[];
128
+ }
129
+ export interface ListAIProfilesOptions {
130
+ source?: RegistrySourceMode;
131
+ refresh?: boolean;
132
+ includeExperimental?: boolean;
133
+ includeDeprecated?: boolean;
134
+ category?: string;
135
+ }
136
+ export interface ResolveAIProfileOptions {
137
+ choice?: string;
138
+ source?: RegistrySourceMode;
139
+ refresh?: boolean;
140
+ allowFallbackToDefaultChoice?: boolean;
141
+ strict?: boolean;
142
+ }
143
+ export interface LoadRegistryOptions {
144
+ source?: RegistrySourceMode;
145
+ refresh?: boolean;
146
+ }
147
+ export interface LoadRegistryResult {
148
+ registry: AIProfilesRegistry;
149
+ warnings: AIProfileWarning[];
150
+ }
151
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,UAAU,GACV,SAAS,GACT,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,CAAC;AAEb,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1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