opencode-antigravity-autopilot 2.2.9 → 2.2.10
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.
- package/README.md +1 -1
- package/dist/auth/AccountRotator.d.ts.map +1 -1
- package/dist/auth/AccountRotator.js +1 -1
- package/dist/auth/AccountRotator.js.map +1 -1
- package/dist/auth/TokenStorageReader.d.ts.map +1 -1
- package/dist/auth/TokenStorageReader.js +1 -1
- package/dist/auth/TokenStorageReader.js.map +1 -1
- package/package.json +2 -2
- package/dist/AsyncLogger.d.ts +0 -5
- package/dist/AsyncLogger.d.ts.map +0 -1
- package/dist/AsyncLogger.js +0 -78
- package/dist/AsyncLogger.js.map +0 -1
- package/dist/logger.d.ts +0 -2
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -30
- package/dist/logger.js.map +0 -1
- package/dist/rotation/reproduce_crash.d.ts +0 -2
- package/dist/rotation/reproduce_crash.d.ts.map +0 -1
- package/dist/rotation/reproduce_crash.js +0 -10
- package/dist/rotation/reproduce_crash.js.map +0 -1
- package/dist/scripts/scripts/test-agent-quota.js +0 -154
- package/dist/scripts/src/auth/AccountRotator.js +0 -143
- package/dist/scripts/src/auth/TokenStorageReader.js +0 -88
- package/dist/scripts/src/manager.js +0 -360
- package/dist/scripts/src/oh-my-opencode.js +0 -145
- package/dist/scripts/src/quota/ApiQuotaPoller.js +0 -340
- package/dist/scripts/src/quota/LSPFinder.js +0 -86
- package/dist/scripts/src/quota/QuotaCacheUpdater.js +0 -212
- package/dist/scripts/src/quota/QuotaPoller.js +0 -86
- package/dist/scripts/src/rotation/ModelSelector.js +0 -63
- package/dist/scripts/src/rotation/QuotaTracker.js +0 -105
- package/dist/scripts/src/types.js +0 -2
- package/dist/scripts/src/utils/logger.js +0 -130
package/README.md
CHANGED
|
@@ -328,7 +328,7 @@ cat ~/.config/opencode/opencode.json
|
|
|
328
328
|
cat ~/.config/opencode/antigravity-accounts.json
|
|
329
329
|
|
|
330
330
|
# Test manually
|
|
331
|
-
node -e "const {QuotaManager} = require('opencode-antigravity-autopilot'); const m = new QuotaManager(); m.initialize().then(() => m.getQuotaViaApi().then(
|
|
331
|
+
node -e "const {QuotaManager} = require('opencode-antigravity-autopilot'); const m = new QuotaManager(); m.initialize().then(() => m.getQuotaViaApi().then());"
|
|
332
332
|
```
|
|
333
333
|
|
|
334
334
|
### Model Switch Not Working
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountRotator.d.ts","sourceRoot":"","sources":["../../src/auth/AccountRotator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,sBAAsB,CAAC;AAM3E,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,mBAAmB,CAAC,CAA6D;IACzF,OAAO,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"AccountRotator.d.ts","sourceRoot":"","sources":["../../src/auth/AccountRotator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,sBAAsB,CAAC;AAM3E,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,mBAAmB,CAAC,CAA6D;IACzF,OAAO,CAAC,MAAM,CAA6C;gBAGzD,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,YAAY,EAAE,MAAM,EACpB,mBAAmB,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAoB3E,iBAAiB,IAAI,iBAAiB,GAAG,IAAI;IAqC7C,oBAAoB,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM;IAyB/E,OAAO,CAAC,UAAU;IAqClB,OAAO,CAAC,cAAc;CASvB"}
|
|
@@ -41,7 +41,6 @@ import { getLogger } from '../utils/logger';
|
|
|
41
41
|
var AccountRotator = (function () {
|
|
42
42
|
function AccountRotator(accounts, initialIndex, activeIndexByFamily) {
|
|
43
43
|
var _a, _b;
|
|
44
|
-
this.logger = getLogger();
|
|
45
44
|
if (!(this instanceof AccountRotator)) {
|
|
46
45
|
return new AccountRotator(accounts, initialIndex, activeIndexByFamily);
|
|
47
46
|
}
|
|
@@ -56,6 +55,7 @@ var AccountRotator = (function () {
|
|
|
56
55
|
else {
|
|
57
56
|
this.activeIndex = initialIndex;
|
|
58
57
|
}
|
|
58
|
+
this.logger = getLogger();
|
|
59
59
|
}
|
|
60
60
|
AccountRotator.prototype.getCurrentAccount = function () {
|
|
61
61
|
if (this.accounts.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountRotator.js","sourceRoot":"","sources":["../../src/auth/AccountRotator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;IAME,wBACE,QAA6B,EAC7B,YAAoB,EACpB,mBAAgF;;
|
|
1
|
+
{"version":3,"file":"AccountRotator.js","sourceRoot":"","sources":["../../src/auth/AccountRotator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;IAME,wBACE,QAA6B,EAC7B,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AAI,iBAAiB,EAAE;IAIlC,cAAc,IAAI,MAAM;IAIxB,sBAAsB;iBAtBY,MAAM;iBAAW,MAAM;sBAAgB,MAAM;;IA0BtF,OAAO,CAAC,IAAI;IA2BZ,OAAO,CAAC,cAAc;CASvB"}
|
|
@@ -4,10 +4,10 @@ import * as os from 'os';
|
|
|
4
4
|
import { getLogger } from '../utils/logger';
|
|
5
5
|
var TokenStorageReader = (function () {
|
|
6
6
|
function TokenStorageReader() {
|
|
7
|
-
this.logger = getLogger();
|
|
8
7
|
if (!(this instanceof TokenStorageReader)) {
|
|
9
8
|
return new TokenStorageReader();
|
|
10
9
|
}
|
|
10
|
+
this.logger = getLogger();
|
|
11
11
|
this.accounts = [];
|
|
12
12
|
this.activeIndex = -1;
|
|
13
13
|
this.load();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenStorageReader.js","sourceRoot":"","sources":["../../src/auth/TokenStorageReader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAqB5C;IAME;
|
|
1
|
+
{"version":3,"file":"TokenStorageReader.js","sourceRoot":"","sources":["../../src/auth/TokenStorageReader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAqB5C;IAME;QACE,IAAI,CAAC,CAAC,IAAI,YAAY,kBAAkB,CAAC,EAAE,CAAC;YAE1C,OAAO,IAAI,kBAAkB,EAAE,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,SAAS,EAAE,CAA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AC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,oCAAoC,EAAE,KAAK,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IAEO,2CAAc,GAAtB;QACE,IAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAClD,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,EAAE,2BAA2B,CAAC,CAAC;QAC3E,CAAC;QAED,IAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,2BAA2B,CAAC,CAAC;IAChF,CAAC;IACH,yBAAC;AAAD,CAAC,AAjED,IAiEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-antigravity-autopilot",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.10",
|
|
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",
|
|
@@ -60,4 +60,4 @@
|
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"opencode-antigravity-auth": "^1.2.8"
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|
package/dist/AsyncLogger.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncLogger.d.ts","sourceRoot":"","sources":["../src/AsyncLogger.ts"],"names":[],"mappings":"AAIA,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAoC;WAE7C,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBpE"}
|
package/dist/AsyncLogger.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
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);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import fs from 'fs';
|
|
38
|
-
var AsyncLogger = (function () {
|
|
39
|
-
function AsyncLogger() {
|
|
40
|
-
}
|
|
41
|
-
AsyncLogger.logAsync = function (message, data) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var timestamp, logMessage, error_1;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
timestamp = new Date().toISOString();
|
|
48
|
-
logMessage = "[".concat(timestamp, "] ").concat(message);
|
|
49
|
-
if (data) {
|
|
50
|
-
try {
|
|
51
|
-
logMessage += " ".concat(JSON.stringify(data));
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
logMessage += " [Circular/Unserializable]";
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
logMessage += '\n';
|
|
58
|
-
_a.label = 1;
|
|
59
|
-
case 1:
|
|
60
|
-
_a.trys.push([1, 3, , 4]);
|
|
61
|
-
return [4, fs.promises.appendFile(this.logFile, logMessage, 'utf8')];
|
|
62
|
-
case 2:
|
|
63
|
-
_a.sent();
|
|
64
|
-
return [3, 4];
|
|
65
|
-
case 3:
|
|
66
|
-
error_1 = _a.sent();
|
|
67
|
-
console.warn('Failed to write to log file:', error_1);
|
|
68
|
-
return [3, 4];
|
|
69
|
-
case 4: return [2];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
AsyncLogger.logFile = '/tmp/antigravity-autopilot.log';
|
|
75
|
-
return AsyncLogger;
|
|
76
|
-
}());
|
|
77
|
-
export { AsyncLogger };
|
|
78
|
-
//# sourceMappingURL=AsyncLogger.js.map
|
package/dist/AsyncLogger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncLogger.js","sourceRoot":"","sources":["../src/AsyncLogger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB;IAAA;IAwBA,CAAC;IArBgB,oBAAQ,GAArB,UAAsB,OAAe,EAAE,IAAU;;;;;;wBACvC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;wBACvC,UAAU,GAAG,WAAI,SAAS,eAAK,OAAO,CAAE,CAAC;wBAE7C,IAAI,IAAI,EAAE,CAAC;4BACP,IAAI,CAAC;gCACD,UAAU,IAAI,WAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAE,CAAC;4BAC7C,CAAC;4BAAC,OAAO,CAAC,EAAE,CAAC;gCACT,UAAU,IAAI,4BAA4B,CAAC;4BAC/C,CAAC;wBACL,CAAC;wBAED,UAAU,IAAI,IAAI,CAAC;;;;wBAGf,WAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,EAAA;;wBAA9D,SAA8D,CAAC;;;;wBAG/D,OAAO,CAAC,IAAI,CAAC,8BAA8B,EAAE,OAAK,CAAC,CAAC;;;;;;KAE3D;IAtBc,mBAAO,GAAG,gCAAgC,CAAC;IAuB9D,kBAAC;CAAA,AAxBD,IAwBC;SAxBY,WAAW"}
|
package/dist/logger.d.ts
DELETED
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAMA,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,QAsBnD"}
|
package/dist/logger.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import * as os from 'os';
|
|
4
|
-
var LOG_FILE_PATH = path.join(os.tmpdir(), 'antigravity-autopilot.log');
|
|
5
|
-
export function logDebug(message, data) {
|
|
6
|
-
try {
|
|
7
|
-
var timestamp = new Date().toISOString();
|
|
8
|
-
var logEntry = "[".concat(timestamp, "] ").concat(message);
|
|
9
|
-
if (data !== undefined) {
|
|
10
|
-
if (data instanceof Error) {
|
|
11
|
-
logEntry += "\nError: ".concat(data.message, "\nStack: ").concat(data.stack);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
try {
|
|
15
|
-
var serialized = JSON.stringify(data, null, 2);
|
|
16
|
-
logEntry += "\nData: ".concat(serialized);
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
logEntry += "\nData: [Circular or Unserializable]";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
logEntry += '\n';
|
|
24
|
-
fs.appendFileSync(LOG_FILE_PATH, logEntry);
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
console.error('Failed to write to log file:', error);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"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ce_crash.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { HardLimitDetector } from './HardLimitDetector';
|
|
2
|
-
console.log('Attempting to call HardLimitDetector without new...');
|
|
3
|
-
try {
|
|
4
|
-
var instance = HardLimitDetector();
|
|
5
|
-
console.log('Successfully created instance via function call');
|
|
6
|
-
}
|
|
7
|
-
catch (error) {
|
|
8
|
-
console.error('Caught error:', error);
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=reproduce_crash.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reproduce_crash.js","sourceRoot":"","sources":["../../src/rotation/reproduce_crash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;AAEnE,IAAI,CAAC;IAED,IAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;AACnE,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACb,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
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);
|
|
28
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
var manager_1 = require("../src/manager");
|
|
55
|
-
var oh_my_opencode_1 = require("../src/oh-my-opencode");
|
|
56
|
-
var QuotaTracker_1 = require("../src/rotation/QuotaTracker");
|
|
57
|
-
// Mock QuotaManager to simulate quota states
|
|
58
|
-
var MockQuotaManager = /** @class */ (function (_super) {
|
|
59
|
-
__extends(MockQuotaManager, _super);
|
|
60
|
-
function MockQuotaManager(mockQuota, mockModel) {
|
|
61
|
-
var _this = _super.call(this) || this;
|
|
62
|
-
_this.mockQuota = mockQuota;
|
|
63
|
-
_this.mockModel = mockModel;
|
|
64
|
-
// @ts-ignore - Accessing private property for test setup
|
|
65
|
-
_this.quotaTracker = new QuotaTracker_1.QuotaTracker(0.02);
|
|
66
|
-
// @ts-ignore - Accessing private property for test setup
|
|
67
|
-
_this.quotaTracker.updateQuota(mockModel, {
|
|
68
|
-
remainingFraction: mockQuota,
|
|
69
|
-
resetTime: new Date(Date.now() + 3600000).toISOString(),
|
|
70
|
-
quotaFraction: mockQuota
|
|
71
|
-
});
|
|
72
|
-
return _this;
|
|
73
|
-
}
|
|
74
|
-
// @ts-ignore - Accessing private property for test setup
|
|
75
|
-
MockQuotaManager.prototype.getQuotaTracker = function () {
|
|
76
|
-
return this.quotaTracker;
|
|
77
|
-
};
|
|
78
|
-
// @ts-ignore - Mocking method
|
|
79
|
-
MockQuotaManager.prototype.selectBestModel = function () {
|
|
80
|
-
return 'fallback-model';
|
|
81
|
-
};
|
|
82
|
-
MockQuotaManager.prototype.rotateAccount = function () {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
-
return __generator(this, function (_a) {
|
|
85
|
-
console.log('Rotating account...');
|
|
86
|
-
return [2 /*return*/];
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
return MockQuotaManager;
|
|
91
|
-
}(manager_1.QuotaManager));
|
|
92
|
-
function testAgentQuotaThreshold() {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
-
var TARGET_MODEL, CURRENT_QUOTA, manager1, integration1, result1, manager2, integration2, result2, manager3, integration3, result3;
|
|
95
|
-
return __generator(this, function (_a) {
|
|
96
|
-
switch (_a.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
console.log('🧪 Testing Agent Quota Threshold Logic (TS version)...\n');
|
|
99
|
-
TARGET_MODEL = 'primary-model';
|
|
100
|
-
CURRENT_QUOTA = 0.05;
|
|
101
|
-
console.log("Context: Model '".concat(TARGET_MODEL, "' has ").concat(CURRENT_QUOTA * 100, "% quota remaining."));
|
|
102
|
-
// Test Case 1: Low Threshold (2%)
|
|
103
|
-
console.log('\n--- Test Case 1: Threshold 2% (Standard) ---');
|
|
104
|
-
manager1 = new MockQuotaManager(CURRENT_QUOTA, TARGET_MODEL);
|
|
105
|
-
integration1 = (0, oh_my_opencode_1.createOhMyOpenCodeIntegration)(manager1, {
|
|
106
|
-
defaultModel: TARGET_MODEL,
|
|
107
|
-
quotaThreshold: 0.02
|
|
108
|
-
});
|
|
109
|
-
return [4 /*yield*/, integration1.getModelForAgent('test-agent', TARGET_MODEL)];
|
|
110
|
-
case 1:
|
|
111
|
-
result1 = _a.sent();
|
|
112
|
-
if (result1 === TARGET_MODEL) {
|
|
113
|
-
console.log('✅ PASS: Kept primary model (5% > 2%)');
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
console.error("\u274C FAIL: Switched to ".concat(result1, " unexpectedly"));
|
|
117
|
-
}
|
|
118
|
-
// Test Case 2: High Threshold (10%)
|
|
119
|
-
console.log('\n--- Test Case 2: Threshold 10% (Aggressive) ---');
|
|
120
|
-
manager2 = new MockQuotaManager(CURRENT_QUOTA, TARGET_MODEL);
|
|
121
|
-
integration2 = (0, oh_my_opencode_1.createOhMyOpenCodeIntegration)(manager2, {
|
|
122
|
-
defaultModel: TARGET_MODEL,
|
|
123
|
-
quotaThreshold: 0.10
|
|
124
|
-
});
|
|
125
|
-
return [4 /*yield*/, integration2.getModelForAgent('test-agent', TARGET_MODEL)];
|
|
126
|
-
case 2:
|
|
127
|
-
result2 = _a.sent();
|
|
128
|
-
if (result2 === 'fallback-model') {
|
|
129
|
-
console.log('✅ PASS: Switched to fallback model (5% < 10%)');
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
console.error("\u274C FAIL: Kept ".concat(result2, " despite low quota"));
|
|
133
|
-
}
|
|
134
|
-
// Test Case 3: Default Threshold (Should be 2%)
|
|
135
|
-
console.log('\n--- Test Case 3: Default Threshold (Implied 2%) ---');
|
|
136
|
-
manager3 = new MockQuotaManager(CURRENT_QUOTA, TARGET_MODEL);
|
|
137
|
-
integration3 = (0, oh_my_opencode_1.createOhMyOpenCodeIntegration)(manager3, {
|
|
138
|
-
defaultModel: TARGET_MODEL
|
|
139
|
-
});
|
|
140
|
-
return [4 /*yield*/, integration3.getModelForAgent('test-agent', TARGET_MODEL)];
|
|
141
|
-
case 3:
|
|
142
|
-
result3 = _a.sent();
|
|
143
|
-
if (result3 === TARGET_MODEL) {
|
|
144
|
-
console.log('✅ PASS: Kept primary model with default threshold');
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
console.error("\u274C FAIL: Switched to ".concat(result3, " unexpectedly"));
|
|
148
|
-
}
|
|
149
|
-
return [2 /*return*/];
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
testAgentQuotaThreshold().catch(console.error);
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
36
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
37
|
-
if (ar || !(i in from)) {
|
|
38
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
39
|
-
ar[i] = from[i];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.AccountRotator = void 0;
|
|
46
|
-
var fs = __importStar(require("fs"));
|
|
47
|
-
var path = __importStar(require("path"));
|
|
48
|
-
var os = __importStar(require("os"));
|
|
49
|
-
var AccountRotator = /** @class */ (function () {
|
|
50
|
-
function AccountRotator(accounts, initialIndex) {
|
|
51
|
-
if (!(this instanceof AccountRotator)) {
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
return new AccountRotator(accounts, initialIndex);
|
|
54
|
-
}
|
|
55
|
-
this.accounts = __spreadArray([], accounts, true);
|
|
56
|
-
this.activeIndex = initialIndex;
|
|
57
|
-
}
|
|
58
|
-
AccountRotator.prototype.getCurrentAccount = function () {
|
|
59
|
-
if (this.accounts.length === 0) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
var count = this.accounts.length;
|
|
63
|
-
var now = Date.now();
|
|
64
|
-
for (var i = 0; i < count; i++) {
|
|
65
|
-
var index = (this.activeIndex + i) % count;
|
|
66
|
-
var account = this.accounts[index];
|
|
67
|
-
if (!account.coolingDownUntil || account.coolingDownUntil <= now) {
|
|
68
|
-
this.activeIndex = index;
|
|
69
|
-
return account;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
var minCooldown = Infinity;
|
|
73
|
-
var minIndex = -1;
|
|
74
|
-
for (var i = 0; i < count; i++) {
|
|
75
|
-
var account = this.accounts[i];
|
|
76
|
-
if (account.coolingDownUntil && account.coolingDownUntil < minCooldown) {
|
|
77
|
-
minCooldown = account.coolingDownUntil;
|
|
78
|
-
minIndex = i;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (minIndex !== -1) {
|
|
82
|
-
this.activeIndex = minIndex;
|
|
83
|
-
return this.accounts[minIndex];
|
|
84
|
-
}
|
|
85
|
-
return this.accounts[this.activeIndex];
|
|
86
|
-
};
|
|
87
|
-
AccountRotator.prototype.markCurrentExhausted = function (cooldownMs, resetTimeISO) {
|
|
88
|
-
if (this.accounts.length === 0) {
|
|
89
|
-
return -1;
|
|
90
|
-
}
|
|
91
|
-
var currentAccount = this.accounts[this.activeIndex];
|
|
92
|
-
if (resetTimeISO) {
|
|
93
|
-
var resetTime = new Date(resetTimeISO);
|
|
94
|
-
if (!Number.isNaN(resetTime.getTime())) {
|
|
95
|
-
currentAccount.coolingDownUntil = resetTime.getTime();
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
currentAccount.coolingDownUntil = Date.now() + (cooldownMs || 30 * 60 * 1000);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
currentAccount.coolingDownUntil = Date.now() + (cooldownMs || 30 * 60 * 1000);
|
|
103
|
-
}
|
|
104
|
-
this.activeIndex = (this.activeIndex + 1) % this.accounts.length;
|
|
105
|
-
this.saveToDisk();
|
|
106
|
-
return this.activeIndex;
|
|
107
|
-
};
|
|
108
|
-
AccountRotator.prototype.saveToDisk = function () {
|
|
109
|
-
var storagePath = this.getStoragePath();
|
|
110
|
-
// Ensure directory exists
|
|
111
|
-
var dir = path.dirname(storagePath);
|
|
112
|
-
if (!fs.existsSync(dir)) {
|
|
113
|
-
try {
|
|
114
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
console.error('Failed to create config directory:', error);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
var storage = {
|
|
122
|
-
version: 3,
|
|
123
|
-
accounts: this.accounts,
|
|
124
|
-
activeIndex: this.activeIndex
|
|
125
|
-
};
|
|
126
|
-
try {
|
|
127
|
-
fs.writeFileSync(storagePath, JSON.stringify(storage, null, 2), 'utf-8');
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
console.error('Failed to save account storage:', error);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
AccountRotator.prototype.getStoragePath = function () {
|
|
134
|
-
var xdgConfigHome = process.env.XDG_CONFIG_HOME;
|
|
135
|
-
if (xdgConfigHome) {
|
|
136
|
-
return path.join(xdgConfigHome, 'opencode', 'antigravity-accounts.json');
|
|
137
|
-
}
|
|
138
|
-
var homeDir = os.homedir();
|
|
139
|
-
return path.join(homeDir, '.config', 'opencode', 'antigravity-accounts.json');
|
|
140
|
-
};
|
|
141
|
-
return AccountRotator;
|
|
142
|
-
}());
|
|
143
|
-
exports.AccountRotator = AccountRotator;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.TokenStorageReader = void 0;
|
|
37
|
-
var fs = __importStar(require("fs"));
|
|
38
|
-
var path = __importStar(require("path"));
|
|
39
|
-
var os = __importStar(require("os"));
|
|
40
|
-
var TokenStorageReader = /** @class */ (function () {
|
|
41
|
-
function TokenStorageReader() {
|
|
42
|
-
if (!(this instanceof TokenStorageReader)) {
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
return new TokenStorageReader();
|
|
45
|
-
}
|
|
46
|
-
this.accounts = [];
|
|
47
|
-
this.activeIndex = -1;
|
|
48
|
-
this.load();
|
|
49
|
-
}
|
|
50
|
-
TokenStorageReader.prototype.getAccounts = function () {
|
|
51
|
-
return this.accounts;
|
|
52
|
-
};
|
|
53
|
-
TokenStorageReader.prototype.getActiveIndex = function () {
|
|
54
|
-
return this.activeIndex;
|
|
55
|
-
};
|
|
56
|
-
TokenStorageReader.prototype.load = function () {
|
|
57
|
-
var _a;
|
|
58
|
-
var storagePath = this.getStoragePath();
|
|
59
|
-
if (!fs.existsSync(storagePath)) {
|
|
60
|
-
console.warn("Token storage file not found at ".concat(storagePath));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
var content = fs.readFileSync(storagePath, 'utf-8');
|
|
65
|
-
var data = JSON.parse(content);
|
|
66
|
-
if (data.version !== 3) {
|
|
67
|
-
console.warn("Unsupported storage version: ".concat(data.version, ". Expected version 3."));
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
var storage = data;
|
|
71
|
-
this.accounts = storage.accounts || [];
|
|
72
|
-
this.activeIndex = (_a = storage.activeIndex) !== null && _a !== void 0 ? _a : -1;
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error('Failed to parse token storage file:', error);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
TokenStorageReader.prototype.getStoragePath = function () {
|
|
79
|
-
var xdgConfigHome = process.env.XDG_CONFIG_HOME;
|
|
80
|
-
if (xdgConfigHome) {
|
|
81
|
-
return path.join(xdgConfigHome, 'opencode', 'antigravity-accounts.json');
|
|
82
|
-
}
|
|
83
|
-
var homeDir = os.homedir();
|
|
84
|
-
return path.join(homeDir, '.config', 'opencode', 'antigravity-accounts.json');
|
|
85
|
-
};
|
|
86
|
-
return TokenStorageReader;
|
|
87
|
-
}());
|
|
88
|
-
exports.TokenStorageReader = TokenStorageReader;
|