@prestyj/ai 5.26.0 → 5.28.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
@@ -40,10 +40,10 @@ Tool parameters are Zod schemas. Converted to JSON Schema at the provider bounda
40
40
 
41
41
  | Provider | Models | Notes |
42
42
  |---|---|---|
43
- | `anthropic` | Claude Fable 5.1, Opus 5.5, Opus 5, Sonnet 5, Haiku 4.5 | Extended thinking, prompt caching, server-side compaction |
43
+ | `anthropic` | Claude Fable 5.1, Opus 5.5, Opus 5, Sonnet 5.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
45
  | `glm` | GLM-5.3 | Z.AI platform, OpenAI-compatible |
46
- | `moonshot` | Kimi K3, Kimi K2.7 Code | Moonshot platform, OpenAI-compatible |
46
+ | `moonshot` | Kimi K3, Kimi K2.8 Preview, Kimi K2.7 Code | Moonshot platform, OpenAI-compatible |
47
47
 
48
48
  ---
49
49
 
package/dist/index.cjs CHANGED
@@ -1100,7 +1100,7 @@ function isAdaptiveThinkingModel(model) {
1100
1100
  function toAnthropicThinking(level, maxTokens, model) {
1101
1101
  if (isAdaptiveThinkingModel(model)) {
1102
1102
  let effort = level;
1103
- if (effort === "xhigh" && !/opus-5|opus-4-8|opus-4-7/.test(model)) {
1103
+ if (effort === "xhigh" && !/opus-5|opus-4[-.]8|opus-4[-.]7|sonnet-5[-.]5/.test(model)) {
1104
1104
  effort = "high";
1105
1105
  }
1106
1106
  return {
@@ -2103,7 +2103,7 @@ async function* runStream2(options) {
2103
2103
  const endpointKey = reasoningFieldKey(providerName, options.baseUrl, options.model);
2104
2104
  const client = createClient2(options);
2105
2105
  const isLocal = options.provider === "local";
2106
- const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
2106
+ const isKimiK3 = options.provider === "moonshot" && (options.model === "kimi-k3" || options.model === "kimi-for-coding");
2107
2107
  const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
2108
2108
  const k3Effort = options.thinking ? toKimiK3Effort(options.thinking) : void 0;
2109
2109
  const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
@@ -2745,7 +2745,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2745
2745
  if (response.status === 400 && message === `The '${options.model}' model is not supported when using Codex with a ChatGPT account.`) {
2746
2746
  hint = "This model is not available through your ChatGPT account. Switch to a model listed for OpenAI via the model selector, or check your ChatGPT usage limits.";
2747
2747
  } else if (response.status === 404 && text.includes("does not exist")) {
2748
- hint = "This model is not in OpenAI's current catalog for your ChatGPT account. Switch to GPT-6 Astra, GPT-5.6 Sol, GPT-5.6 Terra, or GPT-5.6 Luna via the model selector.";
2748
+ hint = "This model is not in OpenAI's current catalog for your ChatGPT account. Switch to GPT-6 Astra, GPT-6 Sol, or GPT-6 Luna via the model selector.";
2749
2749
  }
2750
2750
  throw new ProviderError("openai", message, {
2751
2751
  statusCode: response.status,
@@ -4135,7 +4135,8 @@ var REDACTED = "[REDACTED]";
4135
4135
  var TRUNCATED = "[TRUNCATED]";
4136
4136
  var CIRCULAR = "[CIRCULAR]";
4137
4137
  var SENSITIVE_NAME = /(?:^|[_-])(?:api[_-]?key|access[_-]?token|refresh[_-]?token|token|key|auth(?:orization)?|bearer|cookie|credential|private[_-]?key|password|passwd|secret)(?:$|[_-])/i;
4138
- var SENSITIVE_ASSIGNMENT = /\b((?:api[_-]?key|access[_-]?token|refresh[_-]?token|token|key|auth(?:orization)?|bearer|cookie|credential|private[_-]?key|password|passwd|secret))\b(\s*[=:]\s*)(["']?)([^\s,"';}]+)\3/gi;
4138
+ var ENV_SECRET_ASSIGNMENT = /\b((?:[A-Z0-9]+_)*(?:API_?KEY|ACCESS_TOKEN|REFRESH_TOKEN|TOKEN|KEY|AUTH|AUTHORIZATION|BEARER|CREDENTIALS?|PASSWORD|PASSWD|SECRET))\b(\s*[=:]\s*)(["']?)(?!\$|process\.env|os\.environ|import\.meta|env\.)(?=[^\s,"';}]*\d)([^\s,"';}=$][^\s,"';}]{7,})\3/g;
4139
+ var COMPACT_SECRET_ASSIGNMENT = /\b((?:[a-z0-9]+[_-])*(?:api[_-]?key|access[_-]?token|refresh[_-]?token|token|auth|authorization|credentials?|password|passwd|secret)|(?:[a-z0-9]+[_-])+key)=(["']?)(?!\$)([^\s,"'&;}=][^\s,"'&;}]{7,})\2/gi;
4139
4140
  function escaped(value) {
4140
4141
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4141
4142
  }
@@ -4164,8 +4165,11 @@ function redactText(text, options = {}) {
4164
4165
  /\b(authorization\s*[:=]\s*)(?:bearer|basic)\s+[^\s,;]+/gi,
4165
4166
  `$1${REDACTED}`
4166
4167
  );
4167
- result = result.replace(/\b(bearer|basic)\s+[A-Za-z0-9+/_.=-]{8,}/gi, `$1 ${REDACTED}`);
4168
- result = result.replace(/\b(cookie|set-cookie)(\s*[:=]\s*)[^\r\n]+/gi, `$1$2${REDACTED}`);
4168
+ result = result.replace(
4169
+ /\b(bearer|basic)\s+(?![A-Za-z][a-z]{0,14}\b)[A-Za-z0-9+/_.=-]{8,}/gi,
4170
+ `$1 ${REDACTED}`
4171
+ );
4172
+ result = result.replace(/\b(cookie|set-cookie)(\s*:\s*)[^\s=;:]+=[^\r\n]*/gi, `$1$2${REDACTED}`);
4169
4173
  result = result.replace(
4170
4174
  /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\b/g,
4171
4175
  REDACTED
@@ -4175,8 +4179,12 @@ function redactText(text, options = {}) {
4175
4179
  REDACTED
4176
4180
  );
4177
4181
  result = result.replace(
4178
- SENSITIVE_ASSIGNMENT,
4179
- (_match, name, separator) => `${name}${separator}${REDACTED}`
4182
+ ENV_SECRET_ASSIGNMENT,
4183
+ (_match, name, separator, quote) => `${name}${separator}${quote}${REDACTED}${quote}`
4184
+ );
4185
+ result = result.replace(
4186
+ COMPACT_SECRET_ASSIGNMENT,
4187
+ (_match, name, quote) => `${name}=${quote}${REDACTED}${quote}`
4180
4188
  );
4181
4189
  for (const secret of normalizedSecrets(options.secrets)) {
4182
4190
  result = result.replace(new RegExp(escaped(secret), "g"), REDACTED);
@@ -4196,7 +4204,7 @@ function isMediaObject(value) {
4196
4204
  function redactValue(value, options = {}) {
4197
4205
  const maxDepth = options.maxDepth ?? 20;
4198
4206
  const maxEntries = options.maxEntries ?? 1e4;
4199
- const seen = /* @__PURE__ */ new WeakSet();
4207
+ const ancestors = /* @__PURE__ */ new WeakSet();
4200
4208
  let entries = 0;
4201
4209
  const visit = (current, depth, sensitive = false) => {
4202
4210
  if (typeof current === "string") {
@@ -4210,8 +4218,15 @@ function redactValue(value, options = {}) {
4210
4218
  if (isBinary(current)) return current;
4211
4219
  if (current instanceof Date) return new Date(current.getTime());
4212
4220
  if (depth >= maxDepth) return TRUNCATED;
4213
- if (seen.has(current)) return CIRCULAR;
4214
- seen.add(current);
4221
+ if (ancestors.has(current)) return CIRCULAR;
4222
+ ancestors.add(current);
4223
+ try {
4224
+ return cloneObject(current, depth);
4225
+ } finally {
4226
+ ancestors.delete(current);
4227
+ }
4228
+ };
4229
+ const cloneObject = (current, depth) => {
4215
4230
  if (current instanceof Error) {
4216
4231
  const error = {
4217
4232
  name: current.name,