@tscgoods/antigravity-effort-discovery 0.5.0 → 0.5.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.
- package/README.md +14 -14
- package/package.json +1 -1
- package/plugin.json +2 -2
- package/rules/AGENTS.md +2 -2
- package/scripts/effort-guard.mjs +12 -10
- package/scripts/emit-custom-models.mjs +6 -6
- package/scripts/lib.mjs +32 -7
- package/scripts/probe.mjs +18 -13
- package/scripts/session-note.mjs +13 -8
- package/skills/effort-probe/SKILL.md +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @tscgoods/antigravity-effort-discovery
|
|
2
2
|
|
|
3
|
-
Antigravity CLI(`agy
|
|
3
|
+
Antigravity CLI(`agy`)插件:分别报告 OpenAI 兼容网关的错误回显和 agy 自报档位,提供可选的交集对照及提醒。
|
|
4
4
|
|
|
5
5
|
## 为什么需要
|
|
6
6
|
|
|
@@ -9,9 +9,9 @@ agy 有两种“档位真相”:
|
|
|
9
9
|
1. **agy 自己的模型元数据**:`--effort` 只允许 `low|medium|high|xhigh|max`,且每个模型可用的子集不同(`agy -p "/effort" --output-format json --model <m>` 会返回 `available`)。
|
|
10
10
|
2. **你的网关**:自建/中转网关不一定都接受,甚至接受但不生效。
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
插件分别显示两者;只有同时拿到两份结果才显示交集。**同名模型不保证走同一网关或协议**,需自行确认路由一致;错误回显和单次成功也不证明推理实际生效。
|
|
13
13
|
|
|
14
|
-
> agy
|
|
14
|
+
> agy 的档位菜单无法由本插件的 hook 增删。`customModels` 配置入口和生效条件尚未验证;本插件不自动改你自己的配置。
|
|
15
15
|
|
|
16
16
|
## 安装
|
|
17
17
|
|
|
@@ -45,7 +45,7 @@ agy plugin list --json
|
|
|
45
45
|
node packages\antigravity\scripts\probe.mjs --agy --json
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
provider 来自共享配置 `~/.config/effort-discovery.json`(默认第一个 `api: "openai"` 的 provider,可用 `--provider` 指定),结果缓存到 `~/.cache/effort-discovery/antigravity.json
|
|
48
|
+
provider 来自共享配置 `~/.config/effort-discovery.json`(默认第一个 `api: "openai"` 的 provider,可用 `--provider` 指定),结果缓存到 `~/.cache/effort-discovery/antigravity.json`。`--agy` 启动 agy 自查,可能产生宿主初始化或网络行为;没有两份证据时交集为未知。缓存中的 provider/URL 与当前配置不符时 hook 不提示;超过 6 小时的数据不触发守卫提醒,会话报告仍显示其年龄供参考。
|
|
49
49
|
|
|
50
50
|
## 在非 Gemini 网关上使用模型:`emit-custom-models`(实验结果:未生效,⚠️)
|
|
51
51
|
|
|
@@ -57,18 +57,18 @@ provider 来自共享配置 `~/.config/effort-discovery.json`(默认第一个
|
|
|
57
57
|
|
|
58
58
|
| 能力 | 状态 |
|
|
59
59
|
|---|---|
|
|
60
|
-
| `SessionStart`
|
|
61
|
-
| `/effort-probe`
|
|
62
|
-
| `PreInvocation`
|
|
63
|
-
| 把网关模型加进 agy 的 `/model` 菜单 |
|
|
60
|
+
| `SessionStart` 注入缓存中的网关和 agy 分项证据 | hook 清单通过校验;新代码只做了离线测试 |
|
|
61
|
+
| `/effort-probe` 技能:并排展示网关回显与 agy 自报档位 | 组件清单通过;新代码已离线测试 |
|
|
62
|
+
| `PreInvocation` 提醒证据未列出的档位 | 只提醒,非阻断;新代码尚未做会话内验证 |
|
|
63
|
+
| 把网关模型加进 agy 的 `/model` 菜单 | 1.5.14 测试无效;1.5.20 未验证 |
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
换句话说:插件只汇报已有证据,hook 不能改变 `--effort` 枚举和模型列表;自定义模型生成器是否生效尚无可靠结论。
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
以下生成器仅供研究,**尚无证据表明写入后会生效**;它不建立 OpenAI 与 Gemini 协议兼容性:
|
|
68
68
|
|
|
69
69
|
```powershell
|
|
70
|
-
node
|
|
71
|
-
node
|
|
70
|
+
node packages\antigravity\scripts\emit-custom-models.mjs # 只输出实验片段
|
|
71
|
+
node packages\antigravity\scripts\emit-custom-models.mjs --write # 明确同意后才备份并写入
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
生成器按 `probe.mjs --agy` 的结果,为每个模型 × 每个可用档位生成一条条目:
|
|
@@ -81,7 +81,7 @@ node "$p\scripts\emit-custom-models.mjs" --write # 备份并合并进 ~/.gemi
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
生成器只输出 `low|medium|high`,`max`/`xhigh` 会被跳过;这不是对 agy 支持范围或配置格式的保证。agy 是否接受相同 `modelName` 的多条目也未确认。
|
|
85
85
|
|
|
86
86
|
写入前会备份 `settings.json.bak-<时间戳>`;生成器不会自动改 `modelProvider`。
|
|
87
87
|
|
|
@@ -89,4 +89,4 @@ node "$p\scripts\emit-custom-models.mjs" --write # 备份并合并进 ~/.gemi
|
|
|
89
89
|
|
|
90
90
|
- 插件改成 `hooks.json` + `skills/`;agy **不加载** `commands/`、没有 statusline 组件。
|
|
91
91
|
- hook 命令在插件根目录执行,可用 `PLUGIN_ROOT` / `PLUGIN_DATA` 环境变量;Windows 下用 `cmd /c` 语义,`node ./scripts/...` 是安全写法。
|
|
92
|
-
- hook 失败是 fail-open(非 0 退出只记日志),不会阻塞会话。
|
|
92
|
+
- hook 失败是 fail-open(非 0 退出只记日志),不会阻塞会话。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscgoods/antigravity-effort-discovery",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Antigravity CLI plugin: probe which reasoning-effort levels your gateway accepts, inject the result into sessions, and optionally generate customModels entries.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effort-discovery",
|
|
3
3
|
"displayName": "Effort Discovery",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.3",
|
|
5
5
|
"description": "Probe the gateway for the reasoning-effort levels a model really accepts, inject the result into sessions, and optionally generate customModels entries.",
|
|
6
6
|
"author": "tscgoods",
|
|
7
7
|
"homepage": "https://github.com/lxgy1024/effort-discovery",
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
"reasoning",
|
|
13
13
|
"gateway"
|
|
14
14
|
]
|
|
15
|
-
}
|
|
15
|
+
}
|
package/rules/AGENTS.md
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
- agy 的 `--effort` 是固定枚举 `low|medium|high|xhigh|max`;某个模型能用哪些档位由 agy 的模型元数据决定,插件无法增删。
|
|
4
4
|
- 需要确认某个模型在**你的网关**上到底接受哪些档位时,运行 `node ./scripts/probe.mjs --agy --json`。
|
|
5
|
-
-
|
|
6
|
-
- 不要修改 `~/.gemini/antigravity-cli/settings.json`,除非用户明确要求生成 `customModels`。
|
|
5
|
+
- 汇报用户时区分 `gateway levels`(网关回显)和 `agy levels`(agy 自报);交集只是对照,不能证明两者路由相同或实际生效。
|
|
6
|
+
- 不要修改 `~/.gemini/antigravity-cli/settings.json`,除非用户明确要求生成 `customModels`。
|
package/scripts/effort-guard.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from "node:fs"
|
|
3
|
-
import { AGY_LEVELS, cachePath, readJson } from "./lib.mjs"
|
|
3
|
+
import { AGY_LEVELS, cacheMatchesProvider, cachePath, evidenceFor, matchingModel, readJson } from "./lib.mjs"
|
|
4
4
|
|
|
5
5
|
// PreInvocation 守卫:用户/模型提到不支持的档位时提醒(只提醒,不终止会话)
|
|
6
6
|
let input = {}
|
|
@@ -11,30 +11,32 @@ try {
|
|
|
11
11
|
|
|
12
12
|
const cache = readJson(cachePath())
|
|
13
13
|
if (!cache?.models) process.exit(0)
|
|
14
|
+
if (!cacheMatchesProvider(cache)) process.exit(0)
|
|
15
|
+
if (!Number.isFinite(cache.at) || cache.at > Date.now() || Date.now() - cache.at >= 6 * 60 * 60 * 1000) process.exit(0)
|
|
14
16
|
|
|
15
17
|
const modelName = input?.modelName ?? ""
|
|
16
18
|
const entries = Object.entries(cache.models)
|
|
17
|
-
const current = entries
|
|
19
|
+
const current = matchingModel(entries, modelName)
|
|
18
20
|
if (!current) process.exit(0)
|
|
21
|
+
const observedAt = current[1]?.observedAt ?? current[1]?.at
|
|
22
|
+
if (!Number.isFinite(observedAt) || observedAt > Date.now() || Date.now() - observedAt >= 6 * 60 * 60 * 1000) process.exit(0)
|
|
19
23
|
|
|
20
|
-
const
|
|
21
|
-
AGY_LEVELS.includes(level),
|
|
22
|
-
)
|
|
23
|
-
if (supported.length === 0) process.exit(0)
|
|
24
|
+
const { gateway, agy } = evidenceFor(current[1])
|
|
24
25
|
|
|
25
26
|
const text = String(input?.lastUserInput ?? "")
|
|
26
27
|
const mentioned = [...text.matchAll(/(?:--effort\s+|\/effort\s+)([a-z]+)/gi)].map((m) =>
|
|
27
28
|
m[1].toLowerCase(),
|
|
28
29
|
)
|
|
29
|
-
const offending = mentioned.filter((level) => AGY_LEVELS.includes(level) &&
|
|
30
|
+
const offending = mentioned.filter((level) => AGY_LEVELS.includes(level) &&
|
|
31
|
+
((gateway !== null && !gateway.includes(level)) || (agy !== null && !agy.includes(level))))
|
|
30
32
|
if (offending.length === 0) process.exit(0)
|
|
31
33
|
|
|
32
34
|
const message =
|
|
33
|
-
`⚠️ ${current[0]}
|
|
34
|
-
|
|
35
|
+
`⚠️ ${current[0]} 的已有网关或 agy 声明未列出 ${offending.join(", ")};` +
|
|
36
|
+
`两者可能使用不同路由,请核对后再选择。`
|
|
35
37
|
|
|
36
38
|
process.stdout.write(
|
|
37
39
|
JSON.stringify({
|
|
38
40
|
injectSteps: [{ errorMessage: { userMessage: message } }],
|
|
39
41
|
}) + "\n",
|
|
40
|
-
)
|
|
42
|
+
)
|
|
@@ -22,7 +22,7 @@ const HELP = `用法: node emit-custom-models.mjs [--model <id>] [--write]
|
|
|
22
22
|
读取 ${cachePath()},为网关模型生成 agy 的 customModels 配置片段。
|
|
23
23
|
只输出 JSON 片段(默认),加 --write 才备份并合并进 ${agySettingsPath()}。
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
实验性格式:agy 1.5.14 实测没有生效,1.5.20 未验证;不要依赖输出片段。
|
|
26
26
|
`
|
|
27
27
|
|
|
28
28
|
const args = parseArgs(process.argv.slice(2))
|
|
@@ -48,7 +48,7 @@ for (const model of selected) {
|
|
|
48
48
|
warnings.push(`model ${model} 不在缓存里,跳过`)
|
|
49
49
|
continue
|
|
50
50
|
}
|
|
51
|
-
const levels = info.
|
|
51
|
+
const levels = info.source === "validated" ? info.levels : []
|
|
52
52
|
if (!Array.isArray(levels) || levels.length === 0) {
|
|
53
53
|
warnings.push(`${model}: 没有可信档位(${info.source ?? "unknown"}),跳过`)
|
|
54
54
|
continue
|
|
@@ -57,7 +57,7 @@ for (const model of selected) {
|
|
|
57
57
|
const writable = levels.filter((level) => WRITABLE_LEVELS.includes(level))
|
|
58
58
|
const skipped = levels.filter((level) => !WRITABLE_LEVELS.includes(level))
|
|
59
59
|
if (skipped.length > 0) {
|
|
60
|
-
warnings.push(`${model}:
|
|
60
|
+
warnings.push(`${model}: 实验性生成器跳过 ${skipped.join(", ")}(仅生成 low|medium|high)`)
|
|
61
61
|
}
|
|
62
62
|
if (writable.length === 0) {
|
|
63
63
|
warnings.push(`${model}: 没有任何可写入的档位,跳过`)
|
|
@@ -100,7 +100,7 @@ if (!settings) {
|
|
|
100
100
|
|
|
101
101
|
if (settings.modelProvider && settings.modelProvider !== "gemini") {
|
|
102
102
|
process.stderr.write(
|
|
103
|
-
`warn: 当前 modelProvider = ${settings.modelProvider};customModels
|
|
103
|
+
`warn: 当前 modelProvider = ${settings.modelProvider};customModels 的配置入口和生效条件尚未验证。\n`,
|
|
104
104
|
)
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -119,5 +119,5 @@ writeFileSync(path, JSON.stringify(settings, null, 2) + "\n")
|
|
|
119
119
|
|
|
120
120
|
process.stdout.write(`backup: ${backup}\n`)
|
|
121
121
|
process.stdout.write(`written ${Object.keys(customModels).length} entries to ${path}\n`)
|
|
122
|
-
process.stdout.write("
|
|
123
|
-
for (const warning of warnings) process.stderr.write(`warn: ${warning}\n`)
|
|
122
|
+
process.stdout.write("警告:该配置未验证有效;请自行检查 agy 的 /model,不要依赖该格式。\n")
|
|
123
|
+
for (const warning of warnings) process.stderr.write(`warn: ${warning}\n`)
|
package/scripts/lib.mjs
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
import { execSync } from "node:child_process"
|
|
1
|
+
import { execFileSync, execSync } from "node:child_process"
|
|
2
2
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
|
3
3
|
import { homedir } from "node:os"
|
|
4
4
|
import { dirname, join } from "node:path"
|
|
5
5
|
|
|
6
6
|
export const AGY_LEVELS = ["low", "medium", "high", "xhigh", "max"]
|
|
7
7
|
|
|
8
|
+
/** These are separate observations; an intersection does not establish routing equivalence. */
|
|
9
|
+
export function evidenceFor(info) {
|
|
10
|
+
const gateway = info?.source === "validated" && Array.isArray(info.levels) && info.levels.length
|
|
11
|
+
? info.levels.filter((level) => AGY_LEVELS.includes(level))
|
|
12
|
+
: null
|
|
13
|
+
const agy = Array.isArray(info?.agyAvailable)
|
|
14
|
+
? info.agyAvailable.filter((level) => AGY_LEVELS.includes(level))
|
|
15
|
+
: null
|
|
16
|
+
return {
|
|
17
|
+
gateway,
|
|
18
|
+
agy,
|
|
19
|
+
intersection: gateway !== null && agy !== null ? gateway.filter((level) => agy.includes(level)) : null,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function matchingModel(entries, modelName) {
|
|
24
|
+
if (typeof modelName !== "string" || !modelName) return undefined
|
|
25
|
+
return entries.find(([model]) => model === modelName)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function cacheMatchesProvider(cache) {
|
|
29
|
+
const entry = loadConfig().providers?.[cache?.provider]
|
|
30
|
+
const clean = (value) => typeof value === "string" ? value.replace(/\/+$/, "") : ""
|
|
31
|
+
return Boolean(entry && (!entry.api || entry.api === "openai") && clean(cache?.baseURL) &&
|
|
32
|
+
clean(cache.baseURL) === clean(entry.baseURL ?? entry.url))
|
|
33
|
+
}
|
|
34
|
+
|
|
8
35
|
export function configPath() {
|
|
9
36
|
return (
|
|
10
37
|
process.env.EFFORT_DISCOVERY_CONFIG ??
|
|
@@ -124,13 +151,11 @@ export async function probeOpenAI({ baseURL, apiKey, model, headers = {}, timeou
|
|
|
124
151
|
return sawOk ? { levels: null, source: "no-validation", at: Date.now() } : last
|
|
125
152
|
}
|
|
126
153
|
|
|
127
|
-
/**
|
|
154
|
+
/** Query agy's /effort command. It may perform host initialization or network requests. */
|
|
128
155
|
export function agyAvailable(model) {
|
|
129
156
|
try {
|
|
130
|
-
const output =
|
|
131
|
-
|
|
132
|
-
{ encoding: "utf8", timeout: 60_000, windowsHide: true },
|
|
133
|
-
)
|
|
157
|
+
const output = execFileSync("agy", ["-p", "/effort", "--output-format", "json", "--model", model],
|
|
158
|
+
{ encoding: "utf8", timeout: 60_000, windowsHide: true })
|
|
134
159
|
const json = JSON.parse(output.trim().split("\n").at(-1))
|
|
135
160
|
const data = json?.command?.data
|
|
136
161
|
if (!data) return undefined
|
|
@@ -139,4 +164,4 @@ export function agyAvailable(model) {
|
|
|
139
164
|
} catch {
|
|
140
165
|
return undefined
|
|
141
166
|
}
|
|
142
|
-
}
|
|
167
|
+
}
|
package/scripts/probe.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
AGY_LEVELS,
|
|
4
3
|
agyAvailable,
|
|
5
4
|
agySettingsPath,
|
|
6
5
|
cachePath,
|
|
7
6
|
loadConfig,
|
|
8
|
-
|
|
7
|
+
evidenceFor,
|
|
9
8
|
probeOpenAI,
|
|
10
9
|
readJson,
|
|
11
10
|
resolveSecret,
|
|
@@ -54,6 +53,10 @@ if (!entry) {
|
|
|
54
53
|
)
|
|
55
54
|
process.exit(2)
|
|
56
55
|
}
|
|
56
|
+
if (entry.api && entry.api !== "openai") {
|
|
57
|
+
process.stderr.write(`provider "${providerID}" is not configured for OpenAI-compatible requests\n`)
|
|
58
|
+
process.exit(2)
|
|
59
|
+
}
|
|
57
60
|
|
|
58
61
|
let models = args.models
|
|
59
62
|
if (models.length === 0) {
|
|
@@ -78,6 +81,7 @@ const result = {
|
|
|
78
81
|
provider: providerID,
|
|
79
82
|
baseURL: entry.baseURL ?? entry.url,
|
|
80
83
|
models:
|
|
84
|
+
previousCache?.provider === providerID && previousCache?.baseURL === (entry.baseURL ?? entry.url) &&
|
|
81
85
|
previousCache?.models && typeof previousCache.models === "object"
|
|
82
86
|
? { ...previousCache.models }
|
|
83
87
|
: {},
|
|
@@ -92,17 +96,15 @@ for (const model of models) {
|
|
|
92
96
|
})
|
|
93
97
|
const agy = args.agy ? agyAvailable(model) : undefined
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
const gatewayLevels = Array.isArray(probed.levels) && probed.levels.length > 0 ? probed.levels : null
|
|
97
|
-
const authority = gatewayLevels ? "gateway" : Array.isArray(agy) && agy.length > 0 ? "agy" : null
|
|
98
|
-
const base = gatewayLevels ?? (Array.isArray(agy) && agy.length > 0 ? agy : null)
|
|
99
|
+
const observations = evidenceFor({ ...probed, agyAvailable: agy ?? null })
|
|
99
100
|
|
|
100
101
|
result.models[model] = {
|
|
101
102
|
...probed,
|
|
102
103
|
agyAvailable: agy ?? null,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
observedAt: Date.now(),
|
|
105
|
+
authority: observations.intersection !== null ? "intersection" : observations.gateway !== null ? "gateway" : observations.agy !== null ? "agy" : null,
|
|
106
|
+
// This comparison is meaningful only if the user confirms the two observations use the same route.
|
|
107
|
+
effective: observations.intersection,
|
|
106
108
|
}
|
|
107
109
|
await new Promise((resolve) => setTimeout(resolve, 200))
|
|
108
110
|
}
|
|
@@ -112,12 +114,14 @@ writeJson(cachePath(), result)
|
|
|
112
114
|
if (args.json) {
|
|
113
115
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n")
|
|
114
116
|
} else {
|
|
115
|
-
const rows = [["model", "gateway levels", "agy levels", "source"]]
|
|
117
|
+
const rows = [["model", "gateway levels", "agy levels", "intersection*", "source"]]
|
|
116
118
|
for (const [model, info] of Object.entries(result.models)) {
|
|
119
|
+
const observations = evidenceFor(info)
|
|
117
120
|
rows.push([
|
|
118
121
|
model,
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
observations.gateway === null ? "(unknown)" : observations.gateway.join(" ") || "(none)",
|
|
123
|
+
observations.agy === null ? "(unknown)" : observations.agy.join(" ") || "(none)",
|
|
124
|
+
observations.intersection === null ? "(unknown)" : observations.intersection.join(" ") || "(none)",
|
|
121
125
|
info.source,
|
|
122
126
|
])
|
|
123
127
|
}
|
|
@@ -129,4 +133,5 @@ if (args.json) {
|
|
|
129
133
|
row.map((cell, index) => String(cell ?? "").padEnd(widths[index])).join(" ") + "\n",
|
|
130
134
|
)
|
|
131
135
|
}
|
|
132
|
-
|
|
136
|
+
process.stdout.write("* 仅作对照;需自行确认 agy 和探测网关使用相同路由。\n")
|
|
137
|
+
}
|
package/scripts/session-note.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from "node:fs"
|
|
3
|
-
import { cachePath, readJson } from "./lib.mjs"
|
|
3
|
+
import { cacheMatchesProvider, cachePath, evidenceFor, matchingModel, readJson } from "./lib.mjs"
|
|
4
4
|
|
|
5
5
|
let input = {}
|
|
6
6
|
try {
|
|
@@ -10,14 +10,19 @@ try {
|
|
|
10
10
|
|
|
11
11
|
const cache = readJson(cachePath())
|
|
12
12
|
if (!cache?.models) process.exit(0)
|
|
13
|
+
if (!cacheMatchesProvider(cache)) process.exit(0)
|
|
13
14
|
|
|
14
15
|
const modelName = input?.modelName ?? ""
|
|
15
16
|
const entries = Object.entries(cache.models)
|
|
16
|
-
const current =
|
|
17
|
-
entries.find(([model]) => modelName.includes(model) || model.includes(modelName)) ?? undefined
|
|
17
|
+
const current = matchingModel(entries, modelName)
|
|
18
18
|
|
|
19
|
-
const describe = ([model, info]) =>
|
|
20
|
-
|
|
19
|
+
const describe = ([model, info]) => {
|
|
20
|
+
const { gateway, agy, intersection } = evidenceFor(info)
|
|
21
|
+
const show = (levels) => levels === null ? "未知" : levels.join(", ") || "无"
|
|
22
|
+
const at = info.observedAt ?? info.at
|
|
23
|
+
const age = Number.isFinite(at) ? `${Math.round((Date.now() - at) / 60000)}分钟前` : "时间未知"
|
|
24
|
+
return `${model} (${age}): 网关=${show(gateway)}; agy=${show(agy)}; 交集=${show(intersection)}`
|
|
25
|
+
}
|
|
21
26
|
|
|
22
27
|
const lines = current
|
|
23
28
|
? [`当前模型 ${modelName} → ${describe(current)}`, `其他: ${entries.filter(([m]) => m !== current[0]).map(describe).join("; ") || "无"}`]
|
|
@@ -25,11 +30,11 @@ const lines = current
|
|
|
25
30
|
|
|
26
31
|
const age = Math.round((Date.now() - (cache.at ?? Date.now())) / 60000)
|
|
27
32
|
const message =
|
|
28
|
-
`effort-discovery
|
|
29
|
-
|
|
33
|
+
`effort-discovery:档位证据(${age} 分钟前)\n${lines.join("\n")}\n` +
|
|
34
|
+
`网关与 agy 可能走不同路由;交集仅供对照,并不证明请求生效。需要刷新请运行探测技能。`
|
|
30
35
|
|
|
31
36
|
process.stdout.write(
|
|
32
37
|
JSON.stringify({
|
|
33
38
|
injectSteps: [{ systemMessage: { systemMessage: message.slice(0, 9000) } }],
|
|
34
39
|
}) + "\n",
|
|
35
|
-
)
|
|
40
|
+
)
|
|
@@ -19,12 +19,12 @@ node "${PLUGIN_ROOT}/scripts/probe.mjs" --agy --json
|
|
|
19
19
|
- `gateway levels`:网关实测接受的档位(来自非法值错误回显);
|
|
20
20
|
- `agy levels`:agy 自己的 `/effort` 对同一模型给出的可用档位;
|
|
21
21
|
- `source`:`validated` / `no-validation` / `http-*`。
|
|
22
|
-
3.
|
|
23
|
-
4.
|
|
22
|
+
3. 两边都有结果时才展示交集;同名模型可能走不同路由或协议,不能直接证明安全或生效。
|
|
23
|
+
4. 如果声明不一致,提醒用户核对实际路由和网关行为。
|
|
24
24
|
|
|
25
25
|
## 规则
|
|
26
26
|
|
|
27
27
|
- `no-validation` 表示网关接受任意值、无法确定真实支持范围——直说,不要猜。
|
|
28
28
|
- 探测会真实发请求(每个模型最多 4 次,`max_tokens: 1`),只在自有网关上跑。
|
|
29
29
|
- 不要把探测结果写进 agy 的 `settings.json`;`customModels` 生成属于单独的高级操作,需要用户明确同意。
|
|
30
|
-
-
|
|
30
|
+
- `customModels` 生成器是未验证的实验格式:1.5.14 曾测试无效,1.5.20 未验证;不要承诺写入后可用,只有明确同意时才能写配置。
|