@prestyj/ai 5.12.0 → 5.16.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/README.md CHANGED
@@ -42,7 +42,7 @@ Tool parameters are Zod schemas. Converted to JSON Schema at the provider bounda
42
42
  |---|---|---|
43
43
  | `anthropic` | Claude Opus 5, Sonnet 5, Haiku 4.5 | Extended thinking, prompt caching, server-side compaction |
44
44
  | `openai` | GPT-4.1, o3, o4-mini | Supports OAuth (codex endpoint) and API keys |
45
- | `glm` | GLM-5.1, GLM-4.7 | Z.AI platform, OpenAI-compatible |
45
+ | `glm` | GLM-5.3 | Z.AI platform, OpenAI-compatible |
46
46
  | `moonshot` | Kimi K3, Kimi K2.7 Code | Moonshot platform, OpenAI-compatible |
47
47
 
48
48
  ---
package/dist/index.cjs CHANGED
@@ -53,6 +53,7 @@ __export(index_exports, {
53
53
  redactText: () => redactText,
54
54
  redactValue: () => redactValue,
55
55
  registerPalsuProvider: () => registerPalsuProvider,
56
+ resolveToolSchema: () => resolveToolSchema,
56
57
  sanitizeMessagesForWire: () => sanitizeMessagesForWire,
57
58
  setProviderDiagnostic: () => setProviderDiagnostic,
58
59
  sliceHead: () => sliceHead,
@@ -125,6 +126,7 @@ var PROVIDER_DISPLAY = {
125
126
  openrouter: "OpenRouter",
126
127
  sakana: "Sakana",
127
128
  xai: "xAI (Grok)",
129
+ huggingface: "Hugging Face",
128
130
  xiaomi: "Xiaomi (MiMo)",
129
131
  minimax: "MiniMax"
130
132
  };
@@ -192,7 +194,7 @@ function formatError(err) {
192
194
  provider: err.provider,
193
195
  statusCode: err.statusCode,
194
196
  ...err.requestId ? { requestId: err.requestId } : {},
195
- guidance: "Request access via your Anthropic account team (see platform.claude.com/docs/en/about-claude/models/overview), or switch to Claude Fable 5 via the model selector \u2014 same underlying model, generally available."
197
+ guidance: "Request access via your Anthropic account team (see platform.claude.com/docs/en/about-claude/models/overview), or switch to Claude Fable 5.1 via the model selector \u2014 same underlying model, generally available."
196
198
  };
197
199
  }
198
200
  if (isUsageLimitError(err)) {
@@ -1171,6 +1173,9 @@ function toLocalReasoningEffort(level) {
1171
1173
  if (level === "max" || level === "ultra" || level === "xhigh") return "max";
1172
1174
  return level;
1173
1175
  }
1176
+ function toGlmReasoningEffort(level) {
1177
+ return level === "ultra" ? "max" : level;
1178
+ }
1174
1179
  function toOpenAIReasoningEffort(level, model) {
1175
1180
  const effort = level === "max" || level === "ultra" ? "xhigh" : level;
1176
1181
  if (model.startsWith("fugu") && (effort === "low" || effort === "medium")) {
@@ -1617,7 +1622,15 @@ async function* runStream(options) {
1617
1622
  yield keepalive;
1618
1623
  break;
1619
1624
  }
1620
- // message_stop — loop exits naturally
1625
+ // message_stop — loop exits naturally.
1626
+ //
1627
+ // Deliberately NOT breaking early here. Breaking makes the SDK iterator
1628
+ // run `if (!done) controller.abort()` in its `finally`
1629
+ // (core/streaming.js:97), which tears the connection down instead of
1630
+ // returning it to the keep-alive pool — every turn would then pay a
1631
+ // fresh TLS handshake. Draining to the end is what every other Anthropic
1632
+ // client does, and the stall it guards against is handled by the agent
1633
+ // loop's idle timeout.
1621
1634
  default:
1622
1635
  yield keepalive;
1623
1636
  break;
@@ -2040,6 +2053,11 @@ async function* runStream2(options) {
2040
2053
  if (usesThinkingParam) {
2041
2054
  if (options.thinking) {
2042
2055
  params.thinking = { type: "enabled" };
2056
+ if (options.provider === "glm") {
2057
+ params.reasoning_effort = toGlmReasoningEffort(
2058
+ options.thinking
2059
+ );
2060
+ }
2043
2061
  } else {
2044
2062
  params.thinking = { type: "disabled" };
2045
2063
  }
@@ -3022,6 +3040,7 @@ var CODE_ASSIST_SUPPORTED_MODELS = /* @__PURE__ */ new Set([
3022
3040
  "gemini-3.5-flash",
3023
3041
  "gemini-3-flash",
3024
3042
  "gemini-3.1-flash-lite",
3043
+ "gemini-3.7-flash",
3025
3044
  "gemini-2.5-pro",
3026
3045
  "gemini-2.5-flash",
3027
3046
  "gemma-4-31b-it",
@@ -3044,13 +3063,14 @@ var ACCOUNT_GATED_MODELS = /* @__PURE__ */ new Set([
3044
3063
  "gemini-3-flash",
3045
3064
  "gemini-3.5-flash",
3046
3065
  "gemini-3.1-pro-preview",
3047
- "gemini-3.1-pro-preview-customtools"
3066
+ "gemini-3.1-pro-preview-customtools",
3067
+ "gemini-3.7-flash"
3048
3068
  ]);
3049
3069
  function accountGatedMessage(model) {
3050
3070
  return `Your Google account isn't entitled to "${model}" over Gemini Code Assist OAuth, so the API reports it as not found. This is an account-access limit, not a ezcoder bug.`;
3051
3071
  }
3052
3072
  function accountGatedHint() {
3053
- return `Newer Gemini models (3.5 Flash, 3.1 Pro Preview) are available only to Code Assist Standard/Enterprise accounts with preview/GA access enabled by a cloud admin \u2014 free/personal accounts usually can't call them. Switch to Gemini 3.1 Flash Lite (it works on this account) with /model, or sign in with a Code Assist Standard/Enterprise account that has preview access.`;
3073
+ return `Newer Gemini models (3.7 Flash, 3.5 Flash, 3.1 Pro Preview) are available only to Code Assist Standard/Enterprise accounts with preview/GA access enabled by a cloud admin \u2014 free/personal accounts usually can't call them. Switch to Gemini 3.1 Flash Lite (it works on this account) with /model, or sign in with a Code Assist Standard/Enterprise account that has preview access.`;
3054
3074
  }
3055
3075
  function formatErrorMessage(status, body, model) {
3056
3076
  if (status === 404 && !CODE_ASSIST_SUPPORTED_MODELS.has(model)) {
@@ -3734,6 +3754,18 @@ providerRegistry.register("openrouter", {
3734
3754
  baseUrl: options.baseUrl ?? "https://openrouter.ai/api/v1"
3735
3755
  })
3736
3756
  });
3757
+ providerRegistry.register("huggingface", {
3758
+ // Hugging Face Inference Providers router — one HF token (hf.co/settings/tokens,
3759
+ // "Make calls to Inference Providers" permission) routes to whichever hosted
3760
+ // backend serves each open model. Chat Completions-compatible; model ids are
3761
+ // Hub repo paths ("Qwen/Qwen3-Coder-480B-A35B-Instruct"), optionally with an
3762
+ // ":auto"/":fastest"/":cheapest" provider-selection suffix. Billing follows
3763
+ // each backend's per-token rates on the HF account (small free tier).
3764
+ stream: (options) => streamOpenAI({
3765
+ ...options,
3766
+ baseUrl: options.baseUrl ?? "https://router.huggingface.co/v1"
3767
+ })
3768
+ });
3737
3769
  providerRegistry.register("sakana", {
3738
3770
  // Sakana Fugu is a multi-agent system exposed as a standard LLM through the
3739
3771
  // OpenAI-compatible Sakana API. We ride the Chat Completions transport (the
@@ -4229,6 +4261,7 @@ function registerPalsuProvider(config) {
4229
4261
  redactText,
4230
4262
  redactValue,
4231
4263
  registerPalsuProvider,
4264
+ resolveToolSchema,
4232
4265
  sanitizeMessagesForWire,
4233
4266
  setProviderDiagnostic,
4234
4267
  sliceHead,