@juanbenjumea/pi-agy 0.7.15 → 0.7.16
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/CHANGELOG.md +8 -0
- package/README.md +5 -1
- package/extensions/index.ts +19 -3
- package/extensions/lib/args.ts +27 -14
- package/extensions/lib/cli.ts +5 -1
- package/extensions/lib/inspect.ts +32 -3
- package/extensions/lib/provider-catalog-store.ts +116 -0
- package/extensions/lib/provider-mcp.ts +11 -2
- package/extensions/lib/provider-models.ts +43 -27
- package/extensions/tools.ts +13 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.16
|
|
4
|
+
|
|
5
|
+
- Derive `--effort` support from the catalog instead of a vendor pattern. The previous `/^gpt-oss-/` rule emitted exactly the argv agy rejects: `--model gpt-oss-120b-medium --effort high` fails with "conflicts with --effort=high", while `claude-opus-5-5` accepts the flag. A tier-qualified id now never receives `--effort`, and a base slug only receives a tier its catalog lists.
|
|
6
|
+
- Collapse every family with two or more effort tiers into one picker entry with a thinking-level toggle, rather than only `gemini-*` families. The catalog decides, so `claude-*` bases stop appearing as separate per-tier entries.
|
|
7
|
+
- Treat `xhigh` and `max` as effort tiers. `gemini-4-neon-xhigh` and `gemini-4-hydrogen-xhigh` previously did not match the tier suffix and appeared as standalone models instead of a fourth stop in their family's toggle.
|
|
8
|
+
- Offer `xhigh` and `max` through `agy_execute`'s `effort` parameter, matching `agy --effort`.
|
|
9
|
+
- Cache the last observed model roster so a cold process can answer `getModels()`; the bridge's `agy_model_catalog` tool reads the same cache instead of reporting an empty catalog when live discovery fails. Pi resolves `enabledModels` during startup, so an undiscovered provider reported `No models match pattern "antigravity/<id>"` for an existing model. The cache stores only ids `agy models` returned, is written atomically, and degrades to the previous empty start when unreadable.
|
|
10
|
+
|
|
3
11
|
## 0.7.15
|
|
4
12
|
|
|
5
13
|
- Resolve every model alias against the live `agy models` catalog; no production path ships a model id, a per-family regex, or a fallback roster, so a renamed or new family needs no package update. An unresolvable alias now fails with the alias name, the exact recovery, and the discovered-catalog requirement instead of launching a stale id.
|
package/README.md
CHANGED
|
@@ -40,7 +40,11 @@ In `accept-edits` mode, Pi confirms before writes. agy's own permission behavior
|
|
|
40
40
|
|
|
41
41
|
## Use agy as a Pi model
|
|
42
42
|
|
|
43
|
-
The package registers an `antigravity` provider. Select discovered models as `antigravity/<model>` in Pi's `/model` picker. Models refresh automatically from `agy models` at session startup and whenever Pi opens the model picker (Pi 1.5.2 native refresh). New model names need no package update. Failed discovery keeps the last good catalog; before the first successful discovery the picker is empty rather than a stale built-in list, and `/agy doctor` reports why. Reopen `/model` after signing in to retry. Cache-only refreshes never run the CLI.
|
|
43
|
+
The package registers an `antigravity` provider. Select discovered models as `antigravity/<model>` in Pi's `/model` picker. Models refresh automatically from `agy models` at session startup and whenever Pi opens the model picker (Pi 1.5.2 native refresh). New model names need no package update. Failed discovery keeps the last good catalog; before the first successful discovery the picker is empty rather than a stale built-in list, and `/agy doctor` reports why. Reopen `/model` after signing in to retry. Cache-only refreshes never run the CLI.
|
|
44
|
+
|
|
45
|
+
The last observed roster is also cached in `agy-provider-models.json` next to `agy-config.json`. That file holds only ids `agy models` actually returned, and it exists because Pi resolves configured model scopes at startup: without it, a configured `antigravity/<id>` reports `No models match pattern` for a model that plainly exists, since the provider simply had not discovered anything yet.
|
|
46
|
+
|
|
47
|
+
A family that ships several effort tiers appears as one picker entry with a thinking-level toggle, including `xhigh` and `max` where agy offers them, and `--effort` carries the chosen tier. Families with a single tier, or none, keep agy's exact qualified id and never receive `--effort` — agy rejects that combination as a conflict.
|
|
44
48
|
|
|
45
49
|
Provider turns use a persistent agy process per working directory and can stage attached images for agy to read. By default, an MCP bridge gives agy read-only Pi context and lets it call active Pi tools through Pi's normal permission and approval flow. Set `"providerBridge": false` in `agy-config.json` to disable the bridge.
|
|
46
50
|
|
package/extensions/index.ts
CHANGED
|
@@ -28,6 +28,10 @@ import {
|
|
|
28
28
|
toProviderModelDef,
|
|
29
29
|
type AgyProviderModelEntry,
|
|
30
30
|
} from "./lib/provider-models.js";
|
|
31
|
+
import {
|
|
32
|
+
loadProviderCatalogCache,
|
|
33
|
+
saveProviderCatalogCache,
|
|
34
|
+
} from "./lib/provider-catalog-store.js";
|
|
31
35
|
import { runPreflightCommand } from "./lib/spawn.js";
|
|
32
36
|
|
|
33
37
|
export { truncate } from "./lib/output.js";
|
|
@@ -45,8 +49,14 @@ export { truncate } from "./lib/output.js";
|
|
|
45
49
|
function registerAgyProvider(pi: ExtensionAPI): void {
|
|
46
50
|
if (typeof pi.registerProvider !== "function") return;
|
|
47
51
|
// Keep one handler and catalog array for conversation/driver continuity.
|
|
48
|
-
// Only a generation-checked publication may mutate these entries.
|
|
49
|
-
|
|
52
|
+
// Only a generation-checked publication may mutate these entries. Start from
|
|
53
|
+
// the last roster this machine actually observed: Pi resolves configured
|
|
54
|
+
// model scopes during startup, and an empty catalog there reports a real
|
|
55
|
+
// model as "No models match pattern" before discovery can answer.
|
|
56
|
+
const cached = loadProviderCatalogCache();
|
|
57
|
+
const entries: AgyProviderModelEntry[] = [
|
|
58
|
+
...(cached.length > 0 ? cached : FALLBACK_PROVIDER_MODELS),
|
|
59
|
+
];
|
|
50
60
|
const shutdown = new AbortController();
|
|
51
61
|
let activeUi: { setStatus?: (key: string, text: string | undefined) => void } | undefined;
|
|
52
62
|
const setLiveStatus = (label: string | undefined): void => {
|
|
@@ -118,7 +128,12 @@ function registerAgyProvider(pi: ExtensionAPI): void {
|
|
|
118
128
|
signal.throwIfAborted();
|
|
119
129
|
const live = parseProviderCatalog(raw);
|
|
120
130
|
if (live.length === 0) throw new Error("agy models returned no usable models");
|
|
121
|
-
if (areProviderCatalogsEqual(entries, live))
|
|
131
|
+
if (areProviderCatalogsEqual(entries, live)) {
|
|
132
|
+
// Same roster, possibly only now confirmed on disk (first run after an
|
|
133
|
+
// older version, or a cache cleared by hand).
|
|
134
|
+
saveProviderCatalogCache(live);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
122
137
|
const definitions = modelDefinitions(live);
|
|
123
138
|
await context.publish({
|
|
124
139
|
update: () => {
|
|
@@ -129,6 +144,7 @@ function registerAgyProvider(pi: ExtensionAPI): void {
|
|
|
129
144
|
models = definitions;
|
|
130
145
|
},
|
|
131
146
|
});
|
|
147
|
+
saveProviderCatalogCache(live);
|
|
132
148
|
},
|
|
133
149
|
stream: (model, context, options) => stream(model, context, options as SimpleStreamOptions),
|
|
134
150
|
streamSimple: stream,
|
package/extensions/lib/args.ts
CHANGED
|
@@ -8,8 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
import { validateModelSelector } from "./model-selection.js";
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import {
|
|
12
|
+
effortTiersForModelId,
|
|
13
|
+
getModelCatalog,
|
|
14
|
+
namesEffortTierInId,
|
|
15
|
+
normalizeAgyAgentName,
|
|
16
|
+
} from "./inspect.js";
|
|
17
|
+
import type { AgyEffort, AgyModel, AgyOptions } from "./cli.js";
|
|
13
18
|
|
|
14
19
|
// agy >= 1.1.28 returns partial output with exit 0 when its own print timeout
|
|
15
20
|
// fires. Keep that timeout behind Pi's hard parent deadline (and its 2s kill
|
|
@@ -67,20 +72,24 @@ export function requireAgyModelId(model?: AgyModel, tier?: AgyOptions["tier"]):
|
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
75
|
+
* Effort capability is a catalog fact, never a vendor-name rule.
|
|
76
|
+
*
|
|
77
|
+
* agy rejects `--effort` for a tier-qualified id ("--model …-medium conflicts
|
|
78
|
+
* with --effort=high") and for a family that ships no tiers ("--effort is not
|
|
79
|
+
* supported"), and accepts it for a base slug whose catalog lists the tier
|
|
80
|
+
* asked for. The `/^gpt-oss-/` rule this replaces was wrong in exactly the
|
|
81
|
+
* observed way: `gpt-oss-120b-medium` conflicts, while `claude-opus-5-5`
|
|
82
|
+
* accepts `--effort`. Verified against agy 1.5.13.
|
|
73
83
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return EFFORT_CAPABLE_ID.test(id);
|
|
84
|
+
export function supportsAgyEffortId(id: string, effort?: AgyEffort): boolean {
|
|
85
|
+
const tiers = effortTiersForModelId(id);
|
|
86
|
+
if (tiers.length === 0) return false;
|
|
87
|
+
return effort === undefined || tiers.includes(effort);
|
|
79
88
|
}
|
|
80
89
|
|
|
81
90
|
/**
|
|
82
|
-
* Tier-suffixed aliases already select a low/medium/high variant
|
|
83
|
-
*
|
|
91
|
+
* Tier-suffixed aliases already select a low/medium/high variant, so an alias
|
|
92
|
+
* asking for effort of its own has nothing to add.
|
|
84
93
|
*/
|
|
85
94
|
export function supportsAgyEffort(model?: AgyModel, tier?: AgyOptions["tier"]): boolean {
|
|
86
95
|
const id = resolveAgyModelId(model, tier);
|
|
@@ -102,9 +111,13 @@ export function buildAgyArgs(options: AgyOptions): string[] {
|
|
|
102
111
|
const skipPermissions = options.skipPermissions ?? true;
|
|
103
112
|
const useStream = options.stream ?? true;
|
|
104
113
|
const structured = mode !== "accept-edits" || useStream;
|
|
105
|
-
// An exact id
|
|
114
|
+
// An exact id only needs the one check agy reports on its own terms (`--model
|
|
115
|
+
// …-medium conflicts with --effort`): it names its tier, so no effort can be
|
|
116
|
+
// layered on. Catalog coverage is unnecessary there, and an unsupported tier
|
|
117
|
+
// is left to agy's precise "available: …" error. An alias resolves through
|
|
118
|
+
// the catalog and may only send a tier that catalog offers.
|
|
106
119
|
const effortCapable = options.model_id
|
|
107
|
-
?
|
|
120
|
+
? !namesEffortTierInId(options.model_id)
|
|
108
121
|
: supportsAgyEffort(options.model, options.tier);
|
|
109
122
|
|
|
110
123
|
const args = [
|
package/extensions/lib/cli.ts
CHANGED
|
@@ -19,7 +19,8 @@ export function isAgyModel(value: unknown): value is AgyModel {
|
|
|
19
19
|
return typeof value === "string" && (AGY_MODEL_ALIASES as readonly string[]).includes(value);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
/** Reasoning-effort values `agy --effort` documents. */
|
|
23
|
+
export type AgyEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
23
24
|
|
|
24
25
|
export type { AgyQuotaEntry, AgyUsageSnapshot } from "./usage.js";
|
|
25
26
|
|
|
@@ -42,12 +43,14 @@ export {
|
|
|
42
43
|
checkAgyConnectivity,
|
|
43
44
|
checkAgyHealth,
|
|
44
45
|
checkAgyUsage,
|
|
46
|
+
effortTiersForModelId,
|
|
45
47
|
getModelCatalog,
|
|
46
48
|
inspectAgyAgents,
|
|
47
49
|
inspectAgyModelIds,
|
|
48
50
|
inspectAgyModels,
|
|
49
51
|
inspectAgyVersion,
|
|
50
52
|
isStableModelId,
|
|
53
|
+
namesEffortTierInId,
|
|
51
54
|
normalizeAgyAgentName,
|
|
52
55
|
parseAgyAgents,
|
|
53
56
|
parseModelCatalog,
|
|
@@ -62,6 +65,7 @@ export {
|
|
|
62
65
|
resolveAgyModelAlias,
|
|
63
66
|
resolveAgyModelId,
|
|
64
67
|
supportsAgyEffort,
|
|
68
|
+
supportsAgyEffortId,
|
|
65
69
|
} from "./args.js";
|
|
66
70
|
|
|
67
71
|
export { findAgyQuotaEntries, formatAgyUsage, isAgyQuotaExhausted, parseAgyUsage } from "./usage.js";
|
|
@@ -22,7 +22,7 @@ import { AGY_MODEL_ALIASES, type AgyModel } from "./cli.js";
|
|
|
22
22
|
* and a tier the vendor retires stops matching instead of resolving to an
|
|
23
23
|
* invented id. New families and renames resolve with no code change.
|
|
24
24
|
*/
|
|
25
|
-
const EFFORT_TOKENS: readonly string[] = ["low", "medium", "high", "xhigh"];
|
|
25
|
+
const EFFORT_TOKENS: readonly string[] = ["low", "medium", "high", "xhigh", "max"];
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Release-channel qualifiers that may trail an id (`…-flash-medium-preview`).
|
|
@@ -92,11 +92,40 @@ function classMatchesModelId(classTokens: readonly string[], id: string): boolea
|
|
|
92
92
|
return findTokenRun(idTokens, classTokens) !== -1;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
/** Does this concrete id already name its tier (`…-flash-low`)? */
|
|
96
|
+
export function namesEffortTierInId(id: string): boolean {
|
|
96
97
|
const idTokens = id.toLowerCase().split("-").filter(Boolean);
|
|
97
98
|
return idTokens.length > 0 && EFFORT_TOKENS.includes(idTokens[idTokens.length - 1]!);
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Effort tiers agy accepts on a base slug, derived from the live catalog.
|
|
103
|
+
*
|
|
104
|
+
* agy's own error text defines the rule: `--effort T` is accepted for a base
|
|
105
|
+
* `B` exactly when the catalog carries `B-T` ("has no \"high\" effort
|
|
106
|
+
* (available: low, medium, high)"), is a **conflict** for a tier-qualified id
|
|
107
|
+
* ("--model …-medium conflicts with --effort=high"), and is **unsupported**
|
|
108
|
+
* for a family that ships no tiers. A tier-qualified id therefore answers
|
|
109
|
+
* with no tiers at all, and no vendor name is consulted. Verified against
|
|
110
|
+
* agy 1.5.13.
|
|
111
|
+
*/
|
|
112
|
+
export function effortTiersForModelId(
|
|
113
|
+
baseId: string,
|
|
114
|
+
ids: readonly string[] = Object.values(modelCatalog),
|
|
115
|
+
): string[] {
|
|
116
|
+
if (namesEffortTierInId(baseId)) return [];
|
|
117
|
+
const prefix = `${baseId}-`;
|
|
118
|
+
const tiers = new Set<string>();
|
|
119
|
+
for (const id of ids) {
|
|
120
|
+
if (!id.startsWith(prefix)) continue;
|
|
121
|
+
const suffix = id.slice(prefix.length).toLowerCase();
|
|
122
|
+
if (EFFORT_TOKENS.includes(suffix)) tiers.add(suffix);
|
|
123
|
+
}
|
|
124
|
+
return [...tiers].sort(
|
|
125
|
+
(left, right) => EFFORT_TOKENS.indexOf(left) - EFFORT_TOKENS.indexOf(right),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
100
129
|
export type AgyModelCatalog = Partial<Record<AgyModel, string>>;
|
|
101
130
|
|
|
102
131
|
const UNSTABLE_MODEL_PATTERN =
|
|
@@ -144,7 +173,7 @@ export function parseModelCatalog(output: string, allowPreview = false): AgyMode
|
|
|
144
173
|
const candidates = ids.filter((id) => classMatchesModelId(classTokens, id));
|
|
145
174
|
// A class that ships any effort variant is tier-aware: its aliases must
|
|
146
175
|
// match the requested tier or fail, never fall back to another tier.
|
|
147
|
-
if (candidates.length === 0 || candidates.some(
|
|
176
|
+
if (candidates.length === 0 || candidates.some(namesEffortTierInId)) continue;
|
|
148
177
|
for (const id of candidates) {
|
|
149
178
|
if (compareModelIds(id, found[alias] ?? "") > 0) found[alias] = id;
|
|
150
179
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Last-good provider catalog persistence.
|
|
3
|
+
*
|
|
4
|
+
* The catalog is discovered at runtime and deliberately ships no hardcoded
|
|
5
|
+
* model ids, so a cold process has nothing to answer `getModels()` with until
|
|
6
|
+
* `agy models` returns. Pi resolves configured scopes (`enabledModels`) at
|
|
7
|
+
* startup, so an empty catalog there reports `No models match pattern
|
|
8
|
+
* "antigravity/<id>"` for a model that exists — the provider looked empty, not
|
|
9
|
+
* the model missing.
|
|
10
|
+
*
|
|
11
|
+
* Persisting the last observed roster closes that window without inventing
|
|
12
|
+
* model names: a fresh process starts from real, previously observed entries,
|
|
13
|
+
* and discovery still replaces them. Loading is synchronous because it feeds
|
|
14
|
+
* provider registration; both directions are best effort and never throw, so a
|
|
15
|
+
* corrupt or unwritable cache degrades to today's empty-start behaviour.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
19
|
+
import * as path from "node:path";
|
|
20
|
+
|
|
21
|
+
import { getDefaultConfigPath } from "./config.js";
|
|
22
|
+
import type { AgyProviderEffort, AgyProviderModelEntry } from "./provider-models.js";
|
|
23
|
+
|
|
24
|
+
const CACHE_FILENAME = "agy-provider-models.json";
|
|
25
|
+
const MAX_CACHED_ENTRIES = 500;
|
|
26
|
+
const EFFORT_VALUES: readonly AgyProviderEffort[] = ["low", "medium", "high"];
|
|
27
|
+
|
|
28
|
+
export function providerCatalogCachePath(configPath = getDefaultConfigPath()): string {
|
|
29
|
+
return path.join(path.dirname(configPath), CACHE_FILENAME);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Validate one cached entry; anything malformed is dropped, not repaired. */
|
|
33
|
+
function toEntry(value: unknown): AgyProviderModelEntry | undefined {
|
|
34
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return undefined;
|
|
35
|
+
const record = value as Record<string, unknown>;
|
|
36
|
+
if (typeof record.full !== "string" || !record.full.trim()) return undefined;
|
|
37
|
+
if (typeof record.id !== "string" || !record.id.trim()) return undefined;
|
|
38
|
+
const entry: AgyProviderModelEntry = { full: record.full, id: record.id };
|
|
39
|
+
if (Array.isArray(record.efforts)) {
|
|
40
|
+
const efforts = record.efforts.filter(
|
|
41
|
+
(effort): effort is AgyProviderEffort =>
|
|
42
|
+
typeof effort === "string" && (EFFORT_VALUES as readonly string[]).includes(effort),
|
|
43
|
+
);
|
|
44
|
+
// A base entry is only effort-driven when it still carries usable tiers.
|
|
45
|
+
if (efforts.length > 0) entry.efforts = [...new Set(efforts)];
|
|
46
|
+
}
|
|
47
|
+
return entry;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Read the last-good catalog. Returns `[]` when absent, unreadable, or invalid. */
|
|
51
|
+
export function loadProviderCatalogCache(configPath = getDefaultConfigPath()): AgyProviderModelEntry[] {
|
|
52
|
+
let raw: string;
|
|
53
|
+
try {
|
|
54
|
+
raw = readFileSync(providerCatalogCachePath(configPath), "utf8");
|
|
55
|
+
} catch {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const parsed: unknown = JSON.parse(raw);
|
|
60
|
+
const list = Array.isArray(parsed)
|
|
61
|
+
? parsed
|
|
62
|
+
: typeof parsed === "object" && parsed !== null && Array.isArray((parsed as { models?: unknown }).models)
|
|
63
|
+
? (parsed as { models: unknown[] }).models
|
|
64
|
+
: [];
|
|
65
|
+
const entries: AgyProviderModelEntry[] = [];
|
|
66
|
+
const seen = new Set<string>();
|
|
67
|
+
for (const value of list.slice(0, MAX_CACHED_ENTRIES)) {
|
|
68
|
+
const entry = toEntry(value);
|
|
69
|
+
if (!entry || seen.has(entry.id)) continue;
|
|
70
|
+
seen.add(entry.id);
|
|
71
|
+
entries.push(entry);
|
|
72
|
+
}
|
|
73
|
+
return entries;
|
|
74
|
+
} catch {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Persist the roster just discovered. Writes a sibling temp file and renames,
|
|
81
|
+
* so a crash mid-write can never leave a half-parsed cache behind.
|
|
82
|
+
*/
|
|
83
|
+
export function saveProviderCatalogCache(
|
|
84
|
+
entries: readonly AgyProviderModelEntry[],
|
|
85
|
+
configPath = getDefaultConfigPath(),
|
|
86
|
+
): void {
|
|
87
|
+
if (entries.length === 0) return;
|
|
88
|
+
const target = providerCatalogCachePath(configPath);
|
|
89
|
+
const temp = `${target}.${process.pid}.tmp`;
|
|
90
|
+
try {
|
|
91
|
+
mkdirSync(path.dirname(target), { recursive: true });
|
|
92
|
+
const payload = JSON.stringify(
|
|
93
|
+
{ version: 1, models: entries.slice(0, MAX_CACHED_ENTRIES) },
|
|
94
|
+
null,
|
|
95
|
+
2,
|
|
96
|
+
);
|
|
97
|
+
writeFileSync(temp, payload, { encoding: "utf8", mode: 0o600 });
|
|
98
|
+
renameSync(temp, target);
|
|
99
|
+
} catch {
|
|
100
|
+
// Best effort: an unwritable cache must never fail a refresh.
|
|
101
|
+
try {
|
|
102
|
+
unlinkSync(temp);
|
|
103
|
+
} catch {
|
|
104
|
+
// Nothing to clean up.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Test helper — drop the persisted roster. */
|
|
110
|
+
export function clearProviderCatalogCache(configPath = getDefaultConfigPath()): void {
|
|
111
|
+
try {
|
|
112
|
+
unlinkSync(providerCatalogCachePath(configPath));
|
|
113
|
+
} catch {
|
|
114
|
+
// Absent is already the desired state.
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
35
35
|
|
|
36
36
|
import { getDefaultConfigPath } from "./config.js";
|
|
37
|
+
import { loadProviderCatalogCache } from "./provider-catalog-store.js";
|
|
37
38
|
import { isBridgeInputWithinBudget } from "./bridge-input-budget.js";
|
|
38
39
|
import type { BridgeToolDef } from "./provider-tools.js";
|
|
39
40
|
import { checkAgyUsage, formatAgyUsage } from "./cli.js";
|
|
@@ -750,9 +751,17 @@ async function readCatalog(
|
|
|
750
751
|
const models = parseProviderCatalog(raw);
|
|
751
752
|
if (models.length > 0) return { models, fallback: false, cache: { raw, at: Date.now() } };
|
|
752
753
|
} catch {
|
|
753
|
-
// Fall through to the
|
|
754
|
+
// Fall through to the last roster this machine observed.
|
|
754
755
|
}
|
|
755
|
-
|
|
756
|
+
// The provider persists the roster it discovered, so a discovery failure
|
|
757
|
+
// here degrades to those real, previously observed ids instead of an empty
|
|
758
|
+
// list that reads as "this workspace has no models".
|
|
759
|
+
const observed = loadProviderCatalogCache();
|
|
760
|
+
return {
|
|
761
|
+
models: observed.length > 0 ? observed : [...FALLBACK_PROVIDER_MODELS],
|
|
762
|
+
fallback: true,
|
|
763
|
+
cache,
|
|
764
|
+
};
|
|
756
765
|
}
|
|
757
766
|
|
|
758
767
|
async function readBody(req: IncomingMessage): Promise<{ body?: unknown; tooLarge: boolean }> {
|
|
@@ -6,17 +6,22 @@
|
|
|
6
6
|
*
|
|
7
7
|
* `agy models` prints one model per line: `<slug> <display label>`. Only the
|
|
8
8
|
* first column (the slug) is a valid `--model` value; the label is
|
|
9
|
-
* display-only.
|
|
10
|
-
* base entry with a thinking-level toggle (the picked level
|
|
11
|
-
* `--effort`)
|
|
12
|
-
*
|
|
9
|
+
* display-only. A base whose catalog carries two or more effort tiers collapses
|
|
10
|
+
* to a single base entry with a thinking-level toggle (the picked level becomes
|
|
11
|
+
* agy `--effort`). A base with one tier or none keeps agy's exact qualified
|
|
12
|
+
* slug and never receives `--effort`.
|
|
13
|
+
*
|
|
14
|
+
* That grouping is derived from the catalog alone. Which families accept
|
|
15
|
+
* `--effort` is agy's own answer to "does `B-T` exist" — tier-qualified ids are
|
|
16
|
+
* rejected as a conflict and tierless families as unsupported — so no vendor
|
|
17
|
+
* name needs to be known here.
|
|
13
18
|
*
|
|
14
19
|
* Pure functions only — no spawning, no Pi imports — so the catalog is
|
|
15
20
|
* unit-testable without the CLI.
|
|
16
21
|
*/
|
|
17
22
|
|
|
18
|
-
/** Reasoning-effort tiers agy accepts via `--effort
|
|
19
|
-
export type AgyProviderEffort = "low" | "medium" | "high";
|
|
23
|
+
/** Reasoning-effort tiers agy accepts via `--effort` (`agy --help`). */
|
|
24
|
+
export type AgyProviderEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
20
25
|
|
|
21
26
|
/** Pi thinking levels that map onto agy effort tiers. */
|
|
22
27
|
export type AgyThinkingLevel =
|
|
@@ -28,12 +33,25 @@ export type AgyThinkingLevel =
|
|
|
28
33
|
| "xhigh"
|
|
29
34
|
| "max";
|
|
30
35
|
|
|
31
|
-
const EFFORT_RANK: Record<AgyProviderEffort, number> = {
|
|
36
|
+
const EFFORT_RANK: Record<AgyProviderEffort, number> = {
|
|
37
|
+
low: 0,
|
|
38
|
+
medium: 1,
|
|
39
|
+
high: 2,
|
|
40
|
+
xhigh: 3,
|
|
41
|
+
max: 4,
|
|
42
|
+
};
|
|
32
43
|
|
|
33
|
-
const EFFORT_ORDER: readonly AgyProviderEffort[] = ["low", "medium", "high"];
|
|
44
|
+
const EFFORT_ORDER: readonly AgyProviderEffort[] = ["low", "medium", "high", "xhigh", "max"];
|
|
34
45
|
|
|
35
|
-
/**
|
|
36
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Split an agy slug into (base, tier); tier is null without a tier suffix.
|
|
48
|
+
*
|
|
49
|
+
* `xhigh` and `max` belong here: when they did not, `gemini-4-neon-xhigh`
|
|
50
|
+
* became its own base entry instead of a fourth stop inside the `gemini-4-neon`
|
|
51
|
+
* thinking picker. Longer alternatives come first so `-xhigh` can never be
|
|
52
|
+
* read as `-high`.
|
|
53
|
+
*/
|
|
54
|
+
const TIER_RE = /^(.+)-(xhigh|max|high|medium|low)$/;
|
|
37
55
|
|
|
38
56
|
/**
|
|
39
57
|
* Preserve the established hyphenated first-column format. A leading-dash
|
|
@@ -71,14 +89,6 @@ export function parseAgyModelIds(raw: string): AgyModelId[] {
|
|
|
71
89
|
return [...new Set(ids.filter(isAgyModelId))];
|
|
72
90
|
}
|
|
73
91
|
|
|
74
|
-
/**
|
|
75
|
-
* Families verified to accept base-slug + `--effort`. Only these collapse to
|
|
76
|
-
* a base entry with a thinking toggle; every other family keeps agy's exact
|
|
77
|
-
* qualified slug so unknown or fixed-thinking families degrade safely instead
|
|
78
|
-
* of forcing an unsupported `--effort`.
|
|
79
|
-
*/
|
|
80
|
-
const EFFORT_CAPABLE_FAMILIES: readonly RegExp[] = [/^gemini-/];
|
|
81
|
-
|
|
82
92
|
export interface AgyProviderModelEntry {
|
|
83
93
|
/**
|
|
84
94
|
* Exact agy `--model` value: a base slug (e.g. `gemini-3.8-flash`) when
|
|
@@ -115,9 +125,15 @@ export function toProviderEffort(
|
|
|
115
125
|
candidate = "medium";
|
|
116
126
|
break;
|
|
117
127
|
case "high":
|
|
128
|
+
candidate = "high";
|
|
129
|
+
break;
|
|
130
|
+
// agy exposes these as real stops, so pass them through instead of
|
|
131
|
+
// collapsing every strong level onto "high".
|
|
118
132
|
case "xhigh":
|
|
133
|
+
candidate = "xhigh";
|
|
134
|
+
break;
|
|
119
135
|
case "max":
|
|
120
|
-
candidate = "
|
|
136
|
+
candidate = "max";
|
|
121
137
|
break;
|
|
122
138
|
default:
|
|
123
139
|
candidate = efforts[0] ?? "low";
|
|
@@ -144,8 +160,8 @@ export function slugifyProviderId(full: string): string {
|
|
|
144
160
|
/**
|
|
145
161
|
* Build the thinking-level map for an effort-driven base: `off` and `minimal`
|
|
146
162
|
* are always hidden (agy has no no-thinking mode; a base requires an effort),
|
|
147
|
-
* as is any
|
|
148
|
-
*
|
|
163
|
+
* as is any tier the base does not offer. Pi treats null as hidden, so the
|
|
164
|
+
* toggle shows exactly agy's stops.
|
|
149
165
|
*/
|
|
150
166
|
export function thinkingMapForEfforts(
|
|
151
167
|
efforts: readonly AgyProviderEffort[],
|
|
@@ -154,17 +170,17 @@ export function thinkingMapForEfforts(
|
|
|
154
170
|
off: null,
|
|
155
171
|
minimal: null,
|
|
156
172
|
};
|
|
157
|
-
for (const level of ["low", "medium", "high"] as const) {
|
|
173
|
+
for (const level of ["low", "medium", "high", "xhigh", "max"] as const) {
|
|
158
174
|
if (!efforts.includes(level)) map[level] = null;
|
|
159
175
|
}
|
|
160
176
|
return map;
|
|
161
177
|
}
|
|
162
178
|
|
|
163
179
|
/**
|
|
164
|
-
* Parse raw `agy models` text into provider entries.
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
180
|
+
* Parse raw `agy models` text into provider entries. A base with >= 2 tier
|
|
181
|
+
* variants collapses to one base entry carrying the tiers it accepts;
|
|
182
|
+
* everything else keeps agy's exact qualified slug. Insertion order of
|
|
183
|
+
* first-seen bases is preserved.
|
|
168
184
|
*/
|
|
169
185
|
export function parseProviderCatalog(raw: string): AgyProviderModelEntry[] {
|
|
170
186
|
const groups = new Map<string, { lines: string[]; tiers: Set<AgyProviderEffort> }>();
|
|
@@ -191,7 +207,7 @@ export function parseProviderCatalog(raw: string): AgyProviderModelEntry[] {
|
|
|
191
207
|
};
|
|
192
208
|
for (const [base, group] of groups) {
|
|
193
209
|
const efforts = [...group.tiers].sort((a, b) => EFFORT_RANK[a] - EFFORT_RANK[b]);
|
|
194
|
-
if (efforts.length >= 2
|
|
210
|
+
if (efforts.length >= 2) {
|
|
195
211
|
pushEntry({ full: base, id: slugifyProviderId(base), efforts });
|
|
196
212
|
} else {
|
|
197
213
|
for (const line of group.lines) {
|
package/extensions/tools.ts
CHANGED
|
@@ -88,10 +88,19 @@ export function registerAgyTools(pi: ExtensionAPI): void {
|
|
|
88
88
|
modelAliasSchema({ description: "Model alias. Defaults to 'flash-medium'.", default: "flash-medium" }),
|
|
89
89
|
),
|
|
90
90
|
effort: Type.Optional(
|
|
91
|
-
Type.Union(
|
|
92
|
-
|
|
93
|
-
"
|
|
94
|
-
|
|
91
|
+
Type.Union(
|
|
92
|
+
[
|
|
93
|
+
Type.Literal("low"),
|
|
94
|
+
Type.Literal("medium"),
|
|
95
|
+
Type.Literal("high"),
|
|
96
|
+
Type.Literal("xhigh"),
|
|
97
|
+
Type.Literal("max"),
|
|
98
|
+
],
|
|
99
|
+
{
|
|
100
|
+
description:
|
|
101
|
+
"Reasoning effort passed to agy (--effort). Only sent when the resolved model is a base slug that lists that tier; a tier-qualified id would conflict.",
|
|
102
|
+
},
|
|
103
|
+
),
|
|
95
104
|
),
|
|
96
105
|
agent: Type.Optional(
|
|
97
106
|
Type.String({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juanbenjumea/pi-agy",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.16",
|
|
4
4
|
"description": "Antigravity (agy) provider and delegation for Pi — /model picker, background tasks, loopback MCP tool bridge, quota awareness, and repo verification.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|