@automagik/omni 2.260713.4 → 2.260714.2

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,13 +71388,23 @@ 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"];
71390
71395
  accessModes = ["disabled", "blocklist", "allowlist"];
71391
71396
  settingValueTypes = ["string", "integer", "boolean", "json", "secret"];
71392
71397
  apiKeyStatuses = ["active", "revoked", "expired"];
71393
- apiKeyProfiles = ["cs", "personal", "scout", "coworker", "admin"];
71398
+ apiKeyProfiles = [
71399
+ "cs",
71400
+ "personal",
71401
+ "scout",
71402
+ "coworker",
71403
+ "admin",
71404
+ "console-viewer",
71405
+ "console-operator",
71406
+ "console-admin"
71407
+ ];
71394
71408
  eventTypes = CORE_EVENT_TYPES;
71395
71409
  contentTypes = [
71396
71410
  "text",
@@ -71673,6 +71687,7 @@ var init_schema2 = __esm(() => {
71673
71687
  messageDebounceMaxMs: integer("message_debounce_max_ms").notNull().default(0),
71674
71688
  messageDebounceRestartOnTyping: boolean("message_debounce_restart_on_typing").notNull().default(false),
71675
71689
  messageDebounceMaxWaitMs: integer("message_debounce_max_wait_ms"),
71690
+ messageSupersedeMode: varchar("message_supersede_mode", { length: 20 }).notNull().default("off").$type(),
71676
71691
  agentGateEnabled: boolean("agent_gate_enabled").notNull().default(false),
71677
71692
  agentGateModel: varchar("agent_gate_model", { length: 120 }),
71678
71693
  agentGatePrompt: text("agent_gate_prompt"),
@@ -73413,8 +73428,80 @@ var init_api_keys = __esm(() => {
73413
73428
  });
73414
73429
 
73415
73430
  // ../api/src/constants/profiles.ts
73416
- var COWORKER_DEFAULT_DENYLIST_PRESET_KEY = "khal-os-core", PROFILES;
73431
+ var COWORKER_DEFAULT_DENYLIST_PRESET_KEY = "khal-os-core", CONSOLE_READ_SCOPES, CONSOLE_OPERATE_SCOPES, CONSOLE_ADMINISTRATION_SCOPES, CONSOLE_VIEWER_SCOPES, CONSOLE_OPERATOR_SCOPES, CONSOLE_ADMIN_SCOPES, PROFILES;
73417
73432
  var init_profiles = __esm(() => {
73433
+ CONSOLE_READ_SCOPES = [
73434
+ "access:read",
73435
+ "agent-state:read",
73436
+ "agent-tasks:read",
73437
+ "agents:read",
73438
+ "auth:validate",
73439
+ "automations:read",
73440
+ "batch-jobs:read",
73441
+ "chats:read",
73442
+ "context:read",
73443
+ "conversations:read",
73444
+ "dead-letters:read",
73445
+ "event-ops:read",
73446
+ "events:read",
73447
+ "follow-up:read",
73448
+ "handoffs:read",
73449
+ "instances:read",
73450
+ "journeys:read",
73451
+ "logs:read",
73452
+ "media:read",
73453
+ "messages:read",
73454
+ "metrics:read",
73455
+ "payloads:read",
73456
+ "persons:read",
73457
+ "providers:read",
73458
+ "routes:read",
73459
+ "settings:read",
73460
+ "trust:read",
73461
+ "voice:read",
73462
+ "webhooks:read"
73463
+ ];
73464
+ CONSOLE_OPERATE_SCOPES = [
73465
+ "agent-state:write",
73466
+ "agent-tasks:write",
73467
+ "automations:write",
73468
+ "batch-jobs:write",
73469
+ "chats:write",
73470
+ "context:write",
73471
+ "conversations:write",
73472
+ "dead-letters:write",
73473
+ "event-ops:write",
73474
+ "events:write",
73475
+ "follow-up:write",
73476
+ "instances:write",
73477
+ "media:write",
73478
+ "messages:send",
73479
+ "messages:write",
73480
+ "persons:write",
73481
+ "routes:write",
73482
+ "tts:synthesize",
73483
+ "turns:admin",
73484
+ "turns:close",
73485
+ "voice:write"
73486
+ ];
73487
+ CONSOLE_ADMINISTRATION_SCOPES = [
73488
+ "access:write",
73489
+ "agents:write",
73490
+ "keys:read",
73491
+ "keys:write",
73492
+ "payloads:write",
73493
+ "providers:write",
73494
+ "settings:write",
73495
+ "trust:write",
73496
+ "webhooks:write"
73497
+ ];
73498
+ CONSOLE_VIEWER_SCOPES = [...CONSOLE_READ_SCOPES];
73499
+ CONSOLE_OPERATOR_SCOPES = [...CONSOLE_READ_SCOPES, ...CONSOLE_OPERATE_SCOPES];
73500
+ CONSOLE_ADMIN_SCOPES = [
73501
+ ...CONSOLE_READ_SCOPES,
73502
+ ...CONSOLE_OPERATE_SCOPES,
73503
+ ...CONSOLE_ADMINISTRATION_SCOPES
73504
+ ];
73418
73505
  PROFILES = {
73419
73506
  cs: {
73420
73507
  buckets: ["outgoing", "read", "context", "turn"],
@@ -73445,6 +73532,27 @@ var init_profiles = __esm(() => {
73445
73532
  buckets: ["outgoing", "read", "context", "turn", "multimodal_in", "multimodal_out"],
73446
73533
  requiresLocks: [],
73447
73534
  adminOnlyFlag: true
73535
+ },
73536
+ "console-viewer": {
73537
+ buckets: [],
73538
+ requiresLocks: [],
73539
+ defaultOverrides: {
73540
+ extraScopes: CONSOLE_VIEWER_SCOPES
73541
+ }
73542
+ },
73543
+ "console-operator": {
73544
+ buckets: [],
73545
+ requiresLocks: [],
73546
+ defaultOverrides: {
73547
+ extraScopes: CONSOLE_OPERATOR_SCOPES
73548
+ }
73549
+ },
73550
+ "console-admin": {
73551
+ buckets: [],
73552
+ requiresLocks: [],
73553
+ defaultOverrides: {
73554
+ extraScopes: CONSOLE_ADMIN_SCOPES
73555
+ }
73448
73556
  }
73449
73557
  };
73450
73558
  });
@@ -125056,7 +125164,7 @@ import { fileURLToPath } from "url";
125056
125164
  // package.json
125057
125165
  var package_default = {
125058
125166
  name: "@automagik/omni",
125059
- version: "2.260713.4",
125167
+ version: "2.260714.2",
125060
125168
  description: "LLM-optimized CLI for Omni",
125061
125169
  type: "module",
125062
125170
  bin: {
@@ -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.260713.4",
225886
+ version: "2.260714.2",
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,13 +278128,23 @@ 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"];
278131
278135
  accessModes = ["disabled", "blocklist", "allowlist"];
278132
278136
  settingValueTypes = ["string", "integer", "boolean", "json", "secret"];
278133
278137
  apiKeyStatuses = ["active", "revoked", "expired"];
278134
- apiKeyProfiles = ["cs", "personal", "scout", "coworker", "admin"];
278138
+ apiKeyProfiles = [
278139
+ "cs",
278140
+ "personal",
278141
+ "scout",
278142
+ "coworker",
278143
+ "admin",
278144
+ "console-viewer",
278145
+ "console-operator",
278146
+ "console-admin"
278147
+ ];
278135
278148
  eventTypes = CORE_EVENT_TYPES;
278136
278149
  contentTypes = [
278137
278150
  "text",
@@ -278414,6 +278427,7 @@ var init_schema2 = __esm(() => {
278414
278427
  messageDebounceMaxMs: integer("message_debounce_max_ms").notNull().default(0),
278415
278428
  messageDebounceRestartOnTyping: boolean("message_debounce_restart_on_typing").notNull().default(false),
278416
278429
  messageDebounceMaxWaitMs: integer("message_debounce_max_wait_ms"),
278430
+ messageSupersedeMode: varchar("message_supersede_mode", { length: 20 }).notNull().default("off").$type(),
278417
278431
  agentGateEnabled: boolean("agent_gate_enabled").notNull().default(false),
278418
278432
  agentGateModel: varchar("agent_gate_model", { length: 120 }),
278419
278433
  agentGatePrompt: text("agent_gate_prompt"),
@@ -285026,8 +285040,80 @@ var init_genie_signature = __esm(() => {
285026
285040
  });
285027
285041
 
285028
285042
  // ../api/src/constants/profiles.ts
285029
- var COWORKER_DEFAULT_DENYLIST_PRESET_KEY = "khal-os-core", PROFILES;
285043
+ var COWORKER_DEFAULT_DENYLIST_PRESET_KEY = "khal-os-core", CONSOLE_READ_SCOPES, CONSOLE_OPERATE_SCOPES, CONSOLE_ADMINISTRATION_SCOPES, CONSOLE_VIEWER_SCOPES, CONSOLE_OPERATOR_SCOPES, CONSOLE_ADMIN_SCOPES, PROFILES;
285030
285044
  var init_profiles = __esm(() => {
285045
+ CONSOLE_READ_SCOPES = [
285046
+ "access:read",
285047
+ "agent-state:read",
285048
+ "agent-tasks:read",
285049
+ "agents:read",
285050
+ "auth:validate",
285051
+ "automations:read",
285052
+ "batch-jobs:read",
285053
+ "chats:read",
285054
+ "context:read",
285055
+ "conversations:read",
285056
+ "dead-letters:read",
285057
+ "event-ops:read",
285058
+ "events:read",
285059
+ "follow-up:read",
285060
+ "handoffs:read",
285061
+ "instances:read",
285062
+ "journeys:read",
285063
+ "logs:read",
285064
+ "media:read",
285065
+ "messages:read",
285066
+ "metrics:read",
285067
+ "payloads:read",
285068
+ "persons:read",
285069
+ "providers:read",
285070
+ "routes:read",
285071
+ "settings:read",
285072
+ "trust:read",
285073
+ "voice:read",
285074
+ "webhooks:read"
285075
+ ];
285076
+ CONSOLE_OPERATE_SCOPES = [
285077
+ "agent-state:write",
285078
+ "agent-tasks:write",
285079
+ "automations:write",
285080
+ "batch-jobs:write",
285081
+ "chats:write",
285082
+ "context:write",
285083
+ "conversations:write",
285084
+ "dead-letters:write",
285085
+ "event-ops:write",
285086
+ "events:write",
285087
+ "follow-up:write",
285088
+ "instances:write",
285089
+ "media:write",
285090
+ "messages:send",
285091
+ "messages:write",
285092
+ "persons:write",
285093
+ "routes:write",
285094
+ "tts:synthesize",
285095
+ "turns:admin",
285096
+ "turns:close",
285097
+ "voice:write"
285098
+ ];
285099
+ CONSOLE_ADMINISTRATION_SCOPES = [
285100
+ "access:write",
285101
+ "agents:write",
285102
+ "keys:read",
285103
+ "keys:write",
285104
+ "payloads:write",
285105
+ "providers:write",
285106
+ "settings:write",
285107
+ "trust:write",
285108
+ "webhooks:write"
285109
+ ];
285110
+ CONSOLE_VIEWER_SCOPES = [...CONSOLE_READ_SCOPES];
285111
+ CONSOLE_OPERATOR_SCOPES = [...CONSOLE_READ_SCOPES, ...CONSOLE_OPERATE_SCOPES];
285112
+ CONSOLE_ADMIN_SCOPES = [
285113
+ ...CONSOLE_READ_SCOPES,
285114
+ ...CONSOLE_OPERATE_SCOPES,
285115
+ ...CONSOLE_ADMINISTRATION_SCOPES
285116
+ ];
285031
285117
  PROFILES = {
285032
285118
  cs: {
285033
285119
  buckets: ["outgoing", "read", "context", "turn"],
@@ -285058,6 +285144,27 @@ var init_profiles = __esm(() => {
285058
285144
  buckets: ["outgoing", "read", "context", "turn", "multimodal_in", "multimodal_out"],
285059
285145
  requiresLocks: [],
285060
285146
  adminOnlyFlag: true
285147
+ },
285148
+ "console-viewer": {
285149
+ buckets: [],
285150
+ requiresLocks: [],
285151
+ defaultOverrides: {
285152
+ extraScopes: CONSOLE_VIEWER_SCOPES
285153
+ }
285154
+ },
285155
+ "console-operator": {
285156
+ buckets: [],
285157
+ requiresLocks: [],
285158
+ defaultOverrides: {
285159
+ extraScopes: CONSOLE_OPERATOR_SCOPES
285160
+ }
285161
+ },
285162
+ "console-admin": {
285163
+ buckets: [],
285164
+ requiresLocks: [],
285165
+ defaultOverrides: {
285166
+ extraScopes: CONSOLE_ADMIN_SCOPES
285167
+ }
285061
285168
  }
285062
285169
  };
285063
285170
  });
@@ -285415,6 +285522,17 @@ var init_scopes = __esm(() => {
285415
285522
  "POST /events/search": "events:read",
285416
285523
  "GET /events/:id": "events:read",
285417
285524
  "GET /events/by-sender/:senderId": "events:read",
285525
+ "GET /follow-up/agents/:id": "follow-up:read",
285526
+ "PUT /follow-up/agents/:id": "follow-up:write",
285527
+ "DELETE /follow-up/agents/:id": "follow-up:write",
285528
+ "GET /follow-up/instances/:id": "follow-up:read",
285529
+ "PUT /follow-up/instances/:id": "follow-up:write",
285530
+ "DELETE /follow-up/instances/:id": "follow-up:write",
285531
+ "GET /follow-up/chats/:id": "follow-up:read",
285532
+ "PUT /follow-up/chats/:id": "follow-up:write",
285533
+ "DELETE /follow-up/chats/:id": "follow-up:write",
285534
+ "GET /handoffs": "handoffs:read",
285535
+ "GET /handoffs/:id": "handoffs:read",
285418
285536
  "GET /instances": "instances:read",
285419
285537
  "GET /instances/supported-channels": "instances:read",
285420
285538
  "GET /instances/:id": "instances:read",
@@ -285548,6 +285666,15 @@ var init_scopes = __esm(() => {
285548
285666
  "POST /turns/:id/close": "turns:admin",
285549
285667
  "POST /turns/close-all": "turns:admin",
285550
285668
  "POST /turns/close": "turns:close",
285669
+ "POST /trust/handshake": "trust:write",
285670
+ "GET /trust/hosts": "trust:read",
285671
+ "GET /trust/hosts/:id": "trust:read",
285672
+ "PATCH /trust/hosts/:id": "trust:write",
285673
+ "DELETE /trust/hosts/:id": "trust:write",
285674
+ "POST /voice/join": "voice:write",
285675
+ "POST /voice/leave": "voice:write",
285676
+ "GET /voice/sessions": "voice:read",
285677
+ "GET /voice/sessions/:id": "voice:read",
285551
285678
  "GET /webhook-sources": "webhooks:read",
285552
285679
  "GET /webhook-sources/:id": "webhooks:read",
285553
285680
  "POST /webhook-sources": "webhooks:write",
@@ -338233,6 +338360,9 @@ class MessageDebouncer {
338233
338360
  return;
338234
338361
  this.restartTimer(chatKey, config4);
338235
338362
  }
338363
+ hasPending(instanceId, chatId) {
338364
+ return (this.buffers.get(this.getChatKey(instanceId, chatId))?.length ?? 0) > 0;
338365
+ }
338236
338366
  onUserTyping(instanceId, chatId, config4) {
338237
338367
  const chatKey = this.getChatKey(instanceId, chatId);
338238
338368
  if (this.inFlight.has(chatKey))
@@ -339188,6 +339318,13 @@ class ReactionDedup {
339188
339318
  return false;
339189
339319
  }
339190
339320
  }
339321
+ function hasPendingInbound(instanceId, chatId) {
339322
+ return activeMessageDebouncer?.hasPending(instanceId, chatId) ?? false;
339323
+ }
339324
+ function isReplySuperseded(instance4, chatId) {
339325
+ const mode = instance4.messageSupersedeMode ?? "off";
339326
+ return mode === "discard" && hasPendingInbound(instance4.id, chatId);
339327
+ }
339191
339328
  function getDebounceConfig(instance4) {
339192
339329
  const mode = instance4.messageDebounceMode ?? "disabled";
339193
339330
  const isPresence = mode === "presence";
@@ -339363,6 +339500,11 @@ async function triggerErrorHandoff(services, db2, channel5, instance4, chatId, m
339363
339500
  log101.info("agent_dispatch_error_handoff", { instanceId: instance4.id, chatId, channel: channel5 });
339364
339501
  return true;
339365
339502
  }
339503
+ async function maybeTriggerErrorHandoff(services, db2, channel5, instance4, chatId, customerErrorBlocked, handoffTriggered) {
339504
+ if (!customerErrorBlocked || handoffTriggered)
339505
+ return false;
339506
+ return triggerErrorHandoff(services, db2, channel5, instance4, chatId, resolveErrorHandoffMessage());
339507
+ }
339366
339508
  async function handleDispatchFailure(services, db2, channel5, instance4, chatId, error3) {
339367
339509
  const handedOff = await triggerErrorHandoff(services, db2, channel5, instance4, chatId, resolveErrorHandoffMessage());
339368
339510
  if (handedOff)
@@ -340509,11 +340651,9 @@ async function dispatchViaProvider(services, instance4, messages4, triggerType,
340509
340651
  }
340510
340652
  const chatAfterRun = await services.chats.findByExternalIdSmart(instance4.id, chatId);
340511
340653
  const handoffTriggered = chatAfterRun?.settings?.agentPaused === true;
340512
- let errorHandoffDone = false;
340513
- if (result?.metadata.customerErrorBlocked === true && !handoffTriggered) {
340514
- errorHandoffDone = await triggerErrorHandoff(services, db2, channel5, instance4, chatId, resolveErrorHandoffMessage());
340515
- }
340516
- if (result && result.parts.length > 0 && !handoffTriggered && !errorHandoffDone) {
340654
+ const supersededByNewerInbound = !handoffTriggered && isReplySuperseded(instance4, chatId);
340655
+ const errorHandoffDone = await maybeTriggerErrorHandoff(services, db2, channel5, instance4, chatId, result?.metadata.customerErrorBlocked === true, handoffTriggered);
340656
+ if (result && result.parts.length > 0 && !handoffTriggered && !errorHandoffDone && !supersededByNewerInbound) {
340517
340657
  const selfChat = isSelfChat(chatId, instance4.ownerIdentifier);
340518
340658
  const rawParts = selfChat ? result.parts.map((p2) => `${BOT_PREFIX}${p2}`) : result.parts;
340519
340659
  const parts = await Promise.all(rawParts.map((part) => executeBeforeMessageWriteHooks(instance4.id, chatId, part)));
@@ -340534,6 +340674,13 @@ async function dispatchViaProvider(services, instance4, messages4, triggerType,
340534
340674
  instanceId: instance4.id,
340535
340675
  chatId
340536
340676
  });
340677
+ } else if (supersededByNewerInbound) {
340678
+ log101.info("Agent response discarded \u2014 superseded by newer inbound", {
340679
+ instanceId: instance4.id,
340680
+ chatId,
340681
+ parts: result?.parts.length ?? 0,
340682
+ traceId
340683
+ });
340537
340684
  }
340538
340685
  log101.info("Agent response via IAgentProvider", {
340539
340686
  instanceId: instance4.id,
@@ -340606,6 +340753,15 @@ async function dispatchViaLegacy(services, instance4, messages4, triggerType, ch
340606
340753
  files: mediaFiles.length > 0 ? mediaFiles : undefined
340607
340754
  }));
340608
340755
  const correlationId = messages4[0]?.metadata.correlationId;
340756
+ if (isReplySuperseded(instance4, chatId)) {
340757
+ log101.info("Agent response discarded \u2014 superseded by newer inbound", {
340758
+ instanceId: instance4.id,
340759
+ chatId,
340760
+ parts: result.parts.length,
340761
+ traceId
340762
+ });
340763
+ return;
340764
+ }
340609
340765
  const selfChat = isSelfChat(chatId, instance4.ownerIdentifier);
340610
340766
  const rawParts = selfChat ? result.parts.map((p2) => `${BOT_PREFIX}${p2}`) : result.parts;
340611
340767
  const parts = await Promise.all(rawParts.map((part) => executeBeforeMessageWriteHooks(instance4.id, chatId, part)));
@@ -341932,6 +342088,7 @@ async function setupAgentDispatcher(eventBus, services, db2) {
341932
342088
  }
341933
342089
  await processAgentResponse(services, instance4, messages4, triggerType, db2, eventBus);
341934
342090
  });
342091
+ activeMessageDebouncer = debouncer;
341935
342092
  try {
341936
342093
  await eventBus.subscribe("message.received", async (event) => {
341937
342094
  const payload = event.payload;
@@ -342145,7 +342302,7 @@ async function setupAgentDispatcher(eventBus, services, db2) {
342145
342302
  log101.info("Agent dispatcher shutdown complete");
342146
342303
  };
342147
342304
  }
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;
342305
+ 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
342306
  var init_agent_dispatcher = __esm(() => {
342150
342307
  init_src2();
342151
342308
  init_src();
@@ -354545,6 +354702,7 @@ var init_instances3 = __esm(() => {
354545
354702
  messageDebounceRestartOnTyping: exports_external.boolean().default(false).describe("Restart debounce timer when user is typing"),
354546
354703
  messageDebounceGroupMs: exports_external.number().int().min(0).nullable().default(null).describe("Debounce delay for group chats in milliseconds (null = use messageDebounceMinMs)"),
354547
354704
  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)"),
354705
+ 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
354706
  messageSplitDelayMode: exports_external.enum(["disabled", "fixed", "randomized"]).default("randomized").describe("Between-chunk delay when agent responses are split into multiple messages"),
354549
354707
  messageSplitDelayFixedMs: exports_external.number().int().min(0).default(0).describe('Fixed delay between split chunks in milliseconds (used when messageSplitDelayMode="fixed")'),
354550
354708
  messageSplitDelayMinMs: exports_external.number().int().min(0).default(300).describe('Minimum delay between split chunks in milliseconds (used when messageSplitDelayMode="randomized")'),
@@ -356594,6 +356752,18 @@ function normalizeOverrides(overrides) {
356594
356752
  denylistPresetKey: overrides.denylistPresetKey === null ? undefined : overrides.denylistPresetKey
356595
356753
  };
356596
356754
  }
356755
+ function enforceMintCeiling(c, requestedScopes) {
356756
+ const callerScopes = c.get("apiKey")?.scopes ?? [];
356757
+ const exceeding = requestedScopes.filter((scope) => !ApiKeyService.scopeAllows(callerScopes, scope));
356758
+ if (exceeding.length === 0)
356759
+ return null;
356760
+ return c.json({
356761
+ error: {
356762
+ code: "FORBIDDEN",
356763
+ message: `Cannot mint a key whose scopes exceed the caller's own. Disallowed: ${exceeding.join(", ")}`
356764
+ }
356765
+ }, 403);
356766
+ }
356597
356767
  async function handleProfileCreate(c, data, services) {
356598
356768
  try {
356599
356769
  const resolved = resolveProfile({
@@ -356605,6 +356775,9 @@ async function handleProfileCreate(c, data, services) {
356605
356775
  overrides: normalizeOverrides(data.overrides),
356606
356776
  denylistPresetKey: data.denylistPresetKey
356607
356777
  });
356778
+ const ceilingDenied = enforceMintCeiling(c, resolved.scopes);
356779
+ if (ceilingDenied)
356780
+ return ceilingDenied;
356608
356781
  const result = await services.apiKeys.create({
356609
356782
  name: data.name,
356610
356783
  description: data.description,
@@ -356637,6 +356810,9 @@ async function handleLegacyCreate(c, data, services) {
356637
356810
  if (!data.scopes || data.scopes.length === 0) {
356638
356811
  return c.json({ error: { code: "VALIDATION_ERROR", message: "scopes is required when no profile is supplied" } }, 400);
356639
356812
  }
356813
+ const ceilingDenied = enforceMintCeiling(c, data.scopes);
356814
+ if (ceilingDenied)
356815
+ return ceilingDenied;
356640
356816
  const result = await services.apiKeys.create({
356641
356817
  name: data.name,
356642
356818
  description: data.description,
@@ -356655,8 +356831,17 @@ var init_keys = __esm(() => {
356655
356831
  init_zod();
356656
356832
  init_resolve_profile();
356657
356833
  init_date_query();
356834
+ init_api_keys();
356658
356835
  keysRoutes = new Hono2;
356659
- NON_ADMIN_PROFILES = ["cs", "personal", "scout", "coworker"];
356836
+ NON_ADMIN_PROFILES = [
356837
+ "cs",
356838
+ "personal",
356839
+ "scout",
356840
+ "coworker",
356841
+ "console-viewer",
356842
+ "console-operator",
356843
+ "console-admin"
356844
+ ];
356660
356845
  profileOverridesSchema = exports_external.object({
356661
356846
  add: exports_external.array(exports_external.string()).optional(),
356662
356847
  remove: exports_external.array(exports_external.string()).optional(),
@@ -356670,7 +356855,7 @@ var init_keys = __esm(() => {
356670
356855
  instanceIds: exports_external.array(exports_external.string().uuid()).optional().describe("Restrict key to specific instance IDs"),
356671
356856
  rateLimit: exports_external.number().int().positive().optional().describe("Rate limit in requests per minute"),
356672
356857
  expiresAt: exports_external.string().datetime().optional().describe("Expiration timestamp (ISO 8601)"),
356673
- profile: exports_external.enum(NON_ADMIN_PROFILES).optional().describe("Profile template: cs, personal, scout, coworker. admin is CLI-only and rejected here."),
356858
+ profile: exports_external.enum(NON_ADMIN_PROFILES).optional().describe("Profile template: cs, personal, scout, coworker, console-viewer, console-operator, console-admin. " + "admin is CLI-only and rejected here."),
356674
356859
  overrides: profileOverridesSchema.optional().describe("Tenant overrides merged on top of the profile template"),
356675
356860
  chatAllowlist: exports_external.array(exports_external.string()).optional().describe("Chats this key may target (profile-aware semantics)"),
356676
356861
  instanceAllowlist: exports_external.array(exports_external.string().uuid()).optional().describe("Instances this key may target"),
@@ -356703,7 +356888,7 @@ var init_keys = __esm(() => {
356703
356888
  cursor: exports_external.string().optional().describe("Pagination cursor")
356704
356889
  });
356705
356890
  keysRoutes.post("/", async (c, next) => {
356706
- const raw2 = await c.req.raw.clone().json().catch(() => null);
356891
+ const raw2 = await c.req.json().catch(() => null);
356707
356892
  if (raw2 && typeof raw2 === "object" && raw2.profile === "admin") {
356708
356893
  return c.json({
356709
356894
  error: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260713.4",
3
+ "version": "2.260714.2",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {