summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/http.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/http.ts')
-rw-r--r--packages/cli/src/http.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/cli/src/http.ts b/packages/cli/src/http.ts
index 876f570..585c678 100644
--- a/packages/cli/src/http.ts
+++ b/packages/cli/src/http.ts
@@ -10,6 +10,7 @@
import type {
AgentEvent,
ChatRequest,
+ CompactResponse,
ConversationListResponse,
LastMessageResponse,
ModelsResponse,
@@ -183,6 +184,26 @@ export async function openConversation(
return (await res.json()) as OpenConversationResponse;
}
+interface CompactConversationOpts {
+ readonly server: string;
+ readonly conversationId: string;
+}
+
+export async function compactConversation(
+ deps: FetchDeps,
+ opts: CompactConversationOpts,
+): Promise<CompactResponse> {
+ const url = `${opts.server}/conversations/${encodeURIComponent(opts.conversationId)}/compact`;
+ const res = await deps.fetchImpl(url, { method: "POST" });
+
+ if (!res.ok) {
+ const body = await res.text();
+ throw new Error(`POST /conversations/:id/compact failed with status ${res.status}: ${body}`);
+ }
+
+ return (await res.json()) as CompactResponse;
+}
+
/**
* The outcome of short-ID resolution: either the full conversation id to use,
* or a human-readable error describing why resolution failed.