@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.81
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 919961e: add log
|
|
8
|
+
- Updated dependencies [919961e]
|
|
9
|
+
- @axiom-lattice/core@2.1.71
|
|
10
|
+
- @axiom-lattice/agent-eval@2.1.65
|
|
11
|
+
- @axiom-lattice/pg-stores@1.0.61
|
|
12
|
+
|
|
3
13
|
## 2.1.80
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -67,12 +67,14 @@ interface MessageRouterConfig {
|
|
|
67
67
|
bindingRegistry: BindingRegistry;
|
|
68
68
|
adapterRegistry: ChannelAdapterRegistry;
|
|
69
69
|
installationStore: ChannelInstallationStore;
|
|
70
|
+
logger?: any;
|
|
70
71
|
}
|
|
71
72
|
declare class MessageRouter {
|
|
72
73
|
private middlewares;
|
|
73
74
|
private bindingRegistry;
|
|
74
75
|
private adapterRegistry;
|
|
75
76
|
private installationStore;
|
|
77
|
+
private logger?;
|
|
76
78
|
constructor(config: MessageRouterConfig);
|
|
77
79
|
use(middleware: MessageMiddleware): void;
|
|
78
80
|
dispatch(message: InboundMessage): Promise<DispatchResult>;
|
package/dist/index.d.ts
CHANGED
|
@@ -67,12 +67,14 @@ interface MessageRouterConfig {
|
|
|
67
67
|
bindingRegistry: BindingRegistry;
|
|
68
68
|
adapterRegistry: ChannelAdapterRegistry;
|
|
69
69
|
installationStore: ChannelInstallationStore;
|
|
70
|
+
logger?: any;
|
|
70
71
|
}
|
|
71
72
|
declare class MessageRouter {
|
|
72
73
|
private middlewares;
|
|
73
74
|
private bindingRegistry;
|
|
74
75
|
private adapterRegistry;
|
|
75
76
|
private installationStore;
|
|
77
|
+
private logger?;
|
|
76
78
|
constructor(config: MessageRouterConfig);
|
|
77
79
|
use(middleware: MessageMiddleware): void;
|
|
78
80
|
dispatch(message: InboundMessage): Promise<DispatchResult>;
|
package/dist/index.js
CHANGED
|
@@ -6697,6 +6697,7 @@ var MessageRouter = class {
|
|
|
6697
6697
|
this.bindingRegistry = config.bindingRegistry;
|
|
6698
6698
|
this.adapterRegistry = config.adapterRegistry;
|
|
6699
6699
|
this.installationStore = config.installationStore;
|
|
6700
|
+
this.logger = config.logger;
|
|
6700
6701
|
}
|
|
6701
6702
|
use(middleware) {
|
|
6702
6703
|
this.middlewares.push(middleware);
|
|
@@ -6714,6 +6715,7 @@ var MessageRouter = class {
|
|
|
6714
6715
|
"tenantId is required: provide it in the message or ensure the channelInstallation has a tenantId"
|
|
6715
6716
|
);
|
|
6716
6717
|
}
|
|
6718
|
+
this.logger?.info({ event: "dispatch:start", channel: message.channel, senderId: message.sender.id, tenantId }, "Message dispatch started");
|
|
6717
6719
|
let binding = await this.bindingRegistry.resolve({
|
|
6718
6720
|
channel: message.channel,
|
|
6719
6721
|
senderId: message.sender.id,
|
|
@@ -6750,6 +6752,22 @@ var MessageRouter = class {
|
|
|
6750
6752
|
}
|
|
6751
6753
|
}
|
|
6752
6754
|
ctx.binding = binding;
|
|
6755
|
+
this.logger?.info({
|
|
6756
|
+
event: "dispatch:binding",
|
|
6757
|
+
bindingId: binding.id,
|
|
6758
|
+
agentId: binding.agentId,
|
|
6759
|
+
threadId: binding.threadId,
|
|
6760
|
+
threadMode: binding.threadMode,
|
|
6761
|
+
workspaceId: binding.workspaceId,
|
|
6762
|
+
projectId: binding.projectId
|
|
6763
|
+
}, "Binding resolved");
|
|
6764
|
+
if (binding.threadMode === "per_conversation") {
|
|
6765
|
+
this.logger?.warn({
|
|
6766
|
+
event: "dispatch:per_conversation",
|
|
6767
|
+
bindingId: binding.id,
|
|
6768
|
+
conversationId: message.conversation?.id
|
|
6769
|
+
}, "per_conversation mode active \u2014 thread lookup by conversation not yet implemented, using binding.threadId");
|
|
6770
|
+
}
|
|
6753
6771
|
if (!binding.enabled) {
|
|
6754
6772
|
throw new BindingNotFoundError(
|
|
6755
6773
|
`Binding for sender "${message.sender.id}" is disabled`
|
|
@@ -6759,6 +6777,12 @@ var MessageRouter = class {
|
|
|
6759
6777
|
if (!threadId) {
|
|
6760
6778
|
const threadStore = (0, import_core28.getStoreLattice)("default", "thread").store;
|
|
6761
6779
|
const newThreadId = (0, import_crypto8.randomUUID)();
|
|
6780
|
+
this.logger?.info({
|
|
6781
|
+
event: "dispatch:thread:create",
|
|
6782
|
+
agentId: ctx.binding.agentId,
|
|
6783
|
+
newThreadId,
|
|
6784
|
+
tenantId
|
|
6785
|
+
}, "Creating new thread for binding");
|
|
6762
6786
|
const newThread = await threadStore.createThread(
|
|
6763
6787
|
tenantId,
|
|
6764
6788
|
ctx.binding.agentId,
|
|
@@ -6780,6 +6804,14 @@ var MessageRouter = class {
|
|
|
6780
6804
|
ctx.binding.threadId = threadId;
|
|
6781
6805
|
}
|
|
6782
6806
|
}
|
|
6807
|
+
this.logger?.info({
|
|
6808
|
+
event: "dispatch:agent",
|
|
6809
|
+
agentId: ctx.binding.agentId,
|
|
6810
|
+
threadId,
|
|
6811
|
+
threadMode: ctx.binding.threadMode,
|
|
6812
|
+
senderId: message.sender.id,
|
|
6813
|
+
contentLength: message.content.text.length
|
|
6814
|
+
}, "Dispatching to agent");
|
|
6783
6815
|
const agent = import_core28.agentInstanceManager.getAgent({
|
|
6784
6816
|
tenant_id: tenantId,
|
|
6785
6817
|
assistant_id: ctx.binding.agentId,
|
|
@@ -6787,10 +6819,17 @@ var MessageRouter = class {
|
|
|
6787
6819
|
workspace_id: ctx.binding.workspaceId || "",
|
|
6788
6820
|
project_id: ctx.binding.projectId || ""
|
|
6789
6821
|
});
|
|
6790
|
-
const
|
|
6791
|
-
input: { message: message.content.text }
|
|
6822
|
+
const addResult = await agent.addMessage({
|
|
6823
|
+
input: { message: message.content.text },
|
|
6824
|
+
custom_run_config: message.content.metadata || {}
|
|
6792
6825
|
});
|
|
6793
|
-
|
|
6826
|
+
this.logger?.info({
|
|
6827
|
+
event: "dispatch:complete",
|
|
6828
|
+
agentId: ctx.binding.agentId,
|
|
6829
|
+
threadId,
|
|
6830
|
+
messageId: addResult?.messageId,
|
|
6831
|
+
result: JSON.stringify(addResult)
|
|
6832
|
+
}, "Agent dispatch complete \u2014 messageId = " + (addResult?.messageId || "N/A"));
|
|
6794
6833
|
if (message.replyTarget) {
|
|
6795
6834
|
const adapter = this.adapterRegistry.get(message.replyTarget.adapterChannel);
|
|
6796
6835
|
if (adapter) {
|
|
@@ -6800,7 +6839,7 @@ var MessageRouter = class {
|
|
|
6800
6839
|
if (installation) {
|
|
6801
6840
|
await adapter.sendReply(
|
|
6802
6841
|
message.replyTarget,
|
|
6803
|
-
{ text: ctx.result },
|
|
6842
|
+
{ text: ctx.result || "" },
|
|
6804
6843
|
installation
|
|
6805
6844
|
);
|
|
6806
6845
|
}
|
|
@@ -6815,6 +6854,7 @@ var MessageRouter = class {
|
|
|
6815
6854
|
};
|
|
6816
6855
|
} catch (error) {
|
|
6817
6856
|
ctx.error = error instanceof Error ? error : new Error(String(error));
|
|
6857
|
+
this.logger?.error({ event: "dispatch:error", error: ctx.error.message, channel: message.channel, senderId: message.sender.id }, "Message dispatch failed");
|
|
6818
6858
|
return {
|
|
6819
6859
|
success: false,
|
|
6820
6860
|
bindingId: ctx.binding?.id,
|
|
@@ -6834,18 +6874,6 @@ var MessageRouter = class {
|
|
|
6834
6874
|
return dispatch(0);
|
|
6835
6875
|
}
|
|
6836
6876
|
};
|
|
6837
|
-
function extractTextFromInvokeResult(result) {
|
|
6838
|
-
if (result && typeof result === "object" && "messages" in result) {
|
|
6839
|
-
const messages = result.messages;
|
|
6840
|
-
if (Array.isArray(messages)) {
|
|
6841
|
-
const aiMessages = messages.filter((m) => m.role === "ai");
|
|
6842
|
-
if (aiMessages.length > 0) {
|
|
6843
|
-
return aiMessages.map((m) => m.content).join("\n");
|
|
6844
|
-
}
|
|
6845
|
-
}
|
|
6846
|
-
}
|
|
6847
|
-
return JSON.stringify(result);
|
|
6848
|
-
}
|
|
6849
6877
|
|
|
6850
6878
|
// src/channels/registry.ts
|
|
6851
6879
|
var ChannelAdapterRegistry = class {
|
|
@@ -7437,7 +7465,8 @@ var start = async (config) => {
|
|
|
7437
7465
|
],
|
|
7438
7466
|
bindingRegistry: bindingStore,
|
|
7439
7467
|
adapterRegistry,
|
|
7440
|
-
installationStore
|
|
7468
|
+
installationStore,
|
|
7469
|
+
logger: logger3
|
|
7441
7470
|
});
|
|
7442
7471
|
channelDeps = { router, installationStore };
|
|
7443
7472
|
} catch {
|