File tree 3 files changed +28
-18
lines changed
3 files changed +28
-18
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
26
26
import { confluxPlugin } from "@ai16z/plugin-conflux" ;
27
27
import { solanaPlugin } from "@ai16z/plugin-solana" ;
28
28
import { zgPlugin } from "@ai16z/plugin-0g" ;
29
- import { nodePlugin } from "@ai16z/plugin-node" ;
29
+ import { type NodePlugin , createNodePlugin } from "@ai16z/plugin-node" ;
30
30
import {
31
31
coinbaseCommercePlugin ,
32
32
coinbaseMassPaymentsPlugin ,
@@ -238,6 +238,8 @@ function getSecret(character: Character, secret: string) {
238
238
return character . settings . secrets ?. [ secret ] || process . env [ secret ] ;
239
239
}
240
240
241
+ let nodePlugin : NodePlugin | undefined ;
242
+
241
243
export function createAgent (
242
244
character : Character ,
243
245
db : IDatabaseAdapter ,
@@ -249,6 +251,9 @@ export function createAgent(
249
251
"Creating runtime for character" ,
250
252
character . name
251
253
) ;
254
+
255
+ nodePlugin ??= createNodePlugin ( ) ;
256
+
252
257
return new AgentRuntime ( {
253
258
databaseAdapter : db ,
254
259
token,
Original file line number Diff line number Diff line change @@ -12,18 +12,21 @@ import {
12
12
VideoService ,
13
13
} from "./services/index.ts" ;
14
14
15
- export const nodePlugin : Plugin = {
16
- name : "default" ,
17
- description : "Default plugin, with basic actions and evaluators" ,
18
- services : [
19
- new BrowserService ( ) ,
20
- new ImageDescriptionService ( ) ,
21
- new LlamaService ( ) ,
22
- new PdfService ( ) ,
23
- new SpeechService ( ) ,
24
- new TranscriptionService ( ) ,
25
- new VideoService ( ) ,
26
- ] ,
27
- } ;
28
15
29
- export default nodePlugin ;
16
+ export type NodePlugin = ReturnType < typeof createNodePlugin >
17
+
18
+ export function createNodePlugin ( ) {
19
+ return {
20
+ name : "default" ,
21
+ description : "Default plugin, with basic actions and evaluators" ,
22
+ services : [
23
+ new BrowserService ( ) ,
24
+ new ImageDescriptionService ( ) ,
25
+ new LlamaService ( ) ,
26
+ new PdfService ( ) ,
27
+ new SpeechService ( ) ,
28
+ new TranscriptionService ( ) ,
29
+ new VideoService ( ) ,
30
+ ] ,
31
+ } as const satisfies Plugin
32
+ } ;
Original file line number Diff line number Diff line change @@ -87,7 +87,9 @@ export class BrowserService extends Service implements IBrowserService {
87
87
) ;
88
88
}
89
89
90
- async initialize ( ) {
90
+ async initialize ( ) { }
91
+
92
+ async initializeBrowser ( ) {
91
93
if ( ! this . browser ) {
92
94
this . browser = await chromium . launch ( {
93
95
args : [ "--no-sandbox" , "--disable-setuid-sandbox" ] ,
@@ -118,7 +120,7 @@ export class BrowserService extends Service implements IBrowserService {
118
120
url : string ,
119
121
runtime : IAgentRuntime
120
122
) : Promise < PageContent > {
121
- await this . initialize ( ) ;
123
+ await this . initializeBrowser ( ) ;
122
124
this . queue . push ( url ) ;
123
125
this . processQueue ( runtime ) ;
124
126
@@ -181,7 +183,7 @@ export class BrowserService extends Service implements IBrowserService {
181
183
try {
182
184
if ( ! this . context ) {
183
185
console . log (
184
- "Browser context not initialized. Call initialize () first."
186
+ "Browser context not initialized. Call initializeBrowser () first."
185
187
) ;
186
188
}
187
189
You can’t perform that action at this time.
0 commit comments