lycheedev 2.5.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/bin/lycheedev.mjs +39 -3
  2. package/bin/update.mjs +168 -0
  3. package/native/windows-amd64/lycheedev.exe +0 -0
  4. package/package.json +1 -1
  5. package/payload/addon/Bridge/ActivityView.lua +26 -12
  6. package/payload/addon/Bridge/InputProtection.lua +63 -0
  7. package/payload/addon/Bridge/InputState.lua +45 -0
  8. package/payload/addon/Bridge/MemoryProtocol.lua +31 -0
  9. package/payload/addon/Bridge/ProbeExecution.lua +147 -0
  10. package/payload/addon/Bridge/ReceiverBindings.lua +6 -0
  11. package/payload/addon/Bridge/SlotProtocol.lua +165 -0
  12. package/payload/addon/Bridge/SlotRuntime.lua +106 -0
  13. package/payload/addon/Bridge/StartupBeacon.lua +8 -11
  14. package/payload/addon/Core/Compat.lua +7 -0
  15. package/payload/addon/Core/Controls.lua +16 -0
  16. package/payload/addon/Core/Locale.lua +6 -4
  17. package/payload/addon/Core/Locale_enUS.lua +4 -2
  18. package/payload/addon/Core/Platform.lua +4 -2
  19. package/payload/addon/Core/Runtime.lua +17 -6
  20. package/payload/addon/Lychee Dev.toc +8 -2
  21. package/payload/addon/Modules/AutomationHistory.lua +119 -0
  22. package/payload/addon/Modules/AutomationView.lua +26 -6
  23. package/payload/addon/UI/Pages/About.lua +0 -3
  24. package/payload/addon/UI/Pages/Automation.lua +40 -27
  25. package/payload/addon/UI/Pages/Diagnostics.lua +2 -4
  26. package/payload/addon/UI/Pages/Object.lua +0 -1
  27. package/payload/addon/UI/Pages/Run.lua +2 -1
  28. package/payload/addon/UI/Pages/Trace.lua +0 -1
  29. package/payload/addon/UI/Theme.lua +3 -2
  30. package/payload/addon/UI/Widgets.lua +32 -22
  31. package/payload/addon/UI/Window.lua +3 -35
  32. package/payload/skill/SKILL.md +40 -60
  33. package/payload/skill/agents/openai.yaml +1 -1
  34. package/payload/skill/references/commands.md +22 -15
  35. package/payload/skill/references/error-diagnosis.md +7 -11
  36. package/payload/skill/references/installation.md +64 -13
  37. package/payload/skill/references/live-investigation.md +193 -252
  38. package/payload/skill/references/live-startup.md +62 -132
  39. package/release.json +97 -67
  40. package/payload/addon/UI/Pages/Settings.lua +0 -82
@@ -0,0 +1,165 @@
1
+ local _, ns = ...
2
+
3
+ -- Pure bounded protocol engine. Host input, frames, file loading and async
4
+ -- execution are adapters; there is only one owner and one active business job.
5
+ local ZERO=string.rep("0",32)
6
+ local LIMIT=64
7
+ local function plain(v)return not (issecretvalue and issecretvalue(v)) and type(v)=="table" and getmetatable(v)==nil end
8
+ local function safe(v)return not (issecretvalue and issecretvalue(v))end
9
+
10
+ ns.SlotProtocol = { Count=LIMIT, Create=function(adapter)
11
+ assert(plain(adapter) and ns.MemoryProtocol.Token(adapter.runtime),"invalid slot adapter")
12
+ local wire=ns.MemoryProtocol
13
+ local owner,fence,active,pending
14
+ local sequence,count=0,0
15
+ local consumed,operations,receipts={},{},{}
16
+ local descriptor
17
+ local api={}
18
+ local function observe(op)
19
+ if adapter.observe then
20
+ local ok,result,reason=pcall(adapter.observe,op)
21
+ op.historyError=not ok and "automation_history_failed" or (not result and reason or nil)
22
+ end
23
+ end
24
+ local function nextSlot()
25
+ for i=1,LIMIT do if not consumed[i] then return i end end
26
+ return LIMIT+1
27
+ end
28
+ local function actor()
29
+ local value=adapter.actor()
30
+ if not plain(value) or not safe(value.guid) or not safe(value.character) or not safe(value.realm)
31
+ or type(value.guid)~="string" or type(value.character)~="string" or type(value.realm)~="string" then return nil end
32
+ return value
33
+ end
34
+ local function encode(value,limit)
35
+ local text,reason=adapter.encode(value,limit)
36
+ if not text then return nil,reason end
37
+ return text
38
+ end
39
+ local function publish(e,state,extra,kind)
40
+ if sequence>=4294967295 then return nil,"slot_sequence_exhausted" end
41
+ local a=actor();if not a then return nil,"slot_actor_unavailable" end
42
+ sequence=sequence+1
43
+ local value={schema="lycheedev.slot.v1",runtime=adapter.runtime,owner=owner or "",fence=fence or 0,
44
+ nonce=e.nonce,ticket=e.ticket or ZERO,action=e.action,state=state,sequence=sequence,
45
+ nextSlot=nextSlot(),slots=LIMIT,character=a.character,realm=a.realm,guid=a.guid,
46
+ build=adapter.build,product=adapter.product,release=adapter.release,inventory=adapter.inventory,inputState=adapter.inputState}
47
+ for k,v in pairs(extra or {}) do value[k]=v end
48
+ local text,reason=encode(value,16384);if not text then return nil,reason end
49
+ local record;record,reason=wire.Encode(e.nonce,adapter.runtime,e.ticket or ZERO,kind or 2,1,sequence,text)
50
+ if not record then return nil,reason end
51
+ receipts[e.nonce]=record
52
+ return record,value
53
+ end
54
+ function api.Describe()
55
+ local a=actor();if not a then return nil,"slot_actor_unavailable" end
56
+ local text=encode({schema="lycheedev.slot.identity.v1",runtime=adapter.runtime,owner=owner or "",fence=fence or 0,
57
+ nextSlot=nextSlot(),slots=LIMIT,character=a.character,realm=a.realm,guid=a.guid,
58
+ build=adapter.build,product=adapter.product,release=adapter.release,inventory=adapter.inventory,inputState=adapter.inputState},16384)
59
+ if not text then return nil,"slot_identity_encoding" end
60
+ descriptor=wire.Encode(ZERO,adapter.runtime,ZERO,1,1,sequence,text)
61
+ return descriptor
62
+ end
63
+ local function finish(op,ok,value,metadata)
64
+ if op.state~="running" then return nil,"slot_not_running" end
65
+ op.resourcesReleased=not metadata or metadata.resourcesReleased~=false
66
+ local text,reason=encode({ok=ok,result=ok and value or nil,error=not ok and value or nil,
67
+ resourcesReleased=op.resourcesReleased,logs=metadata and metadata.logs or nil},524288)
68
+ if not text then ok=false;text=assert(encode({ok=false,error=type(reason)=="string" and reason or "report_encoding_failed"},16384)) end
69
+ -- Store body and outcome before constructing its public response.
70
+ op.payload=text;op.bytes=#text;op.checksum=wire.Checksum(text)
71
+ op.body=assert(wire.Encode(op.envelope.nonce,adapter.runtime,op.envelope.ticket,3,3,op.sequence,text))
72
+ op.state="reported";op.ok=ok
73
+ observe(op)
74
+ local record,value=publish(op.envelope,"reported",{reportBytes=op.bytes,reportChecksum=op.checksum,challenge=op.challenge})
75
+ if adapter.activity then adapter.activity("collecting",op.envelope.ticket) end
76
+ return record,value
77
+ end
78
+ local function reject(e,reason)
79
+ if plain(e) and wire.Token(e.nonce) and (e.ticket==nil or wire.Token(e.ticket)) then return publish(e,"rejected",{reason=reason}) end
80
+ return nil,reason
81
+ end
82
+ function api.Receive(index,e)
83
+ if type(index)~="number" or index%1~=0 or index<1 or index>LIMIT then return nil,"slot_index_invalid" end
84
+ if consumed[index] then return nil,"slot_already_consumed" end
85
+ consumed[index]=true -- Load-on-demand is consumed even by invalid data.
86
+ if not plain(e) then return nil,"slot_envelope_invalid" end
87
+ -- Never inspect or execute encoded business code before these checks.
88
+ for _,key in ipairs({"schema","index","runtime","owner","fence","nonce","ticket","action","guid","build","challenge","preparedNonce","reportBytes","reportChecksum"}) do if not safe(e[key]) then return nil,"slot_secret_envelope" end end
89
+ if e.schema~="lycheedev.slot.v1" or e.index~=index or not wire.Token(e.nonce)
90
+ or not wire.Token(e.ticket) or not wire.Token(e.owner) then return nil,"slot_envelope_invalid" end
91
+ if receipts[e.nonce] then return receipts[e.nonce],"slot_nonce_reused" end
92
+ if e.runtime~=adapter.runtime then return reject(e,"slot_runtime_changed") end
93
+ local a=actor();if not a or a.guid~=e.guid or e.build~=adapter.build then return reject(e,"slot_target_changed") end
94
+ if type(e.fence)~="number" or e.fence<1 or e.fence%1~=0 or e.fence>9007199254740991 then return reject(e,"slot_fence_invalid") end
95
+ if e.action=="bind" then
96
+ if owner and owner~=e.owner then return reject(e,"slot_owner_busy") end
97
+ if fence and e.fence<fence then return reject(e,"slot_stale_driver") end
98
+ owner,fence=e.owner,e.fence
99
+ api.Describe()
100
+ return publish(e,"bound")
101
+ end
102
+ if owner~=e.owner or fence~=e.fence then return reject(e,"slot_owner_mismatch") end
103
+ if e.action=="prepare" then
104
+ if active or pending then return reject(e,"slot_busy") end
105
+ if operations[e.ticket] then return reject(e,"slot_operation_exists") end
106
+ if nextSlot()>LIMIT-3 or count>=12 then return reject(e,"slot_capacity") end
107
+ if not safe(e.code) or type(e.code)~="string" or #e.code<1 or #e.code>262144 or e.code:byte(1)==27
108
+ or not safe(e.codeBytes) or e.codeBytes~=#e.code or not safe(e.codeChecksum) or e.codeChecksum~=wire.Checksum(e.code)
109
+ or not safe(e.budget) or type(e.budget)~="number" or e.budget%1~=0 or e.budget<1 or e.budget>120 then return reject(e,"slot_code_invalid") end
110
+ local fn,reason=adapter.compile(e.code)
111
+ local challenge=adapter.runtime:sub(1,24)..string.format("%08x",sequence+1)
112
+ if not fn then
113
+ local op={envelope=e,challenge=challenge,sequence=sequence+1,state="running"}
114
+ operations[e.ticket]=op;active=op;count=count+1
115
+ if adapter.releaseInput then adapter.releaseInput() end
116
+ return finish(op,false,{kind="compile_error",message=reason or "slot_compile_failed"})
117
+ end
118
+ pending={envelope=e,fn=fn,challenge=challenge,sequence=sequence+1,state="prepared"}
119
+ operations[e.ticket]=pending;count=count+1
120
+ observe(pending)
121
+ return publish(e,"prepared",{challenge=challenge})
122
+ elseif e.action=="commit" then
123
+ if not pending or pending.envelope.ticket~=e.ticket or pending.challenge~=e.challenge
124
+ or pending.envelope.nonce~=e.preparedNonce then return reject(e,"slot_commit_mismatch") end
125
+ active=pending;pending=nil;active.state="running"
126
+ local op=active
127
+ observe(op)
128
+ local record,value=publish(e,"accepted")
129
+ if adapter.releaseInput then adapter.releaseInput() end
130
+ if adapter.activity then adapter.activity("running",e.ticket) end
131
+ local ok,reason=pcall(adapter.execute,op.fn,op.envelope.budget,function(ok,result,metadata)return finish(op,ok,result,metadata)end)
132
+ if not ok and op.state=="running" then finish(op,false,"probe_executor_error") end
133
+ return record,value
134
+ elseif e.action=="confirm" then
135
+ local op=operations[e.ticket]
136
+ if not op then return publish(e,"absent",nil,4) end
137
+ return publish(e,op.state,{preparedNonce=op.envelope.nonce,reportBytes=op.bytes,reportChecksum=op.checksum,challenge=op.challenge},4)
138
+ elseif e.action=="release" then
139
+ local op=operations[e.ticket]
140
+ if not op or (op.state~="reported" and op.state~="released")
141
+ or e.reportBytes~=op.bytes or e.reportChecksum~=op.checksum then return reject(e,"slot_release_mismatch") end
142
+ if op.resourcesReleased==false then return reject(e,"slot_resources_pending") end
143
+ op.payload=nil;op.body=nil;op.fn=nil;op.state="released"
144
+ -- Retain identity/digest tombstone; never re-admit its ticket.
145
+ op.envelope.code=nil
146
+ observe(op)
147
+ if active==op then active=nil end
148
+ if adapter.activity then adapter.activity("idle",e.ticket) end
149
+ return publish(e,"released")
150
+ elseif e.action=="unbind" then
151
+ if active or pending then return reject(e,"slot_busy") end
152
+ local record,value=publish(e,"unbound")
153
+ owner,fence=nil,nil;api.Describe();return record,value
154
+ end
155
+ return reject(e,"slot_action_invalid")
156
+ end
157
+ function api.NextSlot()return nextSlot()end
158
+ function api.InputIdentity()
159
+ local a=actor();if not a then return nil end
160
+ return {runtime=adapter.runtime,owner=owner or "",fence=fence or 0,nextSlot=nextSlot(),
161
+ guid=a.guid,build=adapter.build,character=a.character,realm=a.realm}
162
+ end
163
+ function api.Snapshot()return {descriptor=descriptor,receipts=receipts,operations=operations,owner=owner,fence=fence,consumed=consumed}end
164
+ return api
165
+ end }
@@ -0,0 +1,106 @@
1
+ local _, ns = ...
2
+
3
+ local engine,receiving,inputLease,expectedSlot
4
+ local zero=string.rep("0",32)
5
+ local function releaseInput()
6
+ receiving=false
7
+ if inputLease then ns.InputProtection.Release(inputLease);inputLease=nil end
8
+ end
9
+ local function protectInput()
10
+ if receiving then return true end
11
+ local reason
12
+ inputLease,reason=ns.InputProtection.Acquire(2,releaseInput,true)
13
+ if not inputLease then return nil,reason end
14
+ receiving=true
15
+ return true
16
+ end
17
+ local function activity(state,ticket)
18
+ if not ns.ActivityView then return end
19
+ if state=="idle" then ns.ActivityView.Finish(ticket)
20
+ elseif state=="collecting" and ns.ActivityView.Collecting then ns.ActivityView.Collecting(ticket)
21
+ else ns.ActivityView.Begin(ticket) end
22
+ end
23
+ local function start()
24
+ if engine then
25
+ local state=ns.Persistence.Current()
26
+ if ns.InputState and state and state.options.bridgeEnabled~=false then ns.InputState.Start(engine.InputIdentity) end
27
+ return true
28
+ end
29
+ local state,reason=ns.Persistence.Bridge();if not state then return nil,reason end
30
+ local build;build,reason=ns.Platform.ObserveBuild();if not build then return nil,reason end
31
+ local actor;actor,reason=ns.Platform.ObserveActor();if not actor then return nil,reason end
32
+ local epoch=state.memoryEpoch or 0
33
+ if (issecretvalue and issecretvalue(epoch)) or type(epoch)~="number" or epoch<0 or epoch%1~=0 or epoch>=4294967295 then return nil,"slot_epoch_invalid" end
34
+ local clock=ns.Compat.MonotonicSeconds();if not clock or clock>=4294967295 then return nil,"slot_clock_unavailable" end
35
+ -- A reload-persisted generation plus runtime clock and random suffix. The
36
+ -- CLI additionally binds the OS process creation identity and fresh nonce.
37
+ -- This token is an accidental-replay discriminator, not a secret/password.
38
+ state.memoryEpoch=epoch+1
39
+ local runtime=string.format("%08x%08x%04x%04x%04x%04x",epoch+1,math.floor(clock),math.random(0,65535),math.random(0,65535),math.random(0,65535),math.random(0,65535))
40
+ local available=0
41
+ for i=1,64 do
42
+ local name=string.format("Lychee Dev Slot %02d",i)
43
+ if ns.Compat.GetAddOnMetadata(name,"X-Lychee-Slot")==tostring(i)
44
+ and ns.Compat.GetAddOnMetadata(name,"Version")==ns.Release then available=available+1 end
45
+ end
46
+ ns.AutomationHistory.Begin(runtime,{character=actor.character,realm=actor.realm,guid=actor.guid,build=build.build,product=build.product})
47
+ engine=ns.SlotProtocol.Create({runtime=runtime,build=build.build,product=build.product,release=ns.Release,inventory=available,
48
+ inputState=ns.InputState and "lycheedev.input.v1" or nil,
49
+ actor=function()
50
+ local current=ns.Platform.ObserveActor()
51
+ if current and current.guid==actor.guid then return current end
52
+ end,encode=ns.CaptureWriter.Encode,
53
+ compile=function(code)return loadstring(code,"=LycheeMemoryProbe")end,
54
+ execute=ns.ProbeExecution.Run,releaseInput=releaseInput,activity=activity,observe=ns.AutomationHistory.Observe})
55
+ engine.Describe()
56
+ local current=ns.Persistence.Current()
57
+ if ns.InputState and current and current.options.bridgeEnabled~=false then ns.InputState.Start(engine.InputIdentity) end
58
+ return true
59
+ end
60
+ local function inventory()
61
+ for i=1,64 do
62
+ local name=string.format("Lychee Dev Slot %02d",i)
63
+ if ns.Compat.GetAddOnMetadata(name,"X-Lychee-Slot")~=tostring(i)
64
+ or ns.Compat.GetAddOnMetadata(name,"Version")~=ns.Release then return nil,"slot_inventory_incomplete:"..i end
65
+ end
66
+ return true
67
+ end
68
+ local function wake()
69
+ local state=ns.Persistence.Current()
70
+ if not state or state.options.bridgeEnabled==false then return nil,"slot_disabled" end
71
+ local ok,reason=start();if not ok then return nil,reason end
72
+ if ns.Platform.ObserveInputState(true)~=true and not receiving then return nil,"slot_input_not_ready" end
73
+ ok,reason=inventory();if not ok then return nil,reason end
74
+ state.options.bridgeEnabled=true -- Explicit wake opts in; explicit off stays off.
75
+ if ns.StartupBeacon then ns.StartupBeacon.Stop() end
76
+ ok,reason=protectInput();if not ok then releaseInput();return nil,reason end
77
+ local index=engine.NextSlot();if index>64 then releaseInput();return nil,"slot_exhausted" end
78
+ expectedSlot=index
79
+ local loaded,failure=ns.Compat.LoadInputSlot(string.format("Lychee Dev Slot %02d",index))
80
+ expectedSlot=nil
81
+ if not loaded then releaseInput();return nil,failure end
82
+ -- Control transactions have no long-lived keyboard ownership. A fresh
83
+ -- wake protects each input burst; business entry already released it.
84
+ releaseInput()
85
+ engine.Describe()
86
+ return true
87
+ end
88
+ local function guardedWake()
89
+ local ok,result,reason=pcall(wake)
90
+ expectedSlot=nil
91
+ releaseInput()
92
+ if not ok then return nil,"slot_wake_failed" end
93
+ return result,reason
94
+ end
95
+ ns.SlotRuntime={
96
+ Start=start,Wake=guardedWake,Close=function()releaseInput();ns.InputProtection.Cancel()end,
97
+ IsActive=function()return ns.InputProtection.IsActive()end,
98
+ Receive=function(index,envelope)
99
+ if not engine or index~=expectedSlot then return nil,"slot_not_requested" end
100
+ return engine.Receive(index,envelope)
101
+ end,
102
+ Snapshot=function()return engine and engine.Snapshot()end,
103
+ Register=function()
104
+ return ns.ReceiverBindings.Register({wake=guardedWake,submit=guardedWake,close=function()releaseInput();ns.InputProtection.Cancel()end})
105
+ end,
106
+ }
@@ -2,7 +2,7 @@ local _, ns = ...
2
2
 
3
3
  -- A short-lived visual hint, never an identity or execution permission. It is
4
4
  -- armed only for an opted-in bridge at startup and stops permanently on wake.
5
- local frame, blocks, expiry, pulse, untilTime
5
+ local frame, block, expiry, pulse, untilTime
6
6
  local entered, loadingDone, phase, stopped
7
7
  local colors = {{1,0,0},{0,1,0},{0,0,1}}
8
8
  local function stop()
@@ -12,7 +12,7 @@ local function stop()
12
12
  if frame then frame:Hide(); frame:UnregisterAllEvents(); frame:SetScript("OnEvent",nil) end
13
13
  end
14
14
  local function paint()
15
- for index=1,3 do blocks[index]:SetColorTexture(unpack(colors[(index+phase-1)%3+1])) end
15
+ block:SetColorTexture(unpack(colors[phase+1]))
16
16
  end
17
17
  local function tick()
18
18
  pulse=nil
@@ -37,16 +37,12 @@ ns.StartupBeacon = {
37
37
  frame:Hide(); frame:EnableMouse(false); frame:SetFrameStrata("TOOLTIP")
38
38
  local px=ns.Compat.GetPhysicalPixelSize()
39
39
  frame:SetPoint("TOPLEFT",UIParent,"TOPLEFT",4*px,-4*px)
40
- frame:SetSize(32*px,12*px)
40
+ frame:SetSize(12*px,12*px)
41
41
  local background=frame:CreateTexture(nil,"BACKGROUND")
42
42
  background:SetAllPoints(frame); background:SetColorTexture(0,0,0,1)
43
- blocks={}
44
- for index=1,3 do
45
- local block=frame:CreateTexture(nil,"ARTWORK")
46
- block:SetSize(8*px,8*px)
47
- block:SetPoint("TOPLEFT",(2+(index-1)*10)*px,-2*px)
48
- blocks[index]=block
49
- end
43
+ block=frame:CreateTexture(nil,"ARTWORK")
44
+ block:SetSize(8*px,8*px)
45
+ block:SetPoint("TOPLEFT",2*px,-2*px)
50
46
  stopped=false; untilTime=GetTime()+45
51
47
  expiry=C_Timer.NewTimer(45,stop)
52
48
  for _,event in ipairs({"PLAYER_ENTERING_WORLD","LOADING_SCREEN_DISABLED","LOADING_SCREEN_ENABLED",
@@ -54,7 +50,8 @@ ns.StartupBeacon = {
54
50
  frame:SetScript("OnEvent",function(_,event,initial,reloading)
55
51
  if event=="PLAYER_LEAVING_WORLD" or event=="PLAYER_REGEN_DISABLED" then stop(); return end
56
52
  if event=="PLAYER_ENTERING_WORLD" then
57
- if (issecretvalue and (issecretvalue(initial) or issecretvalue(reloading))) or initial~=false or reloading~=true then stop(); return end
53
+ if issecretvalue and (issecretvalue(initial) or issecretvalue(reloading)) then stop(); return end
54
+ if initial~=false or reloading~=true then stop(); return end
58
55
  entered=true
59
56
  elseif event=="LOADING_SCREEN_ENABLED" then
60
57
  loadingDone=false; frame:Hide()
@@ -5,6 +5,13 @@ local ADDON_NAME, ns = ...
5
5
  -- before it is compared, formatted, indexed or branched on; failures open to a
6
6
  -- harmless visible state instead of throwing.
7
7
  ns.Compat = {
8
+ LoadInputSlot = function(name)
9
+ if type(name)~="string" or not name:match("^Lychee Dev Slot %d%d$") then return nil,"slot_name_invalid" end
10
+ if type(C_AddOns)~="table" or type(C_AddOns.LoadAddOn)~="function" then return nil,"slot_loader_unavailable" end
11
+ local ok,loaded,reason=pcall(C_AddOns.LoadAddOn,name)
12
+ if not ok or (issecretvalue and (issecretvalue(loaded) or issecretvalue(reason))) then return nil,"slot_load_failed" end
13
+ return loaded==true and true or nil,type(reason)=="string" and reason or "slot_load_failed"
14
+ end,
8
15
  ReceiverChord = function(key)
9
16
  if (issecretvalue and issecretvalue(key)) or type(key)~="string" then return nil end
10
17
  local number=string.match(key,"^F([1-9]%d?)$")
@@ -79,6 +79,22 @@ ns.Controls = {
79
79
  end
80
80
  local state, failure = ns.Persistence.Current()
81
81
  if not state then return nil, failure end
82
+ if ns.SlotRuntime then
83
+ if command=="connect" or command=="bridge on" then
84
+ state.options.bridgeEnabled=true
85
+ return ns.SlotRuntime.Start()
86
+ elseif command=="disconnect" or command=="bridge off" then
87
+ state.options.bridgeEnabled=false
88
+ if ns.InputState then ns.InputState.Stop() end
89
+ ns.SlotRuntime.Close()
90
+ if ns.ActivityView then ns.ActivityView.Stop() end
91
+ return true
92
+ elseif command=="status" then
93
+ return {transport="memory-slot-v1",enabled=ns.Persistence.BridgeEnabled()}
94
+ else
95
+ return nil,"command_retired: use the memory-slot CLI"
96
+ end
97
+ end
82
98
  if command == "receiver reset" then
83
99
  local profile, reason = ns.ReceiverBindings.Reset()
84
100
  if not profile then return nil, reason end
@@ -322,10 +322,11 @@ ns.L = {
322
322
  AUTO_ACK_RECEIVED = "外部已读取",
323
323
  AUTO_ACK_FAILED = "外部读取失败",
324
324
  AUTO_REPORT_DISPLAY_LIMIT = "显示已在 %d KB 处截断;完整报告以 Ticket 保存。",
325
+ AUTO_REPORT_HISTORY_LIMIT = "历史摘要已在 %d KB 处截断;完整结果保存在调用项目的 .lycheedev/live/ 中。",
325
326
  AUTO_STATUS_RUNNING = "执行中",
326
327
  AUTO_STATUS_FINALIZING = "整理中",
327
- AUTO_STATUS_SUCCEEDED = "已成功",
328
- AUTO_STATUS_FAILED = "已失败",
328
+ AUTO_STATUS_SUCCEEDED = "执行成功",
329
+ AUTO_STATUS_FAILED = "执行失败",
329
330
  AUTO_STATUS_CANCELLED = "已取消",
330
331
  AUTO_STATUS_INTERRUPTED = "已中断",
331
332
  AUTO_KIND_LUA = "Lua 任务",
@@ -376,8 +377,9 @@ ns.L = {
376
377
  SETTINGS_UNSAVED = "未保存",
377
378
  RECEIVER_BINDING_CAPTURE_HELP = "单击快捷键,再按下 Ctrl+Alt 与 [、] 或 F1–F12 的组合,也可加 Shift。",
378
379
  RECEIVER_BINDING_FIXED_HELP = "由 Agent 自动调用。此处仅供查看,无需配置。",
379
- ACTIVITY_CONNECTING = "Agent 连接中",
380
- ACTIVITY_PROBE = "探针运行中",
380
+ ACTIVITY_CONNECTING = "Agent 接管中",
381
+ ACTIVITY_PROBE = "Agent 运行中",
382
+ ACTIVITY_COLLECTING = "结果待收取",
381
383
  DIAGNOSTICS_SEARCH_HINT = "筛选错误关键词…",
382
384
  RECEIVER_BINDING_PRESS = "请按组合键…",
383
385
  REDUCE_MOTION = "减少动态效果",
@@ -327,6 +327,7 @@ local english = {
327
327
  AUTO_ACK_RECEIVED = "Read by the host",
328
328
  AUTO_ACK_FAILED = "Host read failed",
329
329
  AUTO_REPORT_DISPLAY_LIMIT = "Display truncated at %d KB; the full report is stored under the Ticket.",
330
+ AUTO_REPORT_HISTORY_LIMIT = "History preview truncated at %d KB; the full result is in the calling project's .lycheedev/live/ directory.",
330
331
  AUTO_STATUS_RUNNING = "Running",
331
332
  AUTO_STATUS_FINALIZING = "Finalizing",
332
333
  AUTO_STATUS_SUCCEEDED = "Succeeded",
@@ -382,8 +383,9 @@ local english = {
382
383
  SETTINGS_UNSAVED = "Unsaved",
383
384
  RECEIVER_BINDING_CAPTURE_HELP = "Click a shortcut, then press Ctrl+Alt with [, ] or F1-F12. Shift is optional.",
384
385
  RECEIVER_BINDING_FIXED_HELP = "Used automatically by your agent. Shown for reference; no setup needed.",
385
- ACTIVITY_CONNECTING = "Agent connecting",
386
- ACTIVITY_PROBE = "Probe running",
386
+ ACTIVITY_CONNECTING = "Agent in control",
387
+ ACTIVITY_PROBE = "Agent running",
388
+ ACTIVITY_COLLECTING = "Collecting result",
387
389
  DIAGNOSTICS_SEARCH_HINT = "Filter errors by keyword...",
388
390
  RECEIVER_BINDING_PRESS = "Press shortcut...",
389
391
  RECEIVER_BINDINGS = "Command receiver shortcuts",
@@ -12,7 +12,7 @@ ns.Platform = {
12
12
  -- A point-in-time observation, not permission to send input later. The
13
13
  -- caller must also own a current session and observe focus after slash
14
14
  -- dispatch unwinds. Missing or restricted APIs fail closed.
15
- ObserveInputState = function()
15
+ ObserveInputState = function(allowFocusedInput)
16
16
  if type(IsLoggedIn) ~= "function" or type(InCombatLockdown) ~= "function"
17
17
  or type(GetCurrentKeyBoardFocus) ~= "function" then
18
18
  return nil, "input_observation_unavailable"
@@ -29,7 +29,9 @@ ns.Platform = {
29
29
  if combat then return false, "input_combat_lockdown" end
30
30
  local focusOK, focus = pcall(GetCurrentKeyBoardFocus)
31
31
  if not focusOK or restricted(focus) then return nil, "input_focus_unavailable" end
32
- if focus ~= nil then return false, "input_keyboard_focus" end
32
+ -- The slot path sends a non-text key and neither clears nor edits this
33
+ -- object. Other input paths still require an empty keyboard focus.
34
+ if focus ~= nil and allowFocusedInput ~= true then return false, "input_keyboard_focus" end
33
35
  return true
34
36
  end,
35
37
  ObserveActor = function()
@@ -1,6 +1,6 @@
1
1
  local ADDON_NAME, ns = ...
2
2
 
3
- ns.Release = "2.5.0"
3
+ ns.Release = "3.0.0"
4
4
  ns.Startup = { ready = false, reason = "addon_not_loaded" }
5
5
  -- Observability handle: mirrors the addon namespace for host-side /run
6
6
  -- introspection (startup state, identity, commandFailure) on every client.
@@ -42,10 +42,12 @@ local function start(trigger)
42
42
  started = true
43
43
  local registered, registrationFailure = ns.Controls.Register()
44
44
  if not registered then ns.Startup.commandFailure = registrationFailure end
45
- local receiverRegistered, receiverFailure = ns.Receiver.Register()
45
+ local receiverRegistered, receiverFailure
46
+ if ns.SlotRuntime then receiverRegistered,receiverFailure=ns.SlotRuntime.Register()
47
+ else receiverRegistered,receiverFailure=ns.Receiver.Register() end
46
48
  if not receiverRegistered then ns.Startup.receiverFailure = receiverFailure end
47
49
  if ns.StartupBeacon then ns.StartupBeacon.Arm() end
48
- if registered then
50
+ if registered and not ns.SlotRuntime then
49
51
  local resumed, resumeFailure = ns.Reentry.Start(loader)
50
52
  if not resumed then ns.Startup.resumeFailure = resumeFailure end
51
53
  end
@@ -59,7 +61,16 @@ loader:SetScript("OnEvent", function(self, event, name)
59
61
  if event == "ADDON_LOADED" and name ~= ADDON_NAME then return end
60
62
  -- One-shot: the name-matched ADDON_LOADED owns startup, success or not;
61
63
  -- PLAYER_LOGIN is the fallback trigger when that event never matched.
62
- self:UnregisterAllEvents()
63
- self:SetScript("OnEvent", nil)
64
- start(event)
64
+ if ns.SlotRuntime then
65
+ if start(event) then
66
+ -- Actor identity can be unavailable during ADDON_LOADED. The
67
+ -- existing one-shot loader owns the one PLAYER_LOGIN retry.
68
+ local ok=ns.SlotRuntime.Start()
69
+ if ok or event=="PLAYER_LOGIN" then self:UnregisterAllEvents();self:SetScript("OnEvent",nil) end
70
+ end
71
+ else
72
+ self:UnregisterAllEvents()
73
+ self:SetScript("OnEvent", nil)
74
+ start(event)
75
+ end
65
76
  end)
@@ -1,6 +1,6 @@
1
1
  ## Interface: 120100, 50504, 38002, 16001
2
2
  ## Title: Lychee Dev
3
- ## Version: 2.5.0
3
+ ## Version: 3.0.0
4
4
  ## SavedVariables: LycheeToolkitDB
5
5
  ## SavedVariablesPerCharacter: LycheeToolkitBridgeDB
6
6
 
@@ -22,6 +22,10 @@ Core\Persistence.lua
22
22
  Bridge\Session.lua
23
23
  Core\Controls.lua
24
24
  Bridge\CaptureWriter.lua
25
+ Bridge\MemoryProtocol.lua
26
+ Bridge\SlotProtocol.lua
27
+ Bridge\InputProtection.lua
28
+ Bridge\ProbeExecution.lua
25
29
  Bridge\InputProtocol.lua
26
30
  Bridge\MatrixSymbol.lua
27
31
  Bridge\ReceiptView.lua
@@ -30,6 +34,7 @@ Bridge\ReportStore.lua
30
34
  Bridge\Investigation.lua
31
35
  Bridge\ProbeRunner.lua
32
36
  Bridge\Definitions.lua
37
+ Modules\AutomationHistory.lua
33
38
  Modules\AutomationView.lua
34
39
  Bridge\ProbeQueue.lua
35
40
  Bridge\Reentry.lua
@@ -37,6 +42,8 @@ Bridge\Identity.lua
37
42
  Bridge\ReceiverBindings.lua
38
43
  Bridge\StartupBeacon.lua
39
44
  Bridge\Receiver.lua
45
+ Bridge\SlotRuntime.lua
46
+ Bridge\InputState.lua
40
47
  # --- Event catalogs: all four load; Catalog.lua selects ns.Client's table ---
41
48
  Modules\Events\CatalogData_Mainline.lua
42
49
  Modules\Events\CatalogData_Mists.lua
@@ -55,7 +62,6 @@ UI\Widgets.lua
55
62
  UI\TreeView.lua
56
63
  UI\Export.lua
57
64
  UI\Window.lua
58
- UI\Pages\Settings.lua
59
65
  # --- Workbench pages: later page modules insert their load line here ---
60
66
  UI\Pages\About.lua
61
67
  UI\Pages\Run.lua
@@ -0,0 +1,119 @@
1
+ local _, ns = ...
2
+
3
+ -- A bounded, per-character display history, not an execution/recovery journal.
4
+ -- SavedVariables flush on reload/logout. The CLI's project journal owns durable
5
+ -- evidence and retries; these records must never authorize execution.
6
+ local MAX_RECORDS, REPORT_BYTES = 100, 32 * 1024
7
+ local runtime, identity
8
+ local statuses = { loaded=true, running=true, reported=true, acknowledged=true, interrupted=true }
9
+ local phases = { prepared="loaded", running="running", reported="reported", released="acknowledged" }
10
+ local fields={requestId=true,runtime=true,nonce=true,observedAt=true,codeBytes=true,codeAdler32=true,
11
+ character=true,realm=true,guid=true,build=true,product=true,status=true,pending=true,hasReport=true,
12
+ reportBody=true,reportTruncated=true,probeStatus=true,errorCode=true}
13
+ local function safe(v) return not (issecretvalue and issecretvalue(v)) end
14
+ local function plain(v) return safe(v) and type(v)=="table" and getmetatable(v)==nil end
15
+ local function text(v,n) return safe(v) and type(v)=="string" and #v<=n end
16
+ local function number(v) return safe(v) and type(v)=="number" and v>=0 and v<math.huge and v%1==0 end
17
+ local function preview(body)
18
+ local last=math.min(#body,REPORT_BYTES)
19
+ -- CaptureWriter supplies UTF-8. Never persist half of its last codepoint.
20
+ if #body>last then
21
+ local nextByte=body:byte(last+1)
22
+ if nextByte>=128 and nextByte<192 then
23
+ while last>0 and body:byte(last)>=128 and body:byte(last)<192 do last=last-1 end
24
+ last=last-1
25
+ end
26
+ end
27
+ return body:sub(1,last)
28
+ end
29
+ local function valid(record)
30
+ if not plain(record) or not text(record.requestId,68) or not record.requestId:match("^MEM%-%x+$")
31
+ or not text(record.runtime,32) or not text(record.status,16) or not statuses[record.status]
32
+ or not number(record.observedAt) or not number(record.codeBytes) then return false end
33
+ for key in pairs(record) do if not safe(key) or not fields[key] then return false end end
34
+ for key,limit in pairs({nonce=32,character=256,realm=256,guid=128,build=64,product=32,
35
+ codeAdler32=16,reportBody=REPORT_BYTES,probeStatus=16,errorCode=128}) do
36
+ if record[key]~=nil and not text(record[key],limit) then return false end
37
+ end
38
+ for _,key in ipairs({"pending","hasReport","reportTruncated"}) do
39
+ if not safe(record[key]) or (record[key]~=nil and type(record[key])~="boolean") then return false end
40
+ end
41
+ return true
42
+ end
43
+ local function store(create)
44
+ local root,reason=ns.Persistence.Bridge()
45
+ if not root then return nil,reason end
46
+ local saved=root.automationHistory
47
+ if saved==nil and create then saved={schema=1,records={}};root.automationHistory=saved end
48
+ if saved==nil then return nil end
49
+ if not plain(saved) or not safe(saved.schema) or saved.schema~=1 or not plain(saved.records) then
50
+ return nil,"automation_history_invalid"
51
+ end
52
+ local count=0
53
+ for key,record in pairs(saved.records) do
54
+ count=count+1
55
+ if count>MAX_RECORDS or not number(key) or key<1 or key>MAX_RECORDS or not valid(record) then
56
+ return nil,"automation_history_invalid"
57
+ end
58
+ end
59
+ if count~=#saved.records then return nil,"automation_history_invalid" end
60
+ return saved
61
+ end
62
+ local function changed()
63
+ if ns.AutomationView then ns.AutomationView.Changed() end
64
+ end
65
+ local function begin(current,actor)
66
+ runtime,identity=current,actor
67
+ local saved=store(false)
68
+ if not saved then return end
69
+ for _,record in ipairs(saved.records) do
70
+ if record.runtime~=runtime then
71
+ record.pending=false;record.hasReport=false
72
+ if record.status=="loaded" or record.status=="running" then
73
+ record.status="interrupted";record.errorCode="runtime_changed"
74
+ end
75
+ end
76
+ end
77
+ end
78
+ local function observe(op)
79
+ if not runtime or not identity then return nil,"automation_history_not_started" end
80
+ local saved,reason=store(true);if not saved then return nil,reason end
81
+ local requestId="MEM-"..op.envelope.ticket
82
+ local record
83
+ for _,item in ipairs(saved.records) do if item.requestId==requestId and item.runtime==runtime then record=item;break end end
84
+ if not record then
85
+ if #saved.records>=MAX_RECORDS then
86
+ local removed=false
87
+ for i,item in ipairs(saved.records) do
88
+ if not item.pending then table.remove(saved.records,i);removed=true;break end
89
+ end
90
+ if not removed then return nil,"automation_history_full" end
91
+ end
92
+ record={requestId=requestId,runtime=runtime,nonce=op.envelope.nonce,
93
+ observedAt=(time and time()) or 0,codeBytes=op.envelope.codeBytes or 0,
94
+ codeAdler32=string.format("%08x",op.envelope.codeChecksum or 0),
95
+ character=identity.character,realm=identity.realm,guid=identity.guid,build=identity.build,product=identity.product}
96
+ saved.records[#saved.records+1]=record
97
+ end
98
+ record.status=phases[op.state]
99
+ record.pending=op.state~="released"
100
+ record.hasReport=op.state=="reported"
101
+ if op.payload then
102
+ record.reportBody=preview(op.payload)
103
+ record.reportTruncated=#op.payload>REPORT_BYTES
104
+ record.probeStatus=op.ok and "completed" or "failed"
105
+ end
106
+ changed()
107
+ return true
108
+ end
109
+ ns.AutomationHistory={
110
+ MAX_RECORDS=MAX_RECORDS,REPORT_BYTES=REPORT_BYTES,Begin=begin,Observe=observe,
111
+ List=function()local saved,reason=store(false);return saved and saved.records or {},reason end,
112
+ Remove=function(id)
113
+ local saved=store(false);if not saved then return false end
114
+ for i,record in ipairs(saved.records) do
115
+ if record.requestId==id and not record.pending then table.remove(saved.records,i);return true end
116
+ end
117
+ return false
118
+ end,
119
+ }