@agentica/rpc 0.8.3 → 0.9.0-dev.20250302

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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Wrtn Technologies
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Wrtn Technologies
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,177 +1,177 @@
1
- # `@agentica/rpc`
2
- ![agentica-conceptual-diagram](https://github.com/user-attachments/assets/d7ebbd1f-04d3-4b0d-9e2a-234e29dd6c57)
3
-
4
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wrtnlabs/agentica/blob/master/LICENSE)
5
- [![npm version](https://img.shields.io/npm/v/@agentica/rpc.svg)](https://www.npmjs.com/package/@agentica/rpc)
6
- [![Downloads](https://img.shields.io/npm/dm/@agentica/rpc.svg)](https://www.npmjs.com/package/@agentica/rpc)
7
- [![Build Status](https://github.com/wrtnlabs/agentica/workflows/build/badge.svg)](https://github.com/wrtnlabs/agentica/actions?query=workflow%3Abuild)
8
-
9
- RPC module of Agentica for WebSocket Communication
10
-
11
- Agentica is the simplest Agentiic AI library specialized in **LLM Function Calling**, and `@agentica/rpc` is an RPC (Remote Procedure Call) wrapper module. If you combine the RPC wrapper module with [`TGrid`](https://github.com/samchon/tgrid), you can develop the WebSocket AI Chatbot.
12
-
13
- ```typescript
14
- import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
15
- import { Driver, WebSocketConnector } from "tgrid";
16
-
17
- const connector: WebSocketConnector<
18
- null,
19
- IAgenticaRpcListener,
20
- IAgenticaRpcService
21
- > = new WebSocketConnector(null, {
22
- text: async (evt) => {
23
- console.log(evt.role, evt.text);
24
- },
25
- describe: async (evt) => {
26
- console.log("describer", evt.text);
27
- },
28
- });
29
- await connector.connect("ws://localhost:3001");
30
-
31
- const driver: Driver<IAgenticaRpcService> = connector.getDriver();
32
- await driver.conversate("Hello, what you can do?");
33
- ```
34
-
35
-
36
-
37
-
38
- ## How to use
39
- ### Setup
40
- ```bash
41
- npm install @agentica/core @agentica/rpc @samchon/openapi typia tgrid
42
- npx typia setup
43
- ```
44
-
45
- Install `@agentica/rpc` with its dependent libraries.
46
-
47
- Note that, you have to install not only `@agentica/core` and `@agentica/rpc`, but also [`@samchon/openapi`](https://github.com/samchon/openapi), [`typia`](https://github.com/samchon/typia) and [`tgrid`](https://github.com/samchon/tgrid) too.
48
-
49
- `@samchon/openapi` is an OpenAPI specification library which can convert Swagger/OpenAPI document to LLM function calling schema. And `typia` is a transformer (compiler) library which can compose LLM function calling schema from a TypeScript class type. And then `tgrid` is an RPC (REmote Procedure Call) framework supporting the websocket protocol.
50
-
51
- 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`. 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.
52
-
53
- ### Server Application
54
- ```typescript
55
- import { Agentica } from "@agentica/core";
56
- import {
57
- AgenticaRpcService,
58
- IAgenticaRpcListener,
59
- IAgenticaRpcService,
60
- } from "@agentica/rpc";
61
- import { WebSocketServer } from "tgrid";
62
-
63
- const server: WebSocketServer<
64
- null,
65
- IAgenticaRpcService,
66
- IAgenticaRpcListener
67
- > = new WebSocketServer();
68
- await server.open(3001, async (acceptor) => {
69
- await acceptor.accept(
70
- new AgenticaRpcService({
71
- agent: new Agentica({ ... }),
72
- listener: acceptor.getDriver(),
73
- }),
74
- );
75
- });
76
- ```
77
-
78
- When developing backend server, wrap `Agentica` to `AgenticaRpcService`.
79
-
80
- 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.
81
-
82
- ### Client Application
83
- ```typescript
84
- import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
85
- import { Driver, WebSocketConnector } from "tgrid";
86
-
87
- const connector: WebSocketConnector<
88
- null,
89
- IAgenticaRpcListener,
90
- IAgenticaRpcService
91
- > = new WebSocketConnector(null, {
92
- text: async (evt) => {
93
- console.log(evt.role, evt.text);
94
- },
95
- describe: async (evt) => {
96
- console.log("describer", evt.text);
97
- },
98
- });
99
- await connector.connect("ws://localhost:3001");
100
-
101
- const driver: Driver<IAgenticaRpcService> = connector.getDriver();
102
- await driver.conversate("Hello, what you can do?");
103
- ```
104
-
105
- When developing frontend application, define `IAgenticaRpcListener` instance.
106
-
107
- Otherwise you're developing WebSocket protocol client application, connect to the websocket backend server with its URL address, and provide `IAgenticaRpcListener` instance for event listening.
108
-
109
- 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.
110
-
111
-
112
-
113
-
114
- ## Principles
115
- ### Remote Procedure Call
116
- ```mermaid
117
- sequenceDiagram
118
- box Client Application
119
- actor User
120
- participant Driver as Driver<Listener>
121
- participant Connector as Communicator (Client)
122
- end
123
- box Server Application
124
- participant Acceptor as Communicator (Server)
125
- actor Provider
126
- end
127
- User->>Driver: 1. calls a function
128
- Activate User
129
- Activate Driver
130
- Driver->>Connector: 2. delivers the function call
131
- Activate Connector
132
- Deactivate Driver
133
- Connector-->>Acceptor: 3. sends a protocolized<br/>network message<br/>meaning a function call
134
- Deactivate Connector
135
- Activate Acceptor
136
- Acceptor->>Provider: 4. calls the function
137
- Provider->>Acceptor: 5. returns a value
138
- Acceptor-->>Connector: 6. sends a protocolized<br/>network message<br/>meaning a return value
139
- Deactivate Acceptor
140
- Activate Connector
141
- Connector->>Driver: 7. delivers the return value
142
- Deactivate Connector
143
- Activate Driver
144
- Driver->>User: 8. returns the value
145
- Deactivate Driver
146
- Deactivate User
147
- ```
148
-
149
- WebSocket protocol with RPC paradigm for AI chatbot.
150
-
151
- `@agentica/rpc` supports WebSocket protocol that is utilizing [`TGrid`](https://github.com/samchon/tgrid) and its RPC (Remote Procedure Call) paradigm for easy and type safe development. In the RPC paradigm, client application can call a function of `IAgenticaRpcService` remotely as if it were its own object.
152
-
153
- Internally, the RPC has composed with three elements; [`Communicator`](https://tgrid.com/docs/features/components/#communicator), [`Provider`](https://tgrid.com/docs/features/components/#provider) and [`Driver`](https://tgrid.com/docs/features/components/#driver). The first `Communicator` takes a responsibility of (WebSocket) network communication. The next `Provider` means an object providing to the remote system for RPC, and `Driver` is a proxy instance realizing the RPC to the remote provided `Provider` instance.
154
-
155
- For example, below client application code is calling `IAgenticaRpcService.conversate()` function remotely through the `Driver<IAgenticaRpcService>` typed instance. In that case, `IAgenticaRpcService` is the `Provider` instance from server to client. And `WebSocketConnector` is the communicator taking responsibility of WebSocket communication.
156
-
157
- ```typescript
158
- import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
159
- import { Driver, WebSocketConnector } from "tgrid";
160
-
161
- const connector: WebSocketConnector<
162
- null,
163
- IAgenticaRpcListener,
164
- IAgenticaRpcService
165
- > = new WebSocketConnector(null, {
166
- text: async (evt) => {
167
- console.log(evt.role, evt.text);
168
- },
169
- describe: async (evt) => {
170
- console.log("describer", evt.text);
171
- },
172
- });
173
- await connector.connect("ws://localhost:3001");
174
-
175
- const driver: Driver<IAgenticaRpcService> = connector.getDriver();
176
- await driver.conversate("Hello, what you can do?");
1
+ # `@agentica/rpc`
2
+ ![agentica-conceptual-diagram](https://github.com/user-attachments/assets/d7ebbd1f-04d3-4b0d-9e2a-234e29dd6c57)
3
+
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wrtnlabs/agentica/blob/master/LICENSE)
5
+ [![npm version](https://img.shields.io/npm/v/@agentica/rpc.svg)](https://www.npmjs.com/package/@agentica/rpc)
6
+ [![Downloads](https://img.shields.io/npm/dm/@agentica/rpc.svg)](https://www.npmjs.com/package/@agentica/rpc)
7
+ [![Build Status](https://github.com/wrtnlabs/agentica/workflows/build/badge.svg)](https://github.com/wrtnlabs/agentica/actions?query=workflow%3Abuild)
8
+
9
+ RPC module of Agentica for WebSocket Communication
10
+
11
+ Agentica is the simplest Agentiic AI library specialized in **LLM Function Calling**, and `@agentica/rpc` is an RPC (Remote Procedure Call) wrapper module. If you combine the RPC wrapper module with [`TGrid`](https://github.com/samchon/tgrid), you can develop the WebSocket AI Chatbot.
12
+
13
+ ```typescript
14
+ import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
15
+ import { Driver, WebSocketConnector } from "tgrid";
16
+
17
+ const connector: WebSocketConnector<
18
+ null,
19
+ IAgenticaRpcListener,
20
+ IAgenticaRpcService
21
+ > = new WebSocketConnector(null, {
22
+ text: async (evt) => {
23
+ console.log(evt.role, evt.text);
24
+ },
25
+ describe: async (evt) => {
26
+ console.log("describer", evt.text);
27
+ },
28
+ });
29
+ await connector.connect("ws://localhost:3001");
30
+
31
+ const driver: Driver<IAgenticaRpcService> = connector.getDriver();
32
+ await driver.conversate("Hello, what you can do?");
33
+ ```
34
+
35
+
36
+
37
+
38
+ ## How to use
39
+ ### Setup
40
+ ```bash
41
+ npm install @agentica/core @agentica/rpc @samchon/openapi typia tgrid
42
+ npx typia setup
43
+ ```
44
+
45
+ Install `@agentica/rpc` with its dependent libraries.
46
+
47
+ Note that, you have to install not only `@agentica/core` and `@agentica/rpc`, but also [`@samchon/openapi`](https://github.com/samchon/openapi), [`typia`](https://github.com/samchon/typia) and [`tgrid`](https://github.com/samchon/tgrid) too.
48
+
49
+ `@samchon/openapi` is an OpenAPI specification library which can convert Swagger/OpenAPI document to LLM function calling schema. And `typia` is a transformer (compiler) library which can compose LLM function calling schema from a TypeScript class type. And then `tgrid` is an RPC (REmote Procedure Call) framework supporting the websocket protocol.
50
+
51
+ 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`. 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.
52
+
53
+ ### Server Application
54
+ ```typescript
55
+ import { Agentica } from "@agentica/core";
56
+ import {
57
+ AgenticaRpcService,
58
+ IAgenticaRpcListener,
59
+ IAgenticaRpcService,
60
+ } from "@agentica/rpc";
61
+ import { WebSocketServer } from "tgrid";
62
+
63
+ const server: WebSocketServer<
64
+ null,
65
+ IAgenticaRpcService,
66
+ IAgenticaRpcListener
67
+ > = new WebSocketServer();
68
+ await server.open(3001, async (acceptor) => {
69
+ await acceptor.accept(
70
+ new AgenticaRpcService({
71
+ agent: new Agentica({ ... }),
72
+ listener: acceptor.getDriver(),
73
+ }),
74
+ );
75
+ });
76
+ ```
77
+
78
+ When developing backend server, wrap `Agentica` to `AgenticaRpcService`.
79
+
80
+ 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.
81
+
82
+ ### Client Application
83
+ ```typescript
84
+ import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
85
+ import { Driver, WebSocketConnector } from "tgrid";
86
+
87
+ const connector: WebSocketConnector<
88
+ null,
89
+ IAgenticaRpcListener,
90
+ IAgenticaRpcService
91
+ > = new WebSocketConnector(null, {
92
+ text: async (evt) => {
93
+ console.log(evt.role, evt.text);
94
+ },
95
+ describe: async (evt) => {
96
+ console.log("describer", evt.text);
97
+ },
98
+ });
99
+ await connector.connect("ws://localhost:3001");
100
+
101
+ const driver: Driver<IAgenticaRpcService> = connector.getDriver();
102
+ await driver.conversate("Hello, what you can do?");
103
+ ```
104
+
105
+ When developing frontend application, define `IAgenticaRpcListener` instance.
106
+
107
+ Otherwise you're developing WebSocket protocol client application, connect to the websocket backend server with its URL address, and provide `IAgenticaRpcListener` instance for event listening.
108
+
109
+ 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.
110
+
111
+
112
+
113
+
114
+ ## Principles
115
+ ### Remote Procedure Call
116
+ ```mermaid
117
+ sequenceDiagram
118
+ box Client Application
119
+ actor User
120
+ participant Driver as Driver<Listener>
121
+ participant Connector as Communicator (Client)
122
+ end
123
+ box Server Application
124
+ participant Acceptor as Communicator (Server)
125
+ actor Provider
126
+ end
127
+ User->>Driver: 1. calls a function
128
+ Activate User
129
+ Activate Driver
130
+ Driver->>Connector: 2. delivers the function call
131
+ Activate Connector
132
+ Deactivate Driver
133
+ Connector-->>Acceptor: 3. sends a protocolized<br/>network message<br/>meaning a function call
134
+ Deactivate Connector
135
+ Activate Acceptor
136
+ Acceptor->>Provider: 4. calls the function
137
+ Provider->>Acceptor: 5. returns a value
138
+ Acceptor-->>Connector: 6. sends a protocolized<br/>network message<br/>meaning a return value
139
+ Deactivate Acceptor
140
+ Activate Connector
141
+ Connector->>Driver: 7. delivers the return value
142
+ Deactivate Connector
143
+ Activate Driver
144
+ Driver->>User: 8. returns the value
145
+ Deactivate Driver
146
+ Deactivate User
147
+ ```
148
+
149
+ WebSocket protocol with RPC paradigm for AI chatbot.
150
+
151
+ `@agentica/rpc` supports WebSocket protocol that is utilizing [`TGrid`](https://github.com/samchon/tgrid) and its RPC (Remote Procedure Call) paradigm for easy and type safe development. In the RPC paradigm, client application can call a function of `IAgenticaRpcService` remotely as if it were its own object.
152
+
153
+ Internally, the RPC has composed with three elements; [`Communicator`](https://tgrid.com/docs/features/components/#communicator), [`Provider`](https://tgrid.com/docs/features/components/#provider) and [`Driver`](https://tgrid.com/docs/features/components/#driver). The first `Communicator` takes a responsibility of (WebSocket) network communication. The next `Provider` means an object providing to the remote system for RPC, and `Driver` is a proxy instance realizing the RPC to the remote provided `Provider` instance.
154
+
155
+ For example, below client application code is calling `IAgenticaRpcService.conversate()` function remotely through the `Driver<IAgenticaRpcService>` typed instance. In that case, `IAgenticaRpcService` is the `Provider` instance from server to client. And `WebSocketConnector` is the communicator taking responsibility of WebSocket communication.
156
+
157
+ ```typescript
158
+ import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
159
+ import { Driver, WebSocketConnector } from "tgrid";
160
+
161
+ const connector: WebSocketConnector<
162
+ null,
163
+ IAgenticaRpcListener,
164
+ IAgenticaRpcService
165
+ > = new WebSocketConnector(null, {
166
+ text: async (evt) => {
167
+ console.log(evt.role, evt.text);
168
+ },
169
+ describe: async (evt) => {
170
+ console.log("describer", evt.text);
171
+ },
172
+ });
173
+ await connector.connect("ws://localhost:3001");
174
+
175
+ const driver: Driver<IAgenticaRpcService> = connector.getDriver();
176
+ await driver.conversate("Hello, what you can do?");
177
177
  ```
@@ -1,4 +1,5 @@
1
1
  import { Agentica, IAgenticaController } from "@agentica/core";
2
+ import { ILlmSchema } from "@samchon/openapi";
2
3
  import { Primitive } from "typia";
3
4
  import { IAgenticaRpcListener } from "./IAgenticaRpcListener";
4
5
  import { IAgenticaRpcService } from "./IAgenticaRpcService";
@@ -45,14 +46,14 @@ import { IAgenticaRpcService } from "./IAgenticaRpcService";
45
46
  *
46
47
  * @author Samchon
47
48
  */
48
- export declare class AgenticaRpcService implements IAgenticaRpcService {
49
+ export declare class AgenticaRpcService<Model extends ILlmSchema.Model> implements IAgenticaRpcService<Model> {
49
50
  private readonly props;
50
51
  /**
51
52
  * Initializer Constructor.
52
53
  *
53
54
  * @param props Properties to construct the RPC service
54
55
  */
55
- constructor(props: AgenticaRpcService.IProps);
56
+ constructor(props: AgenticaRpcService.IProps<Model>);
56
57
  /**
57
58
  * @inheritDoc
58
59
  */
@@ -60,20 +61,20 @@ export declare class AgenticaRpcService implements IAgenticaRpcService {
60
61
  /**
61
62
  * @inheritDoc
62
63
  */
63
- getControllers(): Promise<Primitive<IAgenticaController>[]>;
64
+ getControllers(): Promise<Primitive<IAgenticaController<Model>>[]>;
64
65
  }
65
66
  export declare namespace AgenticaRpcService {
66
67
  /**
67
68
  * Properties of the {@link AgenticaRpcService}.
68
69
  */
69
- interface IProps {
70
+ interface IProps<Model extends ILlmSchema.Model> {
70
71
  /**
71
72
  * Target agent to provide as RPC service.
72
73
  */
73
- agent: Agentica;
74
+ agent: Agentica<Model>;
74
75
  /**
75
76
  * Listener to be binded on the agent.
76
77
  */
77
- listener: IAgenticaRpcListener;
78
+ listener: IAgenticaRpcListener<Model>;
78
79
  }
79
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AgenticaRpcService.js","sourceRoot":"","sources":["../src/AgenticaRpcService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAa,kBAAkB;IAC7B;;;;OAIG;IACH,YAAoC,KAAgC;QAAhC,UAAK,GAAL,KAAK,CAA2B;QAClE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;QAElC,sBAAsB;QACtB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzD,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjE,qBAAqB;QACrB,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACtE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9D,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9D,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,CAAC,CAAC,IAAI;gBAAE,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;QACnC,CAAC,CAAA,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClE,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,EAAmF,CAAC;QAC5H,CAAC;KAAA;CACF;AAvCD,gDAuCC;AAkBD;;GAEG;AACH,MAAM,SAAS,GAAG,CAAI,GAAM,EAAgB,EAAE,CAC5C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAiB,CAAC"}
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,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzD,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjE,qBAAqB;QACrB,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACtE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9D,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9D,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,CAAC,CAAC,IAAI;gBAAE,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;QACnC,CAAC,CAAA,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAQ,CAAC,SAAS,CAAC,GAAU,CAAC,CAAC,CAAC,CAAC;IACzE,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;;YAGzB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAEM,CAAC;QAC/C,CAAC;KAAA;CACF;AA7CD,gDA6CC;AAkBD;;GAEG;AACH,MAAM,SAAS,GAAG,CAAI,GAAM,EAAgB,EAAE,CAC5C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAiB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { IAgenticaEvent } from "@agentica/core";
2
+ import { ILlmSchema } from "@samchon/openapi";
2
3
  import { Primitive } from "typia";
3
4
  /**
4
5
  * RPC interface of AI agent listener.
@@ -42,7 +43,7 @@ import { Primitive } from "typia";
42
43
  *
43
44
  * @author Samchon
44
45
  */
45
- export interface IAgenticaRpcListener {
46
+ export interface IAgenticaRpcListener<Model extends ILlmSchema.Model> {
46
47
  /**
47
48
  * Describe the function executions' results.
48
49
  *
@@ -51,13 +52,13 @@ export interface IAgenticaRpcListener {
51
52
  *
52
53
  * @param evt Event of a description of function execution results
53
54
  */
54
- describe(evt: Primitive<IAgenticaEvent.IDescribe>): Promise<void>;
55
+ describe(evt: Primitive<IAgenticaEvent.IDescribe<Model>>): Promise<void>;
55
56
  /**
56
57
  * Text conversation message.
57
58
  *
58
59
  * @param evt Event of a text conversation message
59
60
  */
60
- text(evt: Primitive<IAgenticaEvent.IText>): Promise<void>;
61
+ text(evt: IAgenticaEvent.IText): Promise<void>;
61
62
  /**
62
63
  * Initialize the AI agent.
63
64
  *
@@ -66,7 +67,7 @@ export interface IAgenticaRpcListener {
66
67
  *
67
68
  * @param evt Event of initialization
68
69
  */
69
- initialize?(evt: Primitive<IAgenticaEvent.IInitialize>): Promise<void>;
70
+ initialize?(evt: IAgenticaEvent.IInitialize): Promise<void>;
70
71
  /**
71
72
  * Select a function to call.
72
73
  *
@@ -74,7 +75,7 @@ export interface IAgenticaRpcListener {
74
75
  *
75
76
  * @param evt Event of selecting a function to call
76
77
  */
77
- select?(evt: Primitive<IAgenticaEvent.ISelect>): Promise<void>;
78
+ select?(evt: Primitive<IAgenticaEvent.ISelect<Model>>): Promise<void>;
78
79
  /**
79
80
  * Cancel a function to call.
80
81
  *
@@ -82,7 +83,7 @@ export interface IAgenticaRpcListener {
82
83
  *
83
84
  * @param evt Event of canceling a function to call
84
85
  */
85
- cancel?(evt: Primitive<IAgenticaEvent.ICancel>): Promise<void>;
86
+ cancel?(evt: Primitive<IAgenticaEvent.ICancel<Model>>): Promise<void>;
86
87
  /**
87
88
  * Call a function.
88
89
  *
@@ -100,7 +101,7 @@ export interface IAgenticaRpcListener {
100
101
  * @param evt Event of a function calling
101
102
  * @return New arguments if you want to modify, otherwise null or undefined
102
103
  */
103
- call?(evt: Primitive<IAgenticaEvent.ICall>): Promise<object | null | undefined>;
104
+ call?(evt: Primitive<IAgenticaEvent.ICall<Model>>): Promise<object | null | undefined>;
104
105
  /**
105
106
  * Executition of a function.
106
107
  *
@@ -108,5 +109,5 @@ export interface IAgenticaRpcListener {
108
109
  *
109
110
  * @param evt Event of a function execution
110
111
  */
111
- execute?(evt: Primitive<IAgenticaEvent.IExecute>): Promise<void>;
112
+ execute?(evt: IAgenticaEvent.IExecute<Model>): Promise<void>;
112
113
  }
@@ -1,4 +1,5 @@
1
1
  import { IAgenticaController } from "@agentica/core";
2
+ import { ILlmSchema } from "@samchon/openapi";
2
3
  import { Primitive } from "typia";
3
4
  /**
4
5
  * RPC interface of AI agent service.
@@ -13,7 +14,7 @@ import { Primitive } from "typia";
13
14
  *
14
15
  * @author Samchon
15
16
  */
16
- export interface IAgenticaRpcService {
17
+ export interface IAgenticaRpcService<Model extends ILlmSchema.Model> {
17
18
  /**
18
19
  * Conversate with the AI agent.
19
20
  *
@@ -34,5 +35,5 @@ export interface IAgenticaRpcService {
34
35
  * Get controllers, collection of functions that would be
35
36
  * called by the AI chatbot.
36
37
  */
37
- getControllers(): Promise<Primitive<IAgenticaController[]>>;
38
+ getControllers(): Promise<Primitive<IAgenticaController<Model>[]>>;
38
39
  }
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","evt","text","primitive","describe","initialize","select","cancel","async","args","call","arguments","execute","conversate","content","getControllers","obj","JSON","parse","stringify"],"mappings":"MAiDaA;IAMX,WAAAC,CAAoCC;QAAAC,KAAKD,QAALA;QAClC,OAAME,OAAOC,YAAeH;QAG5BE,MAAME,GAAG,SAASC,OAAQF,SAASG,KAAKC,UAAUF;QAClDH,MAAME,GAAG,aAAaC,OAAQF,SAASK,SAASD,UAAUF;QAG1DH,MAAME,GAAG,eAAeC,OAAQF,SAASM,WAAYF,UAAUF;QAC/DH,MAAME,GAAG,WAAWC,OAAQF,SAASO,OAAQH,UAAUF;QACvDH,MAAME,GAAG,WAAWC,OAAQF,SAASQ,OAAQJ,UAAUF;QACvDH,MAAME,GAAG,SAAQQ,MAAOP;YACtB,MAAMQ,aAAwCV,SAASW,KACrDP,UAAUF;YAEZ,MAAMQ,MAAMR,IAAIU,YAAYF;AAAI;QAElCX,MAAME,GAAG,YAAYC,OAAQF,SAASa,QAAST,UAAUF;;IAMpD,gBAAMY,CAAWC;cAChBjB,KAAKD,MAAME,MAAMe,WAAWC;;IAM7B,oBAAMC;QACX,OAAOlB,KAAKD,MAAME,MAAMiB;;;;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","evt","text","primitive","describe","initialize","select","cancel","async","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,SAASC,OAAQF,SAASG,KAAKC,UAAUF;QAClDH,MAAME,GAAG,aAAaC,OAAQF,SAASK,SAASD,UAAUF;QAG1DH,MAAME,GAAG,eAAeC,OAAQF,SAASM,WAAYF,UAAUF;QAC/DH,MAAME,GAAG,WAAWC,OAAQF,SAASO,OAAQH,UAAUF;QACvDH,MAAME,GAAG,WAAWC,OAAQF,SAASQ,OAAQJ,UAAUF;QACvDH,MAAME,GAAG,SAAQQ,MAAOP;YACtB,MAAMQ,aAAwCV,SAASW,KACrDP,UAAUF;YAEZ,MAAMQ,MAAMR,IAAIU,YAAYF;AAAI;QAElCX,MAAME,GAAG,YAAYC,OAAQF,SAASa,QAAST,UAAUF;;IAMpD,gBAAMY,CAAWC;cAChBjB,KAAKD,MAAME,MAAMe,WAAWC;;IAM7B,oBAAMC;QAGX,OAAOlB,KAAKD,MAAME,MAAMiB;;;;AAyB5B,MAAMZ,YAAgBa,OACpBC,KAAKC,MAAMD,KAAKE,UAAUH;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentica/rpc",
3
- "version": "0.8.3",
3
+ "version": "0.9.0-dev.20250302",
4
4
  "main": "lib/index.js",
5
5
  "description": "Agentic AI Library specialized in LLM Function Calling",
6
6
  "scripts": {
@@ -37,13 +37,13 @@
37
37
  "src"
38
38
  ],
39
39
  "dependencies": {
40
- "@agentica/core": "^0.8.3",
41
- "@samchon/openapi": "^2.4.3",
40
+ "@agentica/core": "^0.9.0-dev.20250302",
41
+ "@samchon/openapi": "^3.0.0",
42
42
  "@samchon/shopping-api": "^0.15.0",
43
43
  "chalk": "4.1.2",
44
44
  "openai": "^4.80.0",
45
45
  "tstl": "^3.0.0",
46
- "typia": "^7.6.4"
46
+ "typia": "^8.0.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@rollup/plugin-terser": "^0.4.4",
@@ -53,7 +53,7 @@
53
53
  "rollup": "^4.34.8",
54
54
  "ts-patch": "^3.3.0",
55
55
  "typedoc": "^0.27.7",
56
- "typescript": "~5.7.3"
56
+ "typescript": "~5.8.2"
57
57
  },
58
58
  "module": "lib/index.mjs",
59
59
  "typings": "lib/index.d.ts"
@@ -1,111 +1,118 @@
1
- import { Agentica, IAgenticaController } from "@agentica/core";
2
- import { Primitive } from "typia";
3
-
4
- import { IAgenticaRpcListener } from "./IAgenticaRpcListener";
5
- import { IAgenticaRpcService } from "./IAgenticaRpcService";
6
-
7
- /**
8
- * RPC service for the {@link Agentica}.
9
- *
10
- * `AgenticaRpcService` is class defining an AI agent service
11
- * provided from the server to clients through the RPC (Remote Procedure Call)
12
- * paradigm in the websocket protocol.
13
- *
14
- * Client connecting to the `AgenticaRpcService` providing websocket server
15
- * will call the {@link conversate} function remotely through its basic
16
- * interface type {@link IAgenticaRpcService} with the RPC paradigm.
17
- *
18
- * Also, the client provides the {@link IAgenticaRpcListener} type to the
19
- * server, so that `AgenticaRpcService` will remotely call the
20
- * {@link IAgenticaRpcListener listener}'s functions internally.
21
- *
22
- * You can open the WebSocket server of the AI agent like below:
23
- *
24
- * ```typescript
25
- * import {
26
- * IAgenticaRpcListener,
27
- * IAgenticaRpcService,
28
- * Agentica,
29
- * AgenticaRpcService,
30
- * } from "@agentica/core";
31
- * import { WebSocketServer } from "tgrid";
32
- *
33
- * const server: WebSocketServer<
34
- * null,
35
- * IAgenticaRpcService,
36
- * IAgenticaRpcListener
37
- * > = new WebSocketServer();
38
- * await server.open(3001, async (acceptor) => {
39
- * await acceptor.accept(
40
- * new AgenticaRpcService({
41
- * agent: new Agentica({ ... }),
42
- * listener: acceptor.getDriver(),
43
- * }),
44
- * );
45
- * });
46
- * ```
47
- *
48
- * @author Samchon
49
- */
50
- export class AgenticaRpcService implements IAgenticaRpcService {
51
- /**
52
- * Initializer Constructor.
53
- *
54
- * @param props Properties to construct the RPC service
55
- */
56
- public constructor(private readonly props: AgenticaRpcService.IProps) {
57
- const { agent, listener } = props;
58
-
59
- // ESSENTIAL LISTENERS
60
- agent.on("text", (evt) => listener.text(primitive(evt)));
61
- agent.on("describe", (evt) => listener.describe(primitive(evt)));
62
-
63
- // OPTIONAL LISTENERS
64
- agent.on("initialize", (evt) => listener.initialize!(primitive(evt)));
65
- agent.on("select", (evt) => listener.select!(primitive(evt)));
66
- agent.on("cancel", (evt) => listener.cancel!(primitive(evt)));
67
- agent.on("call", async (evt) => {
68
- const args: object | null | undefined = await listener.call!(
69
- primitive(evt),
70
- );
71
- if (!!args) evt.arguments = args;
72
- });
73
- agent.on("execute", (evt) => listener.execute!(primitive(evt)));
74
- }
75
-
76
- /**
77
- * @inheritDoc
78
- */
79
- public async conversate(content: string): Promise<void> {
80
- await this.props.agent.conversate(content);
81
- }
82
-
83
- /**
84
- * @inheritDoc
85
- */
86
- public async getControllers(): Promise<Primitive<IAgenticaController>[]> {
87
- return this.props.agent.getControllers() satisfies ReadonlyArray<IAgenticaController> as Primitive<IAgenticaController>[];
88
- }
89
- }
90
- export namespace AgenticaRpcService {
91
- /**
92
- * Properties of the {@link AgenticaRpcService}.
93
- */
94
- export interface IProps {
95
- /**
96
- * Target agent to provide as RPC service.
97
- */
98
- agent: Agentica;
99
-
100
- /**
101
- * Listener to be binded on the agent.
102
- */
103
- listener: IAgenticaRpcListener;
104
- }
105
- }
106
-
107
- /**
108
- * @internal
109
- */
110
- const primitive = <T>(obj: T): Primitive<T> =>
111
- JSON.parse(JSON.stringify(obj)) as Primitive<T>;
1
+ import { Agentica, IAgenticaController } from "@agentica/core";
2
+ import { ILlmSchema } from "@samchon/openapi";
3
+ import { Primitive } from "typia";
4
+
5
+ import { IAgenticaRpcListener } from "./IAgenticaRpcListener";
6
+ import { IAgenticaRpcService } from "./IAgenticaRpcService";
7
+
8
+ /**
9
+ * RPC service for the {@link Agentica}.
10
+ *
11
+ * `AgenticaRpcService` is class defining an AI agent service
12
+ * provided from the server to clients through the RPC (Remote Procedure Call)
13
+ * paradigm in the websocket protocol.
14
+ *
15
+ * Client connecting to the `AgenticaRpcService` providing websocket server
16
+ * will call the {@link conversate} function remotely through its basic
17
+ * interface type {@link IAgenticaRpcService} with the RPC paradigm.
18
+ *
19
+ * Also, the client provides the {@link IAgenticaRpcListener} type to the
20
+ * server, so that `AgenticaRpcService` will remotely call the
21
+ * {@link IAgenticaRpcListener listener}'s functions internally.
22
+ *
23
+ * You can open the WebSocket server of the AI agent like below:
24
+ *
25
+ * ```typescript
26
+ * import {
27
+ * IAgenticaRpcListener,
28
+ * IAgenticaRpcService,
29
+ * Agentica,
30
+ * AgenticaRpcService,
31
+ * } from "@agentica/core";
32
+ * import { WebSocketServer } from "tgrid";
33
+ *
34
+ * const server: WebSocketServer<
35
+ * null,
36
+ * IAgenticaRpcService,
37
+ * IAgenticaRpcListener
38
+ * > = new WebSocketServer();
39
+ * await server.open(3001, async (acceptor) => {
40
+ * await acceptor.accept(
41
+ * new AgenticaRpcService({
42
+ * agent: new Agentica({ ... }),
43
+ * listener: acceptor.getDriver(),
44
+ * }),
45
+ * );
46
+ * });
47
+ * ```
48
+ *
49
+ * @author Samchon
50
+ */
51
+ export class AgenticaRpcService<Model extends ILlmSchema.Model>
52
+ implements IAgenticaRpcService<Model>
53
+ {
54
+ /**
55
+ * Initializer Constructor.
56
+ *
57
+ * @param props Properties to construct the RPC service
58
+ */
59
+ public constructor(private readonly props: AgenticaRpcService.IProps<Model>) {
60
+ const { agent, listener } = props;
61
+
62
+ // ESSENTIAL LISTENERS
63
+ agent.on("text", (evt) => listener.text(primitive(evt)));
64
+ agent.on("describe", (evt) => listener.describe(primitive(evt)));
65
+
66
+ // OPTIONAL LISTENERS
67
+ agent.on("initialize", (evt) => listener.initialize!(primitive(evt)));
68
+ agent.on("select", (evt) => listener.select!(primitive(evt)));
69
+ agent.on("cancel", (evt) => listener.cancel!(primitive(evt)));
70
+ agent.on("call", async (evt) => {
71
+ const args: object | null | undefined = await listener.call!(
72
+ primitive(evt),
73
+ );
74
+ if (!!args) evt.arguments = args;
75
+ });
76
+ agent.on("execute", (evt) => listener.execute!(primitive(evt as any)));
77
+ }
78
+
79
+ /**
80
+ * @inheritDoc
81
+ */
82
+ public async conversate(content: string): Promise<void> {
83
+ await this.props.agent.conversate(content);
84
+ }
85
+
86
+ /**
87
+ * @inheritDoc
88
+ */
89
+ public async getControllers(): Promise<
90
+ Primitive<IAgenticaController<Model>>[]
91
+ > {
92
+ return this.props.agent.getControllers() satisfies ReadonlyArray<
93
+ IAgenticaController<Model>
94
+ > as Primitive<IAgenticaController<Model>>[];
95
+ }
96
+ }
97
+ export namespace AgenticaRpcService {
98
+ /**
99
+ * Properties of the {@link AgenticaRpcService}.
100
+ */
101
+ export interface IProps<Model extends ILlmSchema.Model> {
102
+ /**
103
+ * Target agent to provide as RPC service.
104
+ */
105
+ agent: Agentica<Model>;
106
+
107
+ /**
108
+ * Listener to be binded on the agent.
109
+ */
110
+ listener: IAgenticaRpcListener<Model>;
111
+ }
112
+ }
113
+
114
+ /**
115
+ * @internal
116
+ */
117
+ const primitive = <T>(obj: T): Primitive<T> =>
118
+ JSON.parse(JSON.stringify(obj)) as Primitive<T>;
@@ -1,121 +1,122 @@
1
- import { IAgenticaEvent } from "@agentica/core";
2
- import { Primitive } from "typia";
3
-
4
- /**
5
- * RPC interface of AI agent listener.
6
- *
7
- * `IAgenticaRpcListener` is an interface defining an AI agent listener
8
- * provided from the client to server through the RPC (Remote Procedure Call)
9
- * paradigm in the websocket protocol.
10
- *
11
- * It has defined the event listener functions of {@link IAgenticaEvent}
12
- * types. If you skip some event typed functions' implementations,
13
- * the skipped event would be ignored.
14
- *
15
- * Also, the event like listener functions of `IAgenticaRpcListener` type
16
- * are remotely called when a client calls the
17
- * {@link IAgenticaRpcService.conversate} function remotely, so that the
18
- * server responses to the client by the event listener functions.
19
- *
20
- * You can connect to the WebSocket server of the AI agent like below:
21
- *
22
- * ```typescript
23
- * import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/core";
24
- * import { Driver, WebSocketConnector } from "tgrid";
25
- *
26
- * const connector: WebSocketConnector<
27
- * null,
28
- * IAgenticaRpcListener,
29
- * IAgenticaRpcService
30
- * > = new WebSocketConnector(null, {
31
- * text: async (evt) => {
32
- * console.log(evt.role, evt.text);
33
- * },
34
- * describe: async (evt) => {
35
- * console.log("describer", evt.text);
36
- * },
37
- * });
38
- * await connector.connect("ws://localhost:3001");
39
- *
40
- * const driver: Driver<IAgenticaRpcService> = connector.getDriver();
41
- * await driver.conversate("Hello, what you can do?");
42
- * ```
43
- *
44
- * @author Samchon
45
- */
46
- export interface IAgenticaRpcListener {
47
- /**
48
- * Describe the function executions' results.
49
- *
50
- * Inform description message of the function execution's results from
51
- * the AI agent server to client.
52
- *
53
- * @param evt Event of a description of function execution results
54
- */
55
- describe(evt: Primitive<IAgenticaEvent.IDescribe>): Promise<void>;
56
-
57
- /**
58
- * Text conversation message.
59
- *
60
- * @param evt Event of a text conversation message
61
- */
62
- text(evt: Primitive<IAgenticaEvent.IText>): Promise<void>;
63
-
64
- /**
65
- * Initialize the AI agent.
66
- *
67
- * Informs an initialization of controller functions from
68
- * the AI agent server to client.
69
- *
70
- * @param evt Event of initialization
71
- */
72
- initialize?(evt: Primitive<IAgenticaEvent.IInitialize>): Promise<void>;
73
-
74
- /**
75
- * Select a function to call.
76
- *
77
- * Informs a selected function to call from the AI agent server to client.
78
- *
79
- * @param evt Event of selecting a function to call
80
- */
81
- select?(evt: Primitive<IAgenticaEvent.ISelect>): Promise<void>;
82
-
83
- /**
84
- * Cancel a function to call.
85
- *
86
- * Informs a canceling function to call from the AI agent server to client.
87
- *
88
- * @param evt Event of canceling a function to call
89
- */
90
- cancel?(evt: Primitive<IAgenticaEvent.ICancel>): Promise<void>;
91
-
92
- /**
93
- * Call a function.
94
- *
95
- * Informs a function calling from the AI agent server to client.
96
- *
97
- * This event comes before the function execution, so that if you return
98
- * a different value from the original {@link IAgenticaEvent.ICall.arguments},
99
- * you can modify the arguments of the function calling.
100
- *
101
- * Otherwise you do not return anything (`undefined`) or `null` value, the
102
- * arguments of the function calling would not be modified. Also, if you are
103
- * not interested in the function calling event, you can skit its
104
- * implementation.
105
- *
106
- * @param evt Event of a function calling
107
- * @return New arguments if you want to modify, otherwise null or undefined
108
- */
109
- call?(
110
- evt: Primitive<IAgenticaEvent.ICall>,
111
- ): Promise<object | null | undefined>;
112
-
113
- /**
114
- * Executition of a function.
115
- *
116
- * Informs a function execution from the AI agent server to client.
117
- *
118
- * @param evt Event of a function execution
119
- */
120
- execute?(evt: Primitive<IAgenticaEvent.IExecute>): Promise<void>;
121
- }
1
+ import { IAgenticaEvent } from "@agentica/core";
2
+ import { ILlmSchema } from "@samchon/openapi";
3
+ import { Primitive } from "typia";
4
+
5
+ /**
6
+ * RPC interface of AI agent listener.
7
+ *
8
+ * `IAgenticaRpcListener` is an interface defining an AI agent listener
9
+ * provided from the client to server through the RPC (Remote Procedure Call)
10
+ * paradigm in the websocket protocol.
11
+ *
12
+ * It has defined the event listener functions of {@link IAgenticaEvent}
13
+ * types. If you skip some event typed functions' implementations,
14
+ * the skipped event would be ignored.
15
+ *
16
+ * Also, the event like listener functions of `IAgenticaRpcListener` type
17
+ * are remotely called when a client calls the
18
+ * {@link IAgenticaRpcService.conversate} function remotely, so that the
19
+ * server responses to the client by the event listener functions.
20
+ *
21
+ * You can connect to the WebSocket server of the AI agent like below:
22
+ *
23
+ * ```typescript
24
+ * import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/core";
25
+ * import { Driver, WebSocketConnector } from "tgrid";
26
+ *
27
+ * const connector: WebSocketConnector<
28
+ * null,
29
+ * IAgenticaRpcListener,
30
+ * IAgenticaRpcService
31
+ * > = new WebSocketConnector(null, {
32
+ * text: async (evt) => {
33
+ * console.log(evt.role, evt.text);
34
+ * },
35
+ * describe: async (evt) => {
36
+ * console.log("describer", evt.text);
37
+ * },
38
+ * });
39
+ * await connector.connect("ws://localhost:3001");
40
+ *
41
+ * const driver: Driver<IAgenticaRpcService> = connector.getDriver();
42
+ * await driver.conversate("Hello, what you can do?");
43
+ * ```
44
+ *
45
+ * @author Samchon
46
+ */
47
+ export interface IAgenticaRpcListener<Model extends ILlmSchema.Model> {
48
+ /**
49
+ * Describe the function executions' results.
50
+ *
51
+ * Inform description message of the function execution's results from
52
+ * the AI agent server to client.
53
+ *
54
+ * @param evt Event of a description of function execution results
55
+ */
56
+ describe(evt: Primitive<IAgenticaEvent.IDescribe<Model>>): Promise<void>;
57
+
58
+ /**
59
+ * Text conversation message.
60
+ *
61
+ * @param evt Event of a text conversation message
62
+ */
63
+ text(evt: IAgenticaEvent.IText): Promise<void>;
64
+
65
+ /**
66
+ * Initialize the AI agent.
67
+ *
68
+ * Informs an initialization of controller functions from
69
+ * the AI agent server to client.
70
+ *
71
+ * @param evt Event of initialization
72
+ */
73
+ initialize?(evt: IAgenticaEvent.IInitialize): Promise<void>;
74
+
75
+ /**
76
+ * Select a function to call.
77
+ *
78
+ * Informs a selected function to call from the AI agent server to client.
79
+ *
80
+ * @param evt Event of selecting a function to call
81
+ */
82
+ select?(evt: Primitive<IAgenticaEvent.ISelect<Model>>): Promise<void>;
83
+
84
+ /**
85
+ * Cancel a function to call.
86
+ *
87
+ * Informs a canceling function to call from the AI agent server to client.
88
+ *
89
+ * @param evt Event of canceling a function to call
90
+ */
91
+ cancel?(evt: Primitive<IAgenticaEvent.ICancel<Model>>): Promise<void>;
92
+
93
+ /**
94
+ * Call a function.
95
+ *
96
+ * Informs a function calling from the AI agent server to client.
97
+ *
98
+ * This event comes before the function execution, so that if you return
99
+ * a different value from the original {@link IAgenticaEvent.ICall.arguments},
100
+ * you can modify the arguments of the function calling.
101
+ *
102
+ * Otherwise you do not return anything (`undefined`) or `null` value, the
103
+ * arguments of the function calling would not be modified. Also, if you are
104
+ * not interested in the function calling event, you can skit its
105
+ * implementation.
106
+ *
107
+ * @param evt Event of a function calling
108
+ * @return New arguments if you want to modify, otherwise null or undefined
109
+ */
110
+ call?(
111
+ evt: Primitive<IAgenticaEvent.ICall<Model>>,
112
+ ): Promise<object | null | undefined>;
113
+
114
+ /**
115
+ * Executition of a function.
116
+ *
117
+ * Informs a function execution from the AI agent server to client.
118
+ *
119
+ * @param evt Event of a function execution
120
+ */
121
+ execute?(evt: IAgenticaEvent.IExecute<Model>): Promise<void>;
122
+ }
@@ -1,40 +1,41 @@
1
- import { IAgenticaController } from "@agentica/core";
2
- import { Primitive } from "typia";
3
-
4
- /**
5
- * RPC interface of AI agent service.
6
- *
7
- * `IAgenticaRpcService` is an interface defining an AI agent service
8
- * provided from the server to client through the RPC (Remote Procedure Call)
9
- * paradigm in the websocket protocol.
10
- *
11
- * The client will call the {@link conversate} function remotely, and the
12
- * server responses to the client by calling the client's
13
- * {@link IAgenticaRpcListener} functions remotely too.
14
- *
15
- * @author Samchon
16
- */
17
- export interface IAgenticaRpcService {
18
- /**
19
- * Conversate with the AI agent.
20
- *
21
- * User talks to the AI agent with the content.
22
- *
23
- * When AI agent responds some actions like conversating or executing
24
- * LLM (Large Language Model) function calling, the functions defined in the
25
- * {@link IAgenticaRpcListener} would be called through the RPC
26
- * (Remote Procedure Call) paradigm.
27
- *
28
- * @param content The content to talk
29
- * @returns Returned when the conversation process is completely done
30
- */
31
- conversate(content: string): Promise<void>;
32
-
33
- /**
34
- * Get controllers.
35
- *
36
- * Get controllers, collection of functions that would be
37
- * called by the AI chatbot.
38
- */
39
- getControllers(): Promise<Primitive<IAgenticaController[]>>;
40
- }
1
+ import { IAgenticaController } from "@agentica/core";
2
+ import { ILlmSchema } from "@samchon/openapi";
3
+ import { Primitive } from "typia";
4
+
5
+ /**
6
+ * RPC interface of AI agent service.
7
+ *
8
+ * `IAgenticaRpcService` is an interface defining an AI agent service
9
+ * provided from the server to client through the RPC (Remote Procedure Call)
10
+ * paradigm in the websocket protocol.
11
+ *
12
+ * The client will call the {@link conversate} function remotely, and the
13
+ * server responses to the client by calling the client's
14
+ * {@link IAgenticaRpcListener} functions remotely too.
15
+ *
16
+ * @author Samchon
17
+ */
18
+ export interface IAgenticaRpcService<Model extends ILlmSchema.Model> {
19
+ /**
20
+ * Conversate with the AI agent.
21
+ *
22
+ * User talks to the AI agent with the content.
23
+ *
24
+ * When AI agent responds some actions like conversating or executing
25
+ * LLM (Large Language Model) function calling, the functions defined in the
26
+ * {@link IAgenticaRpcListener} would be called through the RPC
27
+ * (Remote Procedure Call) paradigm.
28
+ *
29
+ * @param content The content to talk
30
+ * @returns Returned when the conversation process is completely done
31
+ */
32
+ conversate(content: string): Promise<void>;
33
+
34
+ /**
35
+ * Get controllers.
36
+ *
37
+ * Get controllers, collection of functions that would be
38
+ * called by the AI chatbot.
39
+ */
40
+ getControllers(): Promise<Primitive<IAgenticaController<Model>[]>>;
41
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./IAgenticaRpcListener";
2
- export * from "./IAgenticaRpcService";
3
- export * from "./AgenticaRpcService";
1
+ export * from "./IAgenticaRpcListener";
2
+ export * from "./IAgenticaRpcService";
3
+ export * from "./AgenticaRpcService";