@agentproto/adapter-pi 0.3.3 → 0.3.4

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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createRequire } from 'module';
2
2
  import { defineAgentCli, createAgentCliRuntime } from '@agentproto/driver-agent-cli';
3
+ import { listModels } from '@agentproto/model-catalog';
3
4
  import { spawn } from 'child_process';
4
5
  import { randomUUID } from 'crypto';
5
6
  import { mkdtempSync, writeFileSync, rmSync } from 'fs';
@@ -18900,6 +18901,30 @@ ${client._stderrTail?.() ?? ""}`
18900
18901
  }
18901
18902
 
18902
18903
  // src/index.ts
18904
+ function buildPiModelMenu() {
18905
+ const supported = [
18906
+ { provider: "anthropic", prefix: "anthropic", wirePrefix: "anthropic" },
18907
+ { provider: "openai", prefix: "openai", wirePrefix: "openai" },
18908
+ { provider: "google", prefix: "google", wirePrefix: "google" },
18909
+ { provider: "moonshot", prefix: "moonshot", wirePrefix: "moonshotai" }
18910
+ ];
18911
+ const seen = /* @__PURE__ */ new Set();
18912
+ const out = [];
18913
+ for (const { provider, prefix, wirePrefix } of supported) {
18914
+ for (const model of listModels({ kind: "llm", provider })) {
18915
+ const bareId = model.id;
18916
+ const product = bareId.includes("/") ? bareId.split("/").pop() : bareId;
18917
+ const id = `${wirePrefix}/${product}`;
18918
+ if (seen.has(id)) continue;
18919
+ seen.add(id);
18920
+ out.push({ id, provider });
18921
+ }
18922
+ }
18923
+ return out.sort((a, b) => {
18924
+ if (a.provider !== b.provider) return a.provider.localeCompare(b.provider);
18925
+ return a.id.localeCompare(b.id);
18926
+ });
18927
+ }
18903
18928
  var pi = defineAgentCli({
18904
18929
  name: "Pi",
18905
18930
  id: "pi",
@@ -18926,6 +18951,13 @@ var pi = defineAgentCli({
18926
18951
  env: ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY", "MOONSHOT_API_KEY"]
18927
18952
  }
18928
18953
  },
18954
+ // Pi's model router reads the provider straight off each id's own
18955
+ // `<provider>/<id>` prefix and consults the matching provider env var
18956
+ // (ANTHROPIC_API_KEY, OPENAI_API_KEY, MOONSHOT_API_KEY, …). Declaring this
18957
+ // lets the runtime's billing-auth resolver and catalog eligibility manifest
18958
+ // include api-key profiles for the model-derived direct endpoint — without
18959
+ // it, no profile is eligible and pi models show "needs a profile".
18960
+ modelDerivedApiKey: true,
18929
18961
  sandbox: "./SANDBOX.md",
18930
18962
  protocol: "proprietary",
18931
18963
  adapter: "@agentproto/adapter-pi",
@@ -18944,33 +18976,19 @@ var pi = defineAgentCli({
18944
18976
  routeSelection: "derived-from-model",
18945
18977
  models: {
18946
18978
  // Pi's `--model <pattern>` accepts `provider/id` (verified against pi
18947
- // 0.80.x cli/args.ts + core/model-resolver.ts). `provider` below is
18948
- // read straight off that same prefix — pi routes on it directly, no
18949
- // adapter mode needed.
18979
+ // 0.80.x cli/args.ts + core/model-resolver.ts).
18950
18980
  default: "anthropic/claude-sonnet-4-5",
18951
- allowed: [
18952
- { id: "anthropic/claude-sonnet-4-5", provider: "anthropic" },
18953
- { id: "openai/gpt-5.1", provider: "openai" },
18954
- { id: "google/gemini-2.5-flash", provider: "google" },
18955
- // Model-id PREFIX stays `moonshotai/` — that's what pi's own `--model`
18956
- // resolver expects (see the comment above). The `provider` field is a
18957
- // BILLING endpoint, not a wire-format echo, and must be the CANONICAL
18958
- // catalog slug `moonshot` (base.ts:48) — `moonshotai` is the upstream/
18959
- // wire slug, already documented to drift from ours (base.ts:113-121).
18960
- // Conflating the two is D3: it made the runtime's model→provider
18961
- // eligibility projection compute an unrecognized "moonshotai" endpoint,
18962
- // which doesn't match any real wallet, so a genuinely-eligible moonshot
18963
- // profile was rejected.
18964
- { id: "moonshotai/kimi-k3", provider: "moonshot" },
18965
- { id: "moonshotai/kimi-k2.7-code", provider: "moonshot" }
18966
- ],
18981
+ // Generated from the shared provider catalog. Moonshot ids use the
18982
+ // `moonshotai/` wire prefix pi's model resolver expects, with the
18983
+ // canonical `moonshot` billing provider (not the wire-format
18984
+ // `moonshotai` — see base.ts:113-121).
18985
+ allowed: buildPiModelMenu(),
18967
18986
  env: {
18968
18987
  anthropic: "ANTHROPIC_API_KEY",
18969
18988
  openai: "OPENAI_API_KEY",
18970
18989
  google: "GOOGLE_GENERATIVE_AI_API_KEY",
18971
- // Keyed by the canonical provider slug (matches `provider` above), not
18972
- // the wire-format `moonshotai` prefix — see the comment on the
18973
- // `allowed` entry.
18990
+ // Keyed by the canonical provider slug, not the wire-format
18991
+ // `moonshotai` prefix.
18974
18992
  moonshot: "MOONSHOT_API_KEY"
18975
18993
  }
18976
18994
  },