@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.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +63 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2259,6 +2259,7 @@ interface PendingMessage {
|
|
|
2259
2259
|
createdAt: Date;
|
|
2260
2260
|
priority?: number;
|
|
2261
2261
|
command?: CommandParams<unknown>;
|
|
2262
|
+
custom_run_config?: unknown;
|
|
2262
2263
|
}
|
|
2263
2264
|
interface PendingQueueMessageInput {
|
|
2264
2265
|
message: string;
|
|
@@ -2290,6 +2291,7 @@ interface AddMessageParams {
|
|
|
2290
2291
|
type?: "human" | "system";
|
|
2291
2292
|
priority?: number;
|
|
2292
2293
|
command?: CommandParams<unknown>;
|
|
2294
|
+
custom_run_config?: unknown;
|
|
2293
2295
|
id?: string;
|
|
2294
2296
|
}
|
|
2295
2297
|
interface ThreadInfo {
|
|
@@ -2303,7 +2305,7 @@ interface ThreadInfo {
|
|
|
2303
2305
|
*/
|
|
2304
2306
|
interface IMessageQueueStore {
|
|
2305
2307
|
addMessage(params: AddMessageParams): Promise<PendingMessage>;
|
|
2306
|
-
addMessageAtHead(
|
|
2308
|
+
addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
|
|
2307
2309
|
getPendingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
2308
2310
|
getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
2309
2311
|
getQueueSize(threadId: string): Promise<number>;
|
|
@@ -2464,7 +2466,7 @@ declare class InMemoryThreadStore implements ThreadStore {
|
|
|
2464
2466
|
/**
|
|
2465
2467
|
* Get all threads for a specific tenant and assistant
|
|
2466
2468
|
*/
|
|
2467
|
-
getThreadsByAssistantId(tenantId: string, assistantId: string): Promise<Thread[]>;
|
|
2469
|
+
getThreadsByAssistantId(tenantId: string, assistantId: string, metadataFilter?: Record<string, string>): Promise<Thread[]>;
|
|
2468
2470
|
/**
|
|
2469
2471
|
* Get a thread by ID for a specific tenant
|
|
2470
2472
|
*/
|
|
@@ -2871,7 +2873,7 @@ declare class InMemoryThreadMessageQueueStore implements IMessageQueueStore {
|
|
|
2871
2873
|
private generateId;
|
|
2872
2874
|
private getMessagesForThread;
|
|
2873
2875
|
addMessage(params: AddMessageParams): Promise<PendingMessage>;
|
|
2874
|
-
addMessageAtHead(
|
|
2876
|
+
addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
|
|
2875
2877
|
getPendingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
2876
2878
|
getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
2877
2879
|
getQueueSize(threadId: string): Promise<number>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2259,6 +2259,7 @@ interface PendingMessage {
|
|
|
2259
2259
|
createdAt: Date;
|
|
2260
2260
|
priority?: number;
|
|
2261
2261
|
command?: CommandParams<unknown>;
|
|
2262
|
+
custom_run_config?: unknown;
|
|
2262
2263
|
}
|
|
2263
2264
|
interface PendingQueueMessageInput {
|
|
2264
2265
|
message: string;
|
|
@@ -2290,6 +2291,7 @@ interface AddMessageParams {
|
|
|
2290
2291
|
type?: "human" | "system";
|
|
2291
2292
|
priority?: number;
|
|
2292
2293
|
command?: CommandParams<unknown>;
|
|
2294
|
+
custom_run_config?: unknown;
|
|
2293
2295
|
id?: string;
|
|
2294
2296
|
}
|
|
2295
2297
|
interface ThreadInfo {
|
|
@@ -2303,7 +2305,7 @@ interface ThreadInfo {
|
|
|
2303
2305
|
*/
|
|
2304
2306
|
interface IMessageQueueStore {
|
|
2305
2307
|
addMessage(params: AddMessageParams): Promise<PendingMessage>;
|
|
2306
|
-
addMessageAtHead(
|
|
2308
|
+
addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
|
|
2307
2309
|
getPendingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
2308
2310
|
getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
2309
2311
|
getQueueSize(threadId: string): Promise<number>;
|
|
@@ -2464,7 +2466,7 @@ declare class InMemoryThreadStore implements ThreadStore {
|
|
|
2464
2466
|
/**
|
|
2465
2467
|
* Get all threads for a specific tenant and assistant
|
|
2466
2468
|
*/
|
|
2467
|
-
getThreadsByAssistantId(tenantId: string, assistantId: string): Promise<Thread[]>;
|
|
2469
|
+
getThreadsByAssistantId(tenantId: string, assistantId: string, metadataFilter?: Record<string, string>): Promise<Thread[]>;
|
|
2468
2470
|
/**
|
|
2469
2471
|
* Get a thread by ID for a specific tenant
|
|
2470
2472
|
*/
|
|
@@ -2871,7 +2873,7 @@ declare class InMemoryThreadMessageQueueStore implements IMessageQueueStore {
|
|
|
2871
2873
|
private generateId;
|
|
2872
2874
|
private getMessagesForThread;
|
|
2873
2875
|
addMessage(params: AddMessageParams): Promise<PendingMessage>;
|
|
2874
|
-
addMessageAtHead(
|
|
2876
|
+
addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
|
|
2875
2877
|
getPendingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
2876
2878
|
getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
2877
2879
|
getQueueSize(threadId: string): Promise<number>;
|
package/dist/index.js
CHANGED
|
@@ -5200,7 +5200,7 @@ var InMemoryThreadStore = class {
|
|
|
5200
5200
|
/**
|
|
5201
5201
|
* Get all threads for a specific tenant and assistant
|
|
5202
5202
|
*/
|
|
5203
|
-
async getThreadsByAssistantId(tenantId, assistantId) {
|
|
5203
|
+
async getThreadsByAssistantId(tenantId, assistantId, metadataFilter) {
|
|
5204
5204
|
const tenantThreads = this.threads.get(tenantId);
|
|
5205
5205
|
if (!tenantThreads) {
|
|
5206
5206
|
return [];
|
|
@@ -5209,7 +5209,15 @@ var InMemoryThreadStore = class {
|
|
|
5209
5209
|
if (!assistantThreads) {
|
|
5210
5210
|
return [];
|
|
5211
5211
|
}
|
|
5212
|
-
|
|
5212
|
+
let threads = Array.from(assistantThreads.values());
|
|
5213
|
+
if (metadataFilter && Object.keys(metadataFilter).length > 0) {
|
|
5214
|
+
threads = threads.filter(
|
|
5215
|
+
(thread) => Object.entries(metadataFilter).every(
|
|
5216
|
+
([key, value]) => thread.metadata?.[key] === value
|
|
5217
|
+
)
|
|
5218
|
+
);
|
|
5219
|
+
}
|
|
5220
|
+
return threads;
|
|
5213
5221
|
}
|
|
5214
5222
|
/**
|
|
5215
5223
|
* Get a thread by ID for a specific tenant
|
|
@@ -6635,7 +6643,7 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
6635
6643
|
return this.messages.get(threadId);
|
|
6636
6644
|
}
|
|
6637
6645
|
async addMessage(params) {
|
|
6638
|
-
const { threadId, tenantId, assistantId, content, type = "human", priority = 0, command, id } = params;
|
|
6646
|
+
const { threadId, tenantId, assistantId, content, type = "human", priority = 0, command, custom_run_config, id } = params;
|
|
6639
6647
|
const threadMessages = this.getMessagesForThread(threadId);
|
|
6640
6648
|
const message = {
|
|
6641
6649
|
id: id || this.generateId(),
|
|
@@ -6647,18 +6655,20 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
6647
6655
|
tenantId,
|
|
6648
6656
|
assistantId,
|
|
6649
6657
|
priority,
|
|
6650
|
-
command
|
|
6658
|
+
command,
|
|
6659
|
+
custom_run_config
|
|
6651
6660
|
};
|
|
6652
6661
|
threadMessages.push(message);
|
|
6653
6662
|
return message;
|
|
6654
6663
|
}
|
|
6655
|
-
async addMessageAtHead(
|
|
6664
|
+
async addMessageAtHead(params) {
|
|
6665
|
+
const { threadId, tenantId, assistantId, content, type = "system", id, command, custom_run_config } = params;
|
|
6656
6666
|
const threadMessages = this.getMessagesForThread(threadId);
|
|
6657
|
-
let
|
|
6658
|
-
let
|
|
6659
|
-
if (threadMessages.length > 0) {
|
|
6660
|
-
|
|
6661
|
-
|
|
6667
|
+
let resolvedTenantId = tenantId || "default";
|
|
6668
|
+
let resolvedAssistantId = assistantId || "";
|
|
6669
|
+
if (!tenantId && !assistantId && threadMessages.length > 0) {
|
|
6670
|
+
resolvedTenantId = threadMessages[0].tenantId || "default";
|
|
6671
|
+
resolvedAssistantId = threadMessages[0].assistantId || "";
|
|
6662
6672
|
}
|
|
6663
6673
|
const nextSequence = threadMessages.length;
|
|
6664
6674
|
const message = {
|
|
@@ -6668,11 +6678,12 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
6668
6678
|
sequence: nextSequence,
|
|
6669
6679
|
createdAt: /* @__PURE__ */ new Date(),
|
|
6670
6680
|
status: "pending",
|
|
6671
|
-
tenantId,
|
|
6672
|
-
assistantId,
|
|
6681
|
+
tenantId: resolvedTenantId,
|
|
6682
|
+
assistantId: resolvedAssistantId,
|
|
6673
6683
|
priority: 100,
|
|
6674
6684
|
// High priority for head messages (STEER/Command)
|
|
6675
|
-
command
|
|
6685
|
+
command,
|
|
6686
|
+
custom_run_config
|
|
6676
6687
|
};
|
|
6677
6688
|
threadMessages.push(message);
|
|
6678
6689
|
return message;
|
|
@@ -17099,6 +17110,7 @@ var Agent = class {
|
|
|
17099
17110
|
break;
|
|
17100
17111
|
}
|
|
17101
17112
|
const firstMessage = pendings[0];
|
|
17113
|
+
const files = firstMessage.content?.queueMessage?.input?.files;
|
|
17102
17114
|
const hasCommand = firstMessage.command;
|
|
17103
17115
|
if (hasCommand) {
|
|
17104
17116
|
for (const p of pendings) {
|
|
@@ -17117,12 +17129,15 @@ var Agent = class {
|
|
|
17117
17129
|
const input = {
|
|
17118
17130
|
messages: [new import_langchain61.HumanMessage({ id: humanContent.id, content: humanContent.message })]
|
|
17119
17131
|
};
|
|
17132
|
+
if (files) {
|
|
17133
|
+
input.files = files;
|
|
17134
|
+
}
|
|
17120
17135
|
const queueMessageData = humanContent.queueMessage;
|
|
17121
17136
|
try {
|
|
17122
17137
|
await this.agentStreamExecutor({
|
|
17123
17138
|
input,
|
|
17124
17139
|
command: p.command,
|
|
17125
|
-
custom_run_config: queueMessageData.custom_run_config
|
|
17140
|
+
custom_run_config: p.custom_run_config ?? queueMessageData.custom_run_config
|
|
17126
17141
|
}, signal);
|
|
17127
17142
|
await this.queueStore?.markCompleted(p.id);
|
|
17128
17143
|
const runStatus = await this.getRunStatus();
|
|
@@ -17188,10 +17203,16 @@ var Agent = class {
|
|
|
17188
17203
|
});
|
|
17189
17204
|
});
|
|
17190
17205
|
const firstQueueMessage = remainingPendings[0] ? this.getHumanPendingContent(remainingPendings[0]).queueMessage : void 0;
|
|
17206
|
+
const input = {
|
|
17207
|
+
messages: userMessages
|
|
17208
|
+
};
|
|
17209
|
+
if (files) {
|
|
17210
|
+
input.files = files;
|
|
17211
|
+
}
|
|
17191
17212
|
try {
|
|
17192
17213
|
await this.agentStreamExecutor({
|
|
17193
|
-
input
|
|
17194
|
-
custom_run_config: firstQueueMessage?.custom_run_config
|
|
17214
|
+
input,
|
|
17215
|
+
custom_run_config: remainingPendings[0]?.custom_run_config ?? firstQueueMessage?.custom_run_config
|
|
17195
17216
|
}, signal);
|
|
17196
17217
|
const runStatus = await this.getRunStatus();
|
|
17197
17218
|
const state = await this.getCurrentState();
|
|
@@ -17256,10 +17277,16 @@ var Agent = class {
|
|
|
17256
17277
|
queueMode: "followup" /* FOLLOWUP */
|
|
17257
17278
|
});
|
|
17258
17279
|
const queueMessageData = humanContent.queueMessage || {};
|
|
17280
|
+
const input = {
|
|
17281
|
+
messages: [message]
|
|
17282
|
+
};
|
|
17283
|
+
if (files) {
|
|
17284
|
+
input.files = files;
|
|
17285
|
+
}
|
|
17259
17286
|
try {
|
|
17260
17287
|
await this.agentStreamExecutor({
|
|
17261
|
-
input
|
|
17262
|
-
custom_run_config: queueMessageData.custom_run_config
|
|
17288
|
+
input,
|
|
17289
|
+
custom_run_config: p.custom_run_config ?? queueMessageData.custom_run_config
|
|
17263
17290
|
}, signal);
|
|
17264
17291
|
await this.queueStore?.markCompleted(p.id);
|
|
17265
17292
|
const runStatus = await this.getRunStatus();
|
|
@@ -17456,7 +17483,16 @@ var Agent = class {
|
|
|
17456
17483
|
}
|
|
17457
17484
|
};
|
|
17458
17485
|
if (isHighPriority) {
|
|
17459
|
-
await store.addMessageAtHead(
|
|
17486
|
+
await store.addMessageAtHead({
|
|
17487
|
+
threadId: this.thread_id,
|
|
17488
|
+
tenantId: this.tenant_id,
|
|
17489
|
+
assistantId: this.assistant_id,
|
|
17490
|
+
content,
|
|
17491
|
+
type: "human",
|
|
17492
|
+
command: queueMessage.command,
|
|
17493
|
+
custom_run_config: queueMessage.custom_run_config,
|
|
17494
|
+
id: messageId
|
|
17495
|
+
});
|
|
17460
17496
|
if (useMode === "steer" /* STEER */) {
|
|
17461
17497
|
this.stopQueueProcessor();
|
|
17462
17498
|
await store.resetProcessingToPending(this.thread_id);
|
|
@@ -17470,6 +17506,7 @@ var Agent = class {
|
|
|
17470
17506
|
content,
|
|
17471
17507
|
type: "human",
|
|
17472
17508
|
command: queueMessage.command,
|
|
17509
|
+
custom_run_config: queueMessage.custom_run_config,
|
|
17473
17510
|
id: messageId
|
|
17474
17511
|
});
|
|
17475
17512
|
}
|
|
@@ -17529,11 +17566,13 @@ var Agent = class {
|
|
|
17529
17566
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17530
17567
|
}
|
|
17531
17568
|
};
|
|
17532
|
-
await this.queueStore.addMessageAtHead(
|
|
17533
|
-
thread.threadId,
|
|
17534
|
-
|
|
17535
|
-
|
|
17536
|
-
|
|
17569
|
+
await this.queueStore.addMessageAtHead({
|
|
17570
|
+
threadId: thread.threadId,
|
|
17571
|
+
tenantId: thread.tenantId,
|
|
17572
|
+
assistantId: thread.assistantId,
|
|
17573
|
+
content: reminderContent,
|
|
17574
|
+
type: "system"
|
|
17575
|
+
});
|
|
17537
17576
|
}
|
|
17538
17577
|
async getCurrentState() {
|
|
17539
17578
|
const { runnable_agent } = await this.getLatticeClientAndRuntimeConfig();
|