@receptron/graphai_express 0.0.26 → 0.0.28

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 CHANGED
@@ -13,27 +13,38 @@ yarn add @receptron/graphai_express
13
13
 
14
14
  import express from "express";
15
15
  import * as agents from "@graphai/agents";
16
- import { agentDispatcher, nonStreamAgentDispatcher, streamAgentDispatcher, agentsList, agentDoc } from "@receptron/graphai_express";
16
+ import { agentDispatcher, nonStreamAgentDispatcher, streamAgentDispatcher, agentsList, agentDoc, graphRunner} from "@receptron/graphai_express";
17
17
  import { AgentFunctionInfoDictionary } from "graphai";
18
18
 
19
19
  const agentDictionary: AgentFunctionInfoDictionary = agents;
20
20
  const hostName = "https://example.net";
21
- const apiPrefix = "/api/agents";
21
+ const apiAgentPrefix = "/api/agents";
22
+ const apiGraphPrefix = "/api/graph";
22
23
 
23
- app.get(apiPrefix + "/:agentId", agentDoc(agentDictionary, hostName, apiPrefix)); // each API(agent) document
24
- app.get(apiPrefix + "/", agentsList(agentDictionary, hostName, apiPrefix)); // API(agent) list
24
+ app.get(apiAgentPrefix + "/:agentId", agentDoc(agentDictionary, hostName, apiAgentPrefix)); // each API(agent) document
25
+ app.get(apiAgentPrefix + "/", agentsList(agentDictionary, hostName, apiAgentPrefix)); // API(agent) list
25
26
 
26
- // non stream and strwam
27
- app.post(apiPrefix + "/:agentId", agentDispatcher(agentDictionary));
27
+ // non stream and stream agent server
28
+ app.post(apiAgentPrefix + "/:agentId", agentDispatcher(agentDictionary));
28
29
 
29
- // non stream
30
- app.post(apiPrefix + "/nonstream/:agentId", nonStreamAgentDispatcher(agentDictionary));
30
+ // non stream agent server
31
+ app.post(apiAgentPrefix + "/nonstream/:agentId", nonStreamAgentDispatcher(agentDictionary));
32
+
33
+ // stream agent server
34
+ app.post(apiAgentPrefix + "/stream/:agentId", streamAgentDispatcher(agentDictionary));
35
+
36
+ // non stream and stream agent server
37
+ app.post(apiGraphPrefix + "/", graphRunner(agentDictionary));
31
38
 
32
- // stream
33
- app.post(apiPrefix + "/stream/:agentId", streamAgentDispatcher(agentDictionary));
34
39
 
35
40
  ```
36
41
 
42
+ ### Run Test server
43
+
44
+ ```
45
+ yarn run server
46
+ ```
47
+
37
48
 
38
49
  ### Test from curl
39
50
 
@@ -43,8 +54,9 @@ curl -X POST -H "Content-Type: application/json" -d '{"params": {"message" : "he
43
54
 
44
55
  ### from GraphAI Client
45
56
 
46
- T.B.D.
47
-
57
+ ```
58
+ npx ts-node test/stream_graph.ts
59
+ ```
48
60
 
49
61
  ### for this middleware development
50
62
 
@@ -0,0 +1,9 @@
1
+ import express from "express";
2
+ import type { AgentFunctionInfoDictionary, AgentFilterInfo } from "graphai";
3
+ import { StreamChunkCallback } from "./type";
4
+ export declare const agentsList: (agentDictionary: AgentFunctionInfoDictionary, hostName?: string, urlPath?: string) => (req: express.Request, res: express.Response) => Promise<void>;
5
+ export declare const agentDoc: (agentDictionary: AgentFunctionInfoDictionary, hostName?: string, urlPath?: string) => (req: express.Request, res: express.Response) => Promise<void>;
6
+ export declare const agentDispatcher: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[], streamChunkCallback?: StreamChunkCallback) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
7
+ export declare const agentRunner: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[], streamChunkCallback?: StreamChunkCallback) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
8
+ export declare const nonStreamAgentDispatcher: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[], isDispatch?: boolean) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
9
+ export declare const streamAgentDispatcher: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[], isDispatch?: boolean, streamChunkCallback?: StreamChunkCallback) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
package/lib/agents.js ADDED
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.streamAgentDispatcher = exports.nonStreamAgentDispatcher = exports.agentRunner = exports.agentDispatcher = exports.agentDoc = exports.agentsList = void 0;
4
+ const agent_filters_1 = require("@graphai/agent_filters");
5
+ // express middleware
6
+ // return agent list
7
+ const agentsList = (agentDictionary, hostName = "https://example.com", urlPath = "/agent") => {
8
+ return async (req, res) => {
9
+ const list = Object.keys(agentDictionary).map((agentName) => {
10
+ const agent = agentDictionary[agentName];
11
+ return {
12
+ agentId: agentName,
13
+ name: agent.name,
14
+ url: hostName + urlPath + "/" + agentName,
15
+ description: agent.description,
16
+ category: agent.category,
17
+ author: agent.author,
18
+ license: agent.license,
19
+ repository: agent.repository,
20
+ samples: agent.samples,
21
+ inputs: agent.inputs,
22
+ output: agent.output,
23
+ stream: agent.stream ?? false,
24
+ };
25
+ });
26
+ res.json({ agents: list });
27
+ };
28
+ };
29
+ exports.agentsList = agentsList;
30
+ // express middleware
31
+ // return agent detail info
32
+ const agentDoc = (agentDictionary, hostName = "https://example.com", urlPath = "/agent") => {
33
+ return async (req, res) => {
34
+ const { params } = req;
35
+ const { agentId } = params;
36
+ const agent = agentDictionary[agentId];
37
+ if (agent === undefined) {
38
+ res.status(404).send("Not found");
39
+ return;
40
+ }
41
+ const result = {
42
+ agentId: agentId,
43
+ name: agent.name,
44
+ url: hostName + urlPath + "/" + agentId,
45
+ description: agent.description,
46
+ category: agent.category,
47
+ samples: agent.samples,
48
+ author: agent.author,
49
+ license: agent.license,
50
+ repository: agent.repository,
51
+ };
52
+ res.json(result);
53
+ };
54
+ };
55
+ exports.agentDoc = agentDoc;
56
+ // express middleware
57
+ // dispatch and run agent
58
+ // app.post(apiPrefix + "/:agentId", agentDispatcher(agentDictionary));
59
+ const agentDispatcher = (agentDictionary, agentFilters = [], streamChunkCallback) => {
60
+ const nonStram = (0, exports.nonStreamAgentDispatcher)(agentDictionary, agentFilters, true);
61
+ const stream = (0, exports.streamAgentDispatcher)(agentDictionary, agentFilters, true, streamChunkCallback);
62
+ return async (req, res, next) => {
63
+ const isStreaming = (req.headers["content-type"] || "").startsWith("text/event-stream");
64
+ if (isStreaming) {
65
+ return await stream(req, res, next);
66
+ }
67
+ return await nonStram(req, res, next);
68
+ };
69
+ };
70
+ exports.agentDispatcher = agentDispatcher;
71
+ // express middleware
72
+ // run agent
73
+ // app.post(agentPrefix, agentRunner(agentDictionary));
74
+ const agentRunner = (agentDictionary, agentFilters = [], streamChunkCallback) => {
75
+ const nonStram = (0, exports.nonStreamAgentDispatcher)(agentDictionary, agentFilters, false);
76
+ const stream = (0, exports.streamAgentDispatcher)(agentDictionary, agentFilters, false, streamChunkCallback);
77
+ return async (req, res, next) => {
78
+ const isStreaming = (req.headers["content-type"] || "").startsWith("text/event-stream");
79
+ if (isStreaming) {
80
+ return await stream(req, res, next);
81
+ }
82
+ return await nonStram(req, res, next);
83
+ };
84
+ };
85
+ exports.agentRunner = agentRunner;
86
+ // express middleware
87
+ // run agent
88
+ const nonStreamAgentDispatcher = (agentDictionary, agentFilters = [], isDispatch = true) => {
89
+ return async (req, res, next) => {
90
+ try {
91
+ const dispatcher = agentDispatcherInternal(agentDictionary, agentFilters, isDispatch);
92
+ const result = await dispatcher(req, res);
93
+ return res.json(result);
94
+ }
95
+ catch (e) {
96
+ next(e);
97
+ }
98
+ };
99
+ };
100
+ exports.nonStreamAgentDispatcher = nonStreamAgentDispatcher;
101
+ // express middleware
102
+ // run agent with streaming
103
+ const streamAgentDispatcher = (agentDictionary, agentFilters = [], isDispatch = true, streamChunkCallback) => {
104
+ return async (req, res, next) => {
105
+ try {
106
+ res.setHeader("Content-Type", "text/event-stream;charset=utf-8");
107
+ res.setHeader("Cache-Control", "no-cache, no-transform");
108
+ res.setHeader("X-Accel-Buffering", "no");
109
+ const callback = (context, token) => {
110
+ if (token) {
111
+ if (streamChunkCallback) {
112
+ res.write(streamChunkCallback(context, token));
113
+ }
114
+ else {
115
+ res.write(token);
116
+ }
117
+ }
118
+ };
119
+ const streamAgentFilter = {
120
+ name: "streamAgentFilter",
121
+ agent: (0, agent_filters_1.streamAgentFilterGenerator)(callback),
122
+ };
123
+ const filterList = [...agentFilters, streamAgentFilter];
124
+ const dispatcher = agentDispatcherInternal(agentDictionary, filterList, isDispatch);
125
+ const result = await dispatcher(req, res);
126
+ const json_data = JSON.stringify(result);
127
+ res.write("___END___");
128
+ res.write(json_data);
129
+ return res.end();
130
+ }
131
+ catch (e) {
132
+ next(e);
133
+ }
134
+ };
135
+ };
136
+ exports.streamAgentDispatcher = streamAgentDispatcher;
137
+ // dispatcher internal function
138
+ const agentDispatcherInternal = (agentDictionary, agentFilters = [], isDispatch = true) => {
139
+ return async (req, res) => {
140
+ const { params } = req;
141
+ const { agentId } = isDispatch ? params : req.body;
142
+ const { nodeId, retry, params: agentParams, inputs, namedInputs } = req.body;
143
+ const agent = agentDictionary[agentId];
144
+ if (agent === undefined) {
145
+ res.status(404).send("Not found");
146
+ return;
147
+ }
148
+ const context = {
149
+ params: agentParams || {},
150
+ inputs,
151
+ namedInputs,
152
+ debugInfo: {
153
+ nodeId,
154
+ retry,
155
+ verbose: false,
156
+ },
157
+ agents: agentDictionary,
158
+ filterParams: {},
159
+ };
160
+ const agentFilterRunner = (0, agent_filters_1.agentFilterRunnerBuilder)(agentFilters);
161
+ const result = await agentFilterRunner(context, agent.agent);
162
+ return result;
163
+ };
164
+ };
package/lib/graph.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import express from "express";
2
+ import type { AgentFunctionInfoDictionary, AgentFilterInfo } from "graphai";
3
+ import { StreamChunkCallback } from "./type";
4
+ export declare const graphRunner: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[], streamChunkCallback?: StreamChunkCallback) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
5
+ export declare const streamGraphRunner: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[], streamChunkCallback?: StreamChunkCallback) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
6
+ export declare const nonStreamGraphRunner: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[]) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
package/lib/graph.js ADDED
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nonStreamGraphRunner = exports.streamGraphRunner = exports.graphRunner = void 0;
4
+ const graphai_1 = require("graphai");
5
+ const agent_filters_1 = require("@graphai/agent_filters");
6
+ const graphRunner = (agentDictionary, agentFilters = [], streamChunkCallback) => {
7
+ const stream = (0, exports.streamGraphRunner)(agentDictionary, agentFilters, streamChunkCallback);
8
+ const nonStream = (0, exports.nonStreamGraphRunner)(agentDictionary, agentFilters);
9
+ return async (req, res, next) => {
10
+ const isStreaming = (req.headers["content-type"] || "").startsWith("text/event-stream");
11
+ if (isStreaming) {
12
+ return await stream(req, res, next);
13
+ }
14
+ return await nonStream(req, res, next);
15
+ };
16
+ };
17
+ exports.graphRunner = graphRunner;
18
+ const streamGraphRunner = (agentDictionary, agentFilters = [], streamChunkCallback) => {
19
+ return async (req, res, next) => {
20
+ try {
21
+ res.setHeader("Content-Type", "text/event-stream;charset=utf-8");
22
+ res.setHeader("Cache-Control", "no-cache, no-transform");
23
+ res.setHeader("X-Accel-Buffering", "no");
24
+ const streamCallback = (context, token) => {
25
+ if (token) {
26
+ if (streamChunkCallback) {
27
+ res.write(streamChunkCallback(context, token));
28
+ }
29
+ else {
30
+ res.write(token);
31
+ }
32
+ }
33
+ };
34
+ const streamAgentFilter = {
35
+ name: "streamAgentFilter",
36
+ agent: (0, agent_filters_1.streamAgentFilterGenerator)(streamCallback),
37
+ };
38
+ const filterList = [...agentFilters, streamAgentFilter];
39
+ const dispatcher = streamGraphRunnerInternal(agentDictionary, filterList);
40
+ const result = await dispatcher(req, res);
41
+ const json_data = JSON.stringify(result);
42
+ res.write("___END___");
43
+ res.write(json_data);
44
+ return res.end();
45
+ }
46
+ catch (e) {
47
+ next(e);
48
+ }
49
+ };
50
+ };
51
+ exports.streamGraphRunner = streamGraphRunner;
52
+ const nonStreamGraphRunner = (agentDictionary, agentFilters = []) => {
53
+ return async (req, res, next) => {
54
+ try {
55
+ const dispatcher = streamGraphRunnerInternal(agentDictionary, agentFilters);
56
+ const result = await dispatcher(req, res);
57
+ return res.json(result);
58
+ }
59
+ catch (e) {
60
+ next(e);
61
+ }
62
+ };
63
+ };
64
+ exports.nonStreamGraphRunner = nonStreamGraphRunner;
65
+ // internal function
66
+ const streamGraphRunnerInternal = (agentDictionary, agentFilters = []) => {
67
+ return async (req, res) => {
68
+ const { graphData } = req.body;
69
+ const { config } = req;
70
+ const graphai = new graphai_1.GraphAI(graphData, agentDictionary, { agentFilters, config: config ?? {} });
71
+ const result = await graphai.run(true);
72
+ return result;
73
+ };
74
+ };
package/lib/index.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- import express from "express";
2
- import type { AgentFunctionInfoDictionary, AgentFilterInfo } from "graphai";
3
- import { ExpressAgentInfo } from "./type";
4
- export { ExpressAgentInfo };
5
- export declare const agentsList: (agentDictionary: AgentFunctionInfoDictionary, hostName?: string, urlPath?: string) => (req: express.Request, res: express.Response) => Promise<void>;
6
- export declare const agentDoc: (agentDictionary: AgentFunctionInfoDictionary, hostName?: string, urlPath?: string) => (req: express.Request, res: express.Response) => Promise<void>;
7
- export declare const agentDispatcher: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[]) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
8
- export declare const agentRunner: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[]) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
9
- export declare const nonStreamAgentDispatcher: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[], isDispatch?: boolean) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
10
- export declare const streamAgentDispatcher: (agentDictionary: AgentFunctionInfoDictionary, agentFilters?: AgentFilterInfo[], isDispatch?: boolean) => (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<express.Response<any, Record<string, any>> | undefined>;
1
+ export { agentsList, agentDoc, agentDispatcher, agentRunner, nonStreamAgentDispatcher, streamAgentDispatcher } from "./agents";
2
+ export { graphRunner, streamGraphRunner, nonStreamGraphRunner } from "./graph";
3
+ export { ExpressAgentInfo } from "./type";
package/lib/index.js CHANGED
@@ -1,159 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.streamAgentDispatcher = exports.nonStreamAgentDispatcher = exports.agentRunner = exports.agentDispatcher = exports.agentDoc = exports.agentsList = void 0;
4
- const agent_filters_1 = require("@graphai/agent_filters");
5
- // express middleware
6
- // return agent list
7
- const agentsList = (agentDictionary, hostName = "https://example.com", urlPath = "/agent") => {
8
- return async (req, res) => {
9
- const list = Object.keys(agentDictionary).map((agentName) => {
10
- const agent = agentDictionary[agentName];
11
- return {
12
- agentId: agentName,
13
- name: agent.name,
14
- url: hostName + urlPath + "/" + agentName,
15
- description: agent.description,
16
- category: agent.category,
17
- author: agent.author,
18
- license: agent.license,
19
- repository: agent.repository,
20
- samples: agent.samples,
21
- inputs: agent.inputs,
22
- output: agent.output,
23
- stream: agent.stream ?? false,
24
- };
25
- });
26
- res.json({ agents: list });
27
- };
28
- };
29
- exports.agentsList = agentsList;
30
- // express middleware
31
- // return agent detail info
32
- const agentDoc = (agentDictionary, hostName = "https://example.com", urlPath = "/agent") => {
33
- return async (req, res) => {
34
- const { params } = req;
35
- const { agentId } = params;
36
- const agent = agentDictionary[agentId];
37
- if (agent === undefined) {
38
- res.status(404).send("Not found");
39
- return;
40
- }
41
- const result = {
42
- agentId: agentId,
43
- name: agent.name,
44
- url: hostName + urlPath + "/" + agentId,
45
- description: agent.description,
46
- category: agent.category,
47
- samples: agent.samples,
48
- author: agent.author,
49
- license: agent.license,
50
- repository: agent.repository,
51
- };
52
- res.json(result);
53
- };
54
- };
55
- exports.agentDoc = agentDoc;
56
- // express middleware
57
- // dispatch and run agent
58
- // app.post(apiPrefix + "/:agentId", agentDispatcher(agentDictionary));
59
- const agentDispatcher = (agentDictionary, agentFilters = []) => {
60
- const nonStram = (0, exports.nonStreamAgentDispatcher)(agentDictionary, agentFilters, true);
61
- const stream = (0, exports.streamAgentDispatcher)(agentDictionary, agentFilters, true);
62
- return async (req, res, next) => {
63
- const isStreaming = (req.headers["content-type"] || "").startsWith("text/event-stream");
64
- if (isStreaming) {
65
- return await stream(req, res, next);
66
- }
67
- return await nonStram(req, res, next);
68
- };
69
- };
70
- exports.agentDispatcher = agentDispatcher;
71
- // express middleware
72
- // run agent
73
- // app.post(agentPrefix, agentRunner(agentDictionary));
74
- const agentRunner = (agentDictionary, agentFilters = []) => {
75
- const nonStram = (0, exports.nonStreamAgentDispatcher)(agentDictionary, agentFilters, false);
76
- const stream = (0, exports.streamAgentDispatcher)(agentDictionary, agentFilters, false);
77
- return async (req, res, next) => {
78
- const isStreaming = (req.headers["content-type"] || "").startsWith("text/event-stream");
79
- if (isStreaming) {
80
- return await stream(req, res, next);
81
- }
82
- return await nonStram(req, res, next);
83
- };
84
- };
85
- exports.agentRunner = agentRunner;
86
- // express middleware
87
- // run agent
88
- const nonStreamAgentDispatcher = (agentDictionary, agentFilters = [], isDispatch = true) => {
89
- return async (req, res, next) => {
90
- try {
91
- const dispatcher = agentDispatcherInternal(agentDictionary, agentFilters, isDispatch);
92
- const result = await dispatcher(req, res);
93
- return res.json(result);
94
- }
95
- catch (e) {
96
- next(e);
97
- }
98
- };
99
- };
100
- exports.nonStreamAgentDispatcher = nonStreamAgentDispatcher;
101
- // express middleware
102
- // run agent with streaming
103
- const streamAgentDispatcher = (agentDictionary, agentFilters = [], isDispatch = true) => {
104
- return async (req, res, next) => {
105
- try {
106
- res.setHeader("Content-Type", "text/event-stream;charset=utf-8");
107
- res.setHeader("Cache-Control", "no-cache, no-transform");
108
- res.setHeader("X-Accel-Buffering", "no");
109
- const callback = (context, token) => {
110
- if (token) {
111
- res.write(token);
112
- }
113
- };
114
- const streamAgentFilter = {
115
- name: "streamAgentFilter",
116
- agent: (0, agent_filters_1.streamAgentFilterGenerator)(callback),
117
- };
118
- const filterList = [...agentFilters, streamAgentFilter];
119
- const dispatcher = agentDispatcherInternal(agentDictionary, filterList, isDispatch);
120
- const result = await dispatcher(req, res);
121
- const json_data = JSON.stringify(result);
122
- res.write("___END___");
123
- res.write(json_data);
124
- return res.end();
125
- }
126
- catch (e) {
127
- next(e);
128
- }
129
- };
130
- };
131
- exports.streamAgentDispatcher = streamAgentDispatcher;
132
- // dispatcher internal function
133
- const agentDispatcherInternal = (agentDictionary, agentFilters = [], isDispatch = true) => {
134
- return async (req, res) => {
135
- const { params } = req;
136
- const { agentId } = isDispatch ? params : req.body;
137
- const { nodeId, retry, params: agentParams, inputs, namedInputs } = req.body;
138
- const agent = agentDictionary[agentId];
139
- if (agent === undefined) {
140
- res.status(404).send("Not found");
141
- return;
142
- }
143
- const context = {
144
- params: agentParams || {},
145
- inputs,
146
- namedInputs,
147
- debugInfo: {
148
- nodeId,
149
- retry,
150
- verbose: false,
151
- },
152
- agents: agentDictionary,
153
- filterParams: {},
154
- };
155
- const agentFilterRunner = (0, agent_filters_1.agentFilterRunnerBuilder)(agentFilters);
156
- const result = await agentFilterRunner(context, agent.agent);
157
- return result;
158
- };
159
- };
3
+ exports.nonStreamGraphRunner = exports.streamGraphRunner = exports.graphRunner = exports.streamAgentDispatcher = exports.nonStreamAgentDispatcher = exports.agentRunner = exports.agentDispatcher = exports.agentDoc = exports.agentsList = void 0;
4
+ var agents_1 = require("./agents");
5
+ Object.defineProperty(exports, "agentsList", { enumerable: true, get: function () { return agents_1.agentsList; } });
6
+ Object.defineProperty(exports, "agentDoc", { enumerable: true, get: function () { return agents_1.agentDoc; } });
7
+ Object.defineProperty(exports, "agentDispatcher", { enumerable: true, get: function () { return agents_1.agentDispatcher; } });
8
+ Object.defineProperty(exports, "agentRunner", { enumerable: true, get: function () { return agents_1.agentRunner; } });
9
+ Object.defineProperty(exports, "nonStreamAgentDispatcher", { enumerable: true, get: function () { return agents_1.nonStreamAgentDispatcher; } });
10
+ Object.defineProperty(exports, "streamAgentDispatcher", { enumerable: true, get: function () { return agents_1.streamAgentDispatcher; } });
11
+ var graph_1 = require("./graph");
12
+ Object.defineProperty(exports, "graphRunner", { enumerable: true, get: function () { return graph_1.graphRunner; } });
13
+ Object.defineProperty(exports, "streamGraphRunner", { enumerable: true, get: function () { return graph_1.streamGraphRunner; } });
14
+ Object.defineProperty(exports, "nonStreamGraphRunner", { enumerable: true, get: function () { return graph_1.nonStreamGraphRunner; } });
package/lib/type.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AgentFunctionInfoSample } from "graphai";
1
+ import type { AgentFunctionInfoSample, AgentFunctionContext } from "graphai";
2
2
  export type ExpressAgentInfo = {
3
3
  agentId: string;
4
4
  name: string;
@@ -13,3 +13,4 @@ export type ExpressAgentInfo = {
13
13
  output: any;
14
14
  stream: boolean;
15
15
  };
16
+ export type StreamChunkCallback = (context: AgentFunctionContext, token: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@receptron/graphai_express",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "GraphAI express web server middleware.",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -11,6 +11,7 @@
11
11
  "eslint": "eslint --fix",
12
12
  "server": "ts-node -r tsconfig-paths/register test/express.ts",
13
13
  "test_stream": "ts-node -r tsconfig-paths/register test/stream_client.ts",
14
+ "test_stream2": "ts-node -r tsconfig-paths/register test/stream_graph.ts",
14
15
  "test": "ts-node -r tsconfig-paths/register test/client.ts",
15
16
  "format": "prettier --write '{src,test}/**/*.{yaml,ts,json}'",
16
17
  "ci": "yarn run format && yarn run eslint && yarn run build"
@@ -29,8 +30,12 @@
29
30
  "@graphai/agents": "^0.0.21",
30
31
  "@types/express": "^4.17.21",
31
32
  "@types/node": "^20.14.12",
33
+ "@types/sinon": "^17.0.3",
34
+ "@types/sinon-express-mock": "^1.3.12",
32
35
  "eslint": "^9.7.0",
33
36
  "prettier": "^3.3.3",
37
+ "sinon": "^18.0.0",
38
+ "sinon-express-mock": "^2.2.1",
34
39
  "ts-node": "^10.9.2",
35
40
  "tsc-alias": "^1.8.8",
36
41
  "tsconfig-paths": "^4.2.0",