@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/dist/index.js CHANGED
@@ -1033,7 +1033,7 @@ function isAdaptiveThinkingModel(model) {
1033
1033
  function toAnthropicThinking(level, maxTokens, model) {
1034
1034
  if (isAdaptiveThinkingModel(model)) {
1035
1035
  let effort = level;
1036
- if (effort === "xhigh" && !/opus-5|opus-4-8|opus-4-7/.test(model)) {
1036
+ if (effort === "xhigh" && !/opus-5|opus-4[-.]8|opus-4[-.]7|sonnet-5[-.]5/.test(model)) {
1037
1037
  effort = "high";
1038
1038
  }
1039
1039
  return {
@@ -2036,7 +2036,7 @@ async function* runStream2(options) {
2036
2036
  const endpointKey = reasoningFieldKey(providerName, options.baseUrl, options.model);
2037
2037
  const client = createClient2(options);
2038
2038
  const isLocal = options.provider === "local";
2039
- const isKimiK3 = options.provider === "moonshot" && options.model === "kimi-k3";
2039
+ const isKimiK3 = options.provider === "moonshot" && (options.model === "kimi-k3" || options.model === "kimi-for-coding");
2040
2040
  const isManagedKimiK3 = isKimiK3 && options.baseUrl?.replace(/\/+$/, "").endsWith("/coding/v1") === true;
2041
2041
  const k3Effort = options.thinking ? toKimiK3Effort(options.thinking) : void 0;
2042
2042
  const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
@@ -2678,7 +2678,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
2678
2678
  if (response.status === 400 && message === `The '${options.model}' model is not supported when using Codex with a ChatGPT account.`) {
2679
2679
  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.";
2680
2680
  } else if (response.status === 404 && text.includes("does not exist")) {
2681
- 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.";
2681
+ 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.";
2682
2682
  }
2683
2683
  throw new ProviderError("openai", message, {
2684
2684
  statusCode: response.status,
@@ -4068,7 +4068,8 @@ var REDACTED = "[REDACTED]";
4068
4068
  var TRUNCATED = "[TRUNCATED]";
4069
4069
  var CIRCULAR = "[CIRCULAR]";
4070
4070
  var SENSITIVE_NAME = /(?:^|[_-])(?:api[_-]?key|access[_-]?token|refresh[_-]?token|token|key|auth(?:orization)?|bearer|cookie|credential|private[_-]?key|password|passwd|secret)(?:$|[_-])/i;
4071
- 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;
4071
+ 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;
4072
+ 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;
4072
4073
  function escaped(value) {
4073
4074
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4074
4075
  }
@@ -4097,8 +4098,11 @@ function redactText(text, options = {}) {
4097
4098
  /\b(authorization\s*[:=]\s*)(?:bearer|basic)\s+[^\s,;]+/gi,
4098
4099
  `$1${REDACTED}`
4099
4100
  );
4100
- result = result.replace(/\b(bearer|basic)\s+[A-Za-z0-9+/_.=-]{8,}/gi, `$1 ${REDACTED}`);
4101
- result = result.replace(/\b(cookie|set-cookie)(\s*[:=]\s*)[^\r\n]+/gi, `$1$2${REDACTED}`);
4101
+ result = result.replace(
4102
+ /\b(bearer|basic)\s+(?![A-Za-z][a-z]{0,14}\b)[A-Za-z0-9+/_.=-]{8,}/gi,
4103
+ `$1 ${REDACTED}`
4104
+ );
4105
+ result = result.replace(/\b(cookie|set-cookie)(\s*:\s*)[^\s=;:]+=[^\r\n]*/gi, `$1$2${REDACTED}`);
4102
4106
  result = result.replace(
4103
4107
  /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\b/g,
4104
4108
  REDACTED
@@ -4108,8 +4112,12 @@ function redactText(text, options = {}) {
4108
4112
  REDACTED
4109
4113
  );
4110
4114
  result = result.replace(
4111
- SENSITIVE_ASSIGNMENT,
4112
- (_match, name, separator) => `${name}${separator}${REDACTED}`
4115
+ ENV_SECRET_ASSIGNMENT,
4116
+ (_match, name, separator, quote) => `${name}${separator}${quote}${REDACTED}${quote}`
4117
+ );
4118
+ result = result.replace(
4119
+ COMPACT_SECRET_ASSIGNMENT,
4120
+ (_match, name, quote) => `${name}=${quote}${REDACTED}${quote}`
4113
4121
  );
4114
4122
  for (const secret of normalizedSecrets(options.secrets)) {
4115
4123
  result = result.replace(new RegExp(escaped(secret), "g"), REDACTED);
@@ -4129,7 +4137,7 @@ function isMediaObject(value) {
4129
4137
  function redactValue(value, options = {}) {
4130
4138
  const maxDepth = options.maxDepth ?? 20;
4131
4139
  const maxEntries = options.maxEntries ?? 1e4;
4132
- const seen = /* @__PURE__ */ new WeakSet();
4140
+ const ancestors = /* @__PURE__ */ new WeakSet();
4133
4141
  let entries = 0;
4134
4142
  const visit = (current, depth, sensitive = false) => {
4135
4143
  if (typeof current === "string") {
@@ -4143,8 +4151,15 @@ function redactValue(value, options = {}) {
4143
4151
  if (isBinary(current)) return current;
4144
4152
  if (current instanceof Date) return new Date(current.getTime());
4145
4153
  if (depth >= maxDepth) return TRUNCATED;
4146
- if (seen.has(current)) return CIRCULAR;
4147
- seen.add(current);
4154
+ if (ancestors.has(current)) return CIRCULAR;
4155
+ ancestors.add(current);
4156
+ try {
4157
+ return cloneObject(current, depth);
4158
+ } finally {
4159
+ ancestors.delete(current);
4160
+ }
4161
+ };
4162
+ const cloneObject = (current, depth) => {
4148
4163
  if (current instanceof Error) {
4149
4164
  const error = {
4150
4165
  name: current.name,