@aibridge/driver-agy 0.4.0 → 0.5.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.
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
- package/src/agy.test.ts +4 -4
- package/src/agyQuota.test.ts +4 -4
- package/src/agyQuota.ts +7 -2
- package/src/generateImage.test.ts +2 -2
- package/src/run.test.ts +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
2
2
|
import { homedir, tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { isNotFound, runCaptured, stripAnsi } from "@aibridge/proc";
|
|
4
|
+
import { AuthExpiredError, isNotFound, runCaptured, stripAnsi } from "@aibridge/proc";
|
|
5
5
|
//#region src/agy.ts
|
|
6
6
|
/**
|
|
7
7
|
* Assemble the `agy -p …` argv.
|
|
@@ -76,9 +76,9 @@ async function getAccessToken() {
|
|
|
76
76
|
const access = parsed.token?.access_token;
|
|
77
77
|
const refresh = parsed.token?.refresh_token;
|
|
78
78
|
const expiry = parsed.token?.expiry;
|
|
79
|
-
if (!access) throw new
|
|
79
|
+
if (!access) throw new AuthExpiredError("agy token file has no access_token");
|
|
80
80
|
if (!(expiry ? new Date(expiry).getTime() - Date.now() < 6e4 : false)) return access;
|
|
81
|
-
if (!refresh) throw new
|
|
81
|
+
if (!refresh) throw new AuthExpiredError("agy token expired and no refresh_token present — run `agy` once to re-login");
|
|
82
82
|
const res = await fetch(TOKEN_ENDPOINT, {
|
|
83
83
|
method: "POST",
|
|
84
84
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aibridge/driver-agy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Antigravity (agy) CLI driver for aibridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@aibridge/proc": "0.
|
|
35
|
+
"@aibridge/proc": "0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"tsdown": "0.22.14"
|
package/src/agy.test.ts
CHANGED
|
@@ -4,14 +4,14 @@ import { buildAgyPrintArgs } from './agy.ts';
|
|
|
4
4
|
describe('buildAgyPrintArgs', () => {
|
|
5
5
|
it('assembles default agy args', () => {
|
|
6
6
|
const args = buildAgyPrintArgs('test prompt', {
|
|
7
|
-
model: 'gemini-3.
|
|
7
|
+
model: 'gemini-3.7-flash-high',
|
|
8
8
|
printTimeoutSec: 600,
|
|
9
9
|
});
|
|
10
10
|
expect(args).toEqual([
|
|
11
11
|
'-p',
|
|
12
12
|
'test prompt',
|
|
13
13
|
'--model',
|
|
14
|
-
'gemini-3.
|
|
14
|
+
'gemini-3.7-flash-high',
|
|
15
15
|
'--print-timeout',
|
|
16
16
|
'600s',
|
|
17
17
|
]);
|
|
@@ -19,7 +19,7 @@ describe('buildAgyPrintArgs', () => {
|
|
|
19
19
|
|
|
20
20
|
it('preserves order of skipPermissions and addDirs', () => {
|
|
21
21
|
const args = buildAgyPrintArgs('test prompt', {
|
|
22
|
-
model: 'gemini-3.
|
|
22
|
+
model: 'gemini-3.7-flash-high',
|
|
23
23
|
printTimeoutSec: 600,
|
|
24
24
|
skipPermissions: true,
|
|
25
25
|
addDirs: ['/work/repo', '/tmp/answer-dir'],
|
|
@@ -28,7 +28,7 @@ describe('buildAgyPrintArgs', () => {
|
|
|
28
28
|
'-p',
|
|
29
29
|
'test prompt',
|
|
30
30
|
'--model',
|
|
31
|
-
'gemini-3.
|
|
31
|
+
'gemini-3.7-flash-high',
|
|
32
32
|
'--print-timeout',
|
|
33
33
|
'600s',
|
|
34
34
|
'--dangerously-skip-permissions',
|
package/src/agyQuota.test.ts
CHANGED
|
@@ -112,8 +112,8 @@ test('findModelQuota hits modelId id-form', () => {
|
|
|
112
112
|
groups: [],
|
|
113
113
|
models: [
|
|
114
114
|
{
|
|
115
|
-
modelId: 'gemini-3.
|
|
116
|
-
label: 'Gemini 3.
|
|
115
|
+
modelId: 'gemini-3.7-flash-high',
|
|
116
|
+
label: 'Gemini 3.7 Flash (High)',
|
|
117
117
|
remainingFraction: 0.9,
|
|
118
118
|
exhausted: false,
|
|
119
119
|
resetTime: undefined,
|
|
@@ -121,6 +121,6 @@ test('findModelQuota hits modelId id-form', () => {
|
|
|
121
121
|
],
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
const found = findModelQuota(snapshot, 'gemini-3.
|
|
125
|
-
assert.equal(found?.modelId, 'gemini-3.
|
|
124
|
+
const found = findModelQuota(snapshot, 'gemini-3.7-flash-high');
|
|
125
|
+
assert.equal(found?.modelId, 'gemini-3.7-flash-high');
|
|
126
126
|
});
|
package/src/agyQuota.ts
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import { readFileSync } from 'node:fs';
|
|
22
22
|
import { homedir } from 'node:os';
|
|
23
23
|
import { join } from 'node:path';
|
|
24
|
+
import { AuthExpiredError } from '@aibridge/proc';
|
|
24
25
|
import { AGY_CANONICAL_TO_NATIVE } from './registry.ts';
|
|
25
26
|
|
|
26
27
|
const CLOUDCODE_BASE = 'https://cloudcode-pa.googleapis.com';
|
|
@@ -100,11 +101,15 @@ async function getAccessToken(): Promise<string> {
|
|
|
100
101
|
const access = parsed.token?.access_token;
|
|
101
102
|
const refresh = parsed.token?.refresh_token;
|
|
102
103
|
const expiry = parsed.token?.expiry;
|
|
103
|
-
if (!access) throw new
|
|
104
|
+
if (!access) throw new AuthExpiredError('agy token file has no access_token');
|
|
104
105
|
|
|
105
106
|
const isExpired = expiry ? new Date(expiry).getTime() - Date.now() < 60_000 : false;
|
|
106
107
|
if (!isExpired) return access;
|
|
107
|
-
if (!refresh)
|
|
108
|
+
if (!refresh) {
|
|
109
|
+
throw new AuthExpiredError(
|
|
110
|
+
'agy token expired and no refresh_token present — run `agy` once to re-login',
|
|
111
|
+
);
|
|
112
|
+
}
|
|
108
113
|
|
|
109
114
|
const res = await fetch(TOKEN_ENDPOINT, {
|
|
110
115
|
method: 'POST',
|
|
@@ -9,7 +9,7 @@ describe('generateImage', () => {
|
|
|
9
9
|
const baseReq: ImageGenRequest = {
|
|
10
10
|
prompt: 'A futuristic city skyline',
|
|
11
11
|
workDir: '/tmp/work',
|
|
12
|
-
backendModel: 'gemini-3.
|
|
12
|
+
backendModel: 'gemini-3.7-flash-high',
|
|
13
13
|
aspectRatio: undefined,
|
|
14
14
|
imagePaths: [],
|
|
15
15
|
timeoutSec: 600,
|
|
@@ -45,7 +45,7 @@ describe('generateImage', () => {
|
|
|
45
45
|
|
|
46
46
|
expect(capturedCmd).toBe('agy');
|
|
47
47
|
expect(capturedArgs).toContain('--model');
|
|
48
|
-
expect(capturedArgs).toContain('gemini-3.
|
|
48
|
+
expect(capturedArgs).toContain('gemini-3.7-flash-high');
|
|
49
49
|
expect(capturedArgs).toContain('--dangerously-skip-permissions');
|
|
50
50
|
|
|
51
51
|
const promptIdx = capturedArgs.indexOf('-p');
|
package/src/run.test.ts
CHANGED
|
@@ -24,7 +24,7 @@ describe('agy driver run()', () => {
|
|
|
24
24
|
tools: false,
|
|
25
25
|
timeoutSec: 60,
|
|
26
26
|
cwd: '/test/cwd',
|
|
27
|
-
backendModel: 'gemini-3.
|
|
27
|
+
backendModel: 'gemini-3.7-flash-high',
|
|
28
28
|
},
|
|
29
29
|
fakeExec,
|
|
30
30
|
);
|
|
@@ -34,7 +34,7 @@ describe('agy driver run()', () => {
|
|
|
34
34
|
'-p',
|
|
35
35
|
'do something',
|
|
36
36
|
'--model',
|
|
37
|
-
'gemini-3.
|
|
37
|
+
'gemini-3.7-flash-high',
|
|
38
38
|
'--print-timeout',
|
|
39
39
|
'60s',
|
|
40
40
|
]);
|
|
@@ -71,7 +71,7 @@ describe('agy driver run()', () => {
|
|
|
71
71
|
tools: true,
|
|
72
72
|
timeoutSec: 100,
|
|
73
73
|
cwd: '/repo/root',
|
|
74
|
-
backendModel: 'gemini-3.
|
|
74
|
+
backendModel: 'gemini-3.7-flash-high',
|
|
75
75
|
},
|
|
76
76
|
fakeExec,
|
|
77
77
|
);
|
|
@@ -94,7 +94,7 @@ describe('agy driver run()', () => {
|
|
|
94
94
|
tools: false,
|
|
95
95
|
timeoutSec: 30,
|
|
96
96
|
cwd: '/test/cwd',
|
|
97
|
-
backendModel: 'gemini-3.
|
|
97
|
+
backendModel: 'gemini-3.7-flash-high',
|
|
98
98
|
},
|
|
99
99
|
fakeExec,
|
|
100
100
|
);
|
|
@@ -117,7 +117,7 @@ describe('agy driver run()', () => {
|
|
|
117
117
|
tools: false,
|
|
118
118
|
timeoutSec: 10,
|
|
119
119
|
cwd: '/test/cwd',
|
|
120
|
-
backendModel: 'gemini-3.
|
|
120
|
+
backendModel: 'gemini-3.7-flash-high',
|
|
121
121
|
},
|
|
122
122
|
fakeExec,
|
|
123
123
|
);
|
|
@@ -140,7 +140,7 @@ describe('agy driver run()', () => {
|
|
|
140
140
|
tools: false,
|
|
141
141
|
timeoutSec: 10,
|
|
142
142
|
cwd: '/test/cwd',
|
|
143
|
-
backendModel: 'gemini-3.
|
|
143
|
+
backendModel: 'gemini-3.7-flash-high',
|
|
144
144
|
},
|
|
145
145
|
fakeExec,
|
|
146
146
|
);
|