@cogitator-ai/fastify 0.1.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/LICENSE +21 -0
- package/README.md +380 -0
- package/dist/hooks/auth.d.ts +4 -0
- package/dist/hooks/auth.d.ts.map +1 -0
- package/dist/hooks/auth.js +23 -0
- package/dist/hooks/auth.js.map +1 -0
- package/dist/hooks/error-handler.d.ts +3 -0
- package/dist/hooks/error-handler.d.ts.map +1 -0
- package/dist/hooks/error-handler.js +24 -0
- package/dist/hooks/error-handler.js.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +90 -0
- package/dist/plugin.js.map +1 -0
- package/dist/routes/agents.d.ts +3 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +125 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/health.d.ts +3 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +15 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/index.d.ts +7 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +7 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/swarms.d.ts +3 -0
- package/dist/routes/swarms.d.ts.map +1 -0
- package/dist/routes/swarms.js +193 -0
- package/dist/routes/swarms.js.map +1 -0
- package/dist/routes/threads.d.ts +3 -0
- package/dist/routes/threads.d.ts.map +1 -0
- package/dist/routes/threads.js +122 -0
- package/dist/routes/threads.js.map +1 -0
- package/dist/routes/tools.d.ts +3 -0
- package/dist/routes/tools.d.ts.map +1 -0
- package/dist/routes/tools.js +26 -0
- package/dist/routes/tools.js.map +1 -0
- package/dist/routes/workflows.d.ts +3 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +120 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/streaming/fastify-stream-writer.d.ts +24 -0
- package/dist/streaming/fastify-stream-writer.d.ts.map +1 -0
- package/dist/streaming/fastify-stream-writer.js +75 -0
- package/dist/streaming/fastify-stream-writer.js.map +1 -0
- package/dist/streaming/helpers.d.ts +2 -0
- package/dist/streaming/helpers.d.ts.map +1 -0
- package/dist/streaming/helpers.js +2 -0
- package/dist/streaming/helpers.js.map +1 -0
- package/dist/streaming/index.d.ts +4 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +4 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/protocol.d.ts +3 -0
- package/dist/streaming/protocol.d.ts.map +1 -0
- package/dist/streaming/protocol.js +2 -0
- package/dist/streaming/protocol.js.map +1 -0
- package/dist/types.d.ts +344 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +59 -0
- package/dist/types.js.map +1 -0
- package/dist/websocket/handler.d.ts +7 -0
- package/dist/websocket/handler.d.ts.map +1 -0
- package/dist/websocket/handler.js +132 -0
- package/dist/websocket/handler.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { WorkflowRunRequestSchema } from '../types.js';
|
|
2
|
+
import { FastifyStreamWriter, generateId } from '../streaming/index.js';
|
|
3
|
+
export const workflowRoutes = async (fastify) => {
|
|
4
|
+
fastify.get('/workflows', async () => {
|
|
5
|
+
const workflowList = Object.entries(fastify.cogitator.workflows).map(([name, workflow]) => ({
|
|
6
|
+
name,
|
|
7
|
+
entryPoint: workflow.entryPoint,
|
|
8
|
+
nodes: Array.from(workflow.nodes.keys()),
|
|
9
|
+
}));
|
|
10
|
+
const response = { workflows: workflowList };
|
|
11
|
+
return response;
|
|
12
|
+
});
|
|
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) => {
|
|
23
|
+
const { name } = request.params;
|
|
24
|
+
const workflow = fastify.cogitator.workflows[name];
|
|
25
|
+
if (!workflow) {
|
|
26
|
+
return reply.status(404).send({
|
|
27
|
+
error: { message: `Workflow '${name}' not found`, code: 'NOT_FOUND' },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const { WorkflowExecutor } = await import('@cogitator-ai/workflows');
|
|
32
|
+
const executor = new WorkflowExecutor(fastify.cogitator.runtime);
|
|
33
|
+
const result = await executor.execute(workflow, request.body?.input, request.body?.options);
|
|
34
|
+
const nodeResults = {};
|
|
35
|
+
for (const [nodeName, nodeResult] of result.nodeResults.entries()) {
|
|
36
|
+
nodeResults[nodeName] = nodeResult;
|
|
37
|
+
}
|
|
38
|
+
const response = {
|
|
39
|
+
workflowId: result.workflowId,
|
|
40
|
+
workflowName: result.workflowName,
|
|
41
|
+
state: result.state,
|
|
42
|
+
duration: result.duration,
|
|
43
|
+
nodeResults,
|
|
44
|
+
};
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof Error && error.message.includes('Cannot find module')) {
|
|
49
|
+
return reply.status(501).send({
|
|
50
|
+
error: { message: 'Workflows package not installed', code: 'UNIMPLEMENTED' },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
54
|
+
return reply.status(500).send({
|
|
55
|
+
error: { message, code: 'INTERNAL' },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
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) => {
|
|
69
|
+
const { name } = request.params;
|
|
70
|
+
const workflow = fastify.cogitator.workflows[name];
|
|
71
|
+
if (!workflow) {
|
|
72
|
+
return reply.status(404).send({
|
|
73
|
+
error: { message: `Workflow '${name}' not found`, code: 'NOT_FOUND' },
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const writer = new FastifyStreamWriter(reply);
|
|
77
|
+
const messageId = generateId('wf');
|
|
78
|
+
request.raw.on('close', () => {
|
|
79
|
+
writer.close();
|
|
80
|
+
});
|
|
81
|
+
try {
|
|
82
|
+
const { WorkflowExecutor } = await import('@cogitator-ai/workflows');
|
|
83
|
+
const executor = new WorkflowExecutor(fastify.cogitator.runtime);
|
|
84
|
+
writer.start(messageId);
|
|
85
|
+
const result = await executor.execute(workflow, request.body?.input, {
|
|
86
|
+
...request.body?.options,
|
|
87
|
+
onNodeStart: (node) => {
|
|
88
|
+
writer.workflowEvent('node_started', { nodeName: node, timestamp: Date.now() });
|
|
89
|
+
},
|
|
90
|
+
onNodeComplete: (node, output, duration) => {
|
|
91
|
+
writer.workflowEvent('node_completed', { nodeName: node, output, duration });
|
|
92
|
+
},
|
|
93
|
+
onNodeError: (node, error) => {
|
|
94
|
+
writer.workflowEvent('node_error', { nodeName: node, error: error.message });
|
|
95
|
+
},
|
|
96
|
+
onNodeProgress: (node, progress) => {
|
|
97
|
+
writer.workflowEvent('node_progress', { nodeName: node, progress });
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
writer.workflowEvent('workflow_completed', {
|
|
101
|
+
workflowId: result.workflowId,
|
|
102
|
+
duration: result.duration,
|
|
103
|
+
});
|
|
104
|
+
writer.finish(messageId);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (error instanceof Error && error.message.includes('Cannot find module')) {
|
|
108
|
+
writer.error('Workflows package not installed', 'UNIMPLEMENTED');
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
112
|
+
writer.error(message, 'INTERNAL');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
writer.close();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=workflows.js.map
|
|
@@ -0,0 +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;AAMxE,MAAM,CAAC,MAAM,cAAc,GAAuB,KAAK,EAAE,OAAO,EAAE,EAAE;IAClE,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1F,IAAI;YACJ,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SACzC,CAAC,CAAC,CAAC;QAEJ,MAAM,QAAQ,GAAyB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;QACnE,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,IAAI,CACV,sBAAsB,EACtB;QACE,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI,EAAE,QA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AAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC/E,CAAC;gBACD,cAAc,EAAE,CAAC,IAAY,EAAE,QAAgB,EAAE,EAAE;oBACjD,MAAM,CAAC,aAAa,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACtE,CAAC;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,aAAa,CAAC,oBAAoB,EAAE;gBACzC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;gBAC3E,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,eAAe,CAAC,CAAC;YACnE,CAAC;iBAAM,CAAC;gBACN,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;gBACzE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FastifyReply } from 'fastify';
|
|
2
|
+
import { type Usage } from './protocol.js';
|
|
3
|
+
export declare class FastifyStreamWriter {
|
|
4
|
+
private reply;
|
|
5
|
+
private closed;
|
|
6
|
+
constructor(reply: FastifyReply);
|
|
7
|
+
private write;
|
|
8
|
+
setupHeaders(): void;
|
|
9
|
+
start(messageId: string): void;
|
|
10
|
+
textStart(id: string): void;
|
|
11
|
+
textDelta(id: string, delta: string): void;
|
|
12
|
+
textEnd(id: string): void;
|
|
13
|
+
toolCallStart(id: string, toolName: string): void;
|
|
14
|
+
toolCallDelta(id: string, argsTextDelta: string): void;
|
|
15
|
+
toolCallEnd(id: string): void;
|
|
16
|
+
toolResult(id: string, toolCallId: string, result: unknown): void;
|
|
17
|
+
workflowEvent(event: string, data: unknown): void;
|
|
18
|
+
swarmEvent(event: string, data: unknown): void;
|
|
19
|
+
error(message: string, code?: string): void;
|
|
20
|
+
finish(messageId: string, usage?: Usage): void;
|
|
21
|
+
close(): void;
|
|
22
|
+
get isClosed(): boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=fastify-stream-writer.d.ts.map
|
|
@@ -0,0 +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;AAE5C,OAAO,EAaL,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AAEvB,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,MAAM,CAAS;gBAEX,KAAK,EAAE,YAAY;IAI/B,OAAO,CAAC,KAAK;IAKb,YAAY,IAAI,IAAI;IASpB,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAK9B,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;IAItD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI7B,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAIjE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI;IAIjD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI;IAI9C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAI3C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;IAK9C,KAAK,IAAI,IAAI;IAQb,IAAI,QAAQ,IAAI,OAAO,CAEtB;CACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { encodeSSE, encodeDone } from './helpers.js';
|
|
2
|
+
import { createStartEvent, createTextStartEvent, createTextDeltaEvent, createTextEndEvent, createToolCallStartEvent, createToolCallDeltaEvent, createToolCallEndEvent, createToolResultEvent, createErrorEvent, createFinishEvent, createWorkflowEvent, createSwarmEvent, } from './protocol.js';
|
|
3
|
+
export class FastifyStreamWriter {
|
|
4
|
+
reply;
|
|
5
|
+
closed = false;
|
|
6
|
+
constructor(reply) {
|
|
7
|
+
this.reply = reply;
|
|
8
|
+
}
|
|
9
|
+
write(data) {
|
|
10
|
+
if (this.closed)
|
|
11
|
+
return;
|
|
12
|
+
this.reply.raw.write(encodeSSE(data));
|
|
13
|
+
}
|
|
14
|
+
setupHeaders() {
|
|
15
|
+
this.reply.raw.writeHead(200, {
|
|
16
|
+
'Content-Type': 'text/event-stream',
|
|
17
|
+
'Cache-Control': 'no-cache',
|
|
18
|
+
Connection: 'keep-alive',
|
|
19
|
+
'X-Accel-Buffering': 'no',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
start(messageId) {
|
|
23
|
+
this.setupHeaders();
|
|
24
|
+
this.write(createStartEvent(messageId));
|
|
25
|
+
}
|
|
26
|
+
textStart(id) {
|
|
27
|
+
this.write(createTextStartEvent(id));
|
|
28
|
+
}
|
|
29
|
+
textDelta(id, delta) {
|
|
30
|
+
if (!delta)
|
|
31
|
+
return;
|
|
32
|
+
this.write(createTextDeltaEvent(id, delta));
|
|
33
|
+
}
|
|
34
|
+
textEnd(id) {
|
|
35
|
+
this.write(createTextEndEvent(id));
|
|
36
|
+
}
|
|
37
|
+
toolCallStart(id, toolName) {
|
|
38
|
+
this.write(createToolCallStartEvent(id, toolName));
|
|
39
|
+
}
|
|
40
|
+
toolCallDelta(id, argsTextDelta) {
|
|
41
|
+
this.write(createToolCallDeltaEvent(id, argsTextDelta));
|
|
42
|
+
}
|
|
43
|
+
toolCallEnd(id) {
|
|
44
|
+
this.write(createToolCallEndEvent(id));
|
|
45
|
+
}
|
|
46
|
+
toolResult(id, toolCallId, result) {
|
|
47
|
+
this.write(createToolResultEvent(id, toolCallId, result));
|
|
48
|
+
}
|
|
49
|
+
workflowEvent(event, data) {
|
|
50
|
+
this.write(createWorkflowEvent(event, data));
|
|
51
|
+
}
|
|
52
|
+
swarmEvent(event, data) {
|
|
53
|
+
this.write(createSwarmEvent(event, data));
|
|
54
|
+
}
|
|
55
|
+
error(message, code) {
|
|
56
|
+
this.write(createErrorEvent(message, code));
|
|
57
|
+
}
|
|
58
|
+
finish(messageId, usage) {
|
|
59
|
+
this.write(createFinishEvent(messageId, usage));
|
|
60
|
+
this.reply.raw.write(encodeDone());
|
|
61
|
+
}
|
|
62
|
+
close() {
|
|
63
|
+
if (this.closed)
|
|
64
|
+
return;
|
|
65
|
+
this.closed = true;
|
|
66
|
+
try {
|
|
67
|
+
this.reply.raw.end();
|
|
68
|
+
}
|
|
69
|
+
catch { }
|
|
70
|
+
}
|
|
71
|
+
get isClosed() {
|
|
72
|
+
return this.closed;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=fastify-stream-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fastify-stream-writer.js","sourceRoot":"","sources":["../../src/streaming/fastify-stream-writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GAEjB,MAAM,eAAe,CAAC;AAEvB,MAAM,OAAO,mBAAmB;IACtB,KAAK,CAAe;IACpB,MAAM,GAAG,KAAK,CAAC;IAEvB,YAAY,KAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,IAAa;QACzB,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,YAAY;QACV,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;YAC5B,cAAc,EAAE,mBAAmB;YACnC,eAAe,EAAE,UAAU;YAC3B,UAAU,EAAE,YAAY;YACxB,mBAAmB,EAAE,IAAI;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAiB;QACrB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,SAAS,CAAC,EAAU;QAClB,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,SAAS,CAAC,EA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C,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/streaming/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/streaming/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createStartEvent, createTextStartEvent, createTextDeltaEvent, createTextEndEvent, createToolCallStartEvent, createToolCallDeltaEvent, createToolCallEndEvent, createToolResultEvent, createErrorEvent, createFinishEvent, createWorkflowEvent, createSwarmEvent, } from '@cogitator-ai/server-shared';
|
|
2
|
+
export type { Usage, StreamEvent, StartEvent, TextStartEvent, TextDeltaEvent, TextEndEvent, ToolCallStartEvent, ToolCallDeltaEvent, ToolCallEndEvent, ToolResultEvent, ErrorEvent, FinishEvent, WorkflowEvent, SwarmEvent, } from '@cogitator-ai/server-shared';
|
|
3
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/streaming/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAErC,YAAY,EACV,KAAK,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,WAAW,EACX,aAAa,EACb,UAAU,GACX,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createStartEvent, createTextStartEvent, createTextDeltaEvent, createTextEndEvent, createToolCallStartEvent, createToolCallDeltaEvent, createToolCallEndEvent, createToolResultEvent, createErrorEvent, createFinishEvent, createWorkflowEvent, createSwarmEvent, } from '@cogitator-ai/server-shared';
|
|
2
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/streaming/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import type { FastifyRequest } from 'fastify';
|
|
2
|
+
import type { Cogitator, Agent } from '@cogitator-ai/core';
|
|
3
|
+
import type { Message, ToolCall, ToolResult, RunResult, Workflow, WorkflowResult, WorkflowState, SwarmConfig, SwarmResult, SwarmRunOptions, StreamingWorkflowEvent, SwarmEvent, SwarmMessage } from '@cogitator-ai/types';
|
|
4
|
+
export type { Message, ToolCall, ToolResult, RunResult, Workflow, WorkflowResult, WorkflowState, SwarmConfig, SwarmResult, SwarmRunOptions, StreamingWorkflowEvent, SwarmEvent, SwarmMessage, };
|
|
5
|
+
export interface AuthContext {
|
|
6
|
+
userId?: string;
|
|
7
|
+
roles?: string[];
|
|
8
|
+
permissions?: string[];
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export type AuthFunction = (request: FastifyRequest) => Promise<AuthContext | undefined> | AuthContext | undefined;
|
|
12
|
+
export interface RateLimitConfig {
|
|
13
|
+
max: number;
|
|
14
|
+
timeWindow: number | string;
|
|
15
|
+
keyGenerator?: (request: FastifyRequest) => string;
|
|
16
|
+
errorResponseBuilder?: (request: FastifyRequest, context: {
|
|
17
|
+
max: number;
|
|
18
|
+
ttl: number;
|
|
19
|
+
}) => {
|
|
20
|
+
statusCode: number;
|
|
21
|
+
error: string;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface SwaggerConfig {
|
|
26
|
+
title?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
version?: string;
|
|
29
|
+
contact?: {
|
|
30
|
+
name?: string;
|
|
31
|
+
email?: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
};
|
|
34
|
+
license?: {
|
|
35
|
+
name: string;
|
|
36
|
+
url?: string;
|
|
37
|
+
};
|
|
38
|
+
servers?: Array<{
|
|
39
|
+
url: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
export interface WebSocketConfig {
|
|
44
|
+
path?: string;
|
|
45
|
+
pingInterval?: number;
|
|
46
|
+
pingTimeout?: number;
|
|
47
|
+
maxPayloadSize?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface CogitatorPluginOptions {
|
|
50
|
+
cogitator: Cogitator;
|
|
51
|
+
agents?: Record<string, Agent>;
|
|
52
|
+
workflows?: Record<string, Workflow<WorkflowState>>;
|
|
53
|
+
swarms?: Record<string, SwarmConfig>;
|
|
54
|
+
prefix?: string;
|
|
55
|
+
auth?: AuthFunction;
|
|
56
|
+
rateLimit?: RateLimitConfig;
|
|
57
|
+
enableSwagger?: boolean;
|
|
58
|
+
enableWebSocket?: boolean;
|
|
59
|
+
swagger?: SwaggerConfig;
|
|
60
|
+
websocket?: WebSocketConfig;
|
|
61
|
+
requestTimeout?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface CogitatorContext {
|
|
64
|
+
runtime: Cogitator;
|
|
65
|
+
agents: Record<string, Agent>;
|
|
66
|
+
workflows: Record<string, Workflow<WorkflowState>>;
|
|
67
|
+
swarms: Record<string, SwarmConfig>;
|
|
68
|
+
}
|
|
69
|
+
declare module 'fastify' {
|
|
70
|
+
interface FastifyInstance {
|
|
71
|
+
cogitator: CogitatorContext;
|
|
72
|
+
}
|
|
73
|
+
interface FastifyRequest {
|
|
74
|
+
cogitatorAuth?: AuthContext;
|
|
75
|
+
cogitatorRequestId: string;
|
|
76
|
+
cogitatorStartTime: number;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export interface AgentListResponse {
|
|
80
|
+
agents: Array<{
|
|
81
|
+
name: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
tools: string[];
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
export interface AgentRunRequest {
|
|
87
|
+
input: string;
|
|
88
|
+
context?: Record<string, unknown>;
|
|
89
|
+
threadId?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface AgentRunResponse {
|
|
92
|
+
output: string;
|
|
93
|
+
threadId?: string;
|
|
94
|
+
usage: {
|
|
95
|
+
inputTokens: number;
|
|
96
|
+
outputTokens: number;
|
|
97
|
+
totalTokens: number;
|
|
98
|
+
};
|
|
99
|
+
toolCalls: ToolCall[];
|
|
100
|
+
}
|
|
101
|
+
export interface ThreadResponse {
|
|
102
|
+
id: string;
|
|
103
|
+
messages: Message[];
|
|
104
|
+
metadata?: Record<string, unknown>;
|
|
105
|
+
createdAt: number;
|
|
106
|
+
updatedAt: number;
|
|
107
|
+
}
|
|
108
|
+
export interface AddMessageRequest {
|
|
109
|
+
role: 'user' | 'assistant' | 'system';
|
|
110
|
+
content: string;
|
|
111
|
+
metadata?: Record<string, unknown>;
|
|
112
|
+
}
|
|
113
|
+
export interface ToolListResponse {
|
|
114
|
+
tools: Array<{
|
|
115
|
+
name: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
parameters: Record<string, unknown>;
|
|
118
|
+
}>;
|
|
119
|
+
}
|
|
120
|
+
export interface WorkflowListResponse {
|
|
121
|
+
workflows: Array<{
|
|
122
|
+
name: string;
|
|
123
|
+
entryPoint: string;
|
|
124
|
+
nodes: string[];
|
|
125
|
+
}>;
|
|
126
|
+
}
|
|
127
|
+
export interface WorkflowRunRequest {
|
|
128
|
+
input?: Record<string, unknown>;
|
|
129
|
+
options?: {
|
|
130
|
+
maxConcurrency?: number;
|
|
131
|
+
maxIterations?: number;
|
|
132
|
+
checkpoint?: boolean;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export interface WorkflowRunResponse {
|
|
136
|
+
workflowId: string;
|
|
137
|
+
workflowName: string;
|
|
138
|
+
state: WorkflowState;
|
|
139
|
+
duration: number;
|
|
140
|
+
nodeResults: Record<string, {
|
|
141
|
+
output: unknown;
|
|
142
|
+
duration: number;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
145
|
+
export interface WorkflowStatusResponse {
|
|
146
|
+
runId: string;
|
|
147
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
148
|
+
currentNode?: string;
|
|
149
|
+
progress?: number;
|
|
150
|
+
error?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface SwarmListResponse {
|
|
153
|
+
swarms: Array<{
|
|
154
|
+
name: string;
|
|
155
|
+
strategy: string;
|
|
156
|
+
agents: string[];
|
|
157
|
+
}>;
|
|
158
|
+
}
|
|
159
|
+
export interface SwarmRunRequest {
|
|
160
|
+
input: string;
|
|
161
|
+
context?: Record<string, unknown>;
|
|
162
|
+
threadId?: string;
|
|
163
|
+
timeout?: number;
|
|
164
|
+
}
|
|
165
|
+
export interface SwarmRunResponse {
|
|
166
|
+
swarmId: string;
|
|
167
|
+
swarmName: string;
|
|
168
|
+
strategy: string;
|
|
169
|
+
output: unknown;
|
|
170
|
+
agentResults: Record<string, unknown>;
|
|
171
|
+
usage: {
|
|
172
|
+
totalTokens: number;
|
|
173
|
+
totalCost: number;
|
|
174
|
+
elapsedTime: number;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
export interface BlackboardResponse {
|
|
178
|
+
sections: Record<string, unknown>;
|
|
179
|
+
}
|
|
180
|
+
export interface HealthResponse {
|
|
181
|
+
status: 'ok' | 'degraded' | 'error';
|
|
182
|
+
version?: string;
|
|
183
|
+
uptime: number;
|
|
184
|
+
timestamp: number;
|
|
185
|
+
checks?: Record<string, {
|
|
186
|
+
status: 'ok' | 'error';
|
|
187
|
+
message?: string;
|
|
188
|
+
}>;
|
|
189
|
+
}
|
|
190
|
+
export interface ErrorResponse {
|
|
191
|
+
error: {
|
|
192
|
+
message: string;
|
|
193
|
+
code?: string;
|
|
194
|
+
details?: unknown;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export interface WebSocketMessage {
|
|
198
|
+
type: 'subscribe' | 'unsubscribe' | 'run' | 'stop' | 'ping';
|
|
199
|
+
id?: string;
|
|
200
|
+
channel?: string;
|
|
201
|
+
payload?: unknown;
|
|
202
|
+
}
|
|
203
|
+
export interface WebSocketResponse {
|
|
204
|
+
type: 'subscribed' | 'unsubscribed' | 'event' | 'error' | 'pong';
|
|
205
|
+
id?: string;
|
|
206
|
+
channel?: string;
|
|
207
|
+
payload?: unknown;
|
|
208
|
+
error?: string;
|
|
209
|
+
}
|
|
210
|
+
export interface OpenAPISpec {
|
|
211
|
+
openapi: string;
|
|
212
|
+
info: {
|
|
213
|
+
title: string;
|
|
214
|
+
description?: string;
|
|
215
|
+
version: string;
|
|
216
|
+
contact?: {
|
|
217
|
+
name?: string;
|
|
218
|
+
email?: string;
|
|
219
|
+
url?: string;
|
|
220
|
+
};
|
|
221
|
+
license?: {
|
|
222
|
+
name: string;
|
|
223
|
+
url?: string;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
servers?: Array<{
|
|
227
|
+
url: string;
|
|
228
|
+
description?: string;
|
|
229
|
+
}>;
|
|
230
|
+
paths: Record<string, Record<string, unknown>>;
|
|
231
|
+
components?: {
|
|
232
|
+
schemas?: Record<string, unknown>;
|
|
233
|
+
securitySchemes?: Record<string, unknown>;
|
|
234
|
+
};
|
|
235
|
+
security?: Array<Record<string, string[]>>;
|
|
236
|
+
tags?: Array<{
|
|
237
|
+
name: string;
|
|
238
|
+
description?: string;
|
|
239
|
+
}>;
|
|
240
|
+
}
|
|
241
|
+
export declare const AgentRunRequestSchema: {
|
|
242
|
+
readonly type: "object";
|
|
243
|
+
readonly properties: {
|
|
244
|
+
readonly input: {
|
|
245
|
+
readonly type: "string";
|
|
246
|
+
};
|
|
247
|
+
readonly context: {
|
|
248
|
+
readonly type: "object";
|
|
249
|
+
readonly additionalProperties: true;
|
|
250
|
+
};
|
|
251
|
+
readonly threadId: {
|
|
252
|
+
readonly type: "string";
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
readonly required: readonly ["input"];
|
|
256
|
+
};
|
|
257
|
+
export declare const AgentRunResponseSchema: {
|
|
258
|
+
readonly type: "object";
|
|
259
|
+
readonly properties: {
|
|
260
|
+
readonly output: {
|
|
261
|
+
readonly type: "string";
|
|
262
|
+
};
|
|
263
|
+
readonly threadId: {
|
|
264
|
+
readonly type: "string";
|
|
265
|
+
};
|
|
266
|
+
readonly usage: {
|
|
267
|
+
readonly type: "object";
|
|
268
|
+
readonly properties: {
|
|
269
|
+
readonly inputTokens: {
|
|
270
|
+
readonly type: "number";
|
|
271
|
+
};
|
|
272
|
+
readonly outputTokens: {
|
|
273
|
+
readonly type: "number";
|
|
274
|
+
};
|
|
275
|
+
readonly totalTokens: {
|
|
276
|
+
readonly type: "number";
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
readonly toolCalls: {
|
|
281
|
+
readonly type: "array";
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
export declare const AddMessageRequestSchema: {
|
|
286
|
+
readonly type: "object";
|
|
287
|
+
readonly properties: {
|
|
288
|
+
readonly role: {
|
|
289
|
+
readonly type: "string";
|
|
290
|
+
readonly enum: readonly ["user", "assistant", "system"];
|
|
291
|
+
};
|
|
292
|
+
readonly content: {
|
|
293
|
+
readonly type: "string";
|
|
294
|
+
};
|
|
295
|
+
readonly metadata: {
|
|
296
|
+
readonly type: "object";
|
|
297
|
+
readonly additionalProperties: true;
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
readonly required: readonly ["role", "content"];
|
|
301
|
+
};
|
|
302
|
+
export declare const WorkflowRunRequestSchema: {
|
|
303
|
+
readonly type: "object";
|
|
304
|
+
readonly properties: {
|
|
305
|
+
readonly input: {
|
|
306
|
+
readonly type: "object";
|
|
307
|
+
readonly additionalProperties: true;
|
|
308
|
+
};
|
|
309
|
+
readonly options: {
|
|
310
|
+
readonly type: "object";
|
|
311
|
+
readonly properties: {
|
|
312
|
+
readonly maxConcurrency: {
|
|
313
|
+
readonly type: "number";
|
|
314
|
+
};
|
|
315
|
+
readonly maxIterations: {
|
|
316
|
+
readonly type: "number";
|
|
317
|
+
};
|
|
318
|
+
readonly checkpoint: {
|
|
319
|
+
readonly type: "boolean";
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
export declare const SwarmRunRequestSchema: {
|
|
326
|
+
readonly type: "object";
|
|
327
|
+
readonly properties: {
|
|
328
|
+
readonly input: {
|
|
329
|
+
readonly type: "string";
|
|
330
|
+
};
|
|
331
|
+
readonly context: {
|
|
332
|
+
readonly type: "object";
|
|
333
|
+
readonly additionalProperties: true;
|
|
334
|
+
};
|
|
335
|
+
readonly threadId: {
|
|
336
|
+
readonly type: "string";
|
|
337
|
+
};
|
|
338
|
+
readonly timeout: {
|
|
339
|
+
readonly type: "number";
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
readonly required: readonly ["input"];
|
|
343
|
+
};
|
|
344
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAQ,EACR,cAAc,EACd,aAAa,EACb,WAAW,EACX,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,YAAY,EACb,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,OAAO,EACP,QAAQ,EACR,U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