Skip to content

Commit b511c0e

Browse files
committed
remove unused SimliClientConfig, pass directClient to api, be explicit about what we're binding to
1 parent d1387e3 commit b511c0e

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

packages/client-direct/src/index.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,11 @@ Note that {{agentName}} is capable of reading/seeing/hearing various forms of me
5151
# Instructions: Write the next message for {{agentName}}.
5252
` + messageCompletionFooter;
5353

54-
export interface SimliClientConfig {
55-
apiKey: string;
56-
faceID: string;
57-
handleSilence: boolean;
58-
videoRef: any;
59-
audioRef: any;
60-
}
6154
export class DirectClient {
6255
public app: express.Application;
63-
private agents: Map<string, AgentRuntime>;
56+
private agents: Map<string, AgentRuntime>; // container management
6457
private server: any; // Store server instance
58+
public startAgent: Function; // Store startAgent functor
6559

6660
constructor() {
6761
elizaLogger.log("DirectClient constructor");
@@ -72,7 +66,7 @@ export class DirectClient {
7266
this.app.use(bodyParser.json());
7367
this.app.use(bodyParser.urlencoded({ extended: true }));
7468

75-
const apiRouter = createApiRouter(this.agents);
69+
const apiRouter = createApiRouter(this.agents, this);
7670
this.app.use(apiRouter);
7771

7872
// Define an interface that extends the Express Request interface
@@ -338,7 +332,7 @@ export class DirectClient {
338332
fileResponse.headers
339333
.get("content-disposition")
340334
?.split("filename=")[1]
341-
?.replace(/"/g, "") || "default_name.txt";
335+
?.replace(/"/g, /* " */ "") || "default_name.txt";
342336

343337
console.log("Saving as:", fileName);
344338

@@ -378,6 +372,7 @@ export class DirectClient {
378372
);
379373
}
380374

375+
// agent/src/index.ts:startAgent calls this
381376
public registerAgent(runtime: AgentRuntime) {
382377
this.agents.set(runtime.agentId, runtime);
383378
}
@@ -388,7 +383,7 @@ export class DirectClient {
388383

389384
public start(port: number) {
390385
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}.`);
392387
});
393388

394389
// Handle graceful shutdown
@@ -430,7 +425,7 @@ export const DirectClientInterface: Client = {
430425
client.start(serverPort);
431426
return client;
432427
},
433-
stop: async (_runtime: IAgentRuntime, client?: any) => {
428+
stop: async (_runtime: IAgentRuntime, client?: Client) => {
434429
if (client instanceof DirectClient) {
435430
client.stop();
436431
}

0 commit comments

Comments
 (0)