@yhong91/cpac 0.2.2 → 0.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.
package/README.md CHANGED
@@ -369,7 +369,7 @@ cpac restore cline
369
369
 
370
370
  ```bash
371
371
  cpac ping codex # 目录里匹配 gpt-*-luna 的一条
372
- cpac ping agy # gemini-3.8-flash 和 claude-sonnet-4-6,各一条
372
+ cpac ping agy # 目录里匹配 gemini-*-flash* 的一条,以及 claude-sonnet-4-6
373
373
  ```
374
374
 
375
375
  用 `CPA_API_KEY`。日志只打模型、HTTP 状态和不含 key 的 `x-cpa-*` trace。CPA 按账号轮询,一次只会落在一个账号上。
package/dist/ping.js CHANGED
@@ -1,15 +1,26 @@
1
1
  import { apiBase, catalogSlugs, fetchCatalog } from "./config.js";
2
2
  import { CPACError } from "./util.js";
3
3
  const LUNA = /^gpt-.+-luna$/;
4
+ const GEMINI_EXACT = /^gemini-.+-flash$/;
5
+ const GEMINI_SUFFIX = /^gemini-.+-flash.+$/;
4
6
  export const PING_MODELS = {
5
- agy: ["gemini-3.8-flash", "claude-sonnet-4-6"],
7
+ agy: ["claude-sonnet-4-6"],
6
8
  };
9
+ function lastMatch(slugs, pattern) {
10
+ return slugs.filter((slug) => pattern.test(slug)).sort().at(-1);
11
+ }
7
12
  export function matchLuna(slugs) {
8
- const model = slugs.filter((slug) => LUNA.test(slug)).sort().at(-1);
13
+ const model = lastMatch(slugs, LUNA);
9
14
  if (!model)
10
15
  throw new CPACError("no catalog model matches gpt-*-luna");
11
16
  return model;
12
17
  }
18
+ export function matchGemini(slugs) {
19
+ const model = lastMatch(slugs, GEMINI_EXACT) ?? lastMatch(slugs, GEMINI_SUFFIX);
20
+ if (!model)
21
+ throw new CPACError("no catalog model matches gemini-*-flash*");
22
+ return model;
23
+ }
13
24
  const EMAIL_RE = /[A-Za-z0-9._%+\-]+@/g;
14
25
  function redact(value) {
15
26
  return String(value).replace(EMAIL_RE, "*@");
@@ -22,9 +33,8 @@ export async function runPing(config, target, deps = {}) {
22
33
  if (!apiKey)
23
34
  throw new CPACError(`environment variable ${config.api_key_env} is not set`);
24
35
  const url = `${apiBase(config.cpa_url)}/chat/completions`;
25
- const models = target === "codex"
26
- ? [matchLuna(catalogSlugs((await fetchCatalog(config.cpa_url, apiKey)).bytes))]
27
- : PING_MODELS[target];
36
+ const slugs = catalogSlugs((await fetchCatalog(config.cpa_url, apiKey)).bytes);
37
+ const models = target === "codex" ? [matchLuna(slugs)] : [matchGemini(slugs), ...PING_MODELS.agy];
28
38
  let failed = 0;
29
39
  for (const model of models) {
30
40
  let response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yhong91/cpac",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Connect Codex and Claude Code to a remote CLIProxyAPI gateway",
5
5
  "type": "module",
6
6
  "bin": {