@automagik/omni 2.260525.2 → 2.260528.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
@@ -35744,6 +35744,100 @@ var init_types6 = __esm(() => {
35744
35744
  };
35745
35745
  });
35746
35746
 
35747
+ // ../core/src/providers/execution-context.ts
35748
+ function compactEnv(values) {
35749
+ return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined));
35750
+ }
35751
+ function inferChatType(context) {
35752
+ if (context.type === "dm")
35753
+ return "dm";
35754
+ if (context.source.chatId === context.sender.platformUserId)
35755
+ return "dm";
35756
+ if (context.source.threadId)
35757
+ return "channel";
35758
+ return "group";
35759
+ }
35760
+ function compactCustomer(customer) {
35761
+ if (!customer)
35762
+ return;
35763
+ const compacted = Object.fromEntries(Object.entries(customer).filter(([, value]) => value !== undefined));
35764
+ return Object.keys(compacted).length > 0 ? compacted : undefined;
35765
+ }
35766
+ function buildOmniExecutionContext(context) {
35767
+ const userId = context.sender.personId ?? context.sender.platformUserId;
35768
+ const sessionId = context.sessionId || context.source.threadId || context.source.chatId || userId;
35769
+ const customer = compactCustomer(context.customer);
35770
+ return {
35771
+ identity: {
35772
+ userId,
35773
+ ...context.sender.personId ? { personId: context.sender.personId } : {},
35774
+ platformUserId: context.sender.platformUserId,
35775
+ ...context.sender.displayName ? { displayName: context.sender.displayName } : {}
35776
+ },
35777
+ source: {
35778
+ channel: context.source.channelType,
35779
+ instanceId: context.source.instanceId,
35780
+ chatId: context.source.chatId,
35781
+ ...context.source.threadId ? { threadId: context.source.threadId } : {},
35782
+ messageId: context.source.messageId
35783
+ },
35784
+ session: {
35785
+ id: sessionId,
35786
+ ...context.sessionStrategy ? { strategy: context.sessionStrategy } : {}
35787
+ },
35788
+ trace: {
35789
+ id: context.traceId
35790
+ },
35791
+ ...customer ? { customer } : {}
35792
+ };
35793
+ }
35794
+ function buildOmniEnv(context, executionContext = buildOmniExecutionContext(context)) {
35795
+ return compactEnv({
35796
+ ...context.env ?? {},
35797
+ OMNI_USER_ID: executionContext.identity.userId,
35798
+ OMNI_PERSON_ID: executionContext.identity.personId,
35799
+ OMNI_PLATFORM_USER_ID: executionContext.identity.platformUserId,
35800
+ OMNI_SENDER: executionContext.identity.platformUserId,
35801
+ OMNI_DISPLAY_NAME: executionContext.identity.displayName,
35802
+ OMNI_INSTANCE: executionContext.source.instanceId,
35803
+ OMNI_CHAT: executionContext.source.chatId,
35804
+ OMNI_MESSAGE: executionContext.source.messageId,
35805
+ OMNI_CHANNEL: executionContext.source.channel,
35806
+ OMNI_SESSION: executionContext.session.id,
35807
+ OMNI_TRACE_ID: executionContext.trace.id,
35808
+ OMNI_THREAD: executionContext.source.threadId,
35809
+ OMNI_EXTERNAL_USER_ID: executionContext.customer?.externalUserId,
35810
+ OMNI_CUSTOMER_ID: executionContext.customer?.customerId,
35811
+ OMNI_ORGANIZATION_ID: executionContext.customer?.organizationId,
35812
+ OMNI_TENANT_ID: executionContext.customer?.tenantId
35813
+ });
35814
+ }
35815
+ function buildProviderRequestContext(context) {
35816
+ const executionContext = buildOmniExecutionContext(context);
35817
+ return {
35818
+ userId: executionContext.identity.userId,
35819
+ sessionId: executionContext.session.id,
35820
+ platform: {
35821
+ id: executionContext.identity.platformUserId,
35822
+ channel: executionContext.source.channel,
35823
+ instanceId: executionContext.source.instanceId
35824
+ },
35825
+ sender: {
35826
+ ...executionContext.identity.displayName ? { displayName: executionContext.identity.displayName } : {}
35827
+ },
35828
+ chat: {
35829
+ type: inferChatType(context),
35830
+ id: executionContext.source.chatId,
35831
+ ...executionContext.source.threadId ? { threadId: executionContext.source.threadId } : {}
35832
+ },
35833
+ messageId: executionContext.source.messageId,
35834
+ ...context.content.referencedMessageId ? { replyToMessageId: context.content.referencedMessageId } : {},
35835
+ env: buildOmniEnv(context, executionContext),
35836
+ executionContext
35837
+ };
35838
+ }
35839
+ var OMNI_EXECUTION_CONTEXT_EXTENSION_URI = "https://omni.dev/extensions/execution-context/v1";
35840
+
35747
35841
  // ../core/src/providers/agno-client.ts
35748
35842
  class AgnoClient {
35749
35843
  baseUrl;
@@ -60159,12 +60253,11 @@ class AgnoAgentProvider {
60159
60253
  message2 = `[${context.sender.displayName}]: ${message2}`;
60160
60254
  }
60161
60255
  const request = {
60256
+ ...buildProviderRequestContext(context),
60162
60257
  message: message2,
60163
60258
  agentId: this.config.agentId,
60164
60259
  agentType: this.config.agentType,
60165
60260
  stream: false,
60166
- sessionId: context.sessionId,
60167
- userId: context.sender.platformUserId,
60168
60261
  timeoutMs: this.config.timeoutMs ?? 60000
60169
60262
  };
60170
60263
  log8.info("Triggering Agno agent", {
@@ -60220,20 +60313,6 @@ function boundContextMessages(contextMessages) {
60220
60313
  }
60221
60314
  return bounded;
60222
60315
  }
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
60316
 
60238
60317
  class ClaudeCodeAgentProvider {
60239
60318
  id;
@@ -60357,13 +60436,12 @@ ${fileList}`;
60357
60436
  }
60358
60437
  const { message: message2, resolvedSessionId, internalSessionKey } = prepared;
60359
60438
  const request = {
60439
+ ...buildProviderRequestContext(context),
60360
60440
  message: message2,
60361
60441
  agentId: "claude-code",
60362
60442
  stream: false,
60363
60443
  sessionId: resolvedSessionId,
60364
- userId: context.sender.personId ?? context.sender.platformUserId,
60365
60444
  timeoutMs: this.options.timeoutMs ?? 120000,
60366
- env: buildOmniEnv(context),
60367
60445
  ...context.source.chatId ? { mcpUrlParams: { chat_id: context.source.chatId } } : {}
60368
60446
  };
60369
60447
  log9.info("Triggering Claude Code agent", {
@@ -60400,13 +60478,12 @@ ${fileList}`;
60400
60478
  }
60401
60479
  const { message: message2, resolvedSessionId, internalSessionKey } = prepared;
60402
60480
  const request = {
60481
+ ...buildProviderRequestContext(context),
60403
60482
  message: message2,
60404
60483
  agentId: "claude-code",
60405
60484
  stream: true,
60406
60485
  sessionId: resolvedSessionId,
60407
- userId: context.sender.personId ?? context.sender.platformUserId,
60408
60486
  timeoutMs: this.options.timeoutMs ?? 120000,
60409
- env: buildOmniEnv(context),
60410
60487
  ...context.source.chatId ? { mcpUrlParams: { chat_id: context.source.chatId } } : {}
60411
60488
  };
60412
60489
  log9.info("Triggering Claude Code agent (stream)", {
@@ -60502,6 +60579,7 @@ class WebhookAgentProvider {
60502
60579
  emoji: context.content.emoji
60503
60580
  },
60504
60581
  traceId: context.traceId,
60582
+ executionContext: buildOmniExecutionContext(context),
60505
60583
  replyEndpoint: "POST /api/v2/messages/send"
60506
60584
  };
60507
60585
  log10.info("Sending webhook trigger", {
@@ -61917,10 +61995,9 @@ class AgUiAgentProvider {
61917
61995
  return { parts: [], metadata: { runId: "", providerId: this.id, durationMs: 0 } };
61918
61996
  }
61919
61997
  const request = {
61998
+ ...buildProviderRequestContext(context),
61920
61999
  message: message2,
61921
62000
  agentId: this.config.agentId,
61922
- sessionId: context.sessionId,
61923
- userId: context.sender.platformUserId,
61924
62001
  timeoutMs: this.config.timeoutMs ?? 60000
61925
62002
  };
61926
62003
  log14.info("Triggering AG-UI agent", { agentId: this.config.agentId, traceId: context.traceId });
@@ -61947,10 +62024,9 @@ class AgUiAgentProvider {
61947
62024
  return;
61948
62025
  }
61949
62026
  const request = {
62027
+ ...buildProviderRequestContext(context),
61950
62028
  message: message2,
61951
62029
  agentId: this.config.agentId,
61952
- sessionId: context.sessionId,
61953
- userId: context.sender.platformUserId,
61954
62030
  timeoutMs: this.config.timeoutMs ?? 60000
61955
62031
  };
61956
62032
  log14.info("Streaming AG-UI agent", { agentId: this.config.agentId, traceId: context.traceId });
@@ -62109,16 +62185,23 @@ class A2AClient {
62109
62185
  }
62110
62186
  }
62111
62187
  buildJsonRpcRequest(method, request) {
62188
+ const message2 = {
62189
+ role: "ROLE_USER",
62190
+ parts: [{ text: request.message, mediaType: "text/plain" }],
62191
+ messageId: `msg-${crypto.randomUUID()}`
62192
+ };
62193
+ if (request.executionContext) {
62194
+ message2.extensions = [OMNI_EXECUTION_CONTEXT_EXTENSION_URI];
62195
+ message2.metadata = {
62196
+ omniExecutionContext: request.executionContext
62197
+ };
62198
+ }
62112
62199
  return {
62113
62200
  jsonrpc: "2.0",
62114
62201
  id: `omni-${crypto.randomUUID()}`,
62115
62202
  method,
62116
62203
  params: {
62117
- message: {
62118
- role: "ROLE_USER",
62119
- parts: [{ text: request.message, mediaType: "text/plain" }],
62120
- messageId: `msg-${crypto.randomUUID()}`
62121
- },
62204
+ message: message2,
62122
62205
  configuration: {
62123
62206
  acceptedOutputModes: ["text/plain"],
62124
62207
  returnImmediately: true
@@ -62334,10 +62417,9 @@ class A2AAgentProvider {
62334
62417
  return { parts: [], metadata: { runId: "", providerId: this.id, durationMs: 0 } };
62335
62418
  }
62336
62419
  const request = {
62420
+ ...buildProviderRequestContext(context),
62337
62421
  message: message2,
62338
62422
  agentId: this.config.agentId,
62339
- sessionId: context.sessionId,
62340
- userId: context.sender.platformUserId,
62341
62423
  timeoutMs: this.config.timeoutMs ?? 60000
62342
62424
  };
62343
62425
  log16.info("Triggering A2A agent", { agentId: this.config.agentId, traceId: context.traceId });
@@ -62367,10 +62449,9 @@ class A2AAgentProvider {
62367
62449
  return;
62368
62450
  }
62369
62451
  const request = {
62452
+ ...buildProviderRequestContext(context),
62370
62453
  message: message2,
62371
62454
  agentId: this.config.agentId,
62372
- sessionId: context.sessionId,
62373
- userId: context.sender.platformUserId,
62374
62455
  timeoutMs: this.config.timeoutMs ?? 60000
62375
62456
  };
62376
62457
  log16.info("Streaming A2A agent", { agentId: this.config.agentId, traceId: context.traceId });
@@ -62466,7 +62547,8 @@ class NatsGenieProvider {
62466
62547
  traceId: context.traceId,
62467
62548
  messageId: context.source.messageId,
62468
62549
  files: context.content.files,
62469
- env: context.env
62550
+ env: buildOmniEnv(context),
62551
+ executionContext: buildOmniExecutionContext(context)
62470
62552
  };
62471
62553
  try {
62472
62554
  await this.ensureConnected();
@@ -63449,6 +63531,9 @@ __export(exports_src, {
63449
63531
  calculateBackoffDelay: () => calculateBackoffDelay,
63450
63532
  buildSubscribePattern: () => buildSubscribePattern,
63451
63533
  buildSubject: () => buildSubject,
63534
+ buildProviderRequestContext: () => buildProviderRequestContext,
63535
+ buildOmniExecutionContext: () => buildOmniExecutionContext,
63536
+ buildOmniEnv: () => buildOmniEnv,
63452
63537
  buildConversationKey: () => buildConversationKey,
63453
63538
  buildConsumerConfig: () => buildConsumerConfig,
63454
63539
  armSequence: () => armSequence,
@@ -63493,6 +63578,7 @@ __export(exports_src, {
63493
63578
  OpenClawAgentProvider: () => OpenClawAgentProvider,
63494
63579
  OmniEventRecordSchema: () => OmniEventRecordSchema,
63495
63580
  OmniError: () => OmniError,
63581
+ OMNI_EXECUTION_CONTEXT_EXTENSION_URI: () => OMNI_EXECUTION_CONTEXT_EXTENSION_URI,
63496
63582
  NotFoundError: () => NotFoundError,
63497
63583
  NonEmptyStringSchema: () => NonEmptyStringSchema,
63498
63584
  NatsGenieProvider: () => NatsGenieProvider,
@@ -124617,7 +124703,7 @@ import { fileURLToPath } from "url";
124617
124703
  // package.json
124618
124704
  var package_default = {
124619
124705
  name: "@automagik/omni",
124620
- version: "2.260525.2",
124706
+ version: "2.260528.1",
124621
124707
  description: "LLM-optimized CLI for Omni",
124622
124708
  type: "module",
124623
124709
  bin: {
@@ -29417,6 +29417,100 @@ var init_types7 = __esm(() => {
29417
29417
  };
29418
29418
  });
29419
29419
 
29420
+ // ../core/src/providers/execution-context.ts
29421
+ function compactEnv(values) {
29422
+ return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined));
29423
+ }
29424
+ function inferChatType(context2) {
29425
+ if (context2.type === "dm")
29426
+ return "dm";
29427
+ if (context2.source.chatId === context2.sender.platformUserId)
29428
+ return "dm";
29429
+ if (context2.source.threadId)
29430
+ return "channel";
29431
+ return "group";
29432
+ }
29433
+ function compactCustomer(customer) {
29434
+ if (!customer)
29435
+ return;
29436
+ const compacted = Object.fromEntries(Object.entries(customer).filter(([, value]) => value !== undefined));
29437
+ return Object.keys(compacted).length > 0 ? compacted : undefined;
29438
+ }
29439
+ function buildOmniExecutionContext(context2) {
29440
+ const userId = context2.sender.personId ?? context2.sender.platformUserId;
29441
+ const sessionId = context2.sessionId || context2.source.threadId || context2.source.chatId || userId;
29442
+ const customer = compactCustomer(context2.customer);
29443
+ return {
29444
+ identity: {
29445
+ userId,
29446
+ ...context2.sender.personId ? { personId: context2.sender.personId } : {},
29447
+ platformUserId: context2.sender.platformUserId,
29448
+ ...context2.sender.displayName ? { displayName: context2.sender.displayName } : {}
29449
+ },
29450
+ source: {
29451
+ channel: context2.source.channelType,
29452
+ instanceId: context2.source.instanceId,
29453
+ chatId: context2.source.chatId,
29454
+ ...context2.source.threadId ? { threadId: context2.source.threadId } : {},
29455
+ messageId: context2.source.messageId
29456
+ },
29457
+ session: {
29458
+ id: sessionId,
29459
+ ...context2.sessionStrategy ? { strategy: context2.sessionStrategy } : {}
29460
+ },
29461
+ trace: {
29462
+ id: context2.traceId
29463
+ },
29464
+ ...customer ? { customer } : {}
29465
+ };
29466
+ }
29467
+ function buildOmniEnv(context2, executionContext = buildOmniExecutionContext(context2)) {
29468
+ return compactEnv({
29469
+ ...context2.env ?? {},
29470
+ OMNI_USER_ID: executionContext.identity.userId,
29471
+ OMNI_PERSON_ID: executionContext.identity.personId,
29472
+ OMNI_PLATFORM_USER_ID: executionContext.identity.platformUserId,
29473
+ OMNI_SENDER: executionContext.identity.platformUserId,
29474
+ OMNI_DISPLAY_NAME: executionContext.identity.displayName,
29475
+ OMNI_INSTANCE: executionContext.source.instanceId,
29476
+ OMNI_CHAT: executionContext.source.chatId,
29477
+ OMNI_MESSAGE: executionContext.source.messageId,
29478
+ OMNI_CHANNEL: executionContext.source.channel,
29479
+ OMNI_SESSION: executionContext.session.id,
29480
+ OMNI_TRACE_ID: executionContext.trace.id,
29481
+ OMNI_THREAD: executionContext.source.threadId,
29482
+ OMNI_EXTERNAL_USER_ID: executionContext.customer?.externalUserId,
29483
+ OMNI_CUSTOMER_ID: executionContext.customer?.customerId,
29484
+ OMNI_ORGANIZATION_ID: executionContext.customer?.organizationId,
29485
+ OMNI_TENANT_ID: executionContext.customer?.tenantId
29486
+ });
29487
+ }
29488
+ function buildProviderRequestContext(context2) {
29489
+ const executionContext = buildOmniExecutionContext(context2);
29490
+ return {
29491
+ userId: executionContext.identity.userId,
29492
+ sessionId: executionContext.session.id,
29493
+ platform: {
29494
+ id: executionContext.identity.platformUserId,
29495
+ channel: executionContext.source.channel,
29496
+ instanceId: executionContext.source.instanceId
29497
+ },
29498
+ sender: {
29499
+ ...executionContext.identity.displayName ? { displayName: executionContext.identity.displayName } : {}
29500
+ },
29501
+ chat: {
29502
+ type: inferChatType(context2),
29503
+ id: executionContext.source.chatId,
29504
+ ...executionContext.source.threadId ? { threadId: executionContext.source.threadId } : {}
29505
+ },
29506
+ messageId: executionContext.source.messageId,
29507
+ ...context2.content.referencedMessageId ? { replyToMessageId: context2.content.referencedMessageId } : {},
29508
+ env: buildOmniEnv(context2, executionContext),
29509
+ executionContext
29510
+ };
29511
+ }
29512
+ var OMNI_EXECUTION_CONTEXT_EXTENSION_URI = "https://omni.dev/extensions/execution-context/v1";
29513
+
29420
29514
  // ../core/src/providers/agno-client.ts
29421
29515
  class AgnoClient {
29422
29516
  baseUrl;
@@ -30462,12 +30556,11 @@ class AgnoAgentProvider {
30462
30556
  message2 = `[${context2.sender.displayName}]: ${message2}`;
30463
30557
  }
30464
30558
  const request = {
30559
+ ...buildProviderRequestContext(context2),
30465
30560
  message: message2,
30466
30561
  agentId: this.config.agentId,
30467
30562
  agentType: this.config.agentType,
30468
30563
  stream: false,
30469
- sessionId: context2.sessionId,
30470
- userId: context2.sender.platformUserId,
30471
30564
  timeoutMs: this.config.timeoutMs ?? 60000
30472
30565
  };
30473
30566
  log8.info("Triggering Agno agent", {
@@ -30523,20 +30616,6 @@ function boundContextMessages(contextMessages) {
30523
30616
  }
30524
30617
  return bounded;
30525
30618
  }
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
30619
 
30541
30620
  class ClaudeCodeAgentProvider {
30542
30621
  id;
@@ -30660,13 +30739,12 @@ ${fileList}`;
30660
30739
  }
30661
30740
  const { message: message2, resolvedSessionId, internalSessionKey } = prepared;
30662
30741
  const request = {
30742
+ ...buildProviderRequestContext(context2),
30663
30743
  message: message2,
30664
30744
  agentId: "claude-code",
30665
30745
  stream: false,
30666
30746
  sessionId: resolvedSessionId,
30667
- userId: context2.sender.personId ?? context2.sender.platformUserId,
30668
30747
  timeoutMs: this.options.timeoutMs ?? 120000,
30669
- env: buildOmniEnv(context2),
30670
30748
  ...context2.source.chatId ? { mcpUrlParams: { chat_id: context2.source.chatId } } : {}
30671
30749
  };
30672
30750
  log9.info("Triggering Claude Code agent", {
@@ -30703,13 +30781,12 @@ ${fileList}`;
30703
30781
  }
30704
30782
  const { message: message2, resolvedSessionId, internalSessionKey } = prepared;
30705
30783
  const request = {
30784
+ ...buildProviderRequestContext(context2),
30706
30785
  message: message2,
30707
30786
  agentId: "claude-code",
30708
30787
  stream: true,
30709
30788
  sessionId: resolvedSessionId,
30710
- userId: context2.sender.personId ?? context2.sender.platformUserId,
30711
30789
  timeoutMs: this.options.timeoutMs ?? 120000,
30712
- env: buildOmniEnv(context2),
30713
30790
  ...context2.source.chatId ? { mcpUrlParams: { chat_id: context2.source.chatId } } : {}
30714
30791
  };
30715
30792
  log9.info("Triggering Claude Code agent (stream)", {
@@ -30805,6 +30882,7 @@ class WebhookAgentProvider {
30805
30882
  emoji: context2.content.emoji
30806
30883
  },
30807
30884
  traceId: context2.traceId,
30885
+ executionContext: buildOmniExecutionContext(context2),
30808
30886
  replyEndpoint: "POST /api/v2/messages/send"
30809
30887
  };
30810
30888
  log10.info("Sending webhook trigger", {
@@ -32201,10 +32279,9 @@ class AgUiAgentProvider {
32201
32279
  return { parts: [], metadata: { runId: "", providerId: this.id, durationMs: 0 } };
32202
32280
  }
32203
32281
  const request = {
32282
+ ...buildProviderRequestContext(context2),
32204
32283
  message: message2,
32205
32284
  agentId: this.config.agentId,
32206
- sessionId: context2.sessionId,
32207
- userId: context2.sender.platformUserId,
32208
32285
  timeoutMs: this.config.timeoutMs ?? 60000
32209
32286
  };
32210
32287
  log14.info("Triggering AG-UI agent", { agentId: this.config.agentId, traceId: context2.traceId });
@@ -32231,10 +32308,9 @@ class AgUiAgentProvider {
32231
32308
  return;
32232
32309
  }
32233
32310
  const request = {
32311
+ ...buildProviderRequestContext(context2),
32234
32312
  message: message2,
32235
32313
  agentId: this.config.agentId,
32236
- sessionId: context2.sessionId,
32237
- userId: context2.sender.platformUserId,
32238
32314
  timeoutMs: this.config.timeoutMs ?? 60000
32239
32315
  };
32240
32316
  log14.info("Streaming AG-UI agent", { agentId: this.config.agentId, traceId: context2.traceId });
@@ -32380,16 +32456,23 @@ class A2AClient {
32380
32456
  }
32381
32457
  }
32382
32458
  buildJsonRpcRequest(method, request) {
32459
+ const message2 = {
32460
+ role: "ROLE_USER",
32461
+ parts: [{ text: request.message, mediaType: "text/plain" }],
32462
+ messageId: `msg-${crypto.randomUUID()}`
32463
+ };
32464
+ if (request.executionContext) {
32465
+ message2.extensions = [OMNI_EXECUTION_CONTEXT_EXTENSION_URI];
32466
+ message2.metadata = {
32467
+ omniExecutionContext: request.executionContext
32468
+ };
32469
+ }
32383
32470
  return {
32384
32471
  jsonrpc: "2.0",
32385
32472
  id: `omni-${crypto.randomUUID()}`,
32386
32473
  method,
32387
32474
  params: {
32388
- message: {
32389
- role: "ROLE_USER",
32390
- parts: [{ text: request.message, mediaType: "text/plain" }],
32391
- messageId: `msg-${crypto.randomUUID()}`
32392
- },
32475
+ message: message2,
32393
32476
  configuration: {
32394
32477
  acceptedOutputModes: ["text/plain"],
32395
32478
  returnImmediately: true
@@ -32605,10 +32688,9 @@ class A2AAgentProvider {
32605
32688
  return { parts: [], metadata: { runId: "", providerId: this.id, durationMs: 0 } };
32606
32689
  }
32607
32690
  const request = {
32691
+ ...buildProviderRequestContext(context2),
32608
32692
  message: message2,
32609
32693
  agentId: this.config.agentId,
32610
- sessionId: context2.sessionId,
32611
- userId: context2.sender.platformUserId,
32612
32694
  timeoutMs: this.config.timeoutMs ?? 60000
32613
32695
  };
32614
32696
  log16.info("Triggering A2A agent", { agentId: this.config.agentId, traceId: context2.traceId });
@@ -32638,10 +32720,9 @@ class A2AAgentProvider {
32638
32720
  return;
32639
32721
  }
32640
32722
  const request = {
32723
+ ...buildProviderRequestContext(context2),
32641
32724
  message: message2,
32642
32725
  agentId: this.config.agentId,
32643
- sessionId: context2.sessionId,
32644
- userId: context2.sender.platformUserId,
32645
32726
  timeoutMs: this.config.timeoutMs ?? 60000
32646
32727
  };
32647
32728
  log16.info("Streaming A2A agent", { agentId: this.config.agentId, traceId: context2.traceId });
@@ -32724,7 +32805,8 @@ class NatsGenieProvider {
32724
32805
  traceId: context2.traceId,
32725
32806
  messageId: context2.source.messageId,
32726
32807
  files: context2.content.files,
32727
- env: context2.env
32808
+ env: buildOmniEnv(context2),
32809
+ executionContext: buildOmniExecutionContext(context2)
32728
32810
  };
32729
32811
  try {
32730
32812
  await this.ensureConnected();
@@ -230186,7 +230268,7 @@ var init_sentry_scrub = __esm(() => {
230186
230268
  var require_package8 = __commonJS((exports, module) => {
230187
230269
  module.exports = {
230188
230270
  name: "@omni/api",
230189
- version: "2.260525.2",
230271
+ version: "2.260528.1",
230190
230272
  type: "module",
230191
230273
  exports: {
230192
230274
  ".": {
@@ -331775,7 +331857,7 @@ function resolveEffectiveChatName(params) {
331775
331857
  function mapContentType(contentType) {
331776
331858
  return CONTENT_TYPE_MAP[contentType ?? ""] ?? "text";
331777
331859
  }
331778
- function inferChatType(chatId, isGroup) {
331860
+ function inferChatType2(chatId, isGroup) {
331779
331861
  if (chatId.includes("@g.us") || chatId.includes("@broadcast"))
331780
331862
  return "group";
331781
331863
  if (chatId.includes("@newsletter"))
@@ -332047,7 +332129,7 @@ async function handleMessageReceived(services, payload, metadata, eventTimestamp
332047
332129
  const chatExternalId = truncate3(payload.chatId, 255) ?? payload.chatId;
332048
332130
  const messageExternalId = truncate3(payload.externalId, 255) ?? payload.externalId;
332049
332131
  const rawPayload = payload.rawPayload ? deepSanitize(payload.rawPayload) : undefined;
332050
- const chatType = inferChatType(payload.chatId, rawPayload?.isGroup);
332132
+ const chatType = inferChatType2(payload.chatId, rawPayload?.isGroup);
332051
332133
  const isFromMe2 = rawPayload?.isFromMe === true;
332052
332134
  const pushName = truncate3(payload.senderName ?? rawPayload?.pushName, 255);
332053
332135
  const chatName = truncate3(payload.chatName ?? rawPayload?.chatName, 255);
@@ -332149,7 +332231,7 @@ async function setupMessagePersistence(eventBus, services) {
332149
332231
  const chatExternalId = truncate3(payload.chatId, 255) ?? payload.chatId;
332150
332232
  const messageExternalId = truncate3(payload.externalId, 255) ?? payload.externalId;
332151
332233
  const { chat: chat2 } = await services.chats.findOrCreate(metadata.instanceId, chatExternalId, {
332152
- chatType: inferChatType(payload.chatId),
332234
+ chatType: inferChatType2(payload.chatId),
332153
332235
  channel: metadata.channelType ?? "whatsapp"
332154
332236
  });
332155
332237
  const sentContent = buildSentMessageContentFields(payload);
@@ -333014,6 +333096,62 @@ async function resolvePersonId(services, channel5, instanceId, senderId, metadat
333014
333096
  }
333015
333097
  return;
333016
333098
  }
333099
+ function isRecord(value) {
333100
+ return value !== null && typeof value === "object" && !Array.isArray(value);
333101
+ }
333102
+ function pickString(record, ...keys) {
333103
+ for (const key of keys) {
333104
+ const value = record[key];
333105
+ if (typeof value === "string" && value.length > 0)
333106
+ return value;
333107
+ }
333108
+ return;
333109
+ }
333110
+ function compactCustomerContext(context20) {
333111
+ const compacted = Object.fromEntries(Object.entries(context20).filter(([, value]) => value !== undefined));
333112
+ return Object.keys(compacted).length > 0 ? compacted : undefined;
333113
+ }
333114
+ function customerContextFromRecord(record) {
333115
+ return compactCustomerContext({
333116
+ externalUserId: pickString(record, "externalUserId", "external_user_id"),
333117
+ customerId: pickString(record, "customerId", "customer_id"),
333118
+ organizationId: pickString(record, "organizationId", "organization_id", "orgId", "org_id"),
333119
+ tenantId: pickString(record, "tenantId", "tenant_id")
333120
+ });
333121
+ }
333122
+ function extractA2ACustomerContext(messages4, channel5) {
333123
+ if (channel5 !== "a2a")
333124
+ return;
333125
+ const rawPayload = messages4[0]?.payload.rawPayload;
333126
+ if (!isRecord(rawPayload))
333127
+ return;
333128
+ const executionContext = rawPayload.omniExecutionContext;
333129
+ if (!isRecord(executionContext))
333130
+ return;
333131
+ const customer = isRecord(executionContext.customer) ? executionContext.customer : {};
333132
+ const identity = isRecord(executionContext.identity) ? executionContext.identity : {};
333133
+ return compactCustomerContext({
333134
+ ...customerContextFromRecord(customer),
333135
+ externalUserId: pickString(customer, "externalUserId", "external_user_id") ?? pickString(identity, "platformUserId", "userId")
333136
+ });
333137
+ }
333138
+ async function resolveCustomerContext(services, personId, externalContext) {
333139
+ let storedContext;
333140
+ if (personId) {
333141
+ try {
333142
+ const person2 = await services.persons.getById(personId);
333143
+ if (person2 && isRecord(person2.metadata)) {
333144
+ storedContext = customerContextFromRecord(person2.metadata);
333145
+ }
333146
+ } catch (error3) {
333147
+ log94.debug("Failed to resolve customer context", { personId, error: String(error3) });
333148
+ }
333149
+ }
333150
+ return compactCustomerContext({
333151
+ ...externalContext ?? {},
333152
+ ...storedContext ?? {}
333153
+ });
333154
+ }
333017
333155
  async function fetchSenderMetadata(services, channel5, instanceId, senderId) {
333018
333156
  try {
333019
333157
  const identity = await services.persons.getIdentityByPlatformId(channel5, instanceId, senderId);
@@ -333168,7 +333306,7 @@ async function executeBeforeMessageWriteHooks(instanceId, chatId, content) {
333168
333306
  });
333169
333307
  return result.context.content;
333170
333308
  }
333171
- function buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, allContextMessages) {
333309
+ function buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, customerContext, allContextMessages) {
333172
333310
  const threadId2 = extractThreadId(messages4);
333173
333311
  const env2 = {};
333174
333312
  if (instance4.bridgeTmuxSession) {
@@ -333197,6 +333335,8 @@ function buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4
333197
333335
  referencedMessageId: messages4[0]?.payload.replyToId || undefined
333198
333336
  },
333199
333337
  sessionId,
333338
+ sessionStrategy: instance4.agentSessionStrategy ?? "per_chat",
333339
+ customer: customerContext,
333200
333340
  contextMessages: allContextMessages.length > 0 ? allContextMessages : undefined,
333201
333341
  env: Object.keys(env2).length > 0 ? env2 : undefined
333202
333342
  };
@@ -333219,7 +333359,8 @@ async function dispatchViaStreamingProvider(services, instance4, messages4, trig
333219
333359
  const allContextMessages = mergeContextMessages(extraContextMessages, dbContextMessages);
333220
333360
  const triggerFiles = toTriggerFiles(mediaFiles);
333221
333361
  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);
333362
+ const customerContext = await resolveCustomerContext(services, personId, extractA2ACustomerContext(messages4, channel5));
333363
+ const trigger = buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, customerContext, allContextMessages);
333223
333364
  const chatType = determineChatType(chatId, channel5, rawPl);
333224
333365
  const formatMode = instance4.messageFormatMode ?? "convert";
333225
333366
  const sender = resolved.createSender(instance4.id, chatId, replyToId, chatType, { formatMode });
@@ -333438,7 +333579,8 @@ async function dispatchViaProvider(services, instance4, messages4, triggerType,
333438
333579
  const allContextMessages = mergeContextMessages(extraContextMessages, dbContextMessages);
333439
333580
  const triggerFiles = toTriggerFiles(mediaFiles);
333440
333581
  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);
333582
+ const customerContext = await resolveCustomerContext(services, personId, extractA2ACustomerContext(messages4, channel5));
333583
+ const trigger = buildMessageTrigger(traceId, triggerType, rawEvent, channel5, instance4, chatId, senderId, personId, senderName, messages4, messageTexts, triggerFiles, sessionId, customerContext, allContextMessages);
333442
333584
  if (provider.mode === "turn-based") {
333443
333585
  return dispatchViaTurnBasedProvider(services, instance4, provider, trigger, messages4, chatId, traceId, db2);
333444
333586
  }
@@ -334301,6 +334443,7 @@ async function processReactionTrigger(services, baseInstance, payload, metadata,
334301
334443
  const effectivePersonId = reactionPersonId ?? metadata.personId;
334302
334444
  const senderName2 = await services.agentRunner.getSenderName(effectivePersonId, undefined);
334303
334445
  const sessionId = computeSessionId(instance4.agentSessionStrategy ?? "per_chat", payload.from, externalChatId);
334446
+ const customerContext = await resolveCustomerContext(services, effectivePersonId);
334304
334447
  const trigger = {
334305
334448
  traceId: metadata.traceId,
334306
334449
  type: "reaction",
@@ -334320,7 +334463,9 @@ async function processReactionTrigger(services, baseInstance, payload, metadata,
334320
334463
  emoji: payload.emoji,
334321
334464
  referencedMessageId: payload.messageId
334322
334465
  },
334323
- sessionId
334466
+ sessionId,
334467
+ sessionStrategy: instance4.agentSessionStrategy ?? "per_chat",
334468
+ customer: customerContext
334324
334469
  };
334325
334470
  const result2 = await provider.trigger(trigger);
334326
334471
  if (result2 && result2.parts.length > 0) {
@@ -342675,7 +342820,7 @@ var init_dist6 = __esm(() => {
342675
342820
  });
342676
342821
 
342677
342822
  // ../api/src/services/a2a-discovery.ts
342678
- function isRecord(value) {
342823
+ function isRecord2(value) {
342679
342824
  return value !== null && typeof value === "object" && !Array.isArray(value);
342680
342825
  }
342681
342826
  function stringOverride(value) {
@@ -342722,7 +342867,7 @@ function buildDefaultSkills(capabilities3) {
342722
342867
  }
342723
342868
  function buildA2AAgentCard(params) {
342724
342869
  const { baseUrl, agent: agent3, instance: instance4 } = params;
342725
- const override = isRecord(agent3.agentCard) ? agent3.agentCard : {};
342870
+ const override = isRecord2(agent3.agentCard) ? agent3.agentCard : {};
342726
342871
  const capabilities3 = agent3.capabilities ?? [];
342727
342872
  const endpointUrl = `${normalizeBaseUrl(baseUrl)}/a2a/${instance4.id}`;
342728
342873
  const card = {
@@ -342740,8 +342885,16 @@ function buildA2AAgentCard(params) {
342740
342885
  streaming: true,
342741
342886
  pushNotifications: false,
342742
342887
  extendedAgentCard: false,
342743
- ...isRecord(override.capabilities) ? override.capabilities : {}
342888
+ ...isRecord2(override.capabilities) ? override.capabilities : {}
342744
342889
  },
342890
+ extensions: Array.isArray(override.extensions) ? override.extensions : [
342891
+ {
342892
+ uri: OMNI_EXECUTION_CONTEXT_EXTENSION_URI,
342893
+ description: "Omni execution context metadata for user, source, session, trace, and customer identity.",
342894
+ version: "1.0",
342895
+ required: false
342896
+ }
342897
+ ],
342745
342898
  defaultInputModes: stringArray(override.defaultInputModes) ?? ["text/plain"],
342746
342899
  defaultOutputModes: stringArray(override.defaultOutputModes) ?? ["text/plain"],
342747
342900
  skills: Array.isArray(override.skills) ? override.skills : buildDefaultSkills(capabilities3),
@@ -342760,14 +342913,14 @@ function buildA2AAgentCard(params) {
342760
342913
  description: "Legacy Omni API key header."
342761
342914
  }
342762
342915
  },
342763
- ...isRecord(override.securitySchemes) ? override.securitySchemes : {}
342916
+ ...isRecord2(override.securitySchemes) ? override.securitySchemes : {}
342764
342917
  },
342765
342918
  securityRequirements: [{ schemes: { bearerAuth: { list: [] } } }, { schemes: { apiKeyHeader: { list: [] } } }]
342766
342919
  };
342767
- const providerOverride = isRecord(override.provider) ? override.provider : undefined;
342920
+ const providerOverride = isRecord2(override.provider) ? override.provider : undefined;
342768
342921
  if (providerOverride)
342769
342922
  card.provider = providerOverride;
342770
- const metadataOverride = isRecord(override.metadata) ? override.metadata : undefined;
342923
+ const metadataOverride = isRecord2(override.metadata) ? override.metadata : undefined;
342771
342924
  if (metadataOverride)
342772
342925
  card.metadata = metadataOverride;
342773
342926
  const iconUrl = stringOverride(override.iconUrl);
@@ -342854,6 +343007,9 @@ async function resolveA2AAgentCard(params) {
342854
343007
  provider
342855
343008
  };
342856
343009
  }
343010
+ var init_a2a_discovery = __esm(() => {
343011
+ init_src();
343012
+ });
342857
343013
 
342858
343014
  // ../api/src/routes/v2/a2a.ts
342859
343015
  function baseUrlFromRequest(url) {
@@ -342864,6 +343020,7 @@ var init_a2a = __esm(() => {
342864
343020
  init_dist6();
342865
343021
  init_dist2();
342866
343022
  init_zod();
343023
+ init_a2a_discovery();
342867
343024
  a2aRoutes = new Hono2;
342868
343025
  listQuerySchema = exports_external.object({
342869
343026
  includeUnconfigured: exports_external.coerce.boolean().optional().default(false)
@@ -352845,6 +353002,7 @@ var init_app = __esm(() => {
352845
353002
  init_health2();
352846
353003
  init_openapi2();
352847
353004
  init_v2();
353005
+ init_a2a_discovery();
352848
353006
  httpLog = createLogger("http");
352849
353007
  });
352850
353008
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260525.2",
3
+ "version": "2.260528.1",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {