opencode-antigravity-autopilot 2.2.2 → 2.2.3

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.
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.QuotaPoller = void 0;
43
+ var axios_1 = __importDefault(require("axios"));
44
+ var QuotaPoller = /** @class */ (function () {
45
+ function QuotaPoller() {
46
+ if (!(this instanceof QuotaPoller)) {
47
+ // @ts-ignore
48
+ return new QuotaPoller();
49
+ }
50
+ }
51
+ QuotaPoller.prototype.checkQuota = function (port, csrfToken) {
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ var url, response, quotaInfo, error_1;
54
+ var _a, _b;
55
+ return __generator(this, function (_c) {
56
+ switch (_c.label) {
57
+ case 0:
58
+ _c.trys.push([0, 2, , 3]);
59
+ url = "http://127.0.0.1:".concat(port, "/exa.language_server_pb.LanguageServerService/GetUserStatus");
60
+ return [4 /*yield*/, axios_1.default.post(url, { ideName: "antigravity", ideVersion: "unknown" }, {
61
+ headers: {
62
+ 'Content-Type': 'application/json',
63
+ 'X-Codeium-Csrf-Token': csrfToken
64
+ }
65
+ })];
66
+ case 1:
67
+ response = _c.sent();
68
+ quotaInfo = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.clientModelConfigs) === null || _b === void 0 ? void 0 : _b.quotaInfo;
69
+ if (!quotaInfo) {
70
+ return [2 /*return*/, null];
71
+ }
72
+ return [2 /*return*/, {
73
+ remainingFraction: quotaInfo.remainingFraction,
74
+ resetTime: quotaInfo.resetTime
75
+ }];
76
+ case 2:
77
+ error_1 = _c.sent();
78
+ return [2 /*return*/, null];
79
+ case 3: return [2 /*return*/];
80
+ }
81
+ });
82
+ });
83
+ };
84
+ return QuotaPoller;
85
+ }());
86
+ exports.QuotaPoller = QuotaPoller;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.ModelSelector = void 0;
15
+ var logger_1 = require("../utils/logger");
16
+ var ModelSelector = /** @class */ (function () {
17
+ function ModelSelector(quotaTracker, strategy) {
18
+ var _a, _b, _c, _d;
19
+ if (!(this instanceof ModelSelector)) {
20
+ // @ts-ignore
21
+ return new ModelSelector(quotaTracker, strategy);
22
+ }
23
+ this.logger = (0, logger_1.getLogger)();
24
+ this.quotaTracker = quotaTracker;
25
+ this.strategy = strategy || { preferredModels: [], fallbackModels: [], quotaThreshold: 0.02 };
26
+ this.logger.info('ModelSelector', 'Initialized', {
27
+ preferredModelsCount: (_b = (_a = this.strategy.preferredModels) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
28
+ fallbackModelsCount: (_d = (_c = this.strategy.fallbackModels) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
29
+ quotaThreshold: this.strategy.quotaThreshold,
30
+ });
31
+ }
32
+ ModelSelector.prototype.selectModel = function () {
33
+ this.logger.debug('ModelSelector', 'Selecting model', {
34
+ preferredModels: this.strategy.preferredModels,
35
+ fallbackModels: this.strategy.fallbackModels,
36
+ });
37
+ var preferredModel = this.quotaTracker.getBestAvailableModel(this.strategy.preferredModels);
38
+ if (preferredModel) {
39
+ this.logger.info('ModelSelector', 'Selected preferred model', { model: preferredModel });
40
+ return preferredModel;
41
+ }
42
+ this.logger.warn('ModelSelector', 'No preferred model available, trying fallbacks');
43
+ var fallbackModel = this.quotaTracker.getBestAvailableModel(this.strategy.fallbackModels);
44
+ if (fallbackModel) {
45
+ this.logger.info('ModelSelector', 'Selected fallback model', { model: fallbackModel });
46
+ }
47
+ else {
48
+ this.logger.error('ModelSelector', 'No suitable model found (all exhausted or below threshold)');
49
+ }
50
+ return fallbackModel;
51
+ };
52
+ ModelSelector.prototype.updateStrategy = function (strategy) {
53
+ this.strategy = __assign(__assign({}, this.strategy), strategy);
54
+ };
55
+ ModelSelector.prototype.getStrategy = function () {
56
+ return __assign({}, this.strategy);
57
+ };
58
+ ModelSelector.prototype.getQuotaStates = function () {
59
+ return this.quotaTracker.getAllQuotaStates();
60
+ };
61
+ return ModelSelector;
62
+ }());
63
+ exports.ModelSelector = ModelSelector;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuotaTracker = void 0;
4
+ var logger_1 = require("../utils/logger");
5
+ var QuotaTracker = /** @class */ (function () {
6
+ function QuotaTracker(quotaThreshold) {
7
+ if (quotaThreshold === void 0) { quotaThreshold = 0.02; }
8
+ if (!(this instanceof QuotaTracker)) {
9
+ // @ts-ignore
10
+ return new QuotaTracker(quotaThreshold);
11
+ }
12
+ this.logger = (0, logger_1.getLogger)();
13
+ this.quotaState = new Map();
14
+ this.quotaThreshold = quotaThreshold;
15
+ this.logger.info('QuotaTracker', 'Initialized', {
16
+ quotaThreshold: quotaThreshold,
17
+ thresholdPercentage: "".concat((quotaThreshold * 100).toFixed(1), "%"),
18
+ });
19
+ }
20
+ QuotaTracker.prototype.updateQuota = function (model, quota) {
21
+ var previousState = this.quotaState.get(model);
22
+ var newState = {
23
+ model: model,
24
+ quotaFraction: quota.remainingFraction,
25
+ lastChecked: Date.now(),
26
+ resetTime: quota.resetTime,
27
+ };
28
+ this.quotaState.set(model, newState);
29
+ this.logger.debug('QuotaTracker', 'Quota updated', {
30
+ model: model,
31
+ previousFraction: previousState === null || previousState === void 0 ? void 0 : previousState.quotaFraction,
32
+ newFraction: quota.remainingFraction,
33
+ quotaPercentage: "".concat((quota.remainingFraction * 100).toFixed(1), "%"),
34
+ threshold: "".concat((this.quotaThreshold * 100).toFixed(1), "%"),
35
+ isAboveThreshold: quota.remainingFraction >= this.quotaThreshold,
36
+ });
37
+ };
38
+ QuotaTracker.prototype.getQuotaForModel = function (model) {
39
+ return this.quotaState.get(model) || null;
40
+ };
41
+ QuotaTracker.prototype.isModelAvailable = function (model) {
42
+ var state = this.quotaState.get(model);
43
+ if (!state)
44
+ return true;
45
+ if (state.quotaFraction < this.quotaThreshold) {
46
+ return false;
47
+ }
48
+ return true;
49
+ };
50
+ QuotaTracker.prototype.getBestAvailableModel = function (candidates) {
51
+ var _a;
52
+ this.logger.debug('QuotaTracker', 'Finding best available model', {
53
+ candidatesCount: candidates.length,
54
+ candidates: candidates,
55
+ });
56
+ var bestModel = null;
57
+ var bestQuota = -1;
58
+ for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
59
+ var model = candidates_1[_i];
60
+ if (!this.isModelAvailable(model)) {
61
+ this.logger.debug('QuotaTracker', 'Model unavailable (below threshold)', { model: model });
62
+ continue;
63
+ }
64
+ var state = this.quotaState.get(model);
65
+ var quota = (_a = state === null || state === void 0 ? void 0 : state.quotaFraction) !== null && _a !== void 0 ? _a : 1.0;
66
+ if (quota > bestQuota) {
67
+ bestQuota = quota;
68
+ bestModel = model;
69
+ }
70
+ }
71
+ if (bestModel) {
72
+ this.logger.info('QuotaTracker', 'Best model found', {
73
+ model: bestModel,
74
+ quotaFraction: bestQuota,
75
+ quotaPercentage: "".concat((bestQuota * 100).toFixed(1), "%"),
76
+ });
77
+ }
78
+ else {
79
+ this.logger.warn('QuotaTracker', 'No available model found among candidates', {
80
+ candidatesCount: candidates.length,
81
+ });
82
+ }
83
+ return bestModel;
84
+ };
85
+ QuotaTracker.prototype.getAllQuotaStates = function () {
86
+ return Array.from(this.quotaState.values());
87
+ };
88
+ QuotaTracker.prototype.clearStaleData = function (maxAgeMs) {
89
+ if (maxAgeMs === void 0) { maxAgeMs = 300000; }
90
+ var now = Date.now();
91
+ for (var _i = 0, _a = this.quotaState.entries(); _i < _a.length; _i++) {
92
+ var _b = _a[_i], model = _b[0], state = _b[1];
93
+ if (now - state.lastChecked > maxAgeMs) {
94
+ this.quotaState.delete(model);
95
+ }
96
+ }
97
+ };
98
+ QuotaTracker.prototype.clearAll = function () {
99
+ var count = this.quotaState.size;
100
+ this.quotaState.clear();
101
+ this.logger.info('QuotaTracker', 'Cleared all quota states', { clearedCount: count });
102
+ };
103
+ return QuotaTracker;
104
+ }());
105
+ exports.QuotaTracker = QuotaTracker;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AutopilotLogger = void 0;
7
+ exports.getLogger = getLogger;
8
+ exports.setLogger = setLogger;
9
+ var fs_1 = __importDefault(require("fs"));
10
+ var path_1 = __importDefault(require("path"));
11
+ var AutopilotLogger = /** @class */ (function () {
12
+ function AutopilotLogger(options) {
13
+ var _a;
14
+ this.levelPriority = {
15
+ debug: 0,
16
+ info: 1,
17
+ warn: 2,
18
+ error: 3,
19
+ };
20
+ var logDir = (options === null || options === void 0 ? void 0 : options.logDir) || '/tmp';
21
+ var filename = (options === null || options === void 0 ? void 0 : options.filename) || "autopilot-".concat(this.getDateString(), ".log");
22
+ this.logFilePath = path_1.default.join(logDir, filename);
23
+ this.enabled = (_a = options === null || options === void 0 ? void 0 : options.enabled) !== null && _a !== void 0 ? _a : true;
24
+ this.minLevel = (options === null || options === void 0 ? void 0 : options.minLevel) || 'info';
25
+ if (this.enabled) {
26
+ this.ensureLogDirectory();
27
+ this.logRotation();
28
+ }
29
+ }
30
+ AutopilotLogger.prototype.getDateString = function () {
31
+ var now = new Date();
32
+ return now.toISOString().split('T')[0];
33
+ };
34
+ AutopilotLogger.prototype.ensureLogDirectory = function () {
35
+ var dir = path_1.default.dirname(this.logFilePath);
36
+ if (!fs_1.default.existsSync(dir)) {
37
+ fs_1.default.mkdirSync(dir, { recursive: true });
38
+ }
39
+ };
40
+ AutopilotLogger.prototype.logRotation = function () {
41
+ try {
42
+ var dir = path_1.default.dirname(this.logFilePath);
43
+ var files = fs_1.default.readdirSync(dir);
44
+ var autopilotLogs = files.filter(function (f) { return f.startsWith('autopilot-') && f.endsWith('.log'); });
45
+ var now = Date.now();
46
+ var sevenDaysAgo = now - (7 * 24 * 60 * 60 * 1000);
47
+ for (var _i = 0, autopilotLogs_1 = autopilotLogs; _i < autopilotLogs_1.length; _i++) {
48
+ var file = autopilotLogs_1[_i];
49
+ var filePath = path_1.default.join(dir, file);
50
+ var stats = fs_1.default.statSync(filePath);
51
+ if (stats.mtimeMs < sevenDaysAgo) {
52
+ fs_1.default.unlinkSync(filePath);
53
+ }
54
+ }
55
+ }
56
+ catch (error) {
57
+ }
58
+ };
59
+ AutopilotLogger.prototype.shouldLog = function (level) {
60
+ if (!this.enabled)
61
+ return false;
62
+ return this.levelPriority[level] >= this.levelPriority[this.minLevel];
63
+ };
64
+ AutopilotLogger.prototype.formatLogEntry = function (entry) {
65
+ var dataStr = entry.data ? " | ".concat(JSON.stringify(entry.data)) : '';
66
+ return "[".concat(entry.timestamp, "] [").concat(entry.level.toUpperCase(), "] [").concat(entry.component, "] ").concat(entry.message).concat(dataStr, "\n");
67
+ };
68
+ AutopilotLogger.prototype.writeLog = function (entry) {
69
+ if (!this.shouldLog(entry.level))
70
+ return;
71
+ try {
72
+ var formatted = this.formatLogEntry(entry);
73
+ fs_1.default.appendFileSync(this.logFilePath, formatted, 'utf-8');
74
+ }
75
+ catch (error) {
76
+ // Silently fail - don't use console
77
+ }
78
+ };
79
+ AutopilotLogger.prototype.debug = function (component, message, data) {
80
+ this.writeLog({
81
+ timestamp: new Date().toISOString(),
82
+ level: 'debug',
83
+ component: component,
84
+ message: message,
85
+ data: data,
86
+ });
87
+ };
88
+ AutopilotLogger.prototype.info = function (component, message, data) {
89
+ this.writeLog({
90
+ timestamp: new Date().toISOString(),
91
+ level: 'info',
92
+ component: component,
93
+ message: message,
94
+ data: data,
95
+ });
96
+ };
97
+ AutopilotLogger.prototype.warn = function (component, message, data) {
98
+ this.writeLog({
99
+ timestamp: new Date().toISOString(),
100
+ level: 'warn',
101
+ component: component,
102
+ message: message,
103
+ data: data,
104
+ });
105
+ };
106
+ AutopilotLogger.prototype.error = function (component, message, data) {
107
+ this.writeLog({
108
+ timestamp: new Date().toISOString(),
109
+ level: 'error',
110
+ component: component,
111
+ message: message,
112
+ data: data,
113
+ });
114
+ };
115
+ AutopilotLogger.prototype.getLogFilePath = function () {
116
+ return this.logFilePath;
117
+ };
118
+ return AutopilotLogger;
119
+ }());
120
+ exports.AutopilotLogger = AutopilotLogger;
121
+ var globalLogger = null;
122
+ function getLogger(options) {
123
+ if (!globalLogger) {
124
+ globalLogger = new AutopilotLogger(options);
125
+ }
126
+ return globalLogger;
127
+ }
128
+ function setLogger(logger) {
129
+ globalLogger = logger;
130
+ }
@@ -0,0 +1,5 @@
1
+ export declare function translateModelName(modelName: string): string;
2
+ export declare function getShortModelName(modelName: string): string;
3
+ export declare function formatModelQuotaForToast(modelName: string, quotaPercentage: number): string;
4
+ export declare function formatModelSwitchMessage(fromModel: string, toModel: string, reason: string): string;
5
+ //# sourceMappingURL=model-name-translator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-name-translator.d.ts","sourceRoot":"","sources":["../../src/utils/model-name-translator.ts"],"names":[],"mappings":"AA+FA,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAiC5D;AAYD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAI3D;AASD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAI3F;AAUD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAInG"}
@@ -0,0 +1,119 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ var API_TO_DISPLAY_NAMES = {
13
+ 'MODEL_GEMINI_3_PRO': 'Gemini 3 Pro',
14
+ 'MODEL_GEMINI_3_PRO_LOW': 'Gemini 3 Pro (Low)',
15
+ 'MODEL_GEMINI_3_PRO_HIGH': 'Gemini 3 Pro (High)',
16
+ 'MODEL_GEMINI_3_FLASH': 'Gemini 3 Flash',
17
+ 'MODEL_GEMINI_3_FLASH_LOW': 'Gemini 3 Flash (Low)',
18
+ 'MODEL_GEMINI_3_FLASH_MEDIUM': 'Gemini 3 Flash (Medium)',
19
+ 'MODEL_GEMINI_3_FLASH_HIGH': 'Gemini 3 Flash (High)',
20
+ 'MODEL_GEMINI_2_5_PRO': 'Gemini 2.5 Pro',
21
+ 'MODEL_GEMINI_2_5_FLASH': 'Gemini 2.5 Flash',
22
+ 'MODEL_CLAUDE_4_5_SONNET': 'Claude 4.5 Sonnet',
23
+ 'MODEL_CLAUDE_4_5_SONNET_THINKING': 'Claude 4.5 Sonnet (Thinking)',
24
+ 'MODEL_CLAUDE_4_5_OPUS': 'Claude 4.5 Opus',
25
+ 'MODEL_CLAUDE_4_5_OPUS_THINKING': 'Claude 4.5 Opus (Thinking)',
26
+ 'MODEL_CLAUDE_3_5_SONNET': 'Claude 3.5 Sonnet',
27
+ 'MODEL_OPENAI_GPT_OSS_120B_MEDIUM': 'GPT OSS 120B (Medium)',
28
+ 'MODEL_OPENAI_GPT_4O': 'GPT-4o',
29
+ 'MODEL_PLACEHOLDER_M7': 'Placeholder M7',
30
+ 'MODEL_PLACEHOLDER_M8': 'Placeholder M8',
31
+ 'MODEL_PLACEHOLDER_M12': 'Placeholder M12',
32
+ 'MODEL_PLACEHOLDER_M18': 'Placeholder M18',
33
+ 'MODEL_PLACEHOLDER_M19': 'Placeholder M19',
34
+ };
35
+ var MODEL_PATTERNS = [
36
+ {
37
+ pattern: /^gemini-(\d+(?:\.\d+)?)-(\w+)(?:-(low|medium|high))?$/i,
38
+ format: function (m) {
39
+ var _a, _b;
40
+ var version = m[1];
41
+ var variant = ((_a = m[2]) === null || _a === void 0 ? void 0 : _a.charAt(0).toUpperCase()) + ((_b = m[2]) === null || _b === void 0 ? void 0 : _b.slice(1));
42
+ var tier = m[3] ? " (".concat(m[3].charAt(0).toUpperCase() + m[3].slice(1), ")") : '';
43
+ return "Gemini ".concat(version, " ").concat(variant).concat(tier);
44
+ },
45
+ },
46
+ {
47
+ pattern: /^claude-(sonnet|opus|haiku)-(\d+)-(\d+)(?:-(thinking))?$/i,
48
+ format: function (m) {
49
+ var _a, _b;
50
+ var variant = ((_a = m[1]) === null || _a === void 0 ? void 0 : _a.charAt(0).toUpperCase()) + ((_b = m[1]) === null || _b === void 0 ? void 0 : _b.slice(1));
51
+ var version = "".concat(m[2], ".").concat(m[3]);
52
+ var thinking = m[4] ? ' (Thinking)' : '';
53
+ return "Claude ".concat(version, " ").concat(variant).concat(thinking);
54
+ },
55
+ },
56
+ {
57
+ pattern: /^(?:openai-)?gpt-(.+)$/i,
58
+ format: function (m) {
59
+ var _a;
60
+ var rest = (_a = m[1]) === null || _a === void 0 ? void 0 : _a.replace(/-/g, ' ').split(' ').map(function (w) { return w.charAt(0).toUpperCase() + w.slice(1); }).join(' ');
61
+ return "GPT ".concat(rest);
62
+ },
63
+ },
64
+ ];
65
+ function extractTierSuffix(modelName) {
66
+ var tierMatch = modelName.match(/-(minimal|low|medium|high)$/i);
67
+ return tierMatch ? " (".concat(tierMatch[1].charAt(0).toUpperCase() + tierMatch[1].slice(1), ")") : null;
68
+ }
69
+ export function translateModelName(modelName) {
70
+ var e_1, _a;
71
+ if (!modelName)
72
+ return 'Unknown Model';
73
+ var cleaned = modelName
74
+ .replace(/^antigravity-/i, '')
75
+ .replace(/^google\//i, '')
76
+ .replace(/^anthropic\//i, '')
77
+ .replace(/^openai\//i, '');
78
+ var directMapping = API_TO_DISPLAY_NAMES[modelName] || API_TO_DISPLAY_NAMES[cleaned.toUpperCase().replace(/-/g, '_').replace(/^MODEL_/, 'MODEL_')];
79
+ if (directMapping)
80
+ return directMapping;
81
+ try {
82
+ for (var MODEL_PATTERNS_1 = __values(MODEL_PATTERNS), MODEL_PATTERNS_1_1 = MODEL_PATTERNS_1.next(); !MODEL_PATTERNS_1_1.done; MODEL_PATTERNS_1_1 = MODEL_PATTERNS_1.next()) {
83
+ var _b = MODEL_PATTERNS_1_1.value, pattern = _b.pattern, format = _b.format;
84
+ var match = cleaned.match(pattern);
85
+ if (match) {
86
+ return format(match);
87
+ }
88
+ }
89
+ }
90
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
91
+ finally {
92
+ try {
93
+ if (MODEL_PATTERNS_1_1 && !MODEL_PATTERNS_1_1.done && (_a = MODEL_PATTERNS_1.return)) _a.call(MODEL_PATTERNS_1);
94
+ }
95
+ finally { if (e_1) throw e_1.error; }
96
+ }
97
+ var tierSuffix = extractTierSuffix(cleaned);
98
+ var baseName = tierSuffix ? cleaned.replace(/-(minimal|low|medium|high)$/i, '') : cleaned;
99
+ var formatted = baseName
100
+ .split('-')
101
+ .map(function (word) { return word.charAt(0).toUpperCase() + word.slice(1); })
102
+ .join(' ');
103
+ return tierSuffix ? "".concat(formatted).concat(tierSuffix) : formatted;
104
+ }
105
+ export function getShortModelName(modelName) {
106
+ var translated = translateModelName(modelName);
107
+ return translated.replace(/\s*\([^)]*\)\s*$/, '');
108
+ }
109
+ export function formatModelQuotaForToast(modelName, quotaPercentage) {
110
+ var displayName = translateModelName(modelName);
111
+ var emoji = quotaPercentage <= 2 ? '🔴' : quotaPercentage <= 10 ? '🟡' : '🟢';
112
+ return "".concat(emoji, " ").concat(displayName, ": ").concat(quotaPercentage.toFixed(0), "%");
113
+ }
114
+ export function formatModelSwitchMessage(fromModel, toModel, reason) {
115
+ var fromDisplay = translateModelName(fromModel);
116
+ var toDisplay = translateModelName(toModel);
117
+ return "Switching from ".concat(fromDisplay, " to ").concat(toDisplay, ": ").concat(reason);
118
+ }
119
+ //# sourceMappingURL=model-name-translator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-name-translator.js","sourceRoot":"","sources":["../../src/utils/model-name-translator.ts"],"names":[],"mappings":";;;;;;;;;;;AAWA,IAAM,oBAAoB,GAA2B;IAEnD,oBAAoB,EAAE,cAAc;IACpC,wBAAwB,EAAE,oBAAoB;IAC9C,yBAAyB,EAAE,qBAAqB;IAChD,sBAAsB,EAAE,gBAAgB;IACxC,0BAA0B,EAAE,sBAAsB;IAClD,6BAA6B,EAAE,yBAAyB;IACxD,2BAA2B,EAAE,uBAAuB;IACpD,sBAAsB,EAAE,gBAAgB;IACxC,wBAAwB,EAAE,kBAAkB;IAG5C,yBAAyB,EAAE,mBAAmB;IAC9C,kCAAkC,EAAE,8BAA8B;IAClE,uBAAuB,EAAE,iBAAiB;IAC1C,gCAAgC,EAAE,4BAA4B;IAC9D,yBAAyB,EAAE,mBAAmB;IAG9C,kCAAkC,EAAE,uBAAuB;IAC3D,qBAAqB,EAAE,QAAQ;IAG/B,sBAAsB,EAAE,gBAAg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,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAClD,IAAM,KAAK,GAAG,eAAe,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAChF,OAAO,UAAG,KAAK,cAAI,WAAW,eAAK,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,MAAG,CAAC;AACnE,CAAC;AAUD,MAAM,UAAU,wBAAwB,CAAC,SAAiB,EAAE,OAAe,EAAE,MAAc;IACzF,IAAM,WAAW,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAClD,IAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC9C,OAAO,yBAAkB,WAAW,iBAAO,SAAS,eAAK,MAAM,CAAE,CAAC;AACpE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-antigravity-autopilot",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Intelligent quota monitoring and model auto-switching for OpenCode with Antigravity. Plugin-based, zero source modifications required.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",