@axiom-lattice/gateway 2.1.80 → 2.1.81
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/CHANGELOG.md +10 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +46 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -0
- package/src/router/MessageRouter.ts +51 -18
- package/.turbo/turbo-build.log +0 -32
package/dist/index.mjs
CHANGED
|
@@ -6645,6 +6645,7 @@ var MessageRouter = class {
|
|
|
6645
6645
|
this.bindingRegistry = config.bindingRegistry;
|
|
6646
6646
|
this.adapterRegistry = config.adapterRegistry;
|
|
6647
6647
|
this.installationStore = config.installationStore;
|
|
6648
|
+
this.logger = config.logger;
|
|
6648
6649
|
}
|
|
6649
6650
|
use(middleware) {
|
|
6650
6651
|
this.middlewares.push(middleware);
|
|
@@ -6662,6 +6663,7 @@ var MessageRouter = class {
|
|
|
6662
6663
|
"tenantId is required: provide it in the message or ensure the channelInstallation has a tenantId"
|
|
6663
6664
|
);
|
|
6664
6665
|
}
|
|
6666
|
+
this.logger?.info({ event: "dispatch:start", channel: message.channel, senderId: message.sender.id, tenantId }, "Message dispatch started");
|
|
6665
6667
|
let binding = await this.bindingRegistry.resolve({
|
|
6666
6668
|
channel: message.channel,
|
|
6667
6669
|
senderId: message.sender.id,
|
|
@@ -6698,6 +6700,22 @@ var MessageRouter = class {
|
|
|
6698
6700
|
}
|
|
6699
6701
|
}
|
|
6700
6702
|
ctx.binding = binding;
|
|
6703
|
+
this.logger?.info({
|
|
6704
|
+
event: "dispatch:binding",
|
|
6705
|
+
bindingId: binding.id,
|
|
6706
|
+
agentId: binding.agentId,
|
|
6707
|
+
threadId: binding.threadId,
|
|
6708
|
+
threadMode: binding.threadMode,
|
|
6709
|
+
workspaceId: binding.workspaceId,
|
|
6710
|
+
projectId: binding.projectId
|
|
6711
|
+
}, "Binding resolved");
|
|
6712
|
+
if (binding.threadMode === "per_conversation") {
|
|
6713
|
+
this.logger?.warn({
|
|
6714
|
+
event: "dispatch:per_conversation",
|
|
6715
|
+
bindingId: binding.id,
|
|
6716
|
+
conversationId: message.conversation?.id
|
|
6717
|
+
}, "per_conversation mode active \u2014 thread lookup by conversation not yet implemented, using binding.threadId");
|
|
6718
|
+
}
|
|
6701
6719
|
if (!binding.enabled) {
|
|
6702
6720
|
throw new BindingNotFoundError(
|
|
6703
6721
|
`Binding for sender "${message.sender.id}" is disabled`
|
|
@@ -6707,6 +6725,12 @@ var MessageRouter = class {
|
|
|
6707
6725
|
if (!threadId) {
|
|
6708
6726
|
const threadStore = getStoreLattice14("default", "thread").store;
|
|
6709
6727
|
const newThreadId = randomUUID7();
|
|
6728
|
+
this.logger?.info({
|
|
6729
|
+
event: "dispatch:thread:create",
|
|
6730
|
+
agentId: ctx.binding.agentId,
|
|
6731
|
+
newThreadId,
|
|
6732
|
+
tenantId
|
|
6733
|
+
}, "Creating new thread for binding");
|
|
6710
6734
|
const newThread = await threadStore.createThread(
|
|
6711
6735
|
tenantId,
|
|
6712
6736
|
ctx.binding.agentId,
|
|
@@ -6728,6 +6752,14 @@ var MessageRouter = class {
|
|
|
6728
6752
|
ctx.binding.threadId = threadId;
|
|
6729
6753
|
}
|
|
6730
6754
|
}
|
|
6755
|
+
this.logger?.info({
|
|
6756
|
+
event: "dispatch:agent",
|
|
6757
|
+
agentId: ctx.binding.agentId,
|
|
6758
|
+
threadId,
|
|
6759
|
+
threadMode: ctx.binding.threadMode,
|
|
6760
|
+
senderId: message.sender.id,
|
|
6761
|
+
contentLength: message.content.text.length
|
|
6762
|
+
}, "Dispatching to agent");
|
|
6731
6763
|
const agent = agentInstanceManager6.getAgent({
|
|
6732
6764
|
tenant_id: tenantId,
|
|
6733
6765
|
assistant_id: ctx.binding.agentId,
|
|
@@ -6735,10 +6767,17 @@ var MessageRouter = class {
|
|
|
6735
6767
|
workspace_id: ctx.binding.workspaceId || "",
|
|
6736
6768
|
project_id: ctx.binding.projectId || ""
|
|
6737
6769
|
});
|
|
6738
|
-
const
|
|
6739
|
-
input: { message: message.content.text }
|
|
6770
|
+
const addResult = await agent.addMessage({
|
|
6771
|
+
input: { message: message.content.text },
|
|
6772
|
+
custom_run_config: message.content.metadata || {}
|
|
6740
6773
|
});
|
|
6741
|
-
|
|
6774
|
+
this.logger?.info({
|
|
6775
|
+
event: "dispatch:complete",
|
|
6776
|
+
agentId: ctx.binding.agentId,
|
|
6777
|
+
threadId,
|
|
6778
|
+
messageId: addResult?.messageId,
|
|
6779
|
+
result: JSON.stringify(addResult)
|
|
6780
|
+
}, "Agent dispatch complete \u2014 messageId = " + (addResult?.messageId || "N/A"));
|
|
6742
6781
|
if (message.replyTarget) {
|
|
6743
6782
|
const adapter = this.adapterRegistry.get(message.replyTarget.adapterChannel);
|
|
6744
6783
|
if (adapter) {
|
|
@@ -6748,7 +6787,7 @@ var MessageRouter = class {
|
|
|
6748
6787
|
if (installation) {
|
|
6749
6788
|
await adapter.sendReply(
|
|
6750
6789
|
message.replyTarget,
|
|
6751
|
-
{ text: ctx.result },
|
|
6790
|
+
{ text: ctx.result || "" },
|
|
6752
6791
|
installation
|
|
6753
6792
|
);
|
|
6754
6793
|
}
|
|
@@ -6763,6 +6802,7 @@ var MessageRouter = class {
|
|
|
6763
6802
|
};
|
|
6764
6803
|
} catch (error) {
|
|
6765
6804
|
ctx.error = error instanceof Error ? error : new Error(String(error));
|
|
6805
|
+
this.logger?.error({ event: "dispatch:error", error: ctx.error.message, channel: message.channel, senderId: message.sender.id }, "Message dispatch failed");
|
|
6766
6806
|
return {
|
|
6767
6807
|
success: false,
|
|
6768
6808
|
bindingId: ctx.binding?.id,
|
|
@@ -6782,18 +6822,6 @@ var MessageRouter = class {
|
|
|
6782
6822
|
return dispatch(0);
|
|
6783
6823
|
}
|
|
6784
6824
|
};
|
|
6785
|
-
function extractTextFromInvokeResult(result) {
|
|
6786
|
-
if (result && typeof result === "object" && "messages" in result) {
|
|
6787
|
-
const messages = result.messages;
|
|
6788
|
-
if (Array.isArray(messages)) {
|
|
6789
|
-
const aiMessages = messages.filter((m) => m.role === "ai");
|
|
6790
|
-
if (aiMessages.length > 0) {
|
|
6791
|
-
return aiMessages.map((m) => m.content).join("\n");
|
|
6792
|
-
}
|
|
6793
|
-
}
|
|
6794
|
-
}
|
|
6795
|
-
return JSON.stringify(result);
|
|
6796
|
-
}
|
|
6797
6825
|
|
|
6798
6826
|
// src/channels/registry.ts
|
|
6799
6827
|
var ChannelAdapterRegistry = class {
|
|
@@ -7395,7 +7423,8 @@ var start = async (config) => {
|
|
|
7395
7423
|
],
|
|
7396
7424
|
bindingRegistry: bindingStore,
|
|
7397
7425
|
adapterRegistry,
|
|
7398
|
-
installationStore
|
|
7426
|
+
installationStore,
|
|
7427
|
+
logger: logger3
|
|
7399
7428
|
});
|
|
7400
7429
|
channelDeps = { router, installationStore };
|
|
7401
7430
|
} catch {
|