luv

Workshop wiki

application-adapter.lisp

luvcraft/agent/application-adapter.lisp

system luvcraft/agent · 19 definitions · on GitHub

in-package#:luvcraft.agent

Luvcraft contributes only its application boundary and world vocabulary to the shared harness. Bodies, construction, observation, approval, and presence remain game features in this package.

defclassworld-agent
presence:initformnil:accessorworld-agent-presence:documentation"The embodied Luvcraft body, or NIL."
defunworld-agent-handles
agent
luv.application-agent:application-agent-handlesagent
defvar*agent*nil"The most recently made Luvcraft WORLD-AGENT for REPL convenience."
defparameter*default-agent-model*

gpt-5.6

defparameter*default-agent-tools*'
com-where-am-icom-move-tocom-block-atcom-place-block-atcom-propose-block-boxcom-describe-handlecom-eval
defparameter*default-instructions*

You are an agent standing inside Luvcraft, a small block world running inside a live Common Lisp image. Your tools are the game's own commands. Coordinates are integer block cells: x and z are horizontal, y is up. Results may mention #ABCD handles; pass one to a command accepting a handle to inspect the same object again. Keep answers short; act rather than narrate.

defunlobby-openai-api-key

This is a retained cache read, not MQTT I/O, so construction never stalls the canvas waiting for the lobby.

andluvcraft:*session*
luv.lobby:lobby-client-value
luvcraft:luvcraft-session-lobby-clientluvcraft:*session*
"OPENAI_API_KEY"
pushnew'lobby-openai-api-keyopenai:*api-key-fallbacks*
defunmake-world-agent
&key
reasoning-summary"auto"
reasoning-effort
api-key
openai:default-api-key

Open Luvcraft's thin world-agent specialization for session.

Connection setup performs network I/O; call this from SLY or a setup worker, never from the canvas thread. Once open, ask itself always returns at once.

unlesssession
error"No Luvcraft session: use ./sly play or pass :SESSION."
setf*agent*
luv.application-agent:make-application-agent:class'world-agent:applicationsession:modelmodel:commandscommands:instructionsinstructions:reasoning-summaryreasoning-summary:reasoning-effortreasoning-effort:api-keyapi-key
defunask
text&key
agent
or*agent*
error"No Luvcraft agent is open."

Start a Luvcraft agent turn and return its transcript record immediately.

defunask-and-wait
text&key
agent
or*agent*
error"No Luvcraft agent is open."
timeout120
luv.application-agent:ask-and-waittext:agentagent:timeouttimeout:print-pt
defmethodluv.application-agent:call-in-application-frame
luv:request-canvas-frame
luvcraft:luvcraft-session-canvassession
lambda
timestamp
declare
ignoretimestamp
funcallfunction

The only domain-specific presentation type in the former harness core.

defunplaceable-block-kind-names
loopforkindinluvcraft::*block-kinds*when
luvcraft::block-kind-placeable-pkind
collect
luvcraft:block-kind-namekind
define-presentation-methodaccept
stream
viewtextual-view
&key
let*
string
read-tokenstream
kind
luvcraft:block-kind-named
intern
string-upcasestring
:keyword
nil
orkind
simple-parse-error"~S is not a block kind; try one of ~{~(~A~)~^, ~}."string
define-presentation-methodpresent
objectstream
viewtextual-view
&key
formatstream"~(~A~)"
luvcraft:block-kind-nameobject
defmethodluv.application-agent:presentation-type-json-schema
&restparameters
declare
ignoreparameters
`
"type"."string"
"enum".,
mapcar
lambda
name
string-downcase
symbol-namename