@automagik/omni 2.260525.2 → 2.260529.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.
package/dist/index.js CHANGED
@@ -28459,7 +28459,7 @@ function registerSchemas(entries) {
28459
28459
  eventRegistry.register(entry);
28460
28460
  }
28461
28461
  }
28462
- var log2, eventRegistry, SystemEventSchemas;
28462
+ var log2, eventRegistry, SystemEventSchemas, CustomEventSchemas;
28463
28463
  var init_registry = __esm(() => {
28464
28464
  init_zod();
28465
28465
  init_logger();
@@ -28493,6 +28493,25 @@ var init_registry = __esm(() => {
28493
28493
  severity: exports_external.enum(["warning", "critical"])
28494
28494
  }), { description: "System health degradation detected" })
28495
28495
  };
28496
+ CustomEventSchemas = {
28497
+ chatUnreadUpdated: createEventSchema("custom.chat.unread-updated", exports_external.object({
28498
+ chatId: exports_external.string(),
28499
+ unreadCount: exports_external.number()
28500
+ }), { description: "Platform-native chat unread count update" }),
28501
+ contactsNames: createEventSchema("custom.contacts.names", exports_external.object({
28502
+ names: exports_external.array(exports_external.object({
28503
+ jid: exports_external.string(),
28504
+ name: exports_external.string()
28505
+ }))
28506
+ }), { description: "Contact display names discovered by a channel" }),
28507
+ lidMappingBatch: createEventSchema("custom.lid-mapping.batch", exports_external.object({
28508
+ mappings: exports_external.array(exports_external.object({
28509
+ lidJid: exports_external.string(),
28510
+ phoneJid: exports_external.string()
28511
+ }))
28512
+ }), { description: "Batch of WhatsApp LID to phone JID mappings" })
28513
+ };
28514
+ registerSchemas([...Object.values(SystemEventSchemas), ...Object.values(CustomEventSchemas)]);
28496
28515
  });
28497
28516
 
28498
28517
  // ../core/src/events/nats/subjects.ts
@@ -35744,6 +35763,100 @@ var init_types6 = __esm(() => {
35744
35763
  };
35745
35764
  });
35746
35765
 
35766
+ // ../core/src/providers/execution-context.ts
35767
+ function compactEnv(values) {
35768
+ return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined));
35769
+ }
35770
+ function inferChatType(context) {
35771
+ if (context.type === "dm")
35772
+ return "dm";
35773
+ if (context.source.chatId === context.sender.platformUserId)
35774
+ return "dm";
35775
+ if (context.source.threadId)
35776
+ return "channel";
35777
+ return "group";
35778
+ }
35779
+ function compactCustomer(customer) {
35780
+ if (!customer)
35781
+ return;
35782
+ const compacted = Object.fromEntries(Object.entries(customer).filter(([, value]) => value !== undefined));
35783
+ return Object.keys(compacted).length > 0 ? compacted : undefined;
35784
+ }
35785
+ function buildOmniExecutionContext(context) {
35786
+ const userId = context.sender.personId ?? context.sender.platformUserId;
35787
+ const sessionId = context.sessionId || context.source.threadId || context.source.chatId || userId;
35788
+ const customer = compactCustomer(context.customer);
35789
+ return {
35790
+ identity: {
35791
+ userId,
35792
+ ...context.sender.personId ? { personId: context.sender.personId } : {},
35793
+ platformUserId: context.sender.platformUserId,
35794
+ ...context.sender.displayName ? { displayName: context.sender.displayName } : {}
35795
+ },
35796
+ source: {
35797
+ channel: context.source.channelType,
35798
+ instanceId: context.source.instanceId,
35799
+ chatId: context.source.chatId,
35800
+ ...context.source.threadId ? { threadId: context.source.threadId } : {},
35801
+ messageId: context.source.messageId
35802
+ },
35803
+ session: {
35804
+ id: sessionId,
35805
+ ...context.sessionStrategy ? { strategy: context.sessionStrategy } : {}
35806
+ },
35807
+ trace: {
35808
+ id: context.traceId
35809
+ },
35810
+ ...customer ? { customer } : {}
35811
+ };
35812
+ }
35813
+ function buildOmniEnv(context, executionContext = buildOmniExecutionContext(context)) {
35814
+ return compactEnv({
35815
+ ...context.env ?? {},
35816
+ OMNI_USER_ID: executionContext.identity.userId,
35817
+ OMNI_PERSON_ID: executionContext.identity.personId,
35818
+ OMNI_PLATFORM_USER_ID: executionContext.identity.platformUserId,
35819
+ OMNI_SENDER: executionContext.identity.platformUserId,
35820
+ OMNI_DISPLAY_NAME: executionContext.identity.displayName,
35821
+ OMNI_INSTANCE: executionContext.source.instanceId,
35822
+ OMNI_CHAT: executionContext.source.chatId,
35823
+ OMNI_MESSAGE: executionContext.source.messageId,
35824
+ OMNI_CHANNEL: executionContext.source.channel,
35825
+ OMNI_SESSION: executionContext.session.id,
35826
+ OMNI_TRACE_ID: executionContext.trace.id,
35827
+ OMNI_THREAD: executionContext.source.threadId,
35828
+ OMNI_EXTERNAL_USER_ID: executionContext.customer?.externalUserId,
35829
+ OMNI_CUSTOMER_ID: executionContext.customer?.customerId,
35830
+ OMNI_ORGANIZATION_ID: executionContext.customer?.organizationId,
35831
+ OMNI_TENANT_ID: executionContext.customer?.tenantId
35832
+ });
35833
+ }
35834
+ function buildProviderRequestContext(context) {
35835
+ const executionContext = buildOmniExecutionContext(context);
35836
+ return {
35837
+ userId: executionContext.identity.userId,
35838
+ sessionId: executionContext.session.id,
35839
+ platform: {
35840
+ id: executionContext.identity.platformUserId,
35841
+ channel: executionContext.source.channel,
35842
+ instanceId: executionContext.source.instanceId
35843
+ },
35844
+ sender: {
35845
+ ...executionContext.identity.displayName ? { displayName: executionContext.identity.displayName } : {}
35846
+ },
35847
+ chat: {
35848
+ type: inferChatType(context),
35849
+ id: executionContext.source.chatId,
35850
+ ...executionContext.source.threadId ? { threadId: executionContext.source.threadId } : {}
35851
+ },
35852
+ messageId: executionContext.source.messageId,
35853
+ ...context.content.referencedMessageId ? { replyToMessageId: context.content.referencedMessageId } : {},
35854
+ env: buildOmniEnv(context, executionContext),
35855
+ executionContext
35856
+ };
35857
+ }
35858
+ var OMNI_EXECUTION_CONTEXT_EXTENSION_URI = "https://omni.dev/extensions/execution-context/v1";
35859
+
35747
35860
  // ../core/src/providers/agno-client.ts
35748
35861
  class AgnoClient {
35749
35862
  baseUrl;
@@ -60159,12 +60272,11 @@ class AgnoAgentProvider {
60159
60272
  message2 = `[${context.sender.displayName}]: ${message2}`;
60160
60273
  }
60161
60274
  const request = {
60275
+ ...buildProviderRequestContext(context),
60162
60276
  message: message2,
60163
60277
  agentId: this.config.agentId,
60164
60278
  agentType: this.config.agentType,
60165
60279
  stream: false,
60166
- sessionId: context.sessionId,
60167
- userId: context.sender.platformUserId,
60168
60280
  timeoutMs: this.config.timeoutMs ?? 60000
60169
60281
  };
60170
60282
  log8.info("Triggering Agno agent", {
@@ -60220,20 +60332,6 @@ function boundContextMessages(contextMessages) {
60220
60332
  }
60221
60333
  return bounded;
60222
60334
  }
60223
- function buildOmniEnv(context) {
60224
- return {
60225
- ...context.env ?? {},
60226
- OMNI_INSTANCE: context.source.instanceId,
60227
- OMNI_CHAT: context.source.chatId,
60228
- OMNI_MESSAGE: context.source.messageId,
60229
- OMNI_CHANNEL: context.source.channelType,
60230
- OMNI_SESSION: context.sessionId,
60231
- OMNI_TRACE_ID: context.traceId,
60232
- OMNI_SENDER: context.sender.platformUserId,
60233
- ...context.sender.personId ? { OMNI_PERSON_ID: context.sender.personId } : {},
60234
- ...context.source.threadId ? { OMNI_THREAD: context.source.threadId } : {}
60235
- };
60236
- }
60237
60335
 
60238
60336
  class ClaudeCodeAgentProvider {
60239
60337
  id;
@@ -60357,13 +60455,12 @@ ${fileList}`;
60357
60455
  }
60358
60456
  const { message: message2, resolvedSessionId, internalSessionKey } = prepared;
60359
60457
  const request = {
60458
+ ...buildProviderRequestContext(context),
60360
60459
  message: message2,
60361
60460
  agentId: "claude-code",
60362
60461
  stream: false,
60363
60462
  sessionId: resolvedSessionId,
60364
- userId: context.sender.personId ?? context.sender.platformUserId,
60365
60463
  timeoutMs: this.options.timeoutMs ?? 120000,
60366
- env: buildOmniEnv(context),
60367
60464
  ...context.source.chatId ? { mcpUrlParams: { chat_id: context.source.chatId } } : {}
60368
60465
  };
60369
60466
  log9.info("Triggering Claude Code agent", {
@@ -60400,13 +60497,12 @@ ${fileList}`;
60400
60497
  }
60401
60498
  const { message: message2, resolvedSessionId, internalSessionKey } = prepared;
60402
60499
  const request = {
60500
+ ...buildProviderRequestContext(context),
60403
60501
  message: message2,
60404
60502
  agentId: "claude-code",
60405
60503
  stream: true,
60406
60504
  sessionId: resolvedSessionId,
60407
- userId: context.sender.personId ?? context.sender.platformUserId,
60408
60505
  timeoutMs: this.options.timeoutMs ?? 120000,
60409
- env: buildOmniEnv(context),
60410
60506
  ...context.source.chatId ? { mcpUrlParams: { chat_id: context.source.chatId } } : {}
60411
60507
  };
60412
60508
  log9.info("Triggering Claude Code agent (stream)", {
@@ -60502,6 +60598,7 @@ class WebhookAgentProvider {
60502
60598
  emoji: context.content.emoji
60503
60599
  },
60504
60600
  traceId: context.traceId,
60601
+ executionContext: buildOmniExecutionContext(context),
60505
60602
  replyEndpoint: "POST /api/v2/messages/send"
60506
60603
  };
60507
60604
  log10.info("Sending webhook trigger", {
@@ -61917,10 +62014,9 @@ class AgUiAgentProvider {
61917
62014
  return { parts: [], metadata: { runId: "", providerId: this.id, durationMs: 0 } };
61918
62015
  }
61919
62016
  const request = {
62017
+ ...buildProviderRequestContext(context),
61920
62018
  message: message2,
61921
62019
  agentId: this.config.agentId,
61922
- sessionId: context.sessionId,
61923
- userId: context.sender.platformUserId,
61924
62020
  timeoutMs: this.config.timeoutMs ?? 60000
61925
62021
  };
61926
62022
  log14.info("Triggering AG-UI agent", { agentId: this.config.agentId, traceId: context.traceId });
@@ -61947,10 +62043,9 @@ class AgUiAgentProvider {
61947
62043
  return;
61948
62044
  }
61949
62045
  const request = {
62046
+ ...buildProviderRequestContext(context),
61950
62047
  message: message2,
61951
62048
  agentId: this.config.agentId,
61952
- sessionId: context.sessionId,
61953
- userId: context.sender.platformUserId,
61954
62049
  timeoutMs: this.config.timeoutMs ?? 60000
61955
62050
  };
61956
62051
  log14.info("Streaming AG-UI agent", { agentId: this.config.agentId, traceId: context.traceId });
@@ -62109,16 +62204,23 @@ class A2AClient {
62109
62204
  }
62110
62205
  }
62111
62206
  buildJsonRpcRequest(method, request) {
62207
+ const message2 = {
62208
+ role: "ROLE_USER",
62209
+ parts: [{ text: request.message, mediaType: "text/plain" }],
62210
+ messageId: `msg-${crypto.randomUUID()}`
62211
+ };
62212
+ if (request.executionContext) {
62213
+ message2.extensions = [OMNI_EXECUTION_CONTEXT_EXTENSION_URI];
62214
+ message2.metadata = {
62215
+ omniExecutionContext: request.executionContext
62216
+ };
62217
+ }
62112
62218
  return {
62113
62219
  jsonrpc: "2.0",
62114
62220
  id: `omni-${crypto.randomUUID()}`,
62115
62221
  method,
62116
62222
  params: {
62117
- message: {
62118
- role: "ROLE_USER",
62119
- parts: [{ text: request.message, mediaType: "text/plain" }],
62120
- messageId: `msg-${crypto.randomUUID()}`
62121
- },
62223
+ message: message2,
62122
62224
  configuration: {
62123
62225
  acceptedOutputModes: ["text/plain"],
62124
62226
  returnImmediately: true
@@ -62334,10 +62436,9 @@ class A2AAgentProvider {
62334
62436
  return { parts: [], metadata: { runId: "", providerId: this.id, durationMs: 0 } };
62335
62437
  }
62336
62438
  const request = {
62439
+ ...buildProviderRequestContext(context),
62337
62440
  message: message2,
62338
62441
  agentId: this.config.agentId,
62339
- sessionId: context.sessionId,
62340
- userId: context.sender.platformUserId,
62341
62442
  timeoutMs: this.config.timeoutMs ?? 60000
62342
62443
  };
62343
62444
  log16.info("Triggering A2A agent", { agentId: this.config.agentId, traceId: context.traceId });
@@ -62367,10 +62468,9 @@ class A2AAgentProvider {
62367
62468
  return;
62368
62469
  }
62369
62470
  const request = {
62471
+ ...buildProviderRequestContext(context),
62370
62472
  message: message2,
62371
62473
  agentId: this.config.agentId,
62372
- sessionId: context.sessionId,
62373
- userId: context.sender.platformUserId,
62374
62474
  timeoutMs: this.config.timeoutMs ?? 60000
62375
62475
  };
62376
62476
  log16.info("Streaming A2A agent", { agentId: this.config.agentId, traceId: context.traceId });
@@ -62466,7 +62566,8 @@ class NatsGenieProvider {
62466
62566
  traceId: context.traceId,
62467
62567
  messageId: context.source.messageId,
62468
62568
  files: context.content.files,
62469
- env: context.env
62569
+ env: buildOmniEnv(context),
62570
+ executionContext: buildOmniExecutionContext(context)
62470
62571
  };
62471
62572
  try {
62472
62573
  await this.ensureConnected();
@@ -63449,6 +63550,9 @@ __export(exports_src, {
63449
63550
  calculateBackoffDelay: () => calculateBackoffDelay,
63450
63551
  buildSubscribePattern: () => buildSubscribePattern,
63451
63552
  buildSubject: () => buildSubject,
63553
+ buildProviderRequestContext: () => buildProviderRequestContext,
63554
+ buildOmniExecutionContext: () => buildOmniExecutionContext,
63555
+ buildOmniEnv: () => buildOmniEnv,
63452
63556
  buildConversationKey: () => buildConversationKey,
63453
63557
  buildConsumerConfig: () => buildConsumerConfig,
63454
63558
  armSequence: () => armSequence,
@@ -63493,6 +63597,7 @@ __export(exports_src, {
63493
63597
  OpenClawAgentProvider: () => OpenClawAgentProvider,
63494
63598
  OmniEventRecordSchema: () => OmniEventRecordSchema,
63495
63599
  OmniError: () => OmniError,
63600
+ OMNI_EXECUTION_CONTEXT_EXTENSION_URI: () => OMNI_EXECUTION_CONTEXT_EXTENSION_URI,
63496
63601
  NotFoundError: () => NotFoundError,
63497
63602
  NonEmptyStringSchema: () => NonEmptyStringSchema,
63498
63603
  NatsGenieProvider: () => NatsGenieProvider,
@@ -63551,6 +63656,7 @@ __export(exports_src, {
63551
63656
  DEFAULT_CONSUMER_CONFIG: () => DEFAULT_CONSUMER_CONFIG,
63552
63657
  DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
63553
63658
  DEBOUNCE_MODES: () => DEBOUNCE_MODES,
63659
+ CustomEventSchemas: () => CustomEventSchemas,
63554
63660
  CronExpressions: () => CronExpressions,
63555
63661
  CreatePlatformIdentitySchema: () => CreatePlatformIdentitySchema,
63556
63662
  CreatePersonSchema: () => CreatePersonSchema,
@@ -124617,7 +124723,7 @@ import { fileURLToPath } from "url";
124617
124723
  // package.json
124618
124724
  var package_default = {
124619
124725
  name: "@automagik/omni",
124620
- version: "2.260525.2",
124726
+ version: "2.260529.1",
124621
124727
  description: "LLM-optimized CLI for Omni",
124622
124728
  type: "module",
124623
124729
  bin: {
@@ -133978,7 +134084,7 @@ function createMessagesCommand() {
133978
134084
  error("--chat is required");
133979
134085
  return;
133980
134086
  }
133981
- const resolvedMessageId = await resolveMessageId(messageId);
134087
+ const resolvedMessageId = await resolveMessageId(messageId, channelId);
133982
134088
  const instanceId = await resolveInstanceId(options.instance);
133983
134089
  const config2 = (await Promise.resolve().then(() => (init_config(), exports_config))).loadConfig();
133984
134090
  const baseUrl = config2.apiUrl ?? "http://localhost:8882";
@@ -22418,7 +22418,12 @@ function createEventSchema(eventType, schema, options) {
22418
22418
  description: options?.description
22419
22419
  };
22420
22420
  }
22421
- var log2, eventRegistry, SystemEventSchemas;
22421
+ function registerSchemas(entries) {
22422
+ for (const entry of entries) {
22423
+ eventRegistry.register(entry);
22424
+ }
22425
+ }
22426
+ var log2, eventRegistry, SystemEventSchemas, CustomEventSchemas;
22422
22427
  var init_registry = __esm(() => {
22423
22428
  init_zod();
22424
22429
  init_logger();
@@ -22452,6 +22457,25 @@ var init_registry = __esm(() => {
22452
22457
  severity: exports_external.enum(["warning", "critical"])
22453
22458
  }), { description: "System health degradation detected" })
22454
22459
  };
22460
+ CustomEventSchemas = {
22461
+ chatUnreadUpdated: createEventSchema("custom.chat.unread-updated", exports_external.object({
22462
+ chatId: exports_external.string(),
22463
+ unreadCount: exports_external.number()
22464
+ }), { description: "Platform-native chat unread count update" }),
22465
+ contactsNames: createEventSchema("custom.contacts.names", exports_external.object({
22466
+ names: exports_external.array(exports_external.object({
22467
+ jid: exports_external.string(),
22468
+ name: exports_external.string()
22469
+ }))
22470
+ }), { description: "Contact display names discovered by a channel" }),
22471
+ lidMappingBatch: createEventSchema("custom.lid-mapping.batch", exports_external.object({
22472
+ mappings: exports_external.array(exports_external.object({
22473
+ lidJid: exports_external.string(),
22474
+ phoneJid: exports_external.string()
22475
+ }))
22476
+ }), { description: "Batch of WhatsApp LID to phone JID mappings" })
22477
+ };
22478
+ registerSchemas([...Object.values(SystemEventSchemas), ...Object.values(CustomEventSchemas)]);
22455
22479
  });
22456
22480
 
22457
22481
  // ../core/src/events/nats/subjects.ts
@@ -29417,6 +29441,100 @@ var init_types7 = __esm(() => {
29417
29441
  };
29418
29442
  });
29419
29443
 
29444
+ // ../core/src/providers/execution-context.ts
29445
+ function compactEnv(values) {
29446
+ return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined));
29447
+ }
29448
+ function inferChatType(context2) {
29449
+ if (context2.type === "dm")
29450
+ return "dm";
29451
+ if (context2.source.chatId === context2.sender.platformUserId)
29452
+ return "dm";
29453
+ if (context2.source.threadId)
29454
+ return "channel";
29455
+ return "group";
29456
+ }
29457
+ function compactCustomer(customer) {
29458
+ if (!customer)
29459
+ return;
29460
+ const compacted = Object.fromEntries(Object.entries(customer).filter(([, value]) => value !== undefined));
29461
+ return Object.keys(compacted).length > 0 ? compacted : undefined;
29462
+ }
29463
+ function buildOmniExecutionContext(context2) {
29464
+ const userId = context2.sender.personId ?? context2.sender.platformUserId;
29465
+ const sessionId = context2.sessionId || context2.source.threadId || context2.source.chatId || userId;
29466
+ const customer = compactCustomer(context2.customer);
29467
+ return {
29468
+ identity: {
29469
+ userId,
29470
+ ...context2.sender.personId ? { personId: context2.sender.personId } : {},
29471
+ platformUserId: context2.sender.platformUserId,
29472
+ ...context2.sender.displayName ? { displayName: context2.sender.displayName } : {}
29473
+ },
29474
+ source: {
29475
+ channel: context2.source.channelType,
29476
+ instanceId: context2.source.instanceId,
29477
+ chatId: context2.source.chatId,
29478
+ ...context2.source.threadId ? { threadId: context2.source.threadId } : {},
29479
+ messageId: context2.source.messageId
29480
+ },
29481
+ session: {
29482
+ id: sessionId,
29483
+ ...context2.sessionStrategy ? { strategy: context2.sessionStrategy } : {}
29484
+ },
29485
+ trace: {
29486
+ id: context2.traceId
29487
+ },
29488
+ ...customer ? { customer } : {}
29489
+ };
29490
+ }
29491
+ function buildOmniEnv(context2, executionContext = buildOmniExecutionContext(context2)) {
29492
+ return compactEnv({
29493
+ ...context2.env ?? {},
29494
+ OMNI_USER_ID: executionContext.identity.userId,
29495
+ OMNI_PERSON_ID: executionContext.identity.personId,
29496
+ OMNI_PLATFORM_USER_ID: executionContext.identity.platformUserId,
29497
+ OMNI_SENDER: executionContext.identity.platformUserId,
29498
+ OMNI_DISPLAY_NAME: executionContext.identity.displayName,
29499
+ OMNI_INSTANCE: executionContext.source.instanceId,
29500
+ OMNI_CHAT: executionContext.source.chatId,
29501
+ OMNI_MESSAGE: executionContext.source.messageId,
29502
+ OMNI_CHANNEL: executionContext.source.channel,
29503
+ OMNI_SESSION: executionContext.session.id,
29504
+ OMNI_TRACE_ID: executionContext.trace.id,
29505
+ OMNI_THREAD: executionContext.source.threadId,
29506
+ OMNI_EXTERNAL_USER_ID: executionContext.customer?.externalUserId,
29507
+ OMNI_CUSTOMER_ID: executionContext.customer?.customerId,
29508
+ OMNI_ORGANIZATION_ID: executionContext.customer?.organizationId,
29509
+ OMNI_TENANT_ID: executionContext.customer?.tenantId
29510
+ });
29511
+ }
29512
+ function buildProviderRequestContext(context2) {
29513
+ const executionContext = buildOmniExecutionContext(context2);
29514
+ return {
29515
+ userId: executionContext.identity.userId,
29516
+ sessionId: executionContext.session.id,
29517
+ platform: {
29518
+ id: executionContext.identity.platformUserId,
29519
+ channel: executionContext.source.channel,
29520
+ instanceId: executionContext.source.instanceId
29521
+ },
29522
+ sender: {
29523
+ ...executionContext.identity.displayName ? { displayName: executionContext.identity.displayName } : {}
29524
+ },
29525
+ chat: {
29526
+ type: inferChatType(context2),
29527
+ id: executionContext.source.chatId,
29528
+ ...executionContext.source.threadId ? { threadId: executionContext.source.threadId } : {}
29529
+ },
29530
+ messageId: executionContext.source.messageId,
29531
+ ...context2.content.referencedMessageId ? { replyToMessageId: context2.content.referencedMessageId } : {},
29532
+ env: buildOmniEnv(context2, executionContext),
29533
+ executionContext
29534
+ };
29535
+ }
29536
+ var OMNI_EXECUTION_CONTEXT_EXTENSION_URI = "https://omni.dev/extensions/execution-context/v1";
29537
+
29420
29538
  // ../core/src/providers/agno-client.ts
29421
29539
  class AgnoClient {
29422
29540
  baseUrl;
@@ -30462,12 +30580,11 @@ class AgnoAgentProvider {
30462
30580
  message2 = `[${context2.sender.displayName}]: ${message2}`;
30463
30581
  }
30464
30582
  const request = {
30583
+ ...buildProviderRequestContext(context2),
30465
30584
  message: message2,
30466
30585
  agentId: this.config.agentId,
30467
30586
  agentType: this.config.agentType,
30468
30587
  stream: false,
30469
- sessionId: context2.sessionId,
30470
- userId: context2.sender.platformUserId,
30471
30588
  timeoutMs: this.config.timeoutMs ?? 60000
30472
30589
  };
30473
30590
  log8.info("Triggering Agno agent", {
@@ -30523,20 +30640,6 @@ function boundContextMessages(contextMessages) {
30523
30640
  }
30524
30641
  return bounded;
30525
30642
  }
30526
- function buildOmniEnv(context2) {
30527
- return {
30528
- ...context2.env ?? {},
30529
- OMNI_INSTANCE: context2.source.instanceId,
30530
- OMNI_CHAT: context2.source.chatId,
30531
- OMNI_MESSAGE: context2.source.messageId,
30532
- OMNI_CHANNEL: context2.source.channelType,
30533
- OMNI_SESSION: context2.sessionId,
30534
- OMNI_TRACE_ID: context2.traceId,
30535
- OMNI_SENDER: context2.sender.platformUserId,
30536
- ...context2.sender.personId ? { OMNI_PERSON_ID: context2.sender.personId } : {},
30537
- ...context2.source.threadId ? { OMNI_THREAD: context2.source.threadId } : {}
30538
- };
30539
- }
30540
30643
 
30541
30644
  class ClaudeCodeAgentProvider {
30542
30645
  id;
@@ -30660,13 +30763,12 @@ ${fileList}`;
30660
30763
  }
30661
30764
  const { message: message2, resolvedSessionId, internalSessionKey } = prepared;
30662
30765
  const request = {
30766
+ ...buildProviderRequestContext(context2),
30663
30767
  message: message2,
30664
30768
  agentId: "claude-code",
30665
30769
  stream: false,
30666
30770
  sessionId: resolvedSessionId,
30667
- userId: context2.sender.personId ?? context2.sender.platformUserId,
30668
30771
  timeoutMs: this.options.timeoutMs ?? 120000,
30669
- env: buildOmniEnv(context2),
30670
30772
  ...context2.source.chatId ? { mcpUrlParams: { chat_id: context2.source.chatId } } : {}
30671
30773
  };
30672
30774
  log9.info("Triggering Claude Code agent", {
@@ -30703,13 +30805,12 @@ ${fileList}`;
30703
30805
  }
30704
30806
  const { message: message2, resolvedSessionId, internalSessionKey } = prepared;
30705
30807
  const request = {
30808
+ ...buildProviderRequestContext(context2),
30706
30809
  message: message2,
30707
30810
  agentId: "claude-code",
30708
30811
  stream: true,
30709
30812
  sessionId: resolvedSessionId,
30710
- userId: context2.sender.personId ?? context2.sender.platformUserId,
30711
30813
  timeoutMs: this.options.timeoutMs ?? 120000,
30712
- env: buildOmniEnv(context2),
30713
30814
  ...context2.source.chatId ? { mcpUrlParams: { chat_id: context2.source.chatId } } : {}
30714
30815
  };
30715
30816
  log9.info("Triggering Claude Code agent (stream)", {
@@ -30805,6 +30906,7 @@ class WebhookAgentProvider {
30805
30906
  emoji: context2.content.emoji
30806
30907
  },
30807
30908
  traceId: context2.traceId,
30909
+ executionContext: buildOmniExecutionContext(context2),
30808
30910
  replyEndpoint: "POST /api/v2/messages/send"
30809
30911
  };
30810
30912
  log10.info("Sending webhook trigger", {
@@ -32201,10 +32303,9 @@ class AgUiAgentProvider {
32201
32303
  return { parts: [], metadata: { runId: "", providerId: this.id, durationMs: 0 } };
32202
32304
  }
32203
32305
  const request = {
32306
+ ...buildProviderRequestContext(context2),
32204
32307
  message: message2,
32205
32308
  agentId: this.config.agentId,
32206
- sessionId: context2.sessionId,
32207
- userId: context2.sender.platformUserId,
32208
32309
  timeoutMs: this.config.timeoutMs ?? 60000
32209
32310
  };
32210
32311
  log14.info("Triggering AG-UI agent", { agentId: this.config.agentId, traceId: context2.traceId });
@@ -32231,10 +32332,9 @@ class AgUiAgentProvider {
32231
32332
  return;
32232
32333
  }
32233
32334
  const request = {
32335
+ ...buildProviderRequestContext(context2),
32234
32336
  message: message2,
32235
32337
  agentId: this.config.agentId,
32236
- sessionId: context2.sessionId,
32237
- userId: context2.sender.platformUserId,
32238
32338
  timeoutMs: this.config.timeoutMs ?? 60000
32239
32339
  };
32240
32340
  log14.info("Streaming AG-UI agent", { agentId: this.config.agentId, traceId: context2.traceId });
@@ -32380,16 +32480,23 @@ class A2AClient {
32380
32480
  }
32381
32481
  }
32382
32482
  buildJsonRpcRequest(method, request) {
32483
+ const message2 = {
32484
+ role: "ROLE_USER",
32485
+ parts: [{ text: request.message, mediaType: "text/plain" }],
32486
+ messageId: `msg-${crypto.randomUUID()}`
32487
+ };
32488
+ if (request.executionContext) {
32489
+ message2.extensions = [OMNI_EXECUTION_CONTEXT_EXTENSION_URI];
32490
+ message2.metadata = {
32491
+ omniExecutionContext: request.executionContext
32492
+ };
32493
+ }
32383
32494
  return {
32384
32495
  jsonrpc: "2.0",
32385
32496
  id: `omni-${crypto.randomUUID()}`,
32386
32497
  method,
32387
32498
  params: {
32388
- message: {
32389
- role: "ROLE_USER",
32390
- parts: [{ text: request.message, mediaType: "text/plain" }],
32391
- messageId: `msg-${crypto.randomUUID()}`
32392
- },
32499
+ message: message2,
32393
32500
  configuration: {
32394
32501
  acceptedOutputModes: ["text/plain"],
32395
32502
  returnImmediately: true
@@ -32605,10 +32712,9 @@ class A2AAgentProvider {
32605
32712
  return { parts: [], metadata: { runId: "", providerId: this.id, durationMs: 0 } };
32606
32713
  }
32607
32714
  const request = {
32715
+ ...buildProviderRequestContext(context2),
32608
32716
  message: message2,
32609
32717
  agentId: this.config.agentId,
32610
- sessionId: context2.sessionId,
32611
- userId: context2.sender.platformUserId,
32612
32718
  timeoutMs: this.config.timeoutMs ?? 60000
32613
32719
  };
32614
32720
  log16.info("Triggering A2A agent", { agentId: this.config.agentId, traceId: context2.traceId });
@@ -32638,10 +32744,9 @@ class A2AAgentProvider {
32638
32744
  return;
32639
32745
  }
32640
32746
  const request = {
32747
+ ...buildProviderRequestContext(context2),
32641
32748
  message: message2,
32642
32749
  agentId: this.config.agentId,
32643
- sessionId: context2.sessionId,
32644
- userId: context2.sender.platformUserId,
32645
32750
  timeoutMs: this.config.timeoutMs ?? 60000
32646
32751
  };
32647
32752
  log16.info("Streaming A2A agent", { agentId: this.config.agentId, traceId: context2.traceId });
@@ -32724,7 +32829,8 @@ class NatsGenieProvider {
32724
32829
  traceId: context2.traceId,
32725
32830
  messageId: context2.source.messageId,
32726
32831
  files: context2.content.files,
32727
- env: context2.env
32832
+ env: buildOmniEnv(context2),
32833
+ executionContext: buildOmniExecutionContext(context2)
32728
32834
  };
32729
32835
  try {
32730
32836
  await this.ensureConnected();
@@ -230186,7 +230292,7 @@ var init_sentry_scrub = __esm(() => {
230186
230292
  var require_package8 = __commonJS((exports, module) => {
230187
230293
  module.exports = {
230188
230294
  name: "@omni/api",
230189
- version: "2.260525.2",
230295
+ version: "2.260529.1",
230190
230296
  type: "module",
230191
230297
  exports: {
230192
230298
  ".": {
@@ -331775,7 +331881,7 @@ function resolveEffectiveChatName(params) {
331775
331881
  function mapContentType(contentType) {
331776
331882
  return CONTENT_TYPE_MAP[contentType ?? ""] ?? "text";
331777
331883
  }
331778
- function inferChatType(chatId, isGroup) {
331884
+ function inferChatType2(chatId, isGroup) {
331779
331885
  if (chatId.includes("@g.us") || chatId.includes("@broadcast"))
331780
331886
  return "group";
331781
331887
  if (chatId.includes("@newsletter"))
@@ -332047,7 +332153,7 @@ async function handleMessageReceived(services, payload, metadata, eventTimestamp
332047
332153
  const chatExternalId = truncate3(payload.chatId, 255) ?? payload.chatId;
332048
332154
  const messageExternalId = truncate3(payload.externalId, 255) ?? payload.externalId;
332049
332155
  const rawPayload = payload.rawPayload ? deepSanitize(payload.rawPayload) : undefined;
332050
- const chatType = inferChatType(payload.chatId, rawPayload?.isGroup);
332156
+ const chatType = inferChatType2(payload.chatId, rawPayload?.isGroup);
332051
332157
  const isFromMe2 = rawPayload?.isFromMe === true;
332052
332158
  const pushName = truncate3(payload.senderName ?? rawPayload?.pushName, 255);
332053
332159
  const chatName = truncate3(payload.chatName ?? rawPayload?.chatName, 255);
@@ -332149,7 +332255,7 @@ async function setupMessagePersistence(eventBus, services) {
332149
332255
  const chatExternalId = truncate3(payload.chatId, 255) ?? payload.chatId;
332150
332256
  const messageExternalId = truncate3(payload.externalId, 255) ?? payload.externalId;
332151
332257
  const { chat: chat2 } = await services.chats.findOrCreate(metadata.instanceId, chatExternalId, {
332152
- chatType: inferChatType(payload.chatId),
332258
+ chatType: inferChatType2(payload.chatId),
332153
332259
  channel: metadata.channelType ?? "whatsapp"
332154
332260
  });
332155
332261
  const sentContent = buildSentMessageContentFields(payload);
@@ -332754,6 +332860,26 @@ async function waitForRecord(fn, maxMs = 5000, pollMs = 250) {
332754
332860
  }
332755
332861
  return null;
332756
332862
  }
332863
+ function awaitMediaCompletion(msgId) {
332864
+ return new Promise((resolvePromise, rejectPromise) => {
332865
+ mediaCompletions.set(msgId, { resolve: resolvePromise, reject: rejectPromise, createdAt: Date.now() });
332866
+ setTimeout(() => {
332867
+ if (mediaCompletions.has(msgId)) {
332868
+ mediaCompletions.delete(msgId);
332869
+ rejectPromise(new Error(`media wait timeout (${MEDIA_WAIT_TIMEOUT_MS}ms)`));
332870
+ }
332871
+ }, MEDIA_WAIT_TIMEOUT_MS);
332872
+ });
332873
+ }
332874
+ async function recoverProcessedMediaAfterTimeout(services, chatRecordId, externalId, column2) {
332875
+ const refreshed = await services.messages.getByExternalId(chatRecordId, externalId);
332876
+ if (!refreshed)
332877
+ return null;
332878
+ const recovered = checkProcessedColumn(refreshed, column2);
332879
+ if (recovered === "pending" || recovered === "error")
332880
+ return null;
332881
+ return recovered;
332882
+ }
332757
332883
  async function awaitMediaProcessing(services, instanceId, chatId, externalId, contentType) {
332758
332884
  const column2 = getProcessedColumn(contentType);
332759
332885
  if (!column2)
@@ -332783,9 +332909,22 @@ async function awaitMediaProcessing(services, instanceId, chatId, externalId, co
332783
332909
  const localPath2 = msg.mediaLocalPath ? resolve2(join19(MEDIA_BASE_PATH3, msg.mediaLocalPath)) : null;
332784
332910
  return { content: cached.content, localPath: localPath2 };
332785
332911
  }
332786
- const result = await new Promise((resolvePromise, rejectPromise) => {
332787
- mediaCompletions.set(msg.id, { resolve: resolvePromise, reject: rejectPromise, createdAt: Date.now() });
332788
- });
332912
+ let result;
332913
+ try {
332914
+ result = await awaitMediaCompletion(msg.id);
332915
+ } catch (error3) {
332916
+ log94.warn("Media wait timed out, retrying DB read", {
332917
+ instanceId,
332918
+ chatId,
332919
+ externalId,
332920
+ msgId: msg.id,
332921
+ error: String(error3)
332922
+ });
332923
+ const recovered = await recoverProcessedMediaAfterTimeout(services, chat2.id, externalId, column2);
332924
+ if (recovered)
332925
+ return recovered;
332926
+ return MEDIA_WAIT_NULL;
332927
+ }
332789
332928
  if (!result.content || result.error)
332790
332929
  return MEDIA_WAIT_NULL;
332791
332930
  const updated = await services.messages.getByExternalId(chat2.id, externalId);
@@ -333014,6 +333153,62 @@ async function resolvePersonId(services, channel5, instanceId, senderId, metadat
333014
333153
  }
333015
333154
  return;
333016
333155
  }
333156
+ function isRecord(value) {
333157
+ return value !== null && typeof value === "object" && !Array.isArray(value);
333158
+ }
333159
+ function pickString(record, ...keys) {
333160
+ for (const key of keys) {
333161
+ const value = record[key];
333162
+ if (typeof value === "string" && value.length > 0)
333163
+ return value;
333164
+ }
333165
+ return;
333166
+ }
333167
+ function compactCustomerContext(context20) {
333168
+ const compacted = Object.fromEntries(Object.entries(context20).filter(([, value]) => value !== undefined));
333169
+ return Object.keys(compacted).length > 0 ? compacted : undefined;
333170
+ }
333171
+ function customerContextFromRecord(record) {
333172
+ return compactCustomerContext({
333173
+ externalUserId: pickString(record, "externalUserId", "external_user_id"),
333174
+ customerId: pickString(record, "customerId", "customer_id"),
333175
+ organizationId: pickString(record, "organizationId", "organization_id", "orgId", "org_id"),
333176
+ tenantId: pickString(record, "tenantId", "tenant_id")
333177
+ });
333178
+ }
333179
+ function extractA2ACustomerContext(messages4, channel5) {
333180
+ if (channel5 !== "a2a")
333181
+ return;
333182
+ const rawPayload = messages4[0]?.payload.rawPayload;
333183
+ if (!isRecord(rawPayload))
333184
+ return;
333185
+ const executionContext = rawPayload.omniExecutionContext;
333186
+ if (!isRecord(executionContext))
333187
+ return;
333188
+ const customer = isRecord(executionContext.customer) ? executionContext.customer : {};
333189
+ const identity = isRecord(executionContext.identity) ? executionContext.identity : {};
333190
+ return compactCustomerContext({
333191
+ ...customerContextFromRecord(customer),
333192
+ externalUserId: pickString(customer, "externalUserId", "external_user_id") ?? pickString(identity, "platformUserId", "userId")
333193
+ });
333194
+ }
333195
+ async function resolveCustomerContext(services, personId, externalContext) {
333196
+ let storedContext;
333197
+ if (personId) {
333198
+ try {
333199
+ const person2 = await services.persons.getById(personId);
333200
+ if (person2 && isRecord(person2.metadata)) {
333201
+ storedContext = customerContextFromRecord(person2.metadata);
333202
+ }
333203
+ } catch (error3) {
333204
+ log94.debug("Failed to resolve customer context", { personId, error: String(error3) });
333205
+ }
333206
+ }
333207
+ return compactCustomerContext({
333208
+ ...externalContext ?? {},
333209
+ ...storedContext ?? {}
333210
+ });
333211
+ }
333017
333212
  async function fetchSenderMetadata(services, channel5, instanceId, senderId) {
333018
333213
  try {
333019
333214
  const identity = await services.persons.getIdentityByPlatformId(channel5, instanceId, senderId);
@@ -333168,7 +333363,7 @@ async function executeBeforeMessageWriteHooks(instanceId, chatId, content) {
333168
333363
  });
333169
333364
  return result.context.content;
333170
333365
  }
333171
- function buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, allContextMessages) {
333366
+ function buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, customerContext, allContextMessages) {
333172
333367
  const threadId2 = extractThreadId(messages4);
333173
333368
  const env2 = {};
333174
333369
  if (instance4.bridgeTmuxSession) {
@@ -333197,6 +333392,8 @@ function buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4
333197
333392
  referencedMessageId: messages4[0]?.payload.replyToId || undefined
333198
333393
  },
333199
333394
  sessionId,
333395
+ sessionStrategy: instance4.agentSessionStrategy ?? "per_chat",
333396
+ customer: customerContext,
333200
333397
  contextMessages: allContextMessages.length > 0 ? allContextMessages : undefined,
333201
333398
  env: Object.keys(env2).length > 0 ? env2 : undefined
333202
333399
  };
@@ -333219,7 +333416,8 @@ async function dispatchViaStreamingProvider(services, instance4, messages4, trig
333219
333416
  const allContextMessages = mergeContextMessages(extraContextMessages, dbContextMessages);
333220
333417
  const triggerFiles = toTriggerFiles(mediaFiles);
333221
333418
  await executeBeforeAgentStartHooks(instance4, chatId, senderId, senderName, triggerType, traceId, messages4[0]?.metadata.correlationId, triggerFiles);
333222
- const trigger = buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, allContextMessages);
333419
+ const customerContext = await resolveCustomerContext(services, personId, extractA2ACustomerContext(messages4, channel5));
333420
+ const trigger = buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, customerContext, allContextMessages);
333223
333421
  const chatType = determineChatType(chatId, channel5, rawPl);
333224
333422
  const formatMode = instance4.messageFormatMode ?? "convert";
333225
333423
  const sender = resolved.createSender(instance4.id, chatId, replyToId, chatType, { formatMode });
@@ -333438,7 +333636,8 @@ async function dispatchViaProvider(services, instance4, messages4, triggerType,
333438
333636
  const allContextMessages = mergeContextMessages(extraContextMessages, dbContextMessages);
333439
333637
  const triggerFiles = toTriggerFiles(mediaFiles);
333440
333638
  await executeBeforeAgentStartHooks(instance4, chatId, senderId, senderName, triggerType, traceId, messages4[0]?.metadata.correlationId, triggerFiles);
333441
- const trigger = buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, allContextMessages);
333639
+ const customerContext = await resolveCustomerContext(services, personId, extractA2ACustomerContext(messages4, channel5));
333640
+ const trigger = buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, customerContext, allContextMessages);
333442
333641
  if (provider.mode === "turn-based") {
333443
333642
  return dispatchViaTurnBasedProvider(services, instance4, provider, trigger, messages4, chatId, traceId, db2);
333444
333643
  }
@@ -334301,6 +334500,7 @@ async function processReactionTrigger(services, baseInstance, payload, metadata,
334301
334500
  const effectivePersonId = reactionPersonId ?? metadata.personId;
334302
334501
  const senderName2 = await services.agentRunner.getSenderName(effectivePersonId, undefined);
334303
334502
  const sessionId = computeSessionId(instance4.agentSessionStrategy ?? "per_chat", payload.from, externalChatId);
334503
+ const customerContext = await resolveCustomerContext(services, effectivePersonId);
334304
334504
  const trigger = {
334305
334505
  traceId: metadata.traceId,
334306
334506
  type: "reaction",
@@ -334320,7 +334520,9 @@ async function processReactionTrigger(services, baseInstance, payload, metadata,
334320
334520
  emoji: payload.emoji,
334321
334521
  referencedMessageId: payload.messageId
334322
334522
  },
334323
- sessionId
334523
+ sessionId,
334524
+ sessionStrategy: instance4.agentSessionStrategy ?? "per_chat",
334525
+ customer: customerContext
334324
334526
  };
334325
334527
  const result2 = await provider.trigger(trigger);
334326
334528
  if (result2 && result2.parts.length > 0) {
@@ -334974,7 +335176,7 @@ async function setupAgentDispatcher(eventBus, services, db2) {
334974
335176
  log94.info("Agent dispatcher shutdown complete");
334975
335177
  };
334976
335178
  }
334977
- var log94, _natsGenieProviderCtor, QUOTED_MESSAGE_MAX_CHARS = 4000, DM_HISTORY_LIMIT = 20, 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, DEFAULT_SEND_MEDIA_PATH_TYPES, BOT_PREFIX = "\uD83E\uDD16 ", activeStreams, sessionActivityStore, PROC_REACT_START, PROC_REACT_DONE = "\u2705", providerCache, openclawClientPool, nullFilterWarnedInstances, DEFAULT_GATE_MODEL = "gemini-3-flash-preview", GATE_TIMEOUT_MS = 3000, setupAgentResponder;
335179
+ var log94, _natsGenieProviderCtor, QUOTED_MESSAGE_MAX_CHARS = 4000, DM_HISTORY_LIMIT = 20, 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, DEFAULT_GATE_MODEL = "gemini-3-flash-preview", GATE_TIMEOUT_MS = 3000, setupAgentResponder;
334978
335180
  var init_agent_dispatcher = __esm(() => {
334979
335181
  init_src2();
334980
335182
  init_src();
@@ -342675,7 +342877,7 @@ var init_dist6 = __esm(() => {
342675
342877
  });
342676
342878
 
342677
342879
  // ../api/src/services/a2a-discovery.ts
342678
- function isRecord(value) {
342880
+ function isRecord2(value) {
342679
342881
  return value !== null && typeof value === "object" && !Array.isArray(value);
342680
342882
  }
342681
342883
  function stringOverride(value) {
@@ -342722,7 +342924,7 @@ function buildDefaultSkills(capabilities3) {
342722
342924
  }
342723
342925
  function buildA2AAgentCard(params) {
342724
342926
  const { baseUrl, agent: agent3, instance: instance4 } = params;
342725
- const override = isRecord(agent3.agentCard) ? agent3.agentCard : {};
342927
+ const override = isRecord2(agent3.agentCard) ? agent3.agentCard : {};
342726
342928
  const capabilities3 = agent3.capabilities ?? [];
342727
342929
  const endpointUrl = `${normalizeBaseUrl(baseUrl)}/a2a/${instance4.id}`;
342728
342930
  const card = {
@@ -342740,8 +342942,16 @@ function buildA2AAgentCard(params) {
342740
342942
  streaming: true,
342741
342943
  pushNotifications: false,
342742
342944
  extendedAgentCard: false,
342743
- ...isRecord(override.capabilities) ? override.capabilities : {}
342945
+ ...isRecord2(override.capabilities) ? override.capabilities : {}
342744
342946
  },
342947
+ extensions: Array.isArray(override.extensions) ? override.extensions : [
342948
+ {
342949
+ uri: OMNI_EXECUTION_CONTEXT_EXTENSION_URI,
342950
+ description: "Omni execution context metadata for user, source, session, trace, and customer identity.",
342951
+ version: "1.0",
342952
+ required: false
342953
+ }
342954
+ ],
342745
342955
  defaultInputModes: stringArray(override.defaultInputModes) ?? ["text/plain"],
342746
342956
  defaultOutputModes: stringArray(override.defaultOutputModes) ?? ["text/plain"],
342747
342957
  skills: Array.isArray(override.skills) ? override.skills : buildDefaultSkills(capabilities3),
@@ -342760,14 +342970,14 @@ function buildA2AAgentCard(params) {
342760
342970
  description: "Legacy Omni API key header."
342761
342971
  }
342762
342972
  },
342763
- ...isRecord(override.securitySchemes) ? override.securitySchemes : {}
342973
+ ...isRecord2(override.securitySchemes) ? override.securitySchemes : {}
342764
342974
  },
342765
342975
  securityRequirements: [{ schemes: { bearerAuth: { list: [] } } }, { schemes: { apiKeyHeader: { list: [] } } }]
342766
342976
  };
342767
- const providerOverride = isRecord(override.provider) ? override.provider : undefined;
342977
+ const providerOverride = isRecord2(override.provider) ? override.provider : undefined;
342768
342978
  if (providerOverride)
342769
342979
  card.provider = providerOverride;
342770
- const metadataOverride = isRecord(override.metadata) ? override.metadata : undefined;
342980
+ const metadataOverride = isRecord2(override.metadata) ? override.metadata : undefined;
342771
342981
  if (metadataOverride)
342772
342982
  card.metadata = metadataOverride;
342773
342983
  const iconUrl = stringOverride(override.iconUrl);
@@ -342854,6 +343064,9 @@ async function resolveA2AAgentCard(params) {
342854
343064
  provider
342855
343065
  };
342856
343066
  }
343067
+ var init_a2a_discovery = __esm(() => {
343068
+ init_src();
343069
+ });
342857
343070
 
342858
343071
  // ../api/src/routes/v2/a2a.ts
342859
343072
  function baseUrlFromRequest(url) {
@@ -342864,6 +343077,7 @@ var init_a2a = __esm(() => {
342864
343077
  init_dist6();
342865
343078
  init_dist2();
342866
343079
  init_zod();
343080
+ init_a2a_discovery();
342867
343081
  a2aRoutes = new Hono2;
342868
343082
  listQuerySchema = exports_external.object({
342869
343083
  includeUnconfigured: exports_external.coerce.boolean().optional().default(false)
@@ -349803,6 +350017,14 @@ async function verifyMessageInstanceOwnership(services, message2, instanceId) {
349803
350017
  });
349804
350018
  }
349805
350019
  }
350020
+ async function resolveChannelMessageId(services, messageId, instanceId) {
350021
+ if (!isUUID(messageId))
350022
+ return messageId;
350023
+ const message2 = await services.messages.getById(messageId);
350024
+ await verifyMessageInstanceOwnership(services, message2, instanceId);
350025
+ log105.debug("Resolved internal UUID to external ID", { messageId, externalId: message2.externalId });
350026
+ return message2.externalId;
350027
+ }
349806
350028
  var log105, mediaDownloadLog, messagesRoutes, MIME_BY_EXTENSION, DEFAULT_MIME_BY_MEDIA_TYPE, UUID_REGEX2, MessageSourceSchema, MessageTypeSchema, MessageStatusSchema, DeliveryStatusSchema, listQuerySchema14, createMessageSchema, updateMessageSchema, recordEditSchema, addReactionSchema, removeReactionSchema, updateDeliveryStatusSchema, MentionSchema, sendTextSchema, sendMediaSchema, sendReactionSchema, sendStickerSchema, sendContactSchema, sendLocationSchema, sendHandoffSchema, sendCloseContactSchema, messageRefSchema, _mediaStorageForDownload = null, sendTtsSchema, forwardMessageSchema, sendPresenceSchema, markMessageReadSchema, markBatchReadSchema, sendPollSchema, sendEmbedSchema, editMessageChannelSchema, deleteMessageChannelSchema, starMessageSchema;
349807
350029
  var init_messages5 = __esm(() => {
349808
350030
  init_dist6();
@@ -351337,13 +351559,7 @@ var init_messages5 = __esm(() => {
351337
351559
  recoverable: false
351338
351560
  });
351339
351561
  }
351340
- let resolvedMessageId = messageId;
351341
- if (isUUID(messageId)) {
351342
- const message2 = await services.messages.getById(messageId);
351343
- await verifyMessageInstanceOwnership(services, message2, instanceId);
351344
- resolvedMessageId = message2.externalId;
351345
- log105.debug("Resolved internal UUID to external ID", { messageId, externalId: resolvedMessageId });
351346
- }
351562
+ const resolvedMessageId = await resolveChannelMessageId(services, messageId, instanceId);
351347
351563
  try {
351348
351564
  await plugin7.editMessage(instanceId, channelId, resolvedMessageId, text3);
351349
351565
  } catch (error3) {
@@ -351399,10 +351615,11 @@ var init_messages5 = __esm(() => {
351399
351615
  recoverable: false
351400
351616
  });
351401
351617
  }
351402
- await plugin7.deleteMessage(instanceId, channelId, messageId, fromMe);
351618
+ const resolvedMessageId = await resolveChannelMessageId(services, messageId, instanceId);
351619
+ await plugin7.deleteMessage(instanceId, channelId, resolvedMessageId, fromMe);
351403
351620
  return c.json({
351404
351621
  success: true,
351405
- data: { messageId, deleted: true }
351622
+ data: { messageId, externalId: resolvedMessageId, deleted: true }
351406
351623
  });
351407
351624
  });
351408
351625
  starMessageSchema = exports_external.object({
@@ -352845,6 +353062,7 @@ var init_app = __esm(() => {
352845
353062
  init_health2();
352846
353063
  init_openapi2();
352847
353064
  init_v2();
353065
+ init_a2a_discovery();
352848
353066
  httpLog = createLogger("http");
352849
353067
  });
352850
353068
 
@@ -476415,6 +476633,7 @@ function processLidMappings(data, plugin6, instanceId) {
476415
476633
  }
476416
476634
  }
476417
476635
  function setupAllEventHandlers2(sock, plugin6, instanceId) {
476636
+ const onReadOnlyEvent = sock.ev.on.bind(sock.ev);
476418
476637
  sock.ev.on("call", (calls) => {
476419
476638
  for (const call of calls) {
476420
476639
  const { id: from } = fromJid(call.from);
@@ -476453,6 +476672,12 @@ function setupAllEventHandlers2(sock, plugin6, instanceId) {
476453
476672
  logEvent("chats.delete", { chatIds });
476454
476673
  plugin6.handleChatsDelete(instanceId, chatIds);
476455
476674
  });
476675
+ onReadOnlyEvent("chats.lock", (update) => {
476676
+ waLog.info("Chat lock update", { chatId: update.id, locked: update.locked });
476677
+ if (DEBUG)
476678
+ logEvent("chats.lock", update);
476679
+ plugin6.handleChatLockUpdate(instanceId, update);
476680
+ });
476456
476681
  sock.ev.on("contacts.upsert", (contacts) => {
476457
476682
  if (DEBUG)
476458
476683
  logEvent("contacts.upsert", { count: contacts.length, contacts });
@@ -476489,6 +476714,16 @@ function setupAllEventHandlers2(sock, plugin6, instanceId) {
476489
476714
  logEvent("group.join-request", request);
476490
476715
  plugin6.handleGroupJoinRequest(instanceId, request);
476491
476716
  });
476717
+ onReadOnlyEvent("group.member-tag.update", (update) => {
476718
+ waLog.info("Group member tag update", {
476719
+ groupId: update.groupId,
476720
+ participant: update.participant,
476721
+ label: update.label
476722
+ });
476723
+ if (DEBUG)
476724
+ logEvent("group.member-tag.update", update);
476725
+ plugin6.handleGroupMemberTagUpdate(instanceId, update);
476726
+ });
476492
476727
  sock.ev.on("message-receipt.update", (updates) => {
476493
476728
  for (const update of updates) {
476494
476729
  if (DEBUG) {
@@ -476507,6 +476742,15 @@ function setupAllEventHandlers2(sock, plugin6, instanceId) {
476507
476742
  plugin6.handleMediaUpdate(instanceId, update);
476508
476743
  }
476509
476744
  });
476745
+ onReadOnlyEvent("message-capping.update", (info) => {
476746
+ waLog.info("Message capping update", {
476747
+ type: info && typeof info === "object" ? info.type : undefined,
476748
+ reason: info && typeof info === "object" ? info.reason : undefined
476749
+ });
476750
+ if (DEBUG)
476751
+ logEvent("message-capping.update", info);
476752
+ plugin6.handleMessageCappingUpdate(instanceId, info);
476753
+ });
476510
476754
  sock.ev.on("messaging-history.set", async (history3) => {
476511
476755
  const { chats, contacts, messages: messages2, progress, syncType } = history3;
476512
476756
  waLog.info("History sync", {
@@ -476526,6 +476770,16 @@ function setupAllEventHandlers2(sock, plugin6, instanceId) {
476526
476770
  });
476527
476771
  await plugin6.handleHistorySync(instanceId, history3);
476528
476772
  });
476773
+ onReadOnlyEvent("messaging-history.status", (status) => {
476774
+ waLog.info("History sync status", {
476775
+ syncType: status.syncType,
476776
+ status: status.status,
476777
+ explicit: status.explicit
476778
+ });
476779
+ if (DEBUG)
476780
+ logEvent("messaging-history.status", status);
476781
+ plugin6.handleMessagingHistoryStatus(instanceId, status);
476782
+ });
476529
476783
  sock.ev.on("blocklist.set", (data) => {
476530
476784
  waLog.info("Blocklist set", { count: data.blocklist.length });
476531
476785
  if (DEBUG)
@@ -476538,6 +476792,12 @@ function setupAllEventHandlers2(sock, plugin6, instanceId) {
476538
476792
  logEvent("blocklist.update", data);
476539
476793
  plugin6.handleBlocklistUpdate(instanceId, data.blocklist, data.type);
476540
476794
  });
476795
+ onReadOnlyEvent("settings.update", (update) => {
476796
+ waLog.info("Settings update", { setting: update.setting });
476797
+ if (DEBUG)
476798
+ logEvent("settings.update", update);
476799
+ plugin6.handleSettingsUpdate(instanceId, update);
476800
+ });
476541
476801
  sock.ev.on("labels.edit", (label) => {
476542
476802
  if (DEBUG)
476543
476803
  logEvent("labels.edit", label);
@@ -480264,6 +480524,53 @@ class WhatsAppPlugin extends BaseChannelPlugin {
480264
480524
  async emitMediaReceivedInternal(params) {
480265
480525
  await this.emitMediaReceived(params);
480266
480526
  }
480527
+ whatsappEventMeta(instanceId, suffix) {
480528
+ return {
480529
+ instanceId,
480530
+ channelType: this.id,
480531
+ source: `channel:${this.id}`,
480532
+ correlationId: `${suffix}-${instanceId}`
480533
+ };
480534
+ }
480535
+ handleMessagingHistoryStatus(instanceId, status) {
480536
+ this.eventBus.publishGeneric("custom.whatsapp.messaging-history-status", {
480537
+ instanceId,
480538
+ syncType: status.syncType,
480539
+ status: status.status ?? "unknown",
480540
+ explicit: status.explicit,
480541
+ timestamp: Date.now()
480542
+ }, this.whatsappEventMeta(instanceId, "history-status")).catch((err) => this.logger.warn("Failed to publish messaging history status", { error: String(err) }));
480543
+ }
480544
+ handleMessageCappingUpdate(instanceId, info) {
480545
+ this.eventBus.publishGeneric("custom.whatsapp.message-capping-updated", { instanceId, info, timestamp: Date.now() }, this.whatsappEventMeta(instanceId, "message-capping")).catch((err) => this.logger.warn("Failed to publish message capping update", { error: String(err) }));
480546
+ }
480547
+ handleSettingsUpdate(instanceId, update) {
480548
+ this.eventBus.publishGeneric("custom.whatsapp.settings-updated", {
480549
+ instanceId,
480550
+ setting: update.setting ?? "unknown",
480551
+ value: update.value,
480552
+ timestamp: Date.now()
480553
+ }, this.whatsappEventMeta(instanceId, `settings-${update.setting ?? "unknown"}`)).catch((err) => this.logger.warn("Failed to publish settings update", { error: String(err) }));
480554
+ }
480555
+ handleChatLockUpdate(instanceId, update) {
480556
+ this.eventBus.publishGeneric("custom.whatsapp.chat-lock-updated", {
480557
+ instanceId,
480558
+ chatId: update.id ?? "",
480559
+ locked: update.locked ?? false,
480560
+ timestamp: Date.now()
480561
+ }, this.whatsappEventMeta(instanceId, `chat-lock-${update.id ?? "unknown"}`)).catch((err) => this.logger.warn("Failed to publish chat lock update", { error: String(err) }));
480562
+ }
480563
+ handleGroupMemberTagUpdate(instanceId, update) {
480564
+ this.eventBus.publishGeneric("custom.whatsapp.group-member-tag-updated", {
480565
+ instanceId,
480566
+ groupId: update.groupId ?? "",
480567
+ participant: update.participant ?? "",
480568
+ participantAlt: update.participantAlt,
480569
+ label: update.label ?? "",
480570
+ messageTimestamp: update.messageTimestamp,
480571
+ timestamp: Date.now()
480572
+ }, this.whatsappEventMeta(instanceId, `group-member-tag-${update.groupId ?? "unknown"}`)).catch((err) => this.logger.warn("Failed to publish group member tag update", { error: String(err) }));
480573
+ }
480267
480574
  handleCallReceived(instanceId, callId, from, callType, status, _rawCall) {
480268
480575
  this.logger.info("Call received", { instanceId, callId, from, callType, status });
480269
480576
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260525.2",
3
+ "version": "2.260529.1",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {