@agentica/rpc 0.13.0 → 0.13.2

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
@@ -1,4 +1,5 @@
1
1
  # `@agentica/rpc`
2
+
2
3
  ![agentica-conceptual-diagram](https://github.com/user-attachments/assets/d7ebbd1f-04d3-4b0d-9e2a-234e29dd6c57)
3
4
 
4
5
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wrtnlabs/agentica/blob/master/LICENSE)
@@ -32,11 +33,10 @@ const driver: Driver<IAgenticaRpcService> = connector.getDriver();
32
33
  await driver.conversate("Hello, what you can do?");
33
34
  ```
34
35
 
35
-
36
-
37
-
38
36
  ## How to use
37
+
39
38
  ### Setup
39
+
40
40
  ```bash
41
41
  # SERVER APPLICATION
42
42
  npm install @agentica/core @agentica/rpc @samchon/openapi tgrid typia
@@ -55,6 +55,9 @@ Note that, you have to install not only `@agentica/core` and `@agentica/rpc`, bu
55
55
  By the way, as `typia` is a transformer library analyzing TypeScript source code in the compilation level, it needs additional setup command `npx typia setup` when developing server application. Also, if your client (frontend) application is not using the standard TypeScript compiler (not `tsc`), you have to setup [`@ryoppippi/unplugin-typia`](https://typia.io/docs/setup/#unplugin-typia) too.
56
56
 
57
57
  ### Server Application
58
+
59
+ <!-- eslint-skip -->
60
+
58
61
  ```typescript
59
62
  import { Agentica } from "@agentica/core";
60
63
  import {
@@ -84,6 +87,7 @@ When developing backend server, wrap `Agentica` to `AgenticaRpcService`.
84
87
  If you're developing WebSocket protocol backend server, create a new `Agentica` instance, and wrap it to the `AgenticaRpcService` class. And then open the websocket server like above code. The WebSocket server will call the client functions of the `IAgenticaRpcListener` remotely.
85
88
 
86
89
  ### Client Application
90
+
87
91
  ```typescript
88
92
  import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
89
93
  import { Driver, WebSocketConnector } from "tgrid";
@@ -112,11 +116,10 @@ Otherwise you're developing WebSocket protocol client application, connect to th
112
116
 
113
117
  And then call the backend server's function `IAgenticaRpcService.conversate()` remotely through the `Driver<IAgenticaRpcService>` wrapping. The backend server will call your `IAgenticaRpcListener` functions remotely through the RPC paradigm.
114
118
 
115
-
116
-
117
-
118
119
  ## NestJS Application
120
+
119
121
  ### Bootstrap
122
+
120
123
  ```bash
121
124
  npx nestia start <directory>
122
125
  cd <directory>
@@ -127,6 +130,8 @@ You can integrate `@agentica` with [NestJS Framework](https://nestjs.com) utiliz
127
130
 
128
131
  At first, create a boilerplate project of NestJS combined with Nestia by running `npx nesta start` command. And then install `@agentica/rpc` with its dependency packages.
129
132
 
133
+ <!-- eslint-skip -->
134
+
130
135
  ```typescript
131
136
  import { WebSocketAdaptor } from "@nestia/core";
132
137
  import { INestApplication } from "@nestjs/common";
@@ -153,6 +158,9 @@ export class MyBackend {
153
158
  After setup, update `src/MyBackend.ts` file to call `WebSocketAdaptor.upgrade()` function to the NestJS application instance. The function `WebSocketAdaptor.upgrade()` will make the NestJS backend server to compatible with WebSocket protocol.
154
159
 
155
160
  ### API Controller
161
+
162
+ <!-- eslint-skip -->
163
+
156
164
  ```typescript
157
165
  import { AgenticaRpcService, IAgenticaRpcListener } from "@agentica/rpc";
158
166
  import { WebSocketRoute } from "@nestia/core";
@@ -181,13 +189,14 @@ export class ChatController {
181
189
  }
182
190
  ```
183
191
 
184
- Make a new NestJS controller class like above.
192
+ Make a new NestJS controller class like above.
185
193
 
186
194
  When a client connects to the server with `ws://localhost:3001/chat` URL, Agentica made chatbot would be started in the WebSocket protocol.
187
195
 
188
196
  If you need path or query parameters, utilize `@WebSocketRoute.Path()` or `@WebSocketRoute.Query()` decorator functions.
189
197
 
190
198
  ### Software Development Kit
199
+
191
200
  ```bash
192
201
  npx nestia sdk
193
202
  ```
@@ -213,14 +222,13 @@ const { connector, driver } = await api.functional.chat.start(
213
222
  },
214
223
  } satisfies IAgenticaRpcListener,
215
224
  );
216
- await driver.conversate("Hello, what you can do?");s
225
+ await driver.conversate("Hello, what you can do?");
217
226
  ```
218
227
 
219
-
220
-
221
-
222
228
  ## Principles
229
+
223
230
  ### Remote Procedure Call
231
+
224
232
  ```mermaid
225
233
  sequenceDiagram
226
234
  box Client Application
@@ -282,4 +290,4 @@ await connector.connect("ws://localhost:3001");
282
290
 
283
291
  const driver: Driver<IAgenticaRpcService> = connector.getDriver();
284
292
  await driver.conversate("Hello, what you can do?");
285
- ```
293
+ ```
@@ -1,7 +1,7 @@
1
- import { Agentica, IAgenticaController } from "@agentica/core";
2
- import { ILlmSchema } from "@samchon/openapi";
3
- import { IAgenticaRpcListener } from "./IAgenticaRpcListener";
4
- import { IAgenticaRpcService } from "./IAgenticaRpcService";
1
+ import type { Agentica, IAgenticaController } from "@agentica/core";
2
+ import type { ILlmSchema } from "@samchon/openapi";
3
+ import type { IAgenticaRpcListener } from "./IAgenticaRpcListener";
4
+ import type { IAgenticaRpcService } from "./IAgenticaRpcService";
5
5
  /**
6
6
  * RPC service for the {@link Agentica}.
7
7
  *
@@ -68,15 +68,16 @@ class AgenticaRpcService {
68
68
  return listener.describe(Object.assign(primitive(evt), { text: yield evt.join() }));
69
69
  }));
70
70
  // OPTIONAL LISTENERS
71
- agent.on("initialize", (evt) => listener.initialize(primitive(evt)));
72
- agent.on("select", (evt) => listener.select(primitive(evt)));
73
- agent.on("cancel", (evt) => listener.cancel(primitive(evt)));
71
+ agent.on("initialize", (evt) => __awaiter(this, void 0, void 0, function* () { return listener.initialize(primitive(evt)); }));
72
+ agent.on("select", (evt) => __awaiter(this, void 0, void 0, function* () { return listener.select(primitive(evt)); }));
73
+ agent.on("cancel", (evt) => __awaiter(this, void 0, void 0, function* () { return listener.cancel(primitive(evt)); }));
74
74
  agent.on("call", (evt) => __awaiter(this, void 0, void 0, function* () {
75
75
  const args = yield listener.call(primitive(evt));
76
- if (args)
76
+ if (args != null) {
77
77
  evt.arguments = args;
78
+ }
78
79
  }));
79
- agent.on("execute", (evt) => listener.execute(primitive(evt)));
80
+ agent.on("execute", (evt) => __awaiter(this, void 0, void 0, function* () { return listener.execute(primitive(evt)); }));
80
81
  }
81
82
  /**
82
83
  * @inheritDoc
@@ -99,5 +100,7 @@ exports.AgenticaRpcService = AgenticaRpcService;
99
100
  /**
100
101
  * @internal
101
102
  */
102
- const primitive = (obj) => JSON.parse(JSON.stringify(obj));
103
+ function primitive(obj) {
104
+ return JSON.parse(JSON.stringify(obj));
105
+ }
103
106
  //# sourceMappingURL=AgenticaRpcService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgenticaRpcService.js","sourceRoot":"","sources":["../src/AgenticaRpcService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAa,kBAAkB;IAG7B;;;;OAIG;IACH,YAAoC,KAAuC;QAAvC,UAAK,GAAL,KAAK,CAAkC;QACzE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;QAElC,sBAAsB;QACtB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAO,GAAG,EAAE,EAAE,gDAC7B,OAAA,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAA,GAAA,CACzE,CAAC;QACF,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,CAAO,GAAG,EAAE,EAAE;YACjC,OAAA,QAAQ,CAAC,QAAQ,CACf,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAC1D,CAAA;UAAA,CACF,CAAC;QAEF,qBAAqB;QACrB,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,UA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QAClE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAO,GAAG,EAAE,EAAE;YAC7B,MAAM,IAAI,GAA8B,MAAM,QAAQ,CAAC,IAAK,CAC1D,SAAS,CAAC,GAAG,CAAC,CACf,CAAC;YACF,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;gBACjB,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;YACvB,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,CAAM,GAAG,EAAC,EAAE,gDAAC,OAAA,QAAQ,CAAC,OAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA,GAAA,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACU,UAAU,CAAC,OAAe;;YACrC,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;KAAA;IAED;;OAEG;IACU,cAAc;;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAkC,CAAC;QAC3E,CAAC;KAAA;CACF;AA9CD,gDA8CC;AAkBD;;GAEG;AACH,SAAS,SAAS,CAAI,GAAM;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAiB,CAAC;AACzD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { IAgenticaEventJson } from "@agentica/core";
1
+ import type { IAgenticaEventJson } from "@agentica/core";
2
2
  /**
3
3
  * RPC interface of AI agent listener.
4
4
  *
@@ -50,13 +50,13 @@ export interface IAgenticaRpcListener {
50
50
  *
51
51
  * @param evt Event of a description of function execution results
52
52
  */
53
- describe(evt: IAgenticaEventJson.IDescribe): Promise<void>;
53
+ describe: (evt: IAgenticaEventJson.IDescribe) => Promise<void>;
54
54
  /**
55
55
  * Text conversation message.
56
56
  *
57
57
  * @param evt Event of a text conversation message
58
58
  */
59
- text(evt: IAgenticaEventJson.IText): Promise<void>;
59
+ text: (evt: IAgenticaEventJson.IText) => Promise<void>;
60
60
  /**
61
61
  * Initialize the AI agent.
62
62
  *
@@ -65,7 +65,7 @@ export interface IAgenticaRpcListener {
65
65
  *
66
66
  * @param evt Event of initialization
67
67
  */
68
- initialize?(evt: IAgenticaEventJson.IInitialize): Promise<void>;
68
+ initialize?: (evt: IAgenticaEventJson.IInitialize) => Promise<void>;
69
69
  /**
70
70
  * Select a function to call.
71
71
  *
@@ -73,7 +73,7 @@ export interface IAgenticaRpcListener {
73
73
  *
74
74
  * @param evt Event of selecting a function to call
75
75
  */
76
- select?(evt: IAgenticaEventJson.ISelect): Promise<void>;
76
+ select?: (evt: IAgenticaEventJson.ISelect) => Promise<void>;
77
77
  /**
78
78
  * Cancel a function to call.
79
79
  *
@@ -81,7 +81,7 @@ export interface IAgenticaRpcListener {
81
81
  *
82
82
  * @param evt Event of canceling a function to call
83
83
  */
84
- cancel?(evt: IAgenticaEventJson.ICancel): Promise<void>;
84
+ cancel?: (evt: IAgenticaEventJson.ICancel) => Promise<void>;
85
85
  /**
86
86
  * Call a function.
87
87
  *
@@ -99,7 +99,7 @@ export interface IAgenticaRpcListener {
99
99
  * @param evt Event of a function calling
100
100
  * @return New arguments if you want to modify, otherwise null or undefined
101
101
  */
102
- call?(evt: IAgenticaEventJson.ICall): Promise<object | null | undefined>;
102
+ call?: (evt: IAgenticaEventJson.ICall) => Promise<object | null | undefined>;
103
103
  /**
104
104
  * Executition of a function.
105
105
  *
@@ -107,5 +107,5 @@ export interface IAgenticaRpcListener {
107
107
  *
108
108
  * @param evt Event of a function execution
109
109
  */
110
- execute?(evt: IAgenticaEventJson.IExecute): Promise<void>;
110
+ execute?: (evt: IAgenticaEventJson.IExecute) => Promise<void>;
111
111
  }
@@ -1,5 +1,5 @@
1
- import { IAgenticaController } from "@agentica/core";
2
- import { ILlmSchema } from "@samchon/openapi";
1
+ import type { IAgenticaController } from "@agentica/core";
2
+ import type { ILlmSchema } from "@samchon/openapi";
3
3
  /**
4
4
  * RPC interface of AI agent service.
5
5
  *
@@ -27,12 +27,12 @@ export interface IAgenticaRpcService<Model extends ILlmSchema.Model> {
27
27
  * @param content The content to talk
28
28
  * @returns Returned when the conversation process is completely done
29
29
  */
30
- conversate(content: string): Promise<void>;
30
+ conversate: (content: string) => Promise<void>;
31
31
  /**
32
32
  * Get controllers.
33
33
  *
34
34
  * Get controllers, collection of functions that would be
35
35
  * called by the AI chatbot.
36
36
  */
37
- getControllers(): Promise<IAgenticaController<Model>[]>;
37
+ getControllers: () => Promise<IAgenticaController<Model>[]>;
38
38
  }
package/lib/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
+ export * from "./AgenticaRpcService";
1
2
  export * from "./IAgenticaRpcListener";
2
3
  export * from "./IAgenticaRpcService";
3
- export * from "./AgenticaRpcService";
package/lib/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AgenticaRpcService"), exports);
17
18
  __exportStar(require("./IAgenticaRpcListener"), exports);
18
19
  __exportStar(require("./IAgenticaRpcService"), exports);
19
- __exportStar(require("./AgenticaRpcService"), exports);
20
20
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,wDAAsC;AACtC,uDAAqC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,yDAAuC;AACvC,wDAAsC"}
package/lib/index.mjs CHANGED
@@ -8,14 +8,16 @@ class AgenticaRpcService {
8
8
  agent.on("describe", (async evt => listener.describe(Object.assign(primitive(evt), {
9
9
  text: await evt.join()
10
10
  }))));
11
- agent.on("initialize", (evt => listener.initialize(primitive(evt))));
12
- agent.on("select", (evt => listener.select(primitive(evt))));
13
- agent.on("cancel", (evt => listener.cancel(primitive(evt))));
11
+ agent.on("initialize", (async evt => listener.initialize(primitive(evt))));
12
+ agent.on("select", (async evt => listener.select(primitive(evt))));
13
+ agent.on("cancel", (async evt => listener.cancel(primitive(evt))));
14
14
  agent.on("call", (async evt => {
15
15
  const args = await listener.call(primitive(evt));
16
- if (args) evt.arguments = args;
16
+ if (args != null) {
17
+ evt.arguments = args;
18
+ }
17
19
  }));
18
- agent.on("execute", (evt => listener.execute(primitive(evt))));
20
+ agent.on("execute", (async evt => listener.execute(primitive(evt))));
19
21
  }
20
22
  async conversate(content) {
21
23
  await this.props.agent.conversate(content);
@@ -25,7 +27,9 @@ class AgenticaRpcService {
25
27
  }
26
28
  }
27
29
 
28
- const primitive = obj => JSON.parse(JSON.stringify(obj));
30
+ function primitive(obj) {
31
+ return JSON.parse(JSON.stringify(obj));
32
+ }
29
33
 
30
34
  export { AgenticaRpcService };
31
35
  //# sourceMappingURL=index.mjs.map
package/lib/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/AgenticaRpcService.ts"],"sourcesContent":[null],"names":["AgenticaRpcService","constructor","props","this","agent","listener","on","async","evt","text","Object","assign","primitive","join","describe","initialize","select","cancel","args","call","arguments","execute","conversate","content","getControllers","obj","JSON","parse","stringify"],"mappings":"MAkDaA;IAQX,WAAAC,CAAoCC;QAAAC,KAAKD,QAALA;QAClC,OAAME,OAAOC,YAAeH;QAG5BE,MAAME,GAAG,SAAQC,MAAOC,OACtBH,SAASI,KAAKC,OAAOC,OAAOC,UAAUJ,MAAM;YAAEC,YAAYD,IAAIK;;QAEhET,MAAME,GAAG,aAAYC,MAAOC,OAC1BH,SAASS,SACPJ,OAAOC,OAAOC,UAAUJ,MAAM;YAAEC,YAAYD,IAAIK;;QAKpDT,MAAME,GAAG,eAAeE,OAAQH,SAASU,WAAYH,UAAUJ;QAC/DJ,MAAME,GAAG,WAAWE,OAAQH,SAASW,OAAQJ,UAAUJ;QACvDJ,MAAME,GAAG,WAAWE,OAAQH,SAASY,OAAQL,UAAUJ;QACvDJ,MAAME,GAAG,SAAQC,MAAOC;YACtB,MAAMU,aAAwCb,SAASc,KACrDP,UAAUJ;YAEZ,IAAIU,MAAMV,IAAIY,YAAYF;AAAI;QAEhCd,MAAME,GAAG,YAAYE,OAAQH,SAASgB,QAAST,UAAUJ;;IAMpD,gBAAMc,CAAWC;cAChBpB,KAAKD,MAAME,MAAMkB,WAAWC;;IAM7B,oBAAMC;QACX,OAAOrB,KAAKD,MAAME,MAAMoB;;;;AAuB5B,MAAMZ,YAAgBa,OACpBC,KAAKC,MAAMD,KAAKE,UAAUH;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/AgenticaRpcService.ts"],"sourcesContent":[null],"names":["AgenticaRpcService","constructor","props","this","agent","listener","on","async","evt","text","Object","assign","primitive","join","describe","initialize","select","cancel","args","call","arguments","execute","conversate","content","getControllers","obj","JSON","parse","stringify"],"mappings":"MAkDaA;IAOX,WAAAC,CAAoCC;QAAAC,KAAKD,QAALA;QAClC,OAAME,OAAOC,YAAeH;QAG5BE,MAAME,GAAG,SAAQC,MAAMC,OACrBH,SAASI,KAAKC,OAAOC,OAAOC,UAAUJ,MAAM;YAAEC,YAAYD,IAAIK;;QAChET,MAAME,GAAG,aAAYC,MAAMC,OACzBH,SAASS,SACPJ,OAAOC,OAAOC,UAAUJ,MAAM;YAAEC,YAAYD,IAAIK;;QAIpDT,MAAME,GAAG,eAAcC,MAAMC,OAAOH,SAASU,WAAYH,UAAUJ;QACnEJ,MAAME,GAAG,WAAUC,MAAMC,OAAOH,SAASW,OAAQJ,UAAUJ;QAC3DJ,MAAME,GAAG,WAAUC,MAAMC,OAAOH,SAASY,OAAQL,UAAUJ;QAC3DJ,MAAME,GAAG,SAAQC,MAAOC;YACtB,MAAMU,aAAwCb,SAASc,KACrDP,UAAUJ;YAEZ,IAAIU,QAAQ,MAAM;gBAChBV,IAAIY,YAAYF;;;QAGpBd,MAAME,GAAG,YAAWC,MAAMC,OAAOH,SAASgB,QAAST,UAAUJ;;IAMxD,gBAAMc,CAAWC;cAChBpB,KAAKD,MAAME,MAAMkB,WAAWC;;IAM7B,oBAAMC;QACX,OAAOrB,KAAKD,MAAME,MAAMoB;;;;AAuB5B,SAASZ,UAAaa;IACpB,OAAOC,KAAKC,MAAMD,KAAKE,UAAUH;AACnC;;"}
package/package.json CHANGED
@@ -1,14 +1,10 @@
1
1
  {
2
2
  "name": "@agentica/rpc",
3
- "version": "0.13.0",
4
- "main": "lib/index.js",
5
- "publishConfig": {
6
- "access": "public"
7
- },
3
+ "version": "0.13.2",
8
4
  "description": "Agentic AI Library specialized in LLM Function Calling",
9
5
  "author": "Wrtn Technologies",
10
- "homepage": "https://wrtnlabs.io/agentica",
11
6
  "license": "MIT",
7
+ "homepage": "https://wrtnlabs.io/agentica",
12
8
  "repository": {
13
9
  "type": "git",
14
10
  "url": "https://github.com/wrtnlabs/agentica"
@@ -27,17 +23,21 @@
27
23
  "swagger",
28
24
  "openapi"
29
25
  ],
26
+ "main": "lib/index.js",
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
30
  "files": [
31
- "README.md",
32
31
  "LICENSE",
33
- "package.json",
32
+ "README.md",
34
33
  "lib",
34
+ "package.json",
35
35
  "src"
36
36
  ],
37
37
  "dependencies": {
38
- "@samchon/openapi": "^3.0.0",
39
- "typia": "^8.0.0",
40
- "@agentica/core": "^0.13.0"
38
+ "@samchon/openapi": "^3.2.0",
39
+ "typia": "^8.0.4",
40
+ "@agentica/core": "^0.13.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@rollup/plugin-terser": "^0.4.4",
@@ -1,9 +1,9 @@
1
- import { Agentica, IAgenticaController } from "@agentica/core";
2
- import { ILlmSchema } from "@samchon/openapi";
3
- import { Primitive } from "typia";
1
+ import type { Agentica, IAgenticaController } from "@agentica/core";
2
+ import type { ILlmSchema } from "@samchon/openapi";
3
+ import type { Primitive } from "typia";
4
4
 
5
- import { IAgenticaRpcListener } from "./IAgenticaRpcListener";
6
- import { IAgenticaRpcService } from "./IAgenticaRpcService";
5
+ import type { IAgenticaRpcListener } from "./IAgenticaRpcListener";
6
+ import type { IAgenticaRpcService } from "./IAgenticaRpcService";
7
7
 
8
8
  /**
9
9
  * RPC service for the {@link Agentica}.
@@ -49,8 +49,7 @@ import { IAgenticaRpcService } from "./IAgenticaRpcService";
49
49
  * @author Samchon
50
50
  */
51
51
  export class AgenticaRpcService<Model extends ILlmSchema.Model>
52
- implements IAgenticaRpcService<Model>
53
- {
52
+ implements IAgenticaRpcService<Model> {
54
53
  /**
55
54
  * Initializer Constructor.
56
55
  *
@@ -60,26 +59,26 @@ export class AgenticaRpcService<Model extends ILlmSchema.Model>
60
59
  const { agent, listener } = props;
61
60
 
62
61
  // ESSENTIAL LISTENERS
63
- agent.on("text", async (evt) =>
64
- listener.text(Object.assign(primitive(evt), { text: await evt.join() })),
65
- );
66
- agent.on("describe", async (evt) =>
62
+ agent.on("text", async evt =>
63
+ listener.text(Object.assign(primitive(evt), { text: await evt.join() })));
64
+ agent.on("describe", async evt =>
67
65
  listener.describe(
68
66
  Object.assign(primitive(evt), { text: await evt.join() }),
69
- ),
70
- );
67
+ ));
71
68
 
72
69
  // OPTIONAL LISTENERS
73
- agent.on("initialize", (evt) => listener.initialize!(primitive(evt)));
74
- agent.on("select", (evt) => listener.select!(primitive(evt)));
75
- agent.on("cancel", (evt) => listener.cancel!(primitive(evt)));
70
+ agent.on("initialize", async evt => listener.initialize!(primitive(evt)));
71
+ agent.on("select", async evt => listener.select!(primitive(evt)));
72
+ agent.on("cancel", async evt => listener.cancel!(primitive(evt)));
76
73
  agent.on("call", async (evt) => {
77
74
  const args: object | null | undefined = await listener.call!(
78
75
  primitive(evt),
79
76
  );
80
- if (args) evt.arguments = args;
77
+ if (args != null) {
78
+ evt.arguments = args;
79
+ }
81
80
  });
82
- agent.on("execute", (evt) => listener.execute!(primitive(evt as any)));
81
+ agent.on("execute", async evt => listener.execute!(primitive(evt)));
83
82
  }
84
83
 
85
84
  /**
@@ -116,5 +115,6 @@ export namespace AgenticaRpcService {
116
115
  /**
117
116
  * @internal
118
117
  */
119
- const primitive = <T>(obj: T): Primitive<T> =>
120
- JSON.parse(JSON.stringify(obj)) as Primitive<T>;
118
+ function primitive<T>(obj: T): Primitive<T> {
119
+ return JSON.parse(JSON.stringify(obj)) as Primitive<T>;
120
+ }
@@ -1,4 +1,4 @@
1
- import { IAgenticaEventJson } from "@agentica/core";
1
+ import type { IAgenticaEventJson } from "@agentica/core";
2
2
 
3
3
  /**
4
4
  * RPC interface of AI agent listener.
@@ -51,14 +51,14 @@ export interface IAgenticaRpcListener {
51
51
  *
52
52
  * @param evt Event of a description of function execution results
53
53
  */
54
- describe(evt: IAgenticaEventJson.IDescribe): Promise<void>;
54
+ describe: (evt: IAgenticaEventJson.IDescribe) => Promise<void>;
55
55
 
56
56
  /**
57
57
  * Text conversation message.
58
58
  *
59
59
  * @param evt Event of a text conversation message
60
60
  */
61
- text(evt: IAgenticaEventJson.IText): Promise<void>;
61
+ text: (evt: IAgenticaEventJson.IText) => Promise<void>;
62
62
 
63
63
  /**
64
64
  * Initialize the AI agent.
@@ -68,7 +68,7 @@ export interface IAgenticaRpcListener {
68
68
  *
69
69
  * @param evt Event of initialization
70
70
  */
71
- initialize?(evt: IAgenticaEventJson.IInitialize): Promise<void>;
71
+ initialize?: (evt: IAgenticaEventJson.IInitialize) => Promise<void>;
72
72
 
73
73
  /**
74
74
  * Select a function to call.
@@ -77,7 +77,7 @@ export interface IAgenticaRpcListener {
77
77
  *
78
78
  * @param evt Event of selecting a function to call
79
79
  */
80
- select?(evt: IAgenticaEventJson.ISelect): Promise<void>;
80
+ select?: (evt: IAgenticaEventJson.ISelect) => Promise<void>;
81
81
 
82
82
  /**
83
83
  * Cancel a function to call.
@@ -86,7 +86,7 @@ export interface IAgenticaRpcListener {
86
86
  *
87
87
  * @param evt Event of canceling a function to call
88
88
  */
89
- cancel?(evt: IAgenticaEventJson.ICancel): Promise<void>;
89
+ cancel?: (evt: IAgenticaEventJson.ICancel) => Promise<void>;
90
90
 
91
91
  /**
92
92
  * Call a function.
@@ -105,7 +105,7 @@ export interface IAgenticaRpcListener {
105
105
  * @param evt Event of a function calling
106
106
  * @return New arguments if you want to modify, otherwise null or undefined
107
107
  */
108
- call?(evt: IAgenticaEventJson.ICall): Promise<object | null | undefined>;
108
+ call?: (evt: IAgenticaEventJson.ICall) => Promise<object | null | undefined>;
109
109
 
110
110
  /**
111
111
  * Executition of a function.
@@ -114,5 +114,5 @@ export interface IAgenticaRpcListener {
114
114
  *
115
115
  * @param evt Event of a function execution
116
116
  */
117
- execute?(evt: IAgenticaEventJson.IExecute): Promise<void>;
117
+ execute?: (evt: IAgenticaEventJson.IExecute) => Promise<void>;
118
118
  }
@@ -1,5 +1,5 @@
1
- import { IAgenticaController } from "@agentica/core";
2
- import { ILlmSchema } from "@samchon/openapi";
1
+ import type { IAgenticaController } from "@agentica/core";
2
+ import type { ILlmSchema } from "@samchon/openapi";
3
3
 
4
4
  /**
5
5
  * RPC interface of AI agent service.
@@ -28,7 +28,7 @@ export interface IAgenticaRpcService<Model extends ILlmSchema.Model> {
28
28
  * @param content The content to talk
29
29
  * @returns Returned when the conversation process is completely done
30
30
  */
31
- conversate(content: string): Promise<void>;
31
+ conversate: (content: string) => Promise<void>;
32
32
 
33
33
  /**
34
34
  * Get controllers.
@@ -36,5 +36,5 @@ export interface IAgenticaRpcService<Model extends ILlmSchema.Model> {
36
36
  * Get controllers, collection of functions that would be
37
37
  * called by the AI chatbot.
38
38
  */
39
- getControllers(): Promise<IAgenticaController<Model>[]>;
39
+ getControllers: () => Promise<IAgenticaController<Model>[]>;
40
40
  }
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
+ export * from "./AgenticaRpcService";
1
2
  export * from "./IAgenticaRpcListener";
2
3
  export * from "./IAgenticaRpcService";
3
- export * from "./AgenticaRpcService";