Skip to content

Commit 7e60ec8

Browse files
committed
refactor(appserver): share protocol constants in client
1 parent 32cf6ff commit 7e60ec8

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎src/main/java/io/github/easy4j/codex/appserver/CodexAppServerClient.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public List<AppServerThread> listThreads(int limit, String cursor) {
187187
if (limit > 0) {
188188
params.put("limit", limit);
189189
}
190-
JsonNode result = execRpcNode("thread/list", params);
190+
JsonNode result = execRpcNode(CodexAppServerProtocol.THREAD_LIST, params);
191191
List<AppServerThread> threads = new ArrayList<>();
192192
for (JsonNode node : result.path("threads")) {
193193
threads.add(parseThread(node));
@@ -205,7 +205,7 @@ public List<AppServerThread> listThreads(int limit, String cursor) {
205205
public AppServerThread readThread(String threadId) {
206206
Map<String, Object> params = new LinkedHashMap<>();
207207
params.put("threadId", Objects.requireNonNull(threadId, "threadId").trim());
208-
JsonNode result = execRpcNode("thread/read", params);
208+
JsonNode result = execRpcNode(CodexAppServerProtocol.THREAD_READ, params);
209209
return parseThread(result.path("thread"));
210210
}
211211

@@ -234,26 +234,26 @@ public String readThreadRaw(String threadId) {
234234
public AppServerThread forkThread(String threadId) {
235235
Map<String, Object> params = new LinkedHashMap<>();
236236
params.put("threadId", Objects.requireNonNull(threadId, "threadId").trim());
237-
JsonNode result = execRpcNode("thread/fork", params);
237+
JsonNode result = execRpcNode(CodexAppServerProtocol.THREAD_FORK, params);
238238
return parseThread(result.path("thread"));
239239
}
240240

241241
/** Archives a thread via {@code thread/archive}. */
242242
public void archiveThread(String threadId) {
243-
simpleThreadCall("thread/archive", threadId);
243+
simpleThreadCall(CodexAppServerProtocol.THREAD_ARCHIVE, threadId);
244244
}
245245

246246
/** Unarchives a thread via {@code thread/unarchive}. */
247247
public void unarchiveThread(String threadId) {
248-
simpleThreadCall("thread/unarchive", threadId);
248+
simpleThreadCall(CodexAppServerProtocol.THREAD_UNARCHIVE, threadId);
249249
}
250250

251251
/**
252252
* Permanently deletes a thread and its spawned descendants via
253253
* {@code thread/delete}. Ephemeral roots cannot be deleted.
254254
*/
255255
public void deleteThread(String threadId) {
256-
simpleThreadCall("thread/delete", threadId);
256+
simpleThreadCall(CodexAppServerProtocol.THREAD_DELETE, threadId);
257257
}
258258

259259
/**
@@ -269,7 +269,7 @@ public void interruptTurn(String threadId, String turnId) {
269269
Map<String, Object> params = new LinkedHashMap<>();
270270
params.put("threadId", Objects.requireNonNull(threadId, "threadId").trim());
271271
params.put("turnId", Objects.requireNonNull(turnId, "turnId").trim());
272-
execRpcNode("turn/interrupt", params);
272+
execRpcNode(CodexAppServerProtocol.TURN_INTERRUPT, params);
273273
}
274274

275275
/**
@@ -290,7 +290,7 @@ public void steerTurn(String threadId, String expectedTurnId, String prompt) {
290290
params.put("threadId", Objects.requireNonNull(threadId, "threadId").trim());
291291
params.put("expectedTurnId", Objects.requireNonNull(expectedTurnId, "expectedTurnId").trim());
292292
params.put("input", List.of(input));
293-
execRpcNode("turn/steer", params);
293+
execRpcNode(CodexAppServerProtocol.TURN_STEER, params);
294294
}
295295

296296
/**

0 commit comments

Comments
 (0)