@@ -51,17 +51,11 @@ Note that {{agentName}} is capable of reading/seeing/hearing various forms of me
51
51
# Instructions: Write the next message for {{agentName}}.
52
52
` + messageCompletionFooter ;
53
53
54
- export interface SimliClientConfig {
55
- apiKey : string ;
56
- faceID : string ;
57
- handleSilence : boolean ;
58
- videoRef : any ;
59
- audioRef : any ;
60
- }
61
54
export class DirectClient {
62
55
public app : express . Application ;
63
- private agents : Map < string , AgentRuntime > ;
56
+ private agents : Map < string , AgentRuntime > ; // container management
64
57
private server : any ; // Store server instance
58
+ public startAgent : Function ; // Store startAgent functor
65
59
66
60
constructor ( ) {
67
61
elizaLogger . log ( "DirectClient constructor" ) ;
@@ -72,7 +66,7 @@ export class DirectClient {
72
66
this . app . use ( bodyParser . json ( ) ) ;
73
67
this . app . use ( bodyParser . urlencoded ( { extended : true } ) ) ;
74
68
75
- const apiRouter = createApiRouter ( this . agents ) ;
69
+ const apiRouter = createApiRouter ( this . agents , this ) ;
76
70
this . app . use ( apiRouter ) ;
77
71
78
72
// Define an interface that extends the Express Request interface
@@ -338,7 +332,7 @@ export class DirectClient {
338
332
fileResponse . headers
339
333
. get ( "content-disposition" )
340
334
?. split ( "filename=" ) [ 1 ]
341
- ?. replace ( / " / g, "" ) || "default_name.txt" ;
335
+ ?. replace ( / " / g, /* " */ "" ) || "default_name.txt" ;
342
336
343
337
console . log ( "Saving as:" , fileName ) ;
344
338
@@ -378,6 +372,7 @@ export class DirectClient {
378
372
) ;
379
373
}
380
374
375
+ // agent/src/index.ts:startAgent calls this
381
376
public registerAgent ( runtime : AgentRuntime ) {
382
377
this . agents . set ( runtime . agentId , runtime ) ;
383
378
}
@@ -388,7 +383,7 @@ export class DirectClient {
388
383
389
384
public start ( port : number ) {
390
385
this . server = this . app . listen ( port , ( ) => {
391
- elizaLogger . success ( `Server running at http://localhost:${ port } / ` ) ;
386
+ elizaLogger . success ( `REST API bound to 0.0.0.0: ${ port } . If running locally, access it at http://localhost:${ port } . ` ) ;
392
387
} ) ;
393
388
394
389
// Handle graceful shutdown
@@ -430,7 +425,7 @@ export const DirectClientInterface: Client = {
430
425
client . start ( serverPort ) ;
431
426
return client ;
432
427
} ,
433
- stop : async ( _runtime : IAgentRuntime , client ?: any ) => {
428
+ stop : async ( _runtime : IAgentRuntime , client ?: Client ) => {
434
429
if ( client instanceof DirectClient ) {
435
430
client . stop ( ) ;
436
431
}
0 commit comments