@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/gateway",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.81",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"redis": "^5.0.1",
|
|
41
41
|
"uuid": "^9.0.1",
|
|
42
42
|
"zod": "3.25.76",
|
|
43
|
-
"@axiom-lattice/agent-eval": "2.1.
|
|
44
|
-
"@axiom-lattice/core": "2.1.
|
|
45
|
-
"@axiom-lattice/pg-stores": "1.0.
|
|
43
|
+
"@axiom-lattice/agent-eval": "2.1.65",
|
|
44
|
+
"@axiom-lattice/core": "2.1.71",
|
|
45
|
+
"@axiom-lattice/pg-stores": "1.0.61",
|
|
46
46
|
"@axiom-lattice/protocols": "2.1.36",
|
|
47
47
|
"@axiom-lattice/queue-redis": "1.0.35"
|
|
48
48
|
},
|
package/src/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface MessageRouterConfig {
|
|
|
24
24
|
bindingRegistry: BindingRegistry;
|
|
25
25
|
adapterRegistry: ChannelAdapterRegistry;
|
|
26
26
|
installationStore: ChannelInstallationStore;
|
|
27
|
+
logger?: any;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export class MessageRouter {
|
|
@@ -31,12 +32,14 @@ export class MessageRouter {
|
|
|
31
32
|
private bindingRegistry: BindingRegistry;
|
|
32
33
|
private adapterRegistry: ChannelAdapterRegistry;
|
|
33
34
|
private installationStore: ChannelInstallationStore;
|
|
35
|
+
private logger?: any;
|
|
34
36
|
|
|
35
37
|
constructor(config: MessageRouterConfig) {
|
|
36
38
|
this.middlewares = [...config.middlewares];
|
|
37
39
|
this.bindingRegistry = config.bindingRegistry;
|
|
38
40
|
this.adapterRegistry = config.adapterRegistry;
|
|
39
41
|
this.installationStore = config.installationStore;
|
|
42
|
+
this.logger = config.logger;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
use(middleware: MessageMiddleware): void {
|
|
@@ -61,6 +64,8 @@ export class MessageRouter {
|
|
|
61
64
|
);
|
|
62
65
|
}
|
|
63
66
|
|
|
67
|
+
this.logger?.info({ event: "dispatch:start", channel: message.channel, senderId: message.sender.id, tenantId }, "Message dispatch started");
|
|
68
|
+
|
|
64
69
|
let binding = await this.bindingRegistry.resolve({
|
|
65
70
|
channel: message.channel,
|
|
66
71
|
senderId: message.sender.id,
|
|
@@ -102,6 +107,24 @@ export class MessageRouter {
|
|
|
102
107
|
|
|
103
108
|
ctx.binding = binding;
|
|
104
109
|
|
|
110
|
+
this.logger?.info({
|
|
111
|
+
event: "dispatch:binding",
|
|
112
|
+
bindingId: binding.id,
|
|
113
|
+
agentId: binding.agentId,
|
|
114
|
+
threadId: binding.threadId,
|
|
115
|
+
threadMode: binding.threadMode,
|
|
116
|
+
workspaceId: binding.workspaceId,
|
|
117
|
+
projectId: binding.projectId,
|
|
118
|
+
}, "Binding resolved");
|
|
119
|
+
|
|
120
|
+
if (binding.threadMode === "per_conversation") {
|
|
121
|
+
this.logger?.warn({
|
|
122
|
+
event: "dispatch:per_conversation",
|
|
123
|
+
bindingId: binding.id,
|
|
124
|
+
conversationId: message.conversation?.id,
|
|
125
|
+
}, "per_conversation mode active — thread lookup by conversation not yet implemented, using binding.threadId");
|
|
126
|
+
}
|
|
127
|
+
|
|
105
128
|
if (!binding.enabled) {
|
|
106
129
|
throw new BindingNotFoundError(
|
|
107
130
|
`Binding for sender "${message.sender.id}" is disabled`,
|
|
@@ -112,8 +135,14 @@ export class MessageRouter {
|
|
|
112
135
|
if (!threadId) {
|
|
113
136
|
const threadStore = getStoreLattice("default", "thread").store;
|
|
114
137
|
const newThreadId = randomUUID();
|
|
138
|
+
this.logger?.info({
|
|
139
|
+
event: "dispatch:thread:create",
|
|
140
|
+
agentId: ctx.binding.agentId,
|
|
141
|
+
newThreadId,
|
|
142
|
+
tenantId: tenantId!,
|
|
143
|
+
}, "Creating new thread for binding");
|
|
115
144
|
const newThread = await threadStore.createThread(
|
|
116
|
-
tenantId
|
|
145
|
+
tenantId!,
|
|
117
146
|
ctx.binding.agentId,
|
|
118
147
|
newThreadId,
|
|
119
148
|
{
|
|
@@ -134,19 +163,35 @@ export class MessageRouter {
|
|
|
134
163
|
}
|
|
135
164
|
}
|
|
136
165
|
|
|
166
|
+
this.logger?.info({
|
|
167
|
+
event: "dispatch:agent",
|
|
168
|
+
agentId: ctx.binding.agentId,
|
|
169
|
+
threadId,
|
|
170
|
+
threadMode: ctx.binding.threadMode,
|
|
171
|
+
senderId: message.sender.id,
|
|
172
|
+
contentLength: message.content.text.length,
|
|
173
|
+
}, "Dispatching to agent");
|
|
174
|
+
|
|
137
175
|
const agent = agentInstanceManager.getAgent({
|
|
138
|
-
tenant_id: tenantId
|
|
176
|
+
tenant_id: tenantId!,
|
|
139
177
|
assistant_id: ctx.binding.agentId,
|
|
140
178
|
thread_id: threadId,
|
|
141
179
|
workspace_id: ctx.binding.workspaceId || "",
|
|
142
180
|
project_id: ctx.binding.projectId || "",
|
|
143
181
|
});
|
|
144
182
|
|
|
145
|
-
const
|
|
183
|
+
const addResult = await agent.addMessage({
|
|
146
184
|
input: { message: message.content.text },
|
|
185
|
+
custom_run_config: message.content.metadata || {},
|
|
147
186
|
});
|
|
148
187
|
|
|
149
|
-
|
|
188
|
+
this.logger?.info({
|
|
189
|
+
event: "dispatch:complete",
|
|
190
|
+
agentId: ctx.binding.agentId,
|
|
191
|
+
threadId,
|
|
192
|
+
messageId: (addResult as Record<string, unknown>)?.messageId,
|
|
193
|
+
result: JSON.stringify(addResult),
|
|
194
|
+
}, "Agent dispatch complete — messageId = " + ((addResult as Record<string, unknown>)?.messageId || "N/A"));
|
|
150
195
|
|
|
151
196
|
if (message.replyTarget) {
|
|
152
197
|
const adapter = this.adapterRegistry.get(message.replyTarget.adapterChannel);
|
|
@@ -157,7 +202,7 @@ export class MessageRouter {
|
|
|
157
202
|
if (installation) {
|
|
158
203
|
await adapter.sendReply(
|
|
159
204
|
message.replyTarget,
|
|
160
|
-
{ text: ctx.result },
|
|
205
|
+
{ text: ctx.result || "" },
|
|
161
206
|
installation,
|
|
162
207
|
);
|
|
163
208
|
}
|
|
@@ -173,6 +218,7 @@ export class MessageRouter {
|
|
|
173
218
|
};
|
|
174
219
|
} catch (error) {
|
|
175
220
|
ctx.error = error instanceof Error ? error : new Error(String(error));
|
|
221
|
+
this.logger?.error({ event: "dispatch:error", error: ctx.error.message, channel: message.channel, senderId: message.sender.id }, "Message dispatch failed");
|
|
176
222
|
return {
|
|
177
223
|
success: false,
|
|
178
224
|
bindingId: ctx.binding?.id,
|
|
@@ -196,16 +242,3 @@ export class MessageRouter {
|
|
|
196
242
|
return dispatch(0);
|
|
197
243
|
}
|
|
198
244
|
}
|
|
199
|
-
|
|
200
|
-
function extractTextFromInvokeResult(result: unknown): string {
|
|
201
|
-
if (result && typeof result === "object" && "messages" in result) {
|
|
202
|
-
const messages = (result as { messages: Array<{ role: string; content: string }> }).messages;
|
|
203
|
-
if (Array.isArray(messages)) {
|
|
204
|
-
const aiMessages = messages.filter((m) => m.role === "ai");
|
|
205
|
-
if (aiMessages.length > 0) {
|
|
206
|
-
return aiMessages.map((m) => m.content).join("\n");
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return JSON.stringify(result);
|
|
211
|
-
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @axiom-lattice/gateway@2.1.80 build /home/runner/work/agentic/agentic/packages/gateway
|
|
3
|
-
> tsup src/index.ts --format cjs,esm --dts --clean --sourcemap
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.5.0
|
|
8
|
-
[34mCLI[39m Target: es2020
|
|
9
|
-
[34mCLI[39m Cleaning output folder
|
|
10
|
-
[34mCJS[39m Build start
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[warn] [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m"import.meta" is not available with the "cjs" output format and will be empty[0m [empty-import-meta]
|
|
13
|
-
|
|
14
|
-
src/index.ts:178:33:
|
|
15
|
-
[37m 178 │ const __filename = fileURLToPath([32mimport.meta[37m.url);
|
|
16
|
-
╵ [32m~~~~~~~~~~~[0m
|
|
17
|
-
|
|
18
|
-
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[32mCJS[39m [1mdist/index.js [22m[32m239.18 KB[39m
|
|
22
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m502.61 KB[39m
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in 314ms
|
|
24
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m234.48 KB[39m
|
|
25
|
-
[32mESM[39m [1mdist/sender-PX32VSHB.mjs [22m[32m873.00 B[39m
|
|
26
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m501.10 KB[39m
|
|
27
|
-
[32mESM[39m [1mdist/sender-PX32VSHB.mjs.map [22m[32m2.07 KB[39m
|
|
28
|
-
[32mESM[39m ⚡️ Build success in 322ms
|
|
29
|
-
[34mDTS[39m Build start
|
|
30
|
-
[32mDTS[39m ⚡️ Build success in 14133ms
|
|
31
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m5.01 KB[39m
|
|
32
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m5.01 KB[39m
|