@automagik/omni 2.260624.1 → 2.260624.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/dist/index.js CHANGED
@@ -62332,15 +62332,19 @@ var init_claude_code_client = __esm(() => {
62332
62332
  function isUnsafeCustomerFacingProviderText(text) {
62333
62333
  return Boolean(text && PROVIDER_ERROR_PATTERN.test(text));
62334
62334
  }
62335
- function toSafeCustomerFallback(text) {
62335
+ function resolveSafeProviderErrorMessage(env2 = process.env) {
62336
+ const override = env2.OMNI_SAFE_PROVIDER_ERROR_MESSAGE?.trim();
62337
+ return override || SAFE_PROVIDER_ERROR_MESSAGE;
62338
+ }
62339
+ function toSafeCustomerFallback(text, env2 = process.env) {
62336
62340
  if (isUnsafeCustomerFacingProviderText(text)) {
62337
- return SAFE_PROVIDER_ERROR_MESSAGE;
62341
+ return resolveSafeProviderErrorMessage(env2);
62338
62342
  }
62339
62343
  return text ?? "";
62340
62344
  }
62341
62345
  var SAFE_PROVIDER_ERROR_MESSAGE = "T\xF4 com um probleminha t\xE9cnico aqui agora. J\xE1 estou avisando o time. Pode tentar de novo em alguns minutos? \uD83D\uDE4F", PROVIDER_ERROR_PATTERN;
62342
62346
  var init_customer_safe_errors = __esm(() => {
62343
- PROVIDER_ERROR_PATTERN = /(litellm\.(BadRequestError|AuthenticationError|RateLimitError|APIError)|ModelProviderError|AnthropicException|Authentication Error|Invalid proxy server token|Received API Key|Available Model Group Fallbacks|credit balance is too low|Plans\s*&\s*Billing|\bsk-[A-Za-z0-9_-]{8,}|Bearer\s+[A-Za-z0-9._-]+|api[_ -]?key\s*[=:])/i;
62347
+ PROVIDER_ERROR_PATTERN = /(litellm\.(BadRequestError|AuthenticationError|RateLimitError|APIError)|ModelProviderError|AnthropicException|Authentication Error|Invalid proxy server token|Received API Key|Available Model Group Fallbacks|credit balance is too low|Plans\s*&\s*Billing|\bsk-[A-Za-z0-9_-]{8,}|Bearer\s+[A-Za-z0-9._-]{20,}|api[_ -]?key\s*[=:])/i;
62344
62348
  });
62345
62349
 
62346
62350
  // ../core/src/providers/agno-provider.ts
@@ -62383,7 +62387,8 @@ class AgnoAgentProvider {
62383
62387
  });
62384
62388
  const response = await this.client.run(request);
62385
62389
  const customerContent = toSafeCustomerFallback(response.content);
62386
- if (customerContent !== response.content) {
62390
+ const customerErrorBlocked = customerContent !== response.content;
62391
+ if (customerErrorBlocked) {
62387
62392
  log8.error("Blocked provider error from customer-facing Agno response", {
62388
62393
  agentId: this.config.agentId,
62389
62394
  runId: response.runId,
@@ -62410,7 +62415,8 @@ class AgnoAgentProvider {
62410
62415
  cost: response.metrics ? {
62411
62416
  inputTokens: response.metrics.inputTokens,
62412
62417
  outputTokens: response.metrics.outputTokens
62413
- } : undefined
62418
+ } : undefined,
62419
+ customerErrorBlocked
62414
62420
  }
62415
62421
  };
62416
62422
  }
@@ -62453,7 +62459,7 @@ class AgnoAgentProvider {
62453
62459
  traceId: context.traceId,
62454
62460
  error: message3
62455
62461
  });
62456
- yield { phase: "error", error: SAFE_PROVIDER_ERROR_MESSAGE };
62462
+ yield { phase: "error", error: resolveSafeProviderErrorMessage() };
62457
62463
  }
62458
62464
  }
62459
62465
  async checkHealth() {
@@ -124998,7 +125004,7 @@ import { fileURLToPath } from "url";
124998
125004
  // package.json
124999
125005
  var package_default = {
125000
125006
  name: "@automagik/omni",
125001
- version: "2.260624.1",
125007
+ version: "2.260624.3",
125002
125008
  description: "LLM-optimized CLI for Omni",
125003
125009
  type: "module",
125004
125010
  bin: {
@@ -30665,15 +30665,19 @@ var init_claude_code_client = __esm(() => {
30665
30665
  function isUnsafeCustomerFacingProviderText(text) {
30666
30666
  return Boolean(text && PROVIDER_ERROR_PATTERN.test(text));
30667
30667
  }
30668
- function toSafeCustomerFallback(text) {
30668
+ function resolveSafeProviderErrorMessage(env = process.env) {
30669
+ const override = env.OMNI_SAFE_PROVIDER_ERROR_MESSAGE?.trim();
30670
+ return override || SAFE_PROVIDER_ERROR_MESSAGE;
30671
+ }
30672
+ function toSafeCustomerFallback(text, env = process.env) {
30669
30673
  if (isUnsafeCustomerFacingProviderText(text)) {
30670
- return SAFE_PROVIDER_ERROR_MESSAGE;
30674
+ return resolveSafeProviderErrorMessage(env);
30671
30675
  }
30672
30676
  return text ?? "";
30673
30677
  }
30674
30678
  var SAFE_PROVIDER_ERROR_MESSAGE = "T\xF4 com um probleminha t\xE9cnico aqui agora. J\xE1 estou avisando o time. Pode tentar de novo em alguns minutos? \uD83D\uDE4F", PROVIDER_ERROR_PATTERN;
30675
30679
  var init_customer_safe_errors = __esm(() => {
30676
- PROVIDER_ERROR_PATTERN = /(litellm\.(BadRequestError|AuthenticationError|RateLimitError|APIError)|ModelProviderError|AnthropicException|Authentication Error|Invalid proxy server token|Received API Key|Available Model Group Fallbacks|credit balance is too low|Plans\s*&\s*Billing|\bsk-[A-Za-z0-9_-]{8,}|Bearer\s+[A-Za-z0-9._-]+|api[_ -]?key\s*[=:])/i;
30680
+ PROVIDER_ERROR_PATTERN = /(litellm\.(BadRequestError|AuthenticationError|RateLimitError|APIError)|ModelProviderError|AnthropicException|Authentication Error|Invalid proxy server token|Received API Key|Available Model Group Fallbacks|credit balance is too low|Plans\s*&\s*Billing|\bsk-[A-Za-z0-9_-]{8,}|Bearer\s+[A-Za-z0-9._-]{20,}|api[_ -]?key\s*[=:])/i;
30677
30681
  });
30678
30682
 
30679
30683
  // ../core/src/providers/agno-provider.ts
@@ -30716,7 +30720,8 @@ class AgnoAgentProvider {
30716
30720
  });
30717
30721
  const response = await this.client.run(request);
30718
30722
  const customerContent = toSafeCustomerFallback(response.content);
30719
- if (customerContent !== response.content) {
30723
+ const customerErrorBlocked = customerContent !== response.content;
30724
+ if (customerErrorBlocked) {
30720
30725
  log8.error("Blocked provider error from customer-facing Agno response", {
30721
30726
  agentId: this.config.agentId,
30722
30727
  runId: response.runId,
@@ -30743,7 +30748,8 @@ class AgnoAgentProvider {
30743
30748
  cost: response.metrics ? {
30744
30749
  inputTokens: response.metrics.inputTokens,
30745
30750
  outputTokens: response.metrics.outputTokens
30746
- } : undefined
30751
+ } : undefined,
30752
+ customerErrorBlocked
30747
30753
  }
30748
30754
  };
30749
30755
  }
@@ -30786,7 +30792,7 @@ class AgnoAgentProvider {
30786
30792
  traceId: context2.traceId,
30787
30793
  error: message3
30788
30794
  });
30789
- yield { phase: "error", error: SAFE_PROVIDER_ERROR_MESSAGE };
30795
+ yield { phase: "error", error: resolveSafeProviderErrorMessage() };
30790
30796
  }
30791
30797
  }
30792
30798
  async checkHealth() {
@@ -225285,7 +225291,7 @@ var init_sentry_scrub = __esm(() => {
225285
225291
  var require_package7 = __commonJS((exports, module) => {
225286
225292
  module.exports = {
225287
225293
  name: "@omni/api",
225288
- version: "2.260624.1",
225294
+ version: "2.260624.3",
225289
225295
  type: "module",
225290
225296
  exports: {
225291
225297
  ".": {
@@ -338462,6 +338468,68 @@ async function sendErrorFeedback(channel5, instanceId, chatId, error3, message2)
338462
338468
  log99.error("agent_dispatch_error", { channel: channel5, instanceId, chatId, error: errorMsg });
338463
338469
  await sendTextMessage5(channel5, instanceId, chatId, message2);
338464
338470
  }
338471
+ function resolveErrorHandoffMessage(env2 = process.env) {
338472
+ return env2.OMNI_AGENT_ERROR_HANDOFF_MESSAGE?.trim() || DEFAULT_ERROR_HANDOFF_MESSAGE;
338473
+ }
338474
+ async function triggerErrorHandoff(services, db2, channel5, instance4, chatId, message2) {
338475
+ const plugin7 = await getPlugin(channel5);
338476
+ if (plugin7?.capabilities?.canHandoff !== true)
338477
+ return false;
338478
+ let sendResult;
338479
+ try {
338480
+ sendResult = await plugin7.sendMessage(instance4.id, {
338481
+ to: chatId,
338482
+ content: { type: "text", text: message2 },
338483
+ metadata: { isHandoff: true, motivoHandoff: "agent_dispatch_error" }
338484
+ });
338485
+ } catch (err) {
338486
+ log99.error("agent_dispatch_error_handoff_failed", { instanceId: instance4.id, chatId, error: String(err) });
338487
+ return false;
338488
+ }
338489
+ if (!sendResult?.success) {
338490
+ log99.error("agent_dispatch_error_handoff_delivery_failed", {
338491
+ instanceId: instance4.id,
338492
+ chatId,
338493
+ error: sendResult?.error
338494
+ });
338495
+ return false;
338496
+ }
338497
+ try {
338498
+ const chat2 = await services.chats.findByExternalIdSmart(instance4.id, chatId);
338499
+ if (chat2) {
338500
+ const settings = chat2.settings ?? {};
338501
+ await services.chats.update(chat2.id, { settings: { ...settings, agentPaused: true } });
338502
+ await services.followUpLifecycle.disarm({ chatId: chat2.id, instanceId: instance4.id, reason: "handoff" });
338503
+ await db2.insert(handoffLogs).values({
338504
+ instanceId: instance4.id,
338505
+ chatUuid: chat2.id,
338506
+ chatId,
338507
+ toPhone: chatId,
338508
+ text: message2,
338509
+ extraInfo: null,
338510
+ agentId: instance4.agentId ?? null,
338511
+ externalMessageId: sendResult?.messageId ?? null,
338512
+ handoffFields: null,
338513
+ sentAt: new Date,
338514
+ metadata: { instanceChannel: channel5, channelHandoffSupported: true, motivoHandoff: "agent_dispatch_error" }
338515
+ });
338516
+ }
338517
+ } catch (err) {
338518
+ log99.warn("agent_dispatch_error_handoff_side_effects_failed", {
338519
+ instanceId: instance4.id,
338520
+ chatId,
338521
+ error: String(err)
338522
+ });
338523
+ }
338524
+ log99.info("agent_dispatch_error_handoff", { instanceId: instance4.id, chatId, channel: channel5 });
338525
+ return true;
338526
+ }
338527
+ async function handleDispatchFailure(services, db2, channel5, instance4, chatId, error3) {
338528
+ const handedOff = await triggerErrorHandoff(services, db2, channel5, instance4, chatId, resolveErrorHandoffMessage());
338529
+ if (handedOff)
338530
+ return;
338531
+ await sendErrorFeedback(channel5, instance4.id, chatId, error3, resolveDispatchErrorMessage(null)).catch(() => {});
338532
+ }
338465
338533
  function sleep5(ms) {
338466
338534
  return new Promise((resolve3) => setTimeout(resolve3, ms));
338467
338535
  }
@@ -339563,7 +339631,11 @@ async function dispatchViaProvider(services, instance4, messages4, triggerType,
339563
339631
  }
339564
339632
  const chatAfterRun = await services.chats.findByExternalIdSmart(instance4.id, chatId);
339565
339633
  const handoffTriggered = chatAfterRun?.settings?.agentPaused === true;
339566
- if (result && result.parts.length > 0 && !handoffTriggered) {
339634
+ let errorHandoffDone = false;
339635
+ if (result?.metadata.customerErrorBlocked === true && !handoffTriggered) {
339636
+ errorHandoffDone = await triggerErrorHandoff(services, db2, channel5, instance4, chatId, resolveErrorHandoffMessage());
339637
+ }
339638
+ if (result && result.parts.length > 0 && !handoffTriggered && !errorHandoffDone) {
339567
339639
  const selfChat = isSelfChat(chatId, instance4.ownerIdentifier);
339568
339640
  const rawParts = selfChat ? result.parts.map((p2) => `${BOT_PREFIX}${p2}`) : result.parts;
339569
339641
  const parts = await Promise.all(rawParts.map((part) => executeBeforeMessageWriteHooks(instance4.id, chatId, part)));
@@ -340067,7 +340139,7 @@ async function processAgentResponse(services, instance4, messages4, triggerType,
340067
340139
  error: String(error3),
340068
340140
  traceId
340069
340141
  });
340070
- sendErrorFeedback(channel5, instance4.id, chatId, error3, resolveDispatchErrorMessage(null)).catch(() => {});
340142
+ await handleDispatchFailure(services, db2, channel5, instance4, chatId, error3);
340071
340143
  } finally {
340072
340144
  ackHandle.remove();
340073
340145
  }
@@ -341194,7 +341266,7 @@ async function setupAgentDispatcher(eventBus, services, db2) {
341194
341266
  log99.info("Agent dispatcher shutdown complete");
341195
341267
  };
341196
341268
  }
341197
- var import_api32, log99, agentDispatchLimiter, _natsGenieProviderCtor, QUOTED_MESSAGE_MAX_CHARS = 4000, DM_HISTORY_LIMIT = 20, LIFECYCLE_PREVIEW_MAX_CHARS = 160, LIFECYCLE_SENSITIVE_KEY_PARTS, DEFAULT_DISPATCH_ERROR_MESSAGE = "\u26A0\uFE0F Sorry, I ran into an issue processing your message. Please try again.", TRANSIENT_DISPATCH_ERROR_PATTERNS, TRANSIENT_DISPATCH_RETRY_DELAYS_MS, CHANNEL_MESSAGE_LIMITS, DEFAULT_MESSAGE_LIMIT = 4000, MEDIA_BASE_PATH3, MEDIA_ICONS, MEDIA_WAIT_NULL, mediaCompletions, mediaResultCache, MEDIA_WAIT_TIMEOUT_MS = 30000, DEFAULT_SEND_MEDIA_PATH_TYPES, BOT_PREFIX = "\uD83E\uDD16 ", activeStreams, sessionActivityStore, PROC_REACT_START, PROC_REACT_DONE = "\u2705", providerCache, openclawClientPool, nullFilterWarnedInstances, ACTIVE_OWNER_IDENTIFIER_CACHE_TTL_MS = 1e4, cachedActiveOwnerIdentifiers = null, cachedActiveOwnerIdentifiersAt = 0, DEFAULT_GATE_MODEL = "gemini-3-flash-preview", GATE_TIMEOUT_MS = 3000, setupAgentResponder;
341269
+ var import_api32, log99, agentDispatchLimiter, _natsGenieProviderCtor, QUOTED_MESSAGE_MAX_CHARS = 4000, DM_HISTORY_LIMIT = 20, LIFECYCLE_PREVIEW_MAX_CHARS = 160, LIFECYCLE_SENSITIVE_KEY_PARTS, DEFAULT_DISPATCH_ERROR_MESSAGE = "\u26A0\uFE0F Sorry, I ran into an issue processing your message. Please try again.", DEFAULT_ERROR_HANDOFF_MESSAGE = "T\xF4 com um probleminha t\xE9cnico aqui agora. Logo algu\xE9m do time vai entrar em contato com voc\xEA.", TRANSIENT_DISPATCH_ERROR_PATTERNS, TRANSIENT_DISPATCH_RETRY_DELAYS_MS, CHANNEL_MESSAGE_LIMITS, DEFAULT_MESSAGE_LIMIT = 4000, MEDIA_BASE_PATH3, MEDIA_ICONS, MEDIA_WAIT_NULL, mediaCompletions, mediaResultCache, MEDIA_WAIT_TIMEOUT_MS = 30000, DEFAULT_SEND_MEDIA_PATH_TYPES, BOT_PREFIX = "\uD83E\uDD16 ", activeStreams, sessionActivityStore, PROC_REACT_START, PROC_REACT_DONE = "\u2705", providerCache, openclawClientPool, nullFilterWarnedInstances, ACTIVE_OWNER_IDENTIFIER_CACHE_TTL_MS = 1e4, cachedActiveOwnerIdentifiers = null, cachedActiveOwnerIdentifiersAt = 0, DEFAULT_GATE_MODEL = "gemini-3-flash-preview", GATE_TIMEOUT_MS = 3000, setupAgentResponder;
341198
341270
  var init_agent_dispatcher = __esm(() => {
341199
341271
  init_src2();
341200
341272
  init_src();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260624.1",
3
+ "version": "2.260624.3",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {