@cogitator-ai/fastify 0.1.14 → 0.2.1
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/README.md +66 -38
- package/dist/hooks/error-handler.d.ts.map +1 -1
- package/dist/hooks/error-handler.js +29 -0
- package/dist/hooks/error-handler.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +42 -37
- package/dist/plugin.js.map +1 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +58 -49
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/health.d.ts.map +1 -1
- package/dist/routes/health.js +1 -1
- package/dist/routes/health.js.map +1 -1
- package/dist/routes/swarms.d.ts.map +1 -1
- package/dist/routes/swarms.js +49 -59
- package/dist/routes/swarms.js.map +1 -1
- package/dist/routes/threads.d.ts.map +1 -1
- package/dist/routes/threads.js +11 -30
- package/dist/routes/threads.js.map +1 -1
- package/dist/routes/utils.d.ts +12 -0
- package/dist/routes/utils.d.ts.map +1 -0
- package/dist/routes/utils.js +32 -0
- package/dist/routes/utils.js.map +1 -0
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/workflows.js +57 -56
- package/dist/routes/workflows.js.map +1 -1
- package/dist/streaming/fastify-stream-writer.d.ts +2 -0
- package/dist/streaming/fastify-stream-writer.d.ts.map +1 -1
- package/dist/streaming/fastify-stream-writer.js +27 -2
- package/dist/streaming/fastify-stream-writer.js.map +1 -1
- package/dist/types.d.ts +11 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -6
- package/dist/types.js.map +1 -1
- package/dist/websocket/handler.d.ts.map +1 -1
- package/dist/websocket/handler.js +171 -93
- package/dist/websocket/handler.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarms.d.ts","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"swarms.d.ts","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA8BlD,eAAO,MAAM,WAAW,EAAE,kBAgMzB,CAAC"}
|
package/dist/routes/swarms.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { SwarmRunRequestSchema } from '../types.js';
|
|
2
2
|
import { FastifyStreamWriter, generateId } from '../streaming/index.js';
|
|
3
|
+
import { isModuleNotFound, onClientDisconnect, resolveError, sendError, sendRouteError, } from './utils.js';
|
|
4
|
+
const paramsSchema = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: { name: { type: 'string' } },
|
|
7
|
+
required: ['name'],
|
|
8
|
+
};
|
|
9
|
+
const SWARMS_MISSING = 'Swarms package not installed';
|
|
3
10
|
export const swarmRoutes = async (fastify) => {
|
|
11
|
+
const findSwarm = (name) => Object.hasOwn(fastify.cogitator.swarms, name) ? fastify.cogitator.swarms[name] : undefined;
|
|
4
12
|
fastify.get('/swarms', async () => {
|
|
5
13
|
const swarmList = Object.entries(fastify.cogitator.swarms).map(([name, config]) => {
|
|
6
14
|
const agents = [];
|
|
@@ -21,26 +29,24 @@ export const swarmRoutes = async (fastify) => {
|
|
|
21
29
|
const response = { swarms: swarmList };
|
|
22
30
|
return response;
|
|
23
31
|
});
|
|
24
|
-
fastify.post('/swarms/:name/run', {
|
|
25
|
-
schema: {
|
|
26
|
-
params: {
|
|
27
|
-
type: 'object',
|
|
28
|
-
properties: { name: { type: 'string' } },
|
|
29
|
-
required: ['name'],
|
|
30
|
-
},
|
|
31
|
-
body: SwarmRunRequestSchema,
|
|
32
|
-
},
|
|
33
|
-
}, async (request, reply) => {
|
|
32
|
+
fastify.post('/swarms/:name/run', { schema: { params: paramsSchema, body: SwarmRunRequestSchema } }, async (request, reply) => {
|
|
34
33
|
const { name } = request.params;
|
|
35
|
-
const swarmConfig =
|
|
34
|
+
const swarmConfig = findSwarm(name);
|
|
36
35
|
if (!swarmConfig) {
|
|
37
|
-
return reply
|
|
38
|
-
error: { message: `Swarm '${name}' not found`, code: 'NOT_FOUND' },
|
|
39
|
-
});
|
|
36
|
+
return sendError(reply, 404, `Swarm '${name}' not found`, 'NOT_FOUND');
|
|
40
37
|
}
|
|
38
|
+
let disconnected = false;
|
|
39
|
+
let abortSwarm;
|
|
40
|
+
onClientDisconnect(reply, () => {
|
|
41
|
+
disconnected = true;
|
|
42
|
+
abortSwarm?.();
|
|
43
|
+
});
|
|
41
44
|
try {
|
|
42
45
|
const { Swarm } = await import('@cogitator-ai/swarms');
|
|
43
46
|
const swarm = new Swarm(fastify.cogitator.runtime, swarmConfig);
|
|
47
|
+
abortSwarm = () => swarm.abort();
|
|
48
|
+
if (disconnected)
|
|
49
|
+
swarm.abort();
|
|
44
50
|
const result = await swarm.run({
|
|
45
51
|
input: request.body.input,
|
|
46
52
|
context: request.body.context,
|
|
@@ -70,42 +76,33 @@ export const swarmRoutes = async (fastify) => {
|
|
|
70
76
|
return response;
|
|
71
77
|
}
|
|
72
78
|
catch (error) {
|
|
73
|
-
if (error
|
|
74
|
-
return reply
|
|
75
|
-
error: { message: 'Swarms package not installed', code: 'UNIMPLEMENTED' },
|
|
76
|
-
});
|
|
79
|
+
if (isModuleNotFound(error)) {
|
|
80
|
+
return sendError(reply, 501, SWARMS_MISSING, 'UNIMPLEMENTED');
|
|
77
81
|
}
|
|
78
|
-
|
|
79
|
-
return reply.status(500).send({
|
|
80
|
-
error: { message, code: 'INTERNAL' },
|
|
81
|
-
});
|
|
82
|
+
return sendRouteError(request, reply, error, 'swarm run error');
|
|
82
83
|
}
|
|
83
84
|
});
|
|
84
|
-
fastify.post('/swarms/:name/stream', {
|
|
85
|
-
schema: {
|
|
86
|
-
params: {
|
|
87
|
-
type: 'object',
|
|
88
|
-
properties: { name: { type: 'string' } },
|
|
89
|
-
required: ['name'],
|
|
90
|
-
},
|
|
91
|
-
body: SwarmRunRequestSchema,
|
|
92
|
-
},
|
|
93
|
-
}, async (request, reply) => {
|
|
85
|
+
fastify.post('/swarms/:name/stream', { schema: { params: paramsSchema, body: SwarmRunRequestSchema } }, async (request, reply) => {
|
|
94
86
|
const { name } = request.params;
|
|
95
|
-
const swarmConfig =
|
|
87
|
+
const swarmConfig = findSwarm(name);
|
|
96
88
|
if (!swarmConfig) {
|
|
97
|
-
return reply
|
|
98
|
-
error: { message: `Swarm '${name}' not found`, code: 'NOT_FOUND' },
|
|
99
|
-
});
|
|
89
|
+
return sendError(reply, 404, `Swarm '${name}' not found`, 'NOT_FOUND');
|
|
100
90
|
}
|
|
101
91
|
const writer = new FastifyStreamWriter(reply);
|
|
102
92
|
const messageId = generateId('swarm');
|
|
103
|
-
|
|
93
|
+
let disconnected = false;
|
|
94
|
+
let abortSwarm;
|
|
95
|
+
onClientDisconnect(reply, () => {
|
|
96
|
+
disconnected = true;
|
|
97
|
+
abortSwarm?.();
|
|
104
98
|
writer.close();
|
|
105
99
|
});
|
|
106
100
|
try {
|
|
107
101
|
const { Swarm } = await import('@cogitator-ai/swarms');
|
|
108
102
|
const swarm = new Swarm(fastify.cogitator.runtime, swarmConfig);
|
|
103
|
+
abortSwarm = () => swarm.abort();
|
|
104
|
+
if (disconnected)
|
|
105
|
+
swarm.abort();
|
|
109
106
|
writer.start(messageId);
|
|
110
107
|
const result = await swarm.run({
|
|
111
108
|
input: request.body.input,
|
|
@@ -136,43 +133,36 @@ export const swarmRoutes = async (fastify) => {
|
|
|
136
133
|
writer.swarmEvent('swarm_completed', {
|
|
137
134
|
swarmId: swarm.id,
|
|
138
135
|
output: result.output,
|
|
139
|
-
usage:
|
|
136
|
+
usage: {
|
|
137
|
+
totalTokens: resourceUsage.totalTokens,
|
|
138
|
+
totalCost: resourceUsage.totalCost,
|
|
139
|
+
elapsedTime: resourceUsage.elapsedTime,
|
|
140
|
+
},
|
|
140
141
|
});
|
|
141
142
|
writer.finish(messageId);
|
|
142
143
|
}
|
|
143
144
|
catch (error) {
|
|
144
|
-
if (error
|
|
145
|
-
|
|
145
|
+
if (isModuleNotFound(error)) {
|
|
146
|
+
return sendError(reply, 501, SWARMS_MISSING, 'UNIMPLEMENTED');
|
|
146
147
|
}
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
writer.error(message,
|
|
148
|
+
if (!disconnected) {
|
|
149
|
+
const resolved = resolveError(request, error, 'swarm stream error');
|
|
150
|
+
writer.error(resolved.message, resolved.code);
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
finally {
|
|
153
154
|
writer.close();
|
|
154
155
|
}
|
|
156
|
+
return reply;
|
|
155
157
|
});
|
|
156
|
-
fastify.get('/swarms/:name/blackboard', {
|
|
157
|
-
schema: {
|
|
158
|
-
params: {
|
|
159
|
-
type: 'object',
|
|
160
|
-
properties: { name: { type: 'string' } },
|
|
161
|
-
required: ['name'],
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
}, async (request, reply) => {
|
|
158
|
+
fastify.get('/swarms/:name/blackboard', { schema: { params: paramsSchema } }, async (request, reply) => {
|
|
165
159
|
const { name } = request.params;
|
|
166
|
-
const swarmConfig =
|
|
160
|
+
const swarmConfig = findSwarm(name);
|
|
167
161
|
if (!swarmConfig) {
|
|
168
|
-
return reply
|
|
169
|
-
error: { message: `Swarm '${name}' not found`, code: 'NOT_FOUND' },
|
|
170
|
-
});
|
|
162
|
+
return sendError(reply, 404, `Swarm '${name}' not found`, 'NOT_FOUND');
|
|
171
163
|
}
|
|
172
164
|
if (!swarmConfig.blackboard?.enabled) {
|
|
173
|
-
return reply
|
|
174
|
-
error: { message: 'Blackboard not enabled for this swarm', code: 'INVALID_INPUT' },
|
|
175
|
-
});
|
|
165
|
+
return sendError(reply, 400, 'Blackboard not enabled for this swarm', 'INVALID_INPUT');
|
|
176
166
|
}
|
|
177
167
|
const response = {
|
|
178
168
|
sections: swarmConfig.blackboard.sections || {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarms.js","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"swarms.js","sourceRoot":"","sources":["../../src/routes/swarms.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,cAAc,GACf,MAAM,YAAY,CAAC;AAMpB,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IACxC,QAAQ,EAAE,CAAC,MAAM,CAAC;CACV,CAAC;AAEX,MAAM,cAAc,GAAG,8BAA8B,CAAC;AAEtD,MAAM,CAAC,MAAM,WAAW,GAAuB,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/D,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE,CACjC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE7F,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAChC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE;YAChF,MA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AC,GAAG,CACT,0BAA0B,EAC1B,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EACpC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QAChC,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,IAAI,aAAa,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;YACrC,OAAO,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,uCAAuC,EAAE,eAAe,CAAC,CAAC;QACzF,CAAC;QAED,MAAM,QAAQ,GAAuB;YACnC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,QAAQ,IAAI,EAAE;SAChD,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/routes/threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/routes/threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AASlD,eAAO,MAAM,YAAY,EAAE,kBAqH1B,CAAC"}
|
package/dist/routes/threads.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AddMessageRequestSchema } from '../types.js';
|
|
2
|
+
import { sendError, sendRouteError } from './utils.js';
|
|
2
3
|
export const threadRoutes = async (fastify) => {
|
|
3
4
|
const getMemory = () => fastify.cogitator.runtime.memory;
|
|
4
5
|
fastify.get('/threads/:id', {
|
|
@@ -12,17 +13,13 @@ export const threadRoutes = async (fastify) => {
|
|
|
12
13
|
}, async (request, reply) => {
|
|
13
14
|
const memory = getMemory();
|
|
14
15
|
if (!memory) {
|
|
15
|
-
return reply
|
|
16
|
-
error: { message: 'Memory not configured', code: 'UNAVAILABLE' },
|
|
17
|
-
});
|
|
16
|
+
return sendError(reply, 503, 'Memory not configured', 'UNAVAILABLE');
|
|
18
17
|
}
|
|
19
18
|
const { id } = request.params;
|
|
20
19
|
try {
|
|
21
20
|
const result = await memory.getEntries({ threadId: id });
|
|
22
21
|
if (!result.success) {
|
|
23
|
-
return reply.
|
|
24
|
-
error: { message: result.error ?? 'Unknown error', code: 'INTERNAL' },
|
|
25
|
-
});
|
|
22
|
+
return sendError(reply, 500, result.error ?? 'Unknown error', 'INTERNAL');
|
|
26
23
|
}
|
|
27
24
|
const entries = result.data;
|
|
28
25
|
const messages = entries.map((entry) => entry.message);
|
|
@@ -36,10 +33,7 @@ export const threadRoutes = async (fastify) => {
|
|
|
36
33
|
return response;
|
|
37
34
|
}
|
|
38
35
|
catch (error) {
|
|
39
|
-
|
|
40
|
-
return reply.status(500).send({
|
|
41
|
-
error: { message, code: 'INTERNAL' },
|
|
42
|
-
});
|
|
36
|
+
return sendRouteError(request, reply, error, 'thread get error');
|
|
43
37
|
}
|
|
44
38
|
});
|
|
45
39
|
fastify.post('/threads/:id/messages', {
|
|
@@ -54,9 +48,7 @@ export const threadRoutes = async (fastify) => {
|
|
|
54
48
|
}, async (request, reply) => {
|
|
55
49
|
const memory = getMemory();
|
|
56
50
|
if (!memory) {
|
|
57
|
-
return reply
|
|
58
|
-
error: { message: 'Memory not configured', code: 'UNAVAILABLE' },
|
|
59
|
-
});
|
|
51
|
+
return sendError(reply, 503, 'Memory not configured', 'UNAVAILABLE');
|
|
60
52
|
}
|
|
61
53
|
const { id } = request.params;
|
|
62
54
|
const body = request.body;
|
|
@@ -68,19 +60,15 @@ export const threadRoutes = async (fastify) => {
|
|
|
68
60
|
content: body.content,
|
|
69
61
|
},
|
|
70
62
|
tokenCount: 0,
|
|
63
|
+
metadata: body.metadata,
|
|
71
64
|
});
|
|
72
65
|
if (!result.success) {
|
|
73
|
-
return reply.
|
|
74
|
-
error: { message: result.error ?? 'Unknown error', code: 'INTERNAL' },
|
|
75
|
-
});
|
|
66
|
+
return sendError(reply, 500, result.error ?? 'Unknown error', 'INTERNAL');
|
|
76
67
|
}
|
|
77
68
|
return reply.status(201).send({ success: true });
|
|
78
69
|
}
|
|
79
70
|
catch (error) {
|
|
80
|
-
|
|
81
|
-
return reply.status(500).send({
|
|
82
|
-
error: { message, code: 'INTERNAL' },
|
|
83
|
-
});
|
|
71
|
+
return sendRouteError(request, reply, error, 'thread add message error');
|
|
84
72
|
}
|
|
85
73
|
});
|
|
86
74
|
fastify.delete('/threads/:id', {
|
|
@@ -94,25 +82,18 @@ export const threadRoutes = async (fastify) => {
|
|
|
94
82
|
}, async (request, reply) => {
|
|
95
83
|
const memory = getMemory();
|
|
96
84
|
if (!memory) {
|
|
97
|
-
return reply
|
|
98
|
-
error: { message: 'Memory not configured', code: 'UNAVAILABLE' },
|
|
99
|
-
});
|
|
85
|
+
return sendError(reply, 503, 'Memory not configured', 'UNAVAILABLE');
|
|
100
86
|
}
|
|
101
87
|
const { id } = request.params;
|
|
102
88
|
try {
|
|
103
89
|
const result = await memory.clearThread(id);
|
|
104
90
|
if (!result.success) {
|
|
105
|
-
return reply.
|
|
106
|
-
error: { message: result.error ?? 'Unknown error', code: 'INTERNAL' },
|
|
107
|
-
});
|
|
91
|
+
return sendError(reply, 500, result.error ?? 'Unknown error', 'INTERNAL');
|
|
108
92
|
}
|
|
109
93
|
return reply.status(204).send();
|
|
110
94
|
}
|
|
111
95
|
catch (error) {
|
|
112
|
-
|
|
113
|
-
return reply.status(500).send({
|
|
114
|
-
error: { message, code: 'INTERNAL' },
|
|
115
|
-
});
|
|
96
|
+
return sendRouteError(request, reply, error, 'thread delete error');
|
|
116
97
|
}
|
|
117
98
|
});
|
|
118
99
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../src/routes/threads.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../src/routes/threads.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMvD,MAAM,CAAC,MAAM,YAAY,GAAuB,KAAK,EAAE,OAAO,EAAE,EAAE;IAChE,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;IAEzD,OAAO,CAAC,GAAG,CACT,cAAc,EACd;QACE,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;gBACtC,QAAQ,EAAE,CAAC,IAAI,CAAC;aACjB;SACF;KACF,EACD,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,uBAAuB,EAAE,aAAa,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QAE9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;YACzD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAA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AAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,uBAAuB,EAAE,aAAa,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QAE9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAC5C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,IAAI,eAAe,EAAE,UAAU,CAAC,CAAC;YAC5E,CAAC;YACD,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FastifyReply, FastifyRequest } from 'fastify';
|
|
2
|
+
export declare function sendError(reply: FastifyReply, status: number, message: string, code: string): FastifyReply;
|
|
3
|
+
export declare function isModuleNotFound(error: unknown): boolean;
|
|
4
|
+
export interface ResolvedError {
|
|
5
|
+
status: number;
|
|
6
|
+
message: string;
|
|
7
|
+
code: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveError(request: FastifyRequest, error: unknown, label: string): ResolvedError;
|
|
10
|
+
export declare function sendRouteError(request: FastifyRequest, reply: FastifyReply, error: unknown, label: string): FastifyReply;
|
|
11
|
+
export declare function onClientDisconnect(reply: FastifyReply, handler: () => void): void;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/routes/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG5D,wBAAgB,SAAS,CACvB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,YAAY,CAEd;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOxD;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,aAAa,CAUf;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,YAAY,CAGd;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAIjF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CogitatorError, ERROR_STATUS_CODES } from '@cogitator-ai/types';
|
|
2
|
+
export function sendError(reply, status, message, code) {
|
|
3
|
+
return reply.status(status).send({ error: { message, code } });
|
|
4
|
+
}
|
|
5
|
+
export function isModuleNotFound(error) {
|
|
6
|
+
return (typeof error === 'object' &&
|
|
7
|
+
error !== null &&
|
|
8
|
+
'code' in error &&
|
|
9
|
+
(error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'MODULE_NOT_FOUND'));
|
|
10
|
+
}
|
|
11
|
+
export function resolveError(request, error, label) {
|
|
12
|
+
if (CogitatorError.isCogitatorError(error)) {
|
|
13
|
+
return {
|
|
14
|
+
status: ERROR_STATUS_CODES[error.code] || 500,
|
|
15
|
+
message: error.message,
|
|
16
|
+
code: error.code,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
request.log.error({ err: error }, label);
|
|
20
|
+
return { status: 500, message: 'Internal server error', code: 'INTERNAL' };
|
|
21
|
+
}
|
|
22
|
+
export function sendRouteError(request, reply, error, label) {
|
|
23
|
+
const resolved = resolveError(request, error, label);
|
|
24
|
+
return sendError(reply, resolved.status, resolved.message, resolved.code);
|
|
25
|
+
}
|
|
26
|
+
export function onClientDisconnect(reply, handler) {
|
|
27
|
+
reply.raw.on('close', () => {
|
|
28
|
+
if (!reply.raw.writableEnded)
|
|
29
|
+
handler();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/routes/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,MAAM,UAAU,SAAS,CACvB,KAAmB,EACnB,MAAc,EACd,OAAe,EACf,IAAY;IAEZ,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAsB,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAC7E,CAAC;AACJ,CAAC;AAQD,MAAM,UAAU,YAAY,CAC1B,OAAuB,EACvB,KAAc,EACd,KAAa;IAEb,IAAI,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO;YACL,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG;YAC7C,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,OAAuB,EACvB,KAAmB,EACnB,KAAc,EACd,KAAa;IAEb,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACrD,OAAO,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAmB,EAAE,OAAmB;IACzE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa;YAAE,OAAO,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/routes/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/routes/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAiClD,eAAO,MAAM,cAAc,EAAE,kBAsI5B,CAAC"}
|
package/dist/routes/workflows.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { WorkflowRunRequestSchema } from '../types.js';
|
|
2
2
|
import { FastifyStreamWriter, generateId } from '../streaming/index.js';
|
|
3
|
+
import { isModuleNotFound, onClientDisconnect, resolveError, sendError, sendRouteError, } from './utils.js';
|
|
4
|
+
const paramsSchema = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: { name: { type: 'string' } },
|
|
7
|
+
required: ['name'],
|
|
8
|
+
};
|
|
9
|
+
const WORKFLOWS_MISSING = 'Workflows package not installed';
|
|
10
|
+
function executorOptions(body) {
|
|
11
|
+
const options = body?.options ?? {};
|
|
12
|
+
return {
|
|
13
|
+
maxConcurrency: options.maxConcurrency,
|
|
14
|
+
maxIterations: options.maxIterations,
|
|
15
|
+
checkpoint: options.checkpoint,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
3
18
|
export const workflowRoutes = async (fastify) => {
|
|
19
|
+
const findWorkflow = (name) => Object.hasOwn(fastify.cogitator.workflows, name)
|
|
20
|
+
? fastify.cogitator.workflows[name]
|
|
21
|
+
: undefined;
|
|
4
22
|
fastify.get('/workflows', async () => {
|
|
5
23
|
const workflowList = Object.entries(fastify.cogitator.workflows).map(([name, workflow]) => ({
|
|
6
24
|
name,
|
|
@@ -10,83 +28,60 @@ export const workflowRoutes = async (fastify) => {
|
|
|
10
28
|
const response = { workflows: workflowList };
|
|
11
29
|
return response;
|
|
12
30
|
});
|
|
13
|
-
fastify.post('/workflows/:name/run', {
|
|
14
|
-
schema: {
|
|
15
|
-
params: {
|
|
16
|
-
type: 'object',
|
|
17
|
-
properties: { name: { type: 'string' } },
|
|
18
|
-
required: ['name'],
|
|
19
|
-
},
|
|
20
|
-
body: WorkflowRunRequestSchema,
|
|
21
|
-
},
|
|
22
|
-
}, async (request, reply) => {
|
|
31
|
+
fastify.post('/workflows/:name/run', { schema: { params: paramsSchema, body: WorkflowRunRequestSchema } }, async (request, reply) => {
|
|
23
32
|
const { name } = request.params;
|
|
24
|
-
const workflow =
|
|
33
|
+
const workflow = findWorkflow(name);
|
|
25
34
|
if (!workflow) {
|
|
26
|
-
return reply
|
|
27
|
-
error: { message: `Workflow '${name}' not found`, code: 'NOT_FOUND' },
|
|
28
|
-
});
|
|
35
|
+
return sendError(reply, 404, `Workflow '${name}' not found`, 'NOT_FOUND');
|
|
29
36
|
}
|
|
37
|
+
const abortController = new AbortController();
|
|
38
|
+
onClientDisconnect(reply, () => abortController.abort());
|
|
30
39
|
try {
|
|
31
40
|
const { WorkflowExecutor } = await import('@cogitator-ai/workflows');
|
|
32
41
|
const executor = new WorkflowExecutor(fastify.cogitator.runtime);
|
|
33
|
-
const result = await executor.execute(workflow, request.body?.input,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
const result = await executor.execute(workflow, request.body?.input, {
|
|
43
|
+
...executorOptions(request.body),
|
|
44
|
+
signal: abortController.signal,
|
|
45
|
+
});
|
|
46
|
+
if (result.error) {
|
|
47
|
+
return sendError(reply, 500, `Workflow failed: ${result.error.message}`, 'WORKFLOW_FAILED');
|
|
37
48
|
}
|
|
38
49
|
const response = {
|
|
39
50
|
workflowId: result.workflowId,
|
|
40
51
|
workflowName: result.workflowName,
|
|
41
52
|
state: result.state,
|
|
42
53
|
duration: result.duration,
|
|
43
|
-
nodeResults,
|
|
54
|
+
nodeResults: Object.fromEntries(result.nodeResults),
|
|
44
55
|
};
|
|
45
56
|
return response;
|
|
46
57
|
}
|
|
47
58
|
catch (error) {
|
|
48
|
-
if (error
|
|
49
|
-
return reply
|
|
50
|
-
error: { message: 'Workflows package not installed', code: 'UNIMPLEMENTED' },
|
|
51
|
-
});
|
|
59
|
+
if (isModuleNotFound(error)) {
|
|
60
|
+
return sendError(reply, 501, WORKFLOWS_MISSING, 'UNIMPLEMENTED');
|
|
52
61
|
}
|
|
53
|
-
|
|
54
|
-
return reply.status(500).send({
|
|
55
|
-
error: { message, code: 'INTERNAL' },
|
|
56
|
-
});
|
|
62
|
+
return sendRouteError(request, reply, error, 'workflow run error');
|
|
57
63
|
}
|
|
58
64
|
});
|
|
59
|
-
fastify.post('/workflows/:name/stream', {
|
|
60
|
-
schema: {
|
|
61
|
-
params: {
|
|
62
|
-
type: 'object',
|
|
63
|
-
properties: { name: { type: 'string' } },
|
|
64
|
-
required: ['name'],
|
|
65
|
-
},
|
|
66
|
-
body: WorkflowRunRequestSchema,
|
|
67
|
-
},
|
|
68
|
-
}, async (request, reply) => {
|
|
65
|
+
fastify.post('/workflows/:name/stream', { schema: { params: paramsSchema, body: WorkflowRunRequestSchema } }, async (request, reply) => {
|
|
69
66
|
const { name } = request.params;
|
|
70
|
-
const workflow =
|
|
67
|
+
const workflow = findWorkflow(name);
|
|
71
68
|
if (!workflow) {
|
|
72
|
-
return reply
|
|
73
|
-
error: { message: `Workflow '${name}' not found`, code: 'NOT_FOUND' },
|
|
74
|
-
});
|
|
69
|
+
return sendError(reply, 404, `Workflow '${name}' not found`, 'NOT_FOUND');
|
|
75
70
|
}
|
|
76
71
|
const writer = new FastifyStreamWriter(reply);
|
|
77
72
|
const messageId = generateId('wf');
|
|
78
|
-
|
|
73
|
+
const abortController = new AbortController();
|
|
74
|
+
onClientDisconnect(reply, () => {
|
|
75
|
+
abortController.abort();
|
|
79
76
|
writer.close();
|
|
80
77
|
});
|
|
81
78
|
try {
|
|
82
79
|
const { WorkflowExecutor } = await import('@cogitator-ai/workflows');
|
|
83
80
|
const executor = new WorkflowExecutor(fastify.cogitator.runtime);
|
|
84
81
|
writer.start(messageId);
|
|
85
|
-
const userOptions = request.body?.options ?? {};
|
|
86
82
|
const result = await executor.execute(workflow, request.body?.input, {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
checkpoint: userOptions.checkpoint,
|
|
83
|
+
...executorOptions(request.body),
|
|
84
|
+
signal: abortController.signal,
|
|
90
85
|
onNodeStart: (node) => {
|
|
91
86
|
writer.workflowEvent('node_started', { nodeName: node, timestamp: Date.now() });
|
|
92
87
|
},
|
|
@@ -100,24 +95,30 @@ export const workflowRoutes = async (fastify) => {
|
|
|
100
95
|
writer.workflowEvent('node_progress', { nodeName: node, progress });
|
|
101
96
|
},
|
|
102
97
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
if (result.error) {
|
|
99
|
+
writer.error(`Workflow failed: ${result.error.message}`, 'WORKFLOW_FAILED');
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
writer.workflowEvent('workflow_completed', {
|
|
103
|
+
workflowId: result.workflowId,
|
|
104
|
+
duration: result.duration,
|
|
105
|
+
});
|
|
106
|
+
writer.finish(messageId);
|
|
107
|
+
}
|
|
108
108
|
}
|
|
109
109
|
catch (error) {
|
|
110
|
-
if (error
|
|
111
|
-
|
|
110
|
+
if (isModuleNotFound(error)) {
|
|
111
|
+
return sendError(reply, 501, WORKFLOWS_MISSING, 'UNIMPLEMENTED');
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
writer.error(message,
|
|
113
|
+
if (!abortController.signal.aborted) {
|
|
114
|
+
const resolved = resolveError(request, error, 'workflow stream error');
|
|
115
|
+
writer.error(resolved.message, resolved.code);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
finally {
|
|
119
119
|
writer.close();
|
|
120
120
|
}
|
|
121
|
+
return reply;
|
|
121
122
|
});
|
|
122
123
|
};
|
|
123
124
|
//# sourceMappingURL=workflows.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/routes/workflows.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../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closed;
|
|
6
|
+
private started;
|
|
6
7
|
constructor(reply: FastifyReply);
|
|
8
|
+
private get writable();
|
|
7
9
|
private write;
|
|
8
10
|
private setupHeaders;
|
|
9
11
|
start(messageId: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify-stream-writer.d.ts","sourceRoot":"","sources":["../../src/streaming/fastify-stream-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"fastify-stream-writer.d.ts","sourceRoot":"","sources":["../../src/streaming/fastify-stream-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAaL,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AAEvB,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,KAAK,EAAE,YAAY;IAI/B,OAAO,KAAK,QAAQ,GAQnB;IAED,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,YAAY;IAiBpB,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAM9B,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI3B,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1C,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIzB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIjD,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IAKtD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI7B,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,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