@@ -21,7 +21,7 @@ npm install @openhands/agent-server-typescript-client
2121### Creating a Conversation
2222
2323``` typescript
24- import { Conversation , Agent , RemoteWorkspace } from ' @openhands/agent-server-typescript-client' ;
24+ import { Conversation , Agent , Workspace } from ' @openhands/agent-server-typescript-client' ;
2525
2626const agent: Agent = {
2727 kind: ' CodeActAgent' ,
@@ -32,24 +32,22 @@ const agent: Agent = {
3232};
3333
3434// Create a remote workspace
35- const workspace = new RemoteWorkspace ({
35+ const workspace = new Workspace ({
3636 host: ' http://localhost:3000' ,
3737 workingDir: ' /tmp' ,
3838 apiKey: ' your-session-api-key'
3939});
4040
41- const conversation = await Conversation .create (
42- ' http://localhost:3000' , // Agent server URL
43- agent ,
44- workspace ,
45- {
46- apiKey: ' your-session-api-key' ,
47- initialMessage: ' Hello, can you help me write some code?' ,
48- callback : (event ) => {
49- console .log (' Received event:' , event );
50- }
41+ const conversation = new Conversation (agent , workspace , {
42+ callback : (event ) => {
43+ console .log (' Received event:' , event );
5144 }
52- );
45+ });
46+
47+ // Start the conversation with an initial message
48+ await conversation .start ({
49+ initialMessage: ' Hello, can you help me write some code?'
50+ });
5351
5452// Start WebSocket for real-time events
5553await conversation .startWebSocketClient ();
@@ -63,20 +61,18 @@ await conversation.run();
6361
6462``` typescript
6563// Create a remote workspace for the existing conversation
66- const workspace = new RemoteWorkspace ({
64+ const workspace = new Workspace ({
6765 host: ' http://localhost:3000' ,
6866 workingDir: ' /tmp' ,
6967 apiKey: ' your-session-api-key'
7068});
7169
72- const conversation = await Conversation .load (
73- ' http://localhost:3000' ,
74- ' conversation-id-here' ,
75- workspace ,
76- {
77- apiKey: ' your-session-api-key'
78- }
79- );
70+ const conversation = new Conversation (agent , workspace , {
71+ conversationId: ' conversation-id-here'
72+ });
73+
74+ // Connect to the existing conversation
75+ await conversation .start ();
8076```
8177
8278### Using the Workspace
@@ -136,17 +132,18 @@ await conversation.updateSecrets({
136132
137133## API Reference
138134
139- ### RemoteConversation
135+ ### Conversation
140136
141- The main class for managing conversations with OpenHands agents.
137+ Factory function that creates conversations with OpenHands agents.
142138
143- #### Static Methods
139+ #### Constructor
144140
145- - ` RemoteConversation.create(host, agent, options) ` - Create a new conversation
146- - ` RemoteConversation.load(host, conversationId, options) ` - Load an existing conversation
141+ - ` new Conversation(agent, workspace, options?) ` - Create a new conversation instance
147142
148143#### Instance Methods
149144
145+ - ` start(options?) ` - Start the conversation (creates new or connects to existing)
146+
150147- ` sendMessage(message) ` - Send a message to the agent
151148- ` run() ` - Start agent execution
152149- ` pause() ` - Pause agent execution
0 commit comments