diff options
Diffstat (limited to 'acp.lua')
| -rw-r--r-- | acp.lua | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -222,10 +222,13 @@ function M.launch(s, first, resume_id) local function step(co,...) local ok,err=coroutine.resume(co,...); if not ok then s.fail(tostring(err)) end end - local deadline, idle, request_id, primary_reply + local deadline, idle, request_id, primary_reply, image_capable local steering,steer_usage,last_steer={},nil,nil + local function check_prompt(parts) + for _,v in ipairs(parts) do assert(v.type~='image' or image_capable,'ACP image prompts unavailable') end + end s.steer=function(parts) - assert(s.prompting and waiting,'No active ACP prompt to steer') + assert(s.prompting and waiting,'No active ACP prompt to steer'); check_prompt(parts) serial=serial+1; steering[serial]=true send({id=serial,method='session/prompt',params={sessionId=s.session,prompt=parts}}) end @@ -280,7 +283,8 @@ function M.launch(s, first, resume_id) return (config(opts,s.selector) or {}).currentValue==s.wire and (not s.thought or (thought(opts) or {}).currentValue==s.thought) end - local function turn(text) + local function turn(parts) + check_prompt(parts) local wire = assert(s.resolve(s.effort)) configuring=true s.selector,s.wire=selectors[wire],wire @@ -292,7 +296,7 @@ function M.launch(s, first, resume_id) assert(confirmed(),'Configured model or reasoning level changed'); configuring=false s.prompting=true if s.refresh then pcall(s.refresh) end - local r=call('session/prompt',{sessionId=s.session,prompt={{type='text',text=text}}}) + local r=call('session/prompt',{sessionId=s.session,prompt=parts}) if s.cancelling then assert(r.stopReason=='cancelled' or r.stopReason=='end_turn' or r.stopReason=='max_tokens', 'Turn stopped: '..tostring(r.stopReason)) @@ -305,10 +309,11 @@ function M.launch(s, first, resume_id) local usage=add_usage(M.usage(r.usage),steer_usage) s.prompting=false; s.complete(last_steer and last_steer.reason or reason,usage); steer_usage,last_steer=nil,nil end - s.submit=function(text) step(coroutine.create(turn),text) end + s.submit=function(parts) step(coroutine.create(turn),parts) end local function setup() local init=call('initialize',{protocolVersion=1,clientInfo={name='panto-antigravity',version='1'},clientCapabilities={}}) assert(init.protocolVersion==1,'ACP v1 required'); local caps=init.agentCapabilities or {} + image_capable=((caps.promptCapabilities or {}).image)==true local personal=false; for _,a in ipairs(init.authMethods or {}) do if a.id=='oauth-personal' then personal=true end end assert(personal,'Native personal sign-in unavailable'); call('authenticate',{methodId='oauth-personal'}) local params={cwd=s.cwd,mcpServers=json.array({}),_meta={disableBuiltInTools=true}} |
