@agentica/rpc 0.7.0 → 0.8.0
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 +69 -1
- package/lib/AgenticaRpcService.d.ts +6 -1
- package/lib/AgenticaRpcService.js +8 -0
- package/lib/AgenticaRpcService.js.map +1 -1
- package/lib/IAgenticaRpcService.d.ts +9 -0
- package/lib/index.mjs +3 -0
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/AgenticaRpcService.ts +8 -1
- package/src/IAgenticaRpcService.ts +11 -0
package/README.md
CHANGED
|
@@ -106,4 +106,72 @@ When developing frontend application, define `IAgenticaRpcListener` instance.
|
|
|
106
106
|
|
|
107
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
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.
|
|
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
|
+
```
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Agentica } from "@agentica/core";
|
|
1
|
+
import { Agentica, IAgenticaController } from "@agentica/core";
|
|
2
|
+
import { Primitive } from "typia";
|
|
2
3
|
import { IAgenticaRpcListener } from "./IAgenticaRpcListener";
|
|
3
4
|
import { IAgenticaRpcService } from "./IAgenticaRpcService";
|
|
4
5
|
/**
|
|
@@ -56,6 +57,10 @@ export declare class AgenticaRpcService implements IAgenticaRpcService {
|
|
|
56
57
|
* @inheritDoc
|
|
57
58
|
*/
|
|
58
59
|
conversate(content: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
getControllers(): Promise<Primitive<IAgenticaController>[]>;
|
|
59
64
|
}
|
|
60
65
|
export declare namespace AgenticaRpcService {
|
|
61
66
|
/**
|
|
@@ -84,6 +84,14 @@ class AgenticaRpcService {
|
|
|
84
84
|
yield this.props.agent.conversate(content);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* @inheritDoc
|
|
89
|
+
*/
|
|
90
|
+
getControllers() {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
return this.props.agent.getControllers();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
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|
3
5
|
*
|
|
@@ -26,4 +28,11 @@ export interface IAgenticaRpcService {
|
|
|
26
28
|
* @returns Returned when the conversation process is completely done
|
|
27
29
|
*/
|
|
28
30
|
conversate(content: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Get controllers.
|
|
33
|
+
*
|
|
34
|
+
* Get controllers, collection of functions that would be
|
|
35
|
+
* called by the AI chatbot.
|
|
36
|
+
*/
|
|
37
|
+
getControllers(): Promise<Primitive<IAgenticaController[]>>;
|
|
29
38
|
}
|
package/lib/index.mjs
CHANGED
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","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;;;;
|
|
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;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentica/rpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "Agentic AI Library specialized in LLM Function Calling",
|
|
6
6
|
"scripts": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"src"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@agentica/core": "^0.
|
|
40
|
+
"@agentica/core": "^0.8.0",
|
|
41
41
|
"@samchon/openapi": "^2.4.3",
|
|
42
42
|
"@samchon/shopping-api": "^0.15.0",
|
|
43
43
|
"chalk": "4.1.2",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agentica } from "@agentica/core";
|
|
1
|
+
import { Agentica, IAgenticaController } from "@agentica/core";
|
|
2
2
|
import { Primitive } from "typia";
|
|
3
3
|
|
|
4
4
|
import { IAgenticaRpcListener } from "./IAgenticaRpcListener";
|
|
@@ -79,6 +79,13 @@ export class AgenticaRpcService implements IAgenticaRpcService {
|
|
|
79
79
|
public async conversate(content: string): Promise<void> {
|
|
80
80
|
await this.props.agent.conversate(content);
|
|
81
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
|
+
}
|
|
82
89
|
}
|
|
83
90
|
export namespace AgenticaRpcService {
|
|
84
91
|
/**
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { IAgenticaController } from "@agentica/core";
|
|
2
|
+
import { Primitive } from "typia";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* RPC interface of AI agent service.
|
|
3
6
|
*
|
|
@@ -26,4 +29,12 @@ export interface IAgenticaRpcService {
|
|
|
26
29
|
* @returns Returned when the conversation process is completely done
|
|
27
30
|
*/
|
|
28
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[]>>;
|
|
29
40
|
}
|