@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiom-lattice/gateway",
3
- "version": "2.1.80",
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.64",
44
- "@axiom-lattice/core": "2.1.70",
45
- "@axiom-lattice/pg-stores": "1.0.60",
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
@@ -294,6 +294,7 @@ const start = async (config?: LatticeGatewayConfig) => {
294
294
  bindingRegistry: bindingStore,
295
295
  adapterRegistry,
296
296
  installationStore,
297
+ logger,
297
298
  });
298
299
 
299
300
  channelDeps = { router, installationStore };
@@ -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 invokeResult = await agent.invoke({
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
- ctx.result = extractTextFromInvokeResult(invokeResult);
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
- }
@@ -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
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- CLI Target: es2020
9
- CLI Cleaning output folder
10
- CJS Build start
11
- ESM Build start
12
- [warn] ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
13
-
14
- src/index.ts:178:33:
15
-  178 │ const __filename = fileURLToPath(import.meta.url);
16
- ╵ ~~~~~~~~~~~
17
-
18
- You need to set the output format to "esm" for "import.meta" to work correctly.
19
-
20
-
21
- CJS dist/index.js 239.18 KB
22
- CJS dist/index.js.map 502.61 KB
23
- CJS ⚡️ Build success in 314ms
24
- ESM dist/index.mjs 234.48 KB
25
- ESM dist/sender-PX32VSHB.mjs 873.00 B
26
- ESM dist/index.mjs.map 501.10 KB
27
- ESM dist/sender-PX32VSHB.mjs.map 2.07 KB
28
- ESM ⚡️ Build success in 322ms
29
- DTS Build start
30
- DTS ⚡️ Build success in 14133ms
31
- DTS dist/index.d.ts 5.01 KB
32
- DTS dist/index.d.mts 5.01 KB