@axiom-lattice/gateway 2.1.46 → 2.1.48
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +20 -0
- package/dist/index.js +24 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/controllers/memory.ts +9 -1
- package/src/controllers/run.ts +22 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/gateway",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.48",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"pg": "^8.11.0",
|
|
39
39
|
"redis": "^5.0.1",
|
|
40
40
|
"uuid": "^9.0.1",
|
|
41
|
-
"@axiom-lattice/core": "2.1.
|
|
42
|
-
"@axiom-lattice/pg-stores": "1.0.
|
|
43
|
-
"@axiom-lattice/protocols": "2.1.
|
|
44
|
-
"@axiom-lattice/queue-redis": "1.0.
|
|
41
|
+
"@axiom-lattice/core": "2.1.42",
|
|
42
|
+
"@axiom-lattice/pg-stores": "1.0.32",
|
|
43
|
+
"@axiom-lattice/protocols": "2.1.23",
|
|
44
|
+
"@axiom-lattice/queue-redis": "1.0.22"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/jest": "^29.5.14",
|
|
@@ -167,9 +167,17 @@ export const getAgentState = async (
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// 3. 合并返回
|
|
170
|
+
// Normalize pendingMessages content to string for consistent frontend format
|
|
171
|
+
const normalizedPendingMessages = pendingMessages.map(msg => ({
|
|
172
|
+
...msg,
|
|
173
|
+
content: typeof msg.content === 'object' && msg.content !== null
|
|
174
|
+
? (msg.content.message || JSON.stringify(msg.content))
|
|
175
|
+
: String(msg.content || '')
|
|
176
|
+
}));
|
|
177
|
+
|
|
170
178
|
const mergedResult = {
|
|
171
179
|
...result,
|
|
172
|
-
pendingMessages
|
|
180
|
+
pendingMessages: normalizedPendingMessages
|
|
173
181
|
};
|
|
174
182
|
|
|
175
183
|
reply.send(mergedResult);
|
package/src/controllers/run.ts
CHANGED
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
agentLatticeManager,
|
|
8
8
|
agentInstanceManager,
|
|
9
9
|
} from "@axiom-lattice/core";
|
|
10
|
+
import { MessageChunkTypes } from "@axiom-lattice/protocols";
|
|
10
11
|
|
|
11
12
|
interface ResumeStreamRequest {
|
|
12
13
|
thread_id: string;
|
|
14
|
+
assistant_id: string
|
|
13
15
|
message_id: string;
|
|
14
16
|
known_content: string;
|
|
15
17
|
poll_interval?: number;
|
|
@@ -86,11 +88,10 @@ export const createRun = async (
|
|
|
86
88
|
// return
|
|
87
89
|
// }
|
|
88
90
|
|
|
89
|
-
const stream = agent.chunkStream((result).messageId)
|
|
91
|
+
const stream = agent.chunkStream((result).messageId, [MessageChunkTypes.MESSAGE_COMPLETED])
|
|
90
92
|
|
|
91
93
|
// Forward all chunks to SSE
|
|
92
94
|
for await (const chunk of stream) {
|
|
93
|
-
console.log(input.message, chunk.data.content);
|
|
94
95
|
const success = reply.raw.write(`data: ${JSON.stringify(chunk)}\n\n`);
|
|
95
96
|
if (!success) {
|
|
96
97
|
await new Promise(resolve => reply.raw.once('drain', resolve));
|
|
@@ -136,14 +137,21 @@ export const resumeStream = async (
|
|
|
136
137
|
reply: FastifyReply
|
|
137
138
|
): Promise<void> => {
|
|
138
139
|
try {
|
|
139
|
-
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
const { thread_id, message_id, assistant_id, known_content, poll_interval } =
|
|
140
145
|
request.body as ResumeStreamRequest;
|
|
146
|
+
const tenant_id = request.headers["x-tenant-id"] as string;
|
|
147
|
+
const workspace_id = request.headers["x-workspace-id"] as string;
|
|
148
|
+
const project_id = request.headers["x-project-id"] as string;
|
|
141
149
|
|
|
142
150
|
// Validate request data
|
|
143
|
-
if (!thread_id || !message_id || known_content === undefined) {
|
|
151
|
+
if (!thread_id || !message_id || !assistant_id || known_content === undefined) {
|
|
144
152
|
reply.status(400).send({
|
|
145
153
|
success: false,
|
|
146
|
-
error: "thread_id, message_id, and known_content are required",
|
|
154
|
+
error: "thread_id, message_id, assistant_id, and known_content are required",
|
|
147
155
|
});
|
|
148
156
|
return;
|
|
149
157
|
}
|
|
@@ -162,17 +170,22 @@ export const resumeStream = async (
|
|
|
162
170
|
try {
|
|
163
171
|
// Create Agent instance for accessing chunk buffer
|
|
164
172
|
// Note: assistant_id, tenant_id are not required for chunkStream
|
|
165
|
-
|
|
166
|
-
|
|
173
|
+
// Get or create Agent instance (ensures single instance per thread)
|
|
174
|
+
const agent = agentInstanceManager.getAgent({
|
|
175
|
+
assistant_id,
|
|
167
176
|
thread_id,
|
|
168
|
-
tenant_id
|
|
177
|
+
tenant_id,
|
|
178
|
+
workspace_id,
|
|
179
|
+
project_id,
|
|
169
180
|
});
|
|
170
181
|
|
|
171
182
|
// Get the stream from agent's chunk buffer
|
|
172
|
-
|
|
183
|
+
console.log("[UI]message_id", message_id)
|
|
184
|
+
const stream = agent.chunkStream(message_id, [MessageChunkTypes.THREAD_IDLE]);
|
|
173
185
|
|
|
174
186
|
// Stream the chunks to the client
|
|
175
187
|
for await (const chunk of stream) {
|
|
188
|
+
// console.log(chunk);
|
|
176
189
|
reply.raw.write(`data: ${JSON.stringify(chunk)}\n\n`);
|
|
177
190
|
}
|
|
178
191
|
} catch (error: any) {
|