@automagik/omni 2.260713.3 → 2.260714.1
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.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- Per-instance stale-reply policy for the agent dispatcher.
|
|
2
|
+
--
|
|
3
|
+
-- Adds `instances.message_supersede_mode` ('off' | 'discard', default 'off').
|
|
4
|
+
-- When 'discard', an agent reply whose input snapshot is already stale — i.e.
|
|
5
|
+
-- newer inbound arrived for the chat while the agent was still running — is
|
|
6
|
+
-- dropped instead of delivered. The message debouncer's finally-block re-flush
|
|
7
|
+
-- then dispatches the buffered messages immediately, so the follow-up run
|
|
8
|
+
-- answers everything with full context and the user never receives an
|
|
9
|
+
-- out-of-date reply (e.g. a question they already answered).
|
|
10
|
+
--
|
|
11
|
+
-- Default 'off' preserves current delivery behavior for every existing
|
|
12
|
+
-- instance. See `isReplySuperseded` and the gates in
|
|
13
|
+
-- packages/api/src/plugins/agent-dispatcher.ts.
|
|
14
|
+
--
|
|
15
|
+
-- Hand-written (not `drizzle-kit generate`) to avoid the gupshup column
|
|
16
|
+
-- rename prompts that block non-interactive runs in this repo.
|
|
17
|
+
|
|
18
|
+
ALTER TABLE "instances"
|
|
19
|
+
ADD COLUMN IF NOT EXISTS "message_supersede_mode" varchar(20) DEFAULT 'off' NOT NULL;
|
|
@@ -274,6 +274,13 @@
|
|
|
274
274
|
"when": 1778040000000,
|
|
275
275
|
"tag": "0038_instances_allow_first_party",
|
|
276
276
|
"breakpoints": true
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"idx": 39,
|
|
280
|
+
"version": "7",
|
|
281
|
+
"when": 1783900800000,
|
|
282
|
+
"tag": "0039_instances_message_supersede_mode",
|
|
283
|
+
"breakpoints": true
|
|
277
284
|
}
|
|
278
285
|
]
|
|
279
286
|
}
|
package/dist/index.js
CHANGED
|
@@ -31827,12 +31827,13 @@ var init_guild_config = __esm(() => {
|
|
|
31827
31827
|
});
|
|
31828
31828
|
|
|
31829
31829
|
// ../core/src/schemas/instance.ts
|
|
31830
|
-
var DebounceModeSchema, SplitDelayModeSchema, AgentTypeSchema, AgentProviderSchema, CreateAgentProviderSchema, InstanceSchema, CreateInstanceSchema, InstanceStatusSchema;
|
|
31830
|
+
var DebounceModeSchema, SplitDelayModeSchema, SupersedeModeSchema, AgentTypeSchema, AgentProviderSchema, CreateAgentProviderSchema, InstanceSchema, CreateInstanceSchema, InstanceStatusSchema;
|
|
31831
31831
|
var init_instance = __esm(() => {
|
|
31832
31832
|
init_zod();
|
|
31833
31833
|
init_common();
|
|
31834
31834
|
DebounceModeSchema = exports_external.enum(["disabled", "fixed", "randomized"]);
|
|
31835
31835
|
SplitDelayModeSchema = exports_external.enum(["disabled", "fixed", "randomized"]);
|
|
31836
|
+
SupersedeModeSchema = exports_external.enum(["off", "discard"]);
|
|
31836
31837
|
AgentTypeSchema = exports_external.enum(["agent", "team", "workflow"]);
|
|
31837
31838
|
AgentProviderSchema = exports_external.object({
|
|
31838
31839
|
id: UuidSchema,
|
|
@@ -31904,6 +31905,7 @@ var init_instance = __esm(() => {
|
|
|
31904
31905
|
messageDebounceMode: DebounceModeSchema,
|
|
31905
31906
|
messageDebounceMinMs: exports_external.number().int().min(0),
|
|
31906
31907
|
messageDebounceMaxMs: exports_external.number().int().min(0),
|
|
31908
|
+
messageSupersedeMode: SupersedeModeSchema,
|
|
31907
31909
|
messageSplitDelayMode: SplitDelayModeSchema,
|
|
31908
31910
|
messageSplitDelayFixedMs: exports_external.number().int().min(0),
|
|
31909
31911
|
messageSplitDelayMinMs: exports_external.number().int().min(0),
|
|
@@ -65853,6 +65855,7 @@ __export(exports_src, {
|
|
|
65853
65855
|
UpdateAgentRouteSchema: () => UpdateAgentRouteSchema,
|
|
65854
65856
|
TimestampSchema: () => TimestampSchema,
|
|
65855
65857
|
SystemEventSchemas: () => SystemEventSchemas,
|
|
65858
|
+
SupersedeModeSchema: () => SupersedeModeSchema,
|
|
65856
65859
|
SubscriptionManager: () => SubscriptionManager,
|
|
65857
65860
|
SplitDelayModeSchema: () => SplitDelayModeSchema,
|
|
65858
65861
|
SettingValueTypeSchema: () => SettingValueTypeSchema,
|
|
@@ -71274,6 +71277,7 @@ __export(exports_schema, {
|
|
|
71274
71277
|
syncJobsRelations: () => syncJobsRelations,
|
|
71275
71278
|
syncJobs: () => syncJobs,
|
|
71276
71279
|
syncJobTypes: () => syncJobTypes,
|
|
71280
|
+
supersedeMode: () => supersedeMode,
|
|
71277
71281
|
splitDelayMode: () => splitDelayMode,
|
|
71278
71282
|
settingValueTypes: () => settingValueTypes,
|
|
71279
71283
|
settingChangeHistoryRelations: () => settingChangeHistoryRelations,
|
|
@@ -71363,7 +71367,7 @@ __export(exports_schema, {
|
|
|
71363
71367
|
accessRules: () => accessRules,
|
|
71364
71368
|
accessModes: () => accessModes
|
|
71365
71369
|
});
|
|
71366
|
-
var channelTypes, agentTypes, agentSystems, agentEntityTypes, debounceMode, splitDelayMode, replyFilterMode, agentSessionStrategies, ruleTypes, accessModes, settingValueTypes, apiKeyStatuses, apiKeyProfiles, eventTypes, contentTypes, chatTypes, messageSources, messageTypes, messageStatuses, deliveryStatuses, jobStatuses, providerSchemas, agentProviders, agents, agentRoutes, agentSessions, apiKeys, apiKeyAuditLogs, apiKeysRelations, apiKeyAuditLogsRelations, instances, persons, platformIdentities, conversations, chats, chatParticipants, omniGroups, messages2, omniEvents, handoffLogs, closeContactOutcomes, closeContactLogs, accessRules, globalSettings, settingChangeHistory, batchJobs, syncJobTypes, syncJobs, mediaContent, chatIdMappings, pluginStorage, agentProvidersRelations, agentsRelations, instancesRelations, syncJobsRelations, personsRelations, platformIdentitiesRelations, conversationsRelations, chatsRelations, chatParticipantsRelations, messagesRelations, omniEventsRelations, accessRulesRelations, globalSettingsRelations, settingChangeHistoryRelations, batchJobsRelations, mediaContentRelations, chatIdMappingsRelations, deadLetterStatuses, deadLetterEvents, payloadStorageConfig, payloadStages, eventPayloads, webhookSources, conditionOperators, actionTypes, automationDebounceModes, automations2, automationLogStatuses, automationLogs, consumerOffsets, automationsRelations, automationLogsRelations, triggerLogs, triggerLogsRelations, agentRoutesRelations, agentTaskStatuses, agentTasks, agentTasksRelations, turnStatuses, turnActions, turns, turnsRelations, followUpDisarmReasons, chatFollowUpState, chatFollowUpStateRelations, processedEvents, genieHosts;
|
|
71370
|
+
var channelTypes, agentTypes, agentSystems, agentEntityTypes, debounceMode, splitDelayMode, supersedeMode, replyFilterMode, agentSessionStrategies, ruleTypes, accessModes, settingValueTypes, apiKeyStatuses, apiKeyProfiles, eventTypes, contentTypes, chatTypes, messageSources, messageTypes, messageStatuses, deliveryStatuses, jobStatuses, providerSchemas, agentProviders, agents, agentRoutes, agentSessions, apiKeys, apiKeyAuditLogs, apiKeysRelations, apiKeyAuditLogsRelations, instances, persons, platformIdentities, conversations, chats, chatParticipants, omniGroups, messages2, omniEvents, handoffLogs, closeContactOutcomes, closeContactLogs, accessRules, globalSettings, settingChangeHistory, batchJobs, syncJobTypes, syncJobs, mediaContent, chatIdMappings, pluginStorage, agentProvidersRelations, agentsRelations, instancesRelations, syncJobsRelations, personsRelations, platformIdentitiesRelations, conversationsRelations, chatsRelations, chatParticipantsRelations, messagesRelations, omniEventsRelations, accessRulesRelations, globalSettingsRelations, settingChangeHistoryRelations, batchJobsRelations, mediaContentRelations, chatIdMappingsRelations, deadLetterStatuses, deadLetterEvents, payloadStorageConfig, payloadStages, eventPayloads, webhookSources, conditionOperators, actionTypes, automationDebounceModes, automations2, automationLogStatuses, automationLogs, consumerOffsets, automationsRelations, automationLogsRelations, triggerLogs, triggerLogsRelations, agentRoutesRelations, agentTaskStatuses, agentTasks, agentTasksRelations, turnStatuses, turnActions, turns, turnsRelations, followUpDisarmReasons, chatFollowUpState, chatFollowUpStateRelations, processedEvents, genieHosts;
|
|
71367
71371
|
var init_schema2 = __esm(() => {
|
|
71368
71372
|
init_events();
|
|
71369
71373
|
init_drizzle_orm();
|
|
@@ -71384,6 +71388,7 @@ var init_schema2 = __esm(() => {
|
|
|
71384
71388
|
agentEntityTypes = ["assistant", "workflow", "team", "tool"];
|
|
71385
71389
|
debounceMode = ["disabled", "fixed", "randomized", "presence"];
|
|
71386
71390
|
splitDelayMode = ["disabled", "fixed", "randomized"];
|
|
71391
|
+
supersedeMode = ["off", "discard"];
|
|
71387
71392
|
replyFilterMode = ["all", "filtered"];
|
|
71388
71393
|
agentSessionStrategies = ["per_user", "per_chat", "per_thread"];
|
|
71389
71394
|
ruleTypes = ["allow", "deny", "pending_pairing"];
|
|
@@ -71673,6 +71678,7 @@ var init_schema2 = __esm(() => {
|
|
|
71673
71678
|
messageDebounceMaxMs: integer("message_debounce_max_ms").notNull().default(0),
|
|
71674
71679
|
messageDebounceRestartOnTyping: boolean("message_debounce_restart_on_typing").notNull().default(false),
|
|
71675
71680
|
messageDebounceMaxWaitMs: integer("message_debounce_max_wait_ms"),
|
|
71681
|
+
messageSupersedeMode: varchar("message_supersede_mode", { length: 20 }).notNull().default("off").$type(),
|
|
71676
71682
|
agentGateEnabled: boolean("agent_gate_enabled").notNull().default(false),
|
|
71677
71683
|
agentGateModel: varchar("agent_gate_model", { length: 120 }),
|
|
71678
71684
|
agentGatePrompt: text("agent_gate_prompt"),
|
|
@@ -125056,7 +125062,7 @@ import { fileURLToPath } from "url";
|
|
|
125056
125062
|
// package.json
|
|
125057
125063
|
var package_default = {
|
|
125058
125064
|
name: "@automagik/omni",
|
|
125059
|
-
version: "2.
|
|
125065
|
+
version: "2.260714.1",
|
|
125060
125066
|
description: "LLM-optimized CLI for Omni",
|
|
125061
125067
|
type: "module",
|
|
125062
125068
|
bin: {
|
package/dist/server/index.js
CHANGED
|
@@ -23757,12 +23757,13 @@ var init_guild_config = __esm(() => {
|
|
|
23757
23757
|
});
|
|
23758
23758
|
|
|
23759
23759
|
// ../core/src/schemas/instance.ts
|
|
23760
|
-
var DebounceModeSchema, SplitDelayModeSchema, AgentTypeSchema, AgentProviderSchema, CreateAgentProviderSchema, InstanceSchema, CreateInstanceSchema, InstanceStatusSchema;
|
|
23760
|
+
var DebounceModeSchema, SplitDelayModeSchema, SupersedeModeSchema, AgentTypeSchema, AgentProviderSchema, CreateAgentProviderSchema, InstanceSchema, CreateInstanceSchema, InstanceStatusSchema;
|
|
23761
23761
|
var init_instance = __esm(() => {
|
|
23762
23762
|
init_zod();
|
|
23763
23763
|
init_common();
|
|
23764
23764
|
DebounceModeSchema = exports_external.enum(["disabled", "fixed", "randomized"]);
|
|
23765
23765
|
SplitDelayModeSchema = exports_external.enum(["disabled", "fixed", "randomized"]);
|
|
23766
|
+
SupersedeModeSchema = exports_external.enum(["off", "discard"]);
|
|
23766
23767
|
AgentTypeSchema = exports_external.enum(["agent", "team", "workflow"]);
|
|
23767
23768
|
AgentProviderSchema = exports_external.object({
|
|
23768
23769
|
id: UuidSchema,
|
|
@@ -23834,6 +23835,7 @@ var init_instance = __esm(() => {
|
|
|
23834
23835
|
messageDebounceMode: DebounceModeSchema,
|
|
23835
23836
|
messageDebounceMinMs: exports_external.number().int().min(0),
|
|
23836
23837
|
messageDebounceMaxMs: exports_external.number().int().min(0),
|
|
23838
|
+
messageSupersedeMode: SupersedeModeSchema,
|
|
23837
23839
|
messageSplitDelayMode: SplitDelayModeSchema,
|
|
23838
23840
|
messageSplitDelayFixedMs: exports_external.number().int().min(0),
|
|
23839
23841
|
messageSplitDelayMinMs: exports_external.number().int().min(0),
|
|
@@ -225881,7 +225883,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
225881
225883
|
var require_package7 = __commonJS((exports, module) => {
|
|
225882
225884
|
module.exports = {
|
|
225883
225885
|
name: "@omni/api",
|
|
225884
|
-
version: "2.
|
|
225886
|
+
version: "2.260714.1",
|
|
225885
225887
|
type: "module",
|
|
225886
225888
|
exports: {
|
|
225887
225889
|
".": {
|
|
@@ -278015,6 +278017,7 @@ __export(exports_schema, {
|
|
|
278015
278017
|
syncJobsRelations: () => syncJobsRelations,
|
|
278016
278018
|
syncJobs: () => syncJobs,
|
|
278017
278019
|
syncJobTypes: () => syncJobTypes,
|
|
278020
|
+
supersedeMode: () => supersedeMode,
|
|
278018
278021
|
splitDelayMode: () => splitDelayMode,
|
|
278019
278022
|
settingValueTypes: () => settingValueTypes,
|
|
278020
278023
|
settingChangeHistoryRelations: () => settingChangeHistoryRelations,
|
|
@@ -278104,7 +278107,7 @@ __export(exports_schema, {
|
|
|
278104
278107
|
accessRules: () => accessRules,
|
|
278105
278108
|
accessModes: () => accessModes
|
|
278106
278109
|
});
|
|
278107
|
-
var channelTypes, agentTypes, agentSystems, agentEntityTypes, debounceMode, splitDelayMode, replyFilterMode, agentSessionStrategies, ruleTypes, accessModes, settingValueTypes, apiKeyStatuses, apiKeyProfiles, eventTypes, contentTypes, chatTypes, messageSources, messageTypes, messageStatuses, deliveryStatuses, jobStatuses, providerSchemas, agentProviders, agents, agentRoutes, agentSessions, apiKeys, apiKeyAuditLogs, apiKeysRelations, apiKeyAuditLogsRelations, instances, persons, platformIdentities, conversations, chats, chatParticipants, omniGroups, messages2, omniEvents, handoffLogs, closeContactOutcomes, closeContactLogs, accessRules, globalSettings, settingChangeHistory, batchJobs, syncJobTypes, syncJobs, mediaContent, chatIdMappings, pluginStorage, agentProvidersRelations, agentsRelations, instancesRelations, syncJobsRelations, personsRelations, platformIdentitiesRelations, conversationsRelations, chatsRelations, chatParticipantsRelations, messagesRelations, omniEventsRelations, accessRulesRelations, globalSettingsRelations, settingChangeHistoryRelations, batchJobsRelations, mediaContentRelations, chatIdMappingsRelations, deadLetterStatuses, deadLetterEvents, payloadStorageConfig, payloadStages, eventPayloads, webhookSources, conditionOperators, actionTypes, automationDebounceModes, automations2, automationLogStatuses, automationLogs, consumerOffsets, automationsRelations, automationLogsRelations, triggerLogs, triggerLogsRelations, agentRoutesRelations, agentTaskStatuses, agentTasks, agentTasksRelations, turnStatuses, turnActions, turns, turnsRelations, followUpDisarmReasons, chatFollowUpState, chatFollowUpStateRelations, processedEvents, genieHosts;
|
|
278110
|
+
var channelTypes, agentTypes, agentSystems, agentEntityTypes, debounceMode, splitDelayMode, supersedeMode, replyFilterMode, agentSessionStrategies, ruleTypes, accessModes, settingValueTypes, apiKeyStatuses, apiKeyProfiles, eventTypes, contentTypes, chatTypes, messageSources, messageTypes, messageStatuses, deliveryStatuses, jobStatuses, providerSchemas, agentProviders, agents, agentRoutes, agentSessions, apiKeys, apiKeyAuditLogs, apiKeysRelations, apiKeyAuditLogsRelations, instances, persons, platformIdentities, conversations, chats, chatParticipants, omniGroups, messages2, omniEvents, handoffLogs, closeContactOutcomes, closeContactLogs, accessRules, globalSettings, settingChangeHistory, batchJobs, syncJobTypes, syncJobs, mediaContent, chatIdMappings, pluginStorage, agentProvidersRelations, agentsRelations, instancesRelations, syncJobsRelations, personsRelations, platformIdentitiesRelations, conversationsRelations, chatsRelations, chatParticipantsRelations, messagesRelations, omniEventsRelations, accessRulesRelations, globalSettingsRelations, settingChangeHistoryRelations, batchJobsRelations, mediaContentRelations, chatIdMappingsRelations, deadLetterStatuses, deadLetterEvents, payloadStorageConfig, payloadStages, eventPayloads, webhookSources, conditionOperators, actionTypes, automationDebounceModes, automations2, automationLogStatuses, automationLogs, consumerOffsets, automationsRelations, automationLogsRelations, triggerLogs, triggerLogsRelations, agentRoutesRelations, agentTaskStatuses, agentTasks, agentTasksRelations, turnStatuses, turnActions, turns, turnsRelations, followUpDisarmReasons, chatFollowUpState, chatFollowUpStateRelations, processedEvents, genieHosts;
|
|
278108
278111
|
var init_schema2 = __esm(() => {
|
|
278109
278112
|
init_events();
|
|
278110
278113
|
init_drizzle_orm();
|
|
@@ -278125,6 +278128,7 @@ var init_schema2 = __esm(() => {
|
|
|
278125
278128
|
agentEntityTypes = ["assistant", "workflow", "team", "tool"];
|
|
278126
278129
|
debounceMode = ["disabled", "fixed", "randomized", "presence"];
|
|
278127
278130
|
splitDelayMode = ["disabled", "fixed", "randomized"];
|
|
278131
|
+
supersedeMode = ["off", "discard"];
|
|
278128
278132
|
replyFilterMode = ["all", "filtered"];
|
|
278129
278133
|
agentSessionStrategies = ["per_user", "per_chat", "per_thread"];
|
|
278130
278134
|
ruleTypes = ["allow", "deny", "pending_pairing"];
|
|
@@ -278414,6 +278418,7 @@ var init_schema2 = __esm(() => {
|
|
|
278414
278418
|
messageDebounceMaxMs: integer("message_debounce_max_ms").notNull().default(0),
|
|
278415
278419
|
messageDebounceRestartOnTyping: boolean("message_debounce_restart_on_typing").notNull().default(false),
|
|
278416
278420
|
messageDebounceMaxWaitMs: integer("message_debounce_max_wait_ms"),
|
|
278421
|
+
messageSupersedeMode: varchar("message_supersede_mode", { length: 20 }).notNull().default("off").$type(),
|
|
278417
278422
|
agentGateEnabled: boolean("agent_gate_enabled").notNull().default(false),
|
|
278418
278423
|
agentGateModel: varchar("agent_gate_model", { length: 120 }),
|
|
278419
278424
|
agentGatePrompt: text("agent_gate_prompt"),
|
|
@@ -338233,6 +338238,9 @@ class MessageDebouncer {
|
|
|
338233
338238
|
return;
|
|
338234
338239
|
this.restartTimer(chatKey, config4);
|
|
338235
338240
|
}
|
|
338241
|
+
hasPending(instanceId, chatId) {
|
|
338242
|
+
return (this.buffers.get(this.getChatKey(instanceId, chatId))?.length ?? 0) > 0;
|
|
338243
|
+
}
|
|
338236
338244
|
onUserTyping(instanceId, chatId, config4) {
|
|
338237
338245
|
const chatKey = this.getChatKey(instanceId, chatId);
|
|
338238
338246
|
if (this.inFlight.has(chatKey))
|
|
@@ -339188,6 +339196,13 @@ class ReactionDedup {
|
|
|
339188
339196
|
return false;
|
|
339189
339197
|
}
|
|
339190
339198
|
}
|
|
339199
|
+
function hasPendingInbound(instanceId, chatId) {
|
|
339200
|
+
return activeMessageDebouncer?.hasPending(instanceId, chatId) ?? false;
|
|
339201
|
+
}
|
|
339202
|
+
function isReplySuperseded(instance4, chatId) {
|
|
339203
|
+
const mode = instance4.messageSupersedeMode ?? "off";
|
|
339204
|
+
return mode === "discard" && hasPendingInbound(instance4.id, chatId);
|
|
339205
|
+
}
|
|
339191
339206
|
function getDebounceConfig(instance4) {
|
|
339192
339207
|
const mode = instance4.messageDebounceMode ?? "disabled";
|
|
339193
339208
|
const isPresence = mode === "presence";
|
|
@@ -339363,6 +339378,11 @@ async function triggerErrorHandoff(services, db2, channel5, instance4, chatId, m
|
|
|
339363
339378
|
log101.info("agent_dispatch_error_handoff", { instanceId: instance4.id, chatId, channel: channel5 });
|
|
339364
339379
|
return true;
|
|
339365
339380
|
}
|
|
339381
|
+
async function maybeTriggerErrorHandoff(services, db2, channel5, instance4, chatId, customerErrorBlocked, handoffTriggered) {
|
|
339382
|
+
if (!customerErrorBlocked || handoffTriggered)
|
|
339383
|
+
return false;
|
|
339384
|
+
return triggerErrorHandoff(services, db2, channel5, instance4, chatId, resolveErrorHandoffMessage());
|
|
339385
|
+
}
|
|
339366
339386
|
async function handleDispatchFailure(services, db2, channel5, instance4, chatId, error3) {
|
|
339367
339387
|
const handedOff = await triggerErrorHandoff(services, db2, channel5, instance4, chatId, resolveErrorHandoffMessage());
|
|
339368
339388
|
if (handedOff)
|
|
@@ -340509,11 +340529,9 @@ async function dispatchViaProvider(services, instance4, messages4, triggerType,
|
|
|
340509
340529
|
}
|
|
340510
340530
|
const chatAfterRun = await services.chats.findByExternalIdSmart(instance4.id, chatId);
|
|
340511
340531
|
const handoffTriggered = chatAfterRun?.settings?.agentPaused === true;
|
|
340512
|
-
|
|
340513
|
-
|
|
340514
|
-
|
|
340515
|
-
}
|
|
340516
|
-
if (result && result.parts.length > 0 && !handoffTriggered && !errorHandoffDone) {
|
|
340532
|
+
const supersededByNewerInbound = !handoffTriggered && isReplySuperseded(instance4, chatId);
|
|
340533
|
+
const errorHandoffDone = await maybeTriggerErrorHandoff(services, db2, channel5, instance4, chatId, result?.metadata.customerErrorBlocked === true, handoffTriggered);
|
|
340534
|
+
if (result && result.parts.length > 0 && !handoffTriggered && !errorHandoffDone && !supersededByNewerInbound) {
|
|
340517
340535
|
const selfChat = isSelfChat(chatId, instance4.ownerIdentifier);
|
|
340518
340536
|
const rawParts = selfChat ? result.parts.map((p2) => `${BOT_PREFIX}${p2}`) : result.parts;
|
|
340519
340537
|
const parts = await Promise.all(rawParts.map((part) => executeBeforeMessageWriteHooks(instance4.id, chatId, part)));
|
|
@@ -340534,6 +340552,13 @@ async function dispatchViaProvider(services, instance4, messages4, triggerType,
|
|
|
340534
340552
|
instanceId: instance4.id,
|
|
340535
340553
|
chatId
|
|
340536
340554
|
});
|
|
340555
|
+
} else if (supersededByNewerInbound) {
|
|
340556
|
+
log101.info("Agent response discarded \u2014 superseded by newer inbound", {
|
|
340557
|
+
instanceId: instance4.id,
|
|
340558
|
+
chatId,
|
|
340559
|
+
parts: result?.parts.length ?? 0,
|
|
340560
|
+
traceId
|
|
340561
|
+
});
|
|
340537
340562
|
}
|
|
340538
340563
|
log101.info("Agent response via IAgentProvider", {
|
|
340539
340564
|
instanceId: instance4.id,
|
|
@@ -340606,6 +340631,15 @@ async function dispatchViaLegacy(services, instance4, messages4, triggerType, ch
|
|
|
340606
340631
|
files: mediaFiles.length > 0 ? mediaFiles : undefined
|
|
340607
340632
|
}));
|
|
340608
340633
|
const correlationId = messages4[0]?.metadata.correlationId;
|
|
340634
|
+
if (isReplySuperseded(instance4, chatId)) {
|
|
340635
|
+
log101.info("Agent response discarded \u2014 superseded by newer inbound", {
|
|
340636
|
+
instanceId: instance4.id,
|
|
340637
|
+
chatId,
|
|
340638
|
+
parts: result.parts.length,
|
|
340639
|
+
traceId
|
|
340640
|
+
});
|
|
340641
|
+
return;
|
|
340642
|
+
}
|
|
340609
340643
|
const selfChat = isSelfChat(chatId, instance4.ownerIdentifier);
|
|
340610
340644
|
const rawParts = selfChat ? result.parts.map((p2) => `${BOT_PREFIX}${p2}`) : result.parts;
|
|
340611
340645
|
const parts = await Promise.all(rawParts.map((part) => executeBeforeMessageWriteHooks(instance4.id, chatId, part)));
|
|
@@ -341932,6 +341966,7 @@ async function setupAgentDispatcher(eventBus, services, db2) {
|
|
|
341932
341966
|
}
|
|
341933
341967
|
await processAgentResponse(services, instance4, messages4, triggerType, db2, eventBus);
|
|
341934
341968
|
});
|
|
341969
|
+
activeMessageDebouncer = debouncer;
|
|
341935
341970
|
try {
|
|
341936
341971
|
await eventBus.subscribe("message.received", async (event) => {
|
|
341937
341972
|
const payload = event.payload;
|
|
@@ -342145,7 +342180,7 @@ async function setupAgentDispatcher(eventBus, services, db2) {
|
|
|
342145
342180
|
log101.info("Agent dispatcher shutdown complete");
|
|
342146
342181
|
};
|
|
342147
342182
|
}
|
|
342148
|
-
var import_api32, log101, agentDispatchLimiter, _natsGenieProviderCtor, QUOTED_MESSAGE_MAX_CHARS = 4000, DM_HISTORY_LIMIT = 20, LIFECYCLE_PREVIEW_MAX_CHARS = 160, LIFECYCLE_SENSITIVE_KEY_PARTS, PRESENCE_DEFAULT_MIN_MS = 5000, PRESENCE_DEFAULT_MAX_WAIT_MS = 30000, 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;
|
|
342183
|
+
var import_api32, log101, agentDispatchLimiter, _natsGenieProviderCtor, QUOTED_MESSAGE_MAX_CHARS = 4000, DM_HISTORY_LIMIT = 20, LIFECYCLE_PREVIEW_MAX_CHARS = 160, LIFECYCLE_SENSITIVE_KEY_PARTS, PRESENCE_DEFAULT_MIN_MS = 5000, PRESENCE_DEFAULT_MAX_WAIT_MS = 30000, activeMessageDebouncer = null, 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;
|
|
342149
342184
|
var init_agent_dispatcher = __esm(() => {
|
|
342150
342185
|
init_src2();
|
|
342151
342186
|
init_src();
|
|
@@ -354545,6 +354580,7 @@ var init_instances3 = __esm(() => {
|
|
|
354545
354580
|
messageDebounceRestartOnTyping: exports_external.boolean().default(false).describe("Restart debounce timer when user is typing"),
|
|
354546
354581
|
messageDebounceGroupMs: exports_external.number().int().min(0).nullable().default(null).describe("Debounce delay for group chats in milliseconds (null = use messageDebounceMinMs)"),
|
|
354547
354582
|
messageDebounceMaxWaitMs: exports_external.number().int().min(0).nullable().default(null).describe("Presence-mode hard cap in milliseconds \u2014 flush at firstBuffered + this even under continuous typing (null = no cap)"),
|
|
354583
|
+
messageSupersedeMode: exports_external.enum(["off", "discard"]).default("off").describe("Stale-reply policy: 'discard' drops an agent reply when newer inbound arrived while the agent was running (the debounced re-flush answers with full context); 'off' keeps legacy behavior"),
|
|
354548
354584
|
messageSplitDelayMode: exports_external.enum(["disabled", "fixed", "randomized"]).default("randomized").describe("Between-chunk delay when agent responses are split into multiple messages"),
|
|
354549
354585
|
messageSplitDelayFixedMs: exports_external.number().int().min(0).default(0).describe('Fixed delay between split chunks in milliseconds (used when messageSplitDelayMode="fixed")'),
|
|
354550
354586
|
messageSplitDelayMinMs: exports_external.number().int().min(0).default(300).describe('Minimum delay between split chunks in milliseconds (used when messageSplitDelayMode="randomized")'),
|