@axiom-lattice/core 2.1.44 → 2.1.45

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.mjs CHANGED
@@ -5017,7 +5017,7 @@ var InMemoryThreadStore = class {
5017
5017
  /**
5018
5018
  * Get all threads for a specific tenant and assistant
5019
5019
  */
5020
- async getThreadsByAssistantId(tenantId, assistantId) {
5020
+ async getThreadsByAssistantId(tenantId, assistantId, metadataFilter) {
5021
5021
  const tenantThreads = this.threads.get(tenantId);
5022
5022
  if (!tenantThreads) {
5023
5023
  return [];
@@ -5026,7 +5026,15 @@ var InMemoryThreadStore = class {
5026
5026
  if (!assistantThreads) {
5027
5027
  return [];
5028
5028
  }
5029
- return Array.from(assistantThreads.values());
5029
+ let threads = Array.from(assistantThreads.values());
5030
+ if (metadataFilter && Object.keys(metadataFilter).length > 0) {
5031
+ threads = threads.filter(
5032
+ (thread) => Object.entries(metadataFilter).every(
5033
+ ([key, value]) => thread.metadata?.[key] === value
5034
+ )
5035
+ );
5036
+ }
5037
+ return threads;
5030
5038
  }
5031
5039
  /**
5032
5040
  * Get a thread by ID for a specific tenant
@@ -6452,7 +6460,7 @@ var InMemoryThreadMessageQueueStore = class {
6452
6460
  return this.messages.get(threadId);
6453
6461
  }
6454
6462
  async addMessage(params) {
6455
- const { threadId, tenantId, assistantId, content, type = "human", priority = 0, command, id } = params;
6463
+ const { threadId, tenantId, assistantId, content, type = "human", priority = 0, command, custom_run_config, id } = params;
6456
6464
  const threadMessages = this.getMessagesForThread(threadId);
6457
6465
  const message = {
6458
6466
  id: id || this.generateId(),
@@ -6464,18 +6472,20 @@ var InMemoryThreadMessageQueueStore = class {
6464
6472
  tenantId,
6465
6473
  assistantId,
6466
6474
  priority,
6467
- command
6475
+ command,
6476
+ custom_run_config
6468
6477
  };
6469
6478
  threadMessages.push(message);
6470
6479
  return message;
6471
6480
  }
6472
- async addMessageAtHead(threadId, content, type = "system", id, command) {
6481
+ async addMessageAtHead(params) {
6482
+ const { threadId, tenantId, assistantId, content, type = "system", id, command, custom_run_config } = params;
6473
6483
  const threadMessages = this.getMessagesForThread(threadId);
6474
- let tenantId = "default";
6475
- let assistantId = "";
6476
- if (threadMessages.length > 0) {
6477
- tenantId = threadMessages[0].tenantId || "default";
6478
- assistantId = threadMessages[0].assistantId || "";
6484
+ let resolvedTenantId = tenantId || "default";
6485
+ let resolvedAssistantId = assistantId || "";
6486
+ if (!tenantId && !assistantId && threadMessages.length > 0) {
6487
+ resolvedTenantId = threadMessages[0].tenantId || "default";
6488
+ resolvedAssistantId = threadMessages[0].assistantId || "";
6479
6489
  }
6480
6490
  const nextSequence = threadMessages.length;
6481
6491
  const message = {
@@ -6485,11 +6495,12 @@ var InMemoryThreadMessageQueueStore = class {
6485
6495
  sequence: nextSequence,
6486
6496
  createdAt: /* @__PURE__ */ new Date(),
6487
6497
  status: "pending",
6488
- tenantId,
6489
- assistantId,
6498
+ tenantId: resolvedTenantId,
6499
+ assistantId: resolvedAssistantId,
6490
6500
  priority: 100,
6491
6501
  // High priority for head messages (STEER/Command)
6492
- command
6502
+ command,
6503
+ custom_run_config
6493
6504
  };
6494
6505
  threadMessages.push(message);
6495
6506
  return message;
@@ -16955,6 +16966,7 @@ var Agent = class {
16955
16966
  break;
16956
16967
  }
16957
16968
  const firstMessage = pendings[0];
16969
+ const files = firstMessage.content?.queueMessage?.input?.files;
16958
16970
  const hasCommand = firstMessage.command;
16959
16971
  if (hasCommand) {
16960
16972
  for (const p of pendings) {
@@ -16973,12 +16985,15 @@ var Agent = class {
16973
16985
  const input = {
16974
16986
  messages: [new HumanMessage2({ id: humanContent.id, content: humanContent.message })]
16975
16987
  };
16988
+ if (files) {
16989
+ input.files = files;
16990
+ }
16976
16991
  const queueMessageData = humanContent.queueMessage;
16977
16992
  try {
16978
16993
  await this.agentStreamExecutor({
16979
16994
  input,
16980
16995
  command: p.command,
16981
- custom_run_config: queueMessageData.custom_run_config
16996
+ custom_run_config: p.custom_run_config ?? queueMessageData.custom_run_config
16982
16997
  }, signal);
16983
16998
  await this.queueStore?.markCompleted(p.id);
16984
16999
  const runStatus = await this.getRunStatus();
@@ -17044,10 +17059,16 @@ var Agent = class {
17044
17059
  });
17045
17060
  });
17046
17061
  const firstQueueMessage = remainingPendings[0] ? this.getHumanPendingContent(remainingPendings[0]).queueMessage : void 0;
17062
+ const input = {
17063
+ messages: userMessages
17064
+ };
17065
+ if (files) {
17066
+ input.files = files;
17067
+ }
17047
17068
  try {
17048
17069
  await this.agentStreamExecutor({
17049
- input: { messages: userMessages },
17050
- custom_run_config: firstQueueMessage?.custom_run_config
17070
+ input,
17071
+ custom_run_config: remainingPendings[0]?.custom_run_config ?? firstQueueMessage?.custom_run_config
17051
17072
  }, signal);
17052
17073
  const runStatus = await this.getRunStatus();
17053
17074
  const state = await this.getCurrentState();
@@ -17112,10 +17133,16 @@ var Agent = class {
17112
17133
  queueMode: "followup" /* FOLLOWUP */
17113
17134
  });
17114
17135
  const queueMessageData = humanContent.queueMessage || {};
17136
+ const input = {
17137
+ messages: [message]
17138
+ };
17139
+ if (files) {
17140
+ input.files = files;
17141
+ }
17115
17142
  try {
17116
17143
  await this.agentStreamExecutor({
17117
- input: { messages: [message] },
17118
- custom_run_config: queueMessageData.custom_run_config
17144
+ input,
17145
+ custom_run_config: p.custom_run_config ?? queueMessageData.custom_run_config
17119
17146
  }, signal);
17120
17147
  await this.queueStore?.markCompleted(p.id);
17121
17148
  const runStatus = await this.getRunStatus();
@@ -17312,7 +17339,16 @@ var Agent = class {
17312
17339
  }
17313
17340
  };
17314
17341
  if (isHighPriority) {
17315
- await store.addMessageAtHead(this.thread_id, content, "human", messageId, queueMessage.command);
17342
+ await store.addMessageAtHead({
17343
+ threadId: this.thread_id,
17344
+ tenantId: this.tenant_id,
17345
+ assistantId: this.assistant_id,
17346
+ content,
17347
+ type: "human",
17348
+ command: queueMessage.command,
17349
+ custom_run_config: queueMessage.custom_run_config,
17350
+ id: messageId
17351
+ });
17316
17352
  if (useMode === "steer" /* STEER */) {
17317
17353
  this.stopQueueProcessor();
17318
17354
  await store.resetProcessingToPending(this.thread_id);
@@ -17326,6 +17362,7 @@ var Agent = class {
17326
17362
  content,
17327
17363
  type: "human",
17328
17364
  command: queueMessage.command,
17365
+ custom_run_config: queueMessage.custom_run_config,
17329
17366
  id: messageId
17330
17367
  });
17331
17368
  }
@@ -17385,11 +17422,13 @@ var Agent = class {
17385
17422
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
17386
17423
  }
17387
17424
  };
17388
- await this.queueStore.addMessageAtHead(
17389
- thread.threadId,
17390
- reminderContent,
17391
- "system"
17392
- );
17425
+ await this.queueStore.addMessageAtHead({
17426
+ threadId: thread.threadId,
17427
+ tenantId: thread.tenantId,
17428
+ assistantId: thread.assistantId,
17429
+ content: reminderContent,
17430
+ type: "system"
17431
+ });
17393
17432
  }
17394
17433
  async getCurrentState() {
17395
17434
  const { runnable_agent } = await this.getLatticeClientAndRuntimeConfig();