Skip to content

Commit

Permalink
Implement RPC for ClientIO interface (#565)
Browse files Browse the repository at this point in the history
Switch electron to use it.
Also switch the web api to use the Dispatcher and ClientIO RPC, which
means most of the placeholder are gone.
  • Loading branch information
curtisman authored Jan 17, 2025
1 parent d121462 commit c4d7013
Show file tree
Hide file tree
Showing 21 changed files with 629 additions and 1,213 deletions.
4 changes: 1 addition & 3 deletions ts/packages/api/data/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"wwwroot": "../shell/out/renderer",
"port": 3000,
"broadcast": true,
"blobBackupEnabled": true,
"storageProvider": "aws"
"broadcast": true
}
1 change: 1 addition & 0 deletions ts/packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@typeagent/agent-sdk": "workspace:*",
"agent-cache": "workspace:*",
"agent-dispatcher": "workspace:*",
"agent-rpc": "workspace:*",
"aiclient": "workspace:*",
"chalk": "^5.3.0",
"common-utils": "workspace:*",
Expand Down
25 changes: 6 additions & 19 deletions ts/packages/api/src/typeAgentServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// Licensed under the MIT License.

import dotenv from "dotenv";
import { createDispatcher, Dispatcher, getUserDataDir } from "agent-dispatcher";
import { getUserDataDir } from "agent-dispatcher";
import { readFileSync } from "node:fs";
import {
TypeAgentAPIServerConfig,
TypeAgentAPIWebServer,
} from "./webServer.js";
import { WebAPIClientIO } from "./webClientIO.js";
import { TypeAgentAPIWebSocketServer } from "./webSocketServer.js";
import { getDefaultAppAgentProviders } from "agent-dispatcher/internal";
import {
// BlobServiceClient,
// BlockBlobClient,
Expand All @@ -25,10 +23,10 @@ import { isDirectoryPath } from "typeagent";
import { TypeAgentStorageProvider } from "./storageProvider.js";
import { AzureStorageProvider } from "./storageProviders/azureStorageProvider.js";
import { AWSStorageProvider } from "./storageProviders/awsStorageProvider.js";
import { WebDispatcher, createWebDispatcher } from "./webDispatcher.js";

export class TypeAgentServer {
private dispatcher: Dispatcher | undefined;
private webClientIO: WebAPIClientIO | undefined;
private webDispatcher: WebDispatcher | undefined;
private webSocketServer: TypeAgentAPIWebSocketServer | undefined;
private webServer: TypeAgentAPIWebServer | undefined;
private fileWriteDebouncer: Map<string, number> = new Map<string, number>();
Expand Down Expand Up @@ -85,33 +83,22 @@ export class TypeAgentServer {
*/
}

// dispatcher
this.webClientIO = new WebAPIClientIO();
this.dispatcher = await createDispatcher("api", {
appAgentProviders: getDefaultAppAgentProviders(),
explanationAsynchronousMode: true,
persistSession: true,
enableServiceHost: true,
metrics: true,
clientIO: this.webClientIO,
});

this.webDispatcher = await createWebDispatcher();
// web server
this.webServer = new TypeAgentAPIWebServer(this.config);
this.webServer.start();

// websocket server
this.webSocketServer = new TypeAgentAPIWebSocketServer(
this.webServer.server,
this.dispatcher,
this.webClientIO!,
this.webDispatcher.connect,
);
}

stop() {
this.webServer?.stop();
this.webSocketServer?.stop();
this.dispatcher?.close();
this.webDispatcher?.close();
}

/**
Expand Down
270 changes: 0 additions & 270 deletions ts/packages/api/src/webClientIO.ts

This file was deleted.

Loading

0 comments on commit c4d7013

Please sign in to comment.