From 870e714d62ac5baa1b5faf28f091a1eff209d976 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 10 Apr 2026 00:31:12 +0100 Subject: Move state/session lenses right after / types. --- kaakaa/tea.scm | 88 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'kaakaa') diff --git a/kaakaa/tea.scm b/kaakaa/tea.scm index 2736633..d9a6c00 100644 --- a/kaakaa/tea.scm +++ b/kaakaa/tea.scm @@ -84,50 +84,6 @@ (define (initial-state) (state #f 0 0 '() '())) -(define-record-type* ( llm-request llm-request?) - (fields (session-id llm-request-session-id) - (messages llm-request-messages))) - -(define-record-type* ( llm-response llm-response?) - (fields (session-id llm-response-session-id) - (json llm-response-json))) - -(define-record-type* ( acp-message acp-message?) - (fields (json acp-message-json))) - -(define-record-type* ( command command?) - (fields (description command-description) - (next-state command-next-state))) - -(define (command->spec name command) - "Serialize @var{command} of @var{name} to ACP-compatible JSON spec." - `(("name" . ,name) - ("description" . ,(command-description command)))) - -(define (agent-message-chunk session-id text) - "Return an @samp{agent_message_chunk} @samp{session/update} ACP message for -@var{session-id} with @var{text}." - (acp-message `(("jsonrpc" . "2.0") - ("method" . "session/update") - ("params" - ("sessionId" . ,session-id) - ("update" - ("sessionUpdate" . "agent_message_chunk") - ("content" - ("type" . "text") - ("text" . ,text))))))) - -(define %cwd-command - (command "Print current working directory of the session" - (lambda (state session-id _) - (values state - (list (agent-message-chunk session-id - (focus (state-cwd session-id) - state))))))) - -(define %commands - `(("cwd" . ,%cwd-command))) - (define (state-cwd session-id) "Return a lens to focus on current working directory of session with @var{session-id} in state." @@ -200,6 +156,50 @@ in @var{state}." ;; There are tool calls or a cancellation in progress; do nothing. (list))) +(define-record-type* ( llm-request llm-request?) + (fields (session-id llm-request-session-id) + (messages llm-request-messages))) + +(define-record-type* ( llm-response llm-response?) + (fields (session-id llm-response-session-id) + (json llm-response-json))) + +(define-record-type* ( acp-message acp-message?) + (fields (json acp-message-json))) + +(define-record-type* ( command command?) + (fields (description command-description) + (next-state command-next-state))) + +(define (command->spec name command) + "Serialize @var{command} of @var{name} to ACP-compatible JSON spec." + `(("name" . ,name) + ("description" . ,(command-description command)))) + +(define (agent-message-chunk session-id text) + "Return an @samp{agent_message_chunk} @samp{session/update} ACP message for +@var{session-id} with @var{text}." + (acp-message `(("jsonrpc" . "2.0") + ("method" . "session/update") + ("params" + ("sessionId" . ,session-id) + ("update" + ("sessionUpdate" . "agent_message_chunk") + ("content" + ("type" . "text") + ("text" . ,text))))))) + +(define %cwd-command + (command "Print current working directory of the session" + (lambda (state session-id _) + (values state + (list (agent-message-chunk session-id + (focus (state-cwd session-id) + state))))))) + +(define %commands + `(("cwd" . ,%cwd-command))) + (define (next-state-slash-command state session-id command-name argument) "Given current @var{state} and an invocation of slash var{command-name} with @var{argument} for @var{session-id}, return the next state and a list of -- cgit 1.4.1