lycheedev 2.0.1 → 2.0.3
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.
- package/README.md +2 -0
- package/THIRD_PARTY_NOTICES +3 -2
- package/native/windows-amd64/lycheedev.exe +0 -0
- package/package.json +1 -1
- package/payload/addon/Bridge/CaptureWriter.lua +97 -0
- package/payload/addon/Bridge/FaultRunner.lua +41 -0
- package/payload/addon/Bridge/Identity.lua +1 -1
- package/payload/addon/Bridge/ProbeQueue.lua +51 -4
- package/payload/addon/Bridge/ProbeRunner.lua +100 -21
- package/payload/addon/Bridge/ReceiptView.lua +103 -31
- package/payload/addon/Bridge/Reentry.lua +77 -9
- package/payload/addon/Bridge/ReportStore.lua +28 -11
- package/payload/addon/Bridge/Session.lua +1 -1
- package/payload/addon/Core/ClientGate.lua +31 -0
- package/payload/addon/Core/Compat.lua +19 -21
- package/payload/addon/Core/Controls.lua +58 -9
- package/payload/addon/Core/Platform.lua +5 -1
- package/payload/addon/Core/Runtime.lua +47 -10
- package/payload/addon/{Lychee Dev_Mainline.toc → Lychee Dev.toc } +14 -7
- package/payload/addon/Modules/Events/Catalog.lua +5 -1
- package/payload/addon/Modules/Events/CatalogData_Forever.lua +1 -1
- package/payload/addon/Modules/Events/CatalogData_Mainline.lua +1 -1
- package/payload/addon/Modules/Events/CatalogData_Mists.lua +1 -1
- package/payload/addon/Modules/Events/CatalogData_Titan.lua +1 -1
- package/payload/skill/SKILL.md +22 -4
- package/payload/skill/references/addon-validation.md +37 -8
- package/payload/skill/references/asset-export.md +27 -2
- package/payload/skill/references/commands.md +163 -121
- package/payload/skill/references/data-investigation.md +52 -14
- package/payload/skill/references/error-diagnosis.md +22 -32
- package/payload/skill/references/installation.md +6 -0
- package/payload/skill/references/live-investigation.md +173 -107
- package/payload/skill/references/live-startup.md +86 -0
- package/payload/skill/references/source-research.md +29 -11
- package/release.json +76 -96
- package/payload/addon/Clients/Evergreen.lua +0 -2
- package/payload/addon/Clients/Live.lua +0 -2
- package/payload/addon/Clients/Pandaria.lua +0 -2
- package/payload/addon/Clients/Titan.lua +0 -2
- package/payload/addon/Lychee Dev_Forever.toc +0 -52
- package/payload/addon/Lychee Dev_Mists.toc +0 -52
- package/payload/addon/Lychee Dev_Wrath.toc +0 -52
package/README.md
CHANGED
|
@@ -32,6 +32,8 @@ removal is an explicit command that only touches files the toolkit owns.
|
|
|
32
32
|
|
|
33
33
|
The launcher never downloads fallback binaries and never reads legacy tool homes
|
|
34
34
|
(`~/.wowdoc`, `~/.wowdata`). Unsupported platforms fail with a precise error.
|
|
35
|
+
The current workspace is `~/.lycheedev`; legacy homes and legacy SavedVariables
|
|
36
|
+
are intentionally not imported.
|
|
35
37
|
|
|
36
38
|
## Contents
|
|
37
39
|
|
package/THIRD_PARTY_NOTICES
CHANGED
|
@@ -2,8 +2,9 @@ THIRD-PARTY NOTICES for the lycheedev package (payload/addon, payload/skill and
|
|
|
2
2
|
the native/ lycheedev binaries).
|
|
3
3
|
|
|
4
4
|
Development status: the npm manifest declares "license": "MIT" (owner licensing
|
|
5
|
-
decision recorded 2026-09-23, see below)
|
|
6
|
-
|
|
5
|
+
decision recorded 2026-09-23, see below). Development versions may be private
|
|
6
|
+
under the version policy; a released or release-candidate package is publishable.
|
|
7
|
+
This file is the complete
|
|
7
8
|
third-party inventory for the current tree, not a partial image-codec list. The
|
|
8
9
|
repository root THIRD_PARTY_NOTICES.md records the source-side provenance
|
|
9
10
|
detail. Component versions are the versions pinned in go.sum and compiled into
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -139,6 +139,60 @@ local function digestBytes(text)
|
|
|
139
139
|
return string.format("%04x%04x", high, low)
|
|
140
140
|
end
|
|
141
141
|
|
|
142
|
+
-- Every signal is drawn into a QR symbol, so its size decides whether the host
|
|
143
|
+
-- can sample the module grid at all. A retained session already proved the actor
|
|
144
|
+
-- and the build, so repeating them in each receipt only spends modules: the host
|
|
145
|
+
-- fills them back from its baseline and still refuses a value that contradicts
|
|
146
|
+
-- it. Identity, reset and cleared markers are the exception, because they
|
|
147
|
+
-- establish or re-establish the actor.
|
|
148
|
+
--
|
|
149
|
+
-- The session nonce is different and must NOT be dropped blindly: the ready and
|
|
150
|
+
-- loaded receipts are what establish it, so the host has nothing to fill from
|
|
151
|
+
-- until one of them has been read. Only the receipts that echo an
|
|
152
|
+
-- already-established session may omit it.
|
|
153
|
+
local WIRE_FIELDS = {
|
|
154
|
+
schema = true, kind = true, sessionNonce = true, requestId = true,
|
|
155
|
+
release = true, product = true, build = true,
|
|
156
|
+
reloadNonce = true, cleanupNonce = true, probeNonce = true,
|
|
157
|
+
actorState = true, inputReason = true, sequence = true, runtimeEpoch = true,
|
|
158
|
+
inputReady = true, codeBytes = true, codeAdler32 = true,
|
|
159
|
+
reportBytes = true, reportAdler32 = true,
|
|
160
|
+
}
|
|
161
|
+
local WIRE_MARKER_FIELDS = { character = true, realm = true, guid = true }
|
|
162
|
+
-- A standalone ready can establish a read-only live bind without a preceding
|
|
163
|
+
-- identity probe. Keep its actor on the wire; paired readiness is compacted
|
|
164
|
+
-- only after the host already owns a request-scoped session.
|
|
165
|
+
local WIRE_MARKERS = { identity = true, reset = true, cleared = true, ready = true }
|
|
166
|
+
-- Kinds whose session nonce is redundant because the session provably exists on
|
|
167
|
+
-- the host already: they answer a request the host itself created for that
|
|
168
|
+
-- nonce, and the host compares the nonce it filled in.
|
|
169
|
+
local WIRE_ECHOES_SESSION = { reported = true, acknowledged = true, cancelled = true }
|
|
170
|
+
|
|
171
|
+
-- wireDocument projects a signal onto its transmitted form. Fields outside the
|
|
172
|
+
-- profile are dropped rather than rejected: the projection is what the host
|
|
173
|
+
-- compares against the archived receipt, so an unlisted field simply stops
|
|
174
|
+
-- matching and never lets a caller believe a value was carried when it was not.
|
|
175
|
+
local function wireDocument(value)
|
|
176
|
+
rejectRestricted(value)
|
|
177
|
+
if type(value) ~= "table" or getmetatable(value) ~= nil then
|
|
178
|
+
return value
|
|
179
|
+
end
|
|
180
|
+
rejectRestricted(value.schema)
|
|
181
|
+
if value.schema ~= "lycheedev.signal.v1" then return value end
|
|
182
|
+
rejectRestricted(value.kind)
|
|
183
|
+
local marker = WIRE_MARKERS[value.kind] == true
|
|
184
|
+
local echoes = WIRE_ECHOES_SESSION[value.kind] == true
|
|
185
|
+
local filtered = {}
|
|
186
|
+
for key, child in pairs(value) do
|
|
187
|
+
rejectRestricted(key)
|
|
188
|
+
local carried = WIRE_FIELDS[key] or (marker and WIRE_MARKER_FIELDS[key])
|
|
189
|
+
if carried and not (key == "sessionNonce" and echoes) then
|
|
190
|
+
filtered[key] = child
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
return filtered
|
|
194
|
+
end
|
|
195
|
+
|
|
142
196
|
ns.CaptureWriter = {
|
|
143
197
|
Encode = function(value, limit)
|
|
144
198
|
if issecretvalue and issecretvalue(limit) then return nil, "report_invalid_budget" end
|
|
@@ -148,6 +202,49 @@ ns.CaptureWriter = {
|
|
|
148
202
|
end
|
|
149
203
|
local ok, result = pcall(encodeDocument, value, limit)
|
|
150
204
|
if not ok then return nil, result end
|
|
205
|
+
-- Every encoded value is the exact UTF-8 JSON text that is both drawn
|
|
206
|
+
-- into the QR symbol and stored in SavedVariables. Transport
|
|
207
|
+
-- compression is not applied here: a raw DEFLATE stream is not valid
|
|
208
|
+
-- UTF-8, and SavedVariables must stay valid UTF-8 for the host to read
|
|
209
|
+
-- any of the toolkit state at all.
|
|
210
|
+
return result
|
|
211
|
+
end,
|
|
212
|
+
-- EncodeSignal is the only entry point that produces a machine-readable
|
|
213
|
+
-- receipt. Encode stays byte-exact for whatever a caller passes. A rejected
|
|
214
|
+
-- projection reports the exact offending field so a caller can tell an
|
|
215
|
+
-- unrecognized field from a malformed value.
|
|
216
|
+
EncodeSignal = function(value, limit)
|
|
217
|
+
local ok, projected = pcall(wireDocument, value)
|
|
218
|
+
if not ok then
|
|
219
|
+
if type(projected) == "string" and #projected > 0 and #projected <= 128 then
|
|
220
|
+
return nil, projected
|
|
221
|
+
end
|
|
222
|
+
return nil, "report_invalid_document"
|
|
223
|
+
end
|
|
224
|
+
local encoded, failure = ns.CaptureWriter.Encode(projected, limit)
|
|
225
|
+
return encoded, failure, encoded and projected or nil
|
|
226
|
+
end,
|
|
227
|
+
-- Optical-only envelope: the stored receipt stays byte-exact. Readiness is
|
|
228
|
+
-- a fresh, independently sequenced observation of the same session. The
|
|
229
|
+
-- host expands this tuple into a second signal, never into report content.
|
|
230
|
+
EncodeReceiptPair = function(receipt, ready)
|
|
231
|
+
local ok, suffix = pcall(function()
|
|
232
|
+
rejectRestricted(receipt); rejectRestricted(ready)
|
|
233
|
+
if type(receipt) ~= "string" or #receipt > 2048 or not isUTF8(receipt)
|
|
234
|
+
or type(ready) ~= "table" or getmetatable(ready) then error("receipt_invalid_pair", 0) end
|
|
235
|
+
-- Traverse before branching, including any secret-valued fields.
|
|
236
|
+
encodeDocument(ready, 4096)
|
|
237
|
+
if ready.kind ~= "ready" or ready.inputReady ~= true or ready.requestId ~= ""
|
|
238
|
+
or type(ready.sessionNonce) ~= "string" or #ready.sessionNonce ~= 32
|
|
239
|
+
or not string.match(ready.sessionNonce, "^[0-9a-f]+$")
|
|
240
|
+
or type(ready.sequence) ~= "number" or type(ready.runtimeEpoch) ~= "number" then
|
|
241
|
+
error("receipt_invalid_pair", 0)
|
|
242
|
+
end
|
|
243
|
+
return encodeDocument({ready.sessionNonce, ready.sequence, ready.runtimeEpoch}, 256)
|
|
244
|
+
end)
|
|
245
|
+
if not ok then return nil, "receipt_invalid_pair" end
|
|
246
|
+
local result = '{"schema":"lycheedev.receipt.v1","receipt":' .. receipt .. ',"ready":' .. suffix .. '}'
|
|
247
|
+
if #result > 4096 then return nil, "receipt_invalid_pair" end
|
|
151
248
|
return result
|
|
152
249
|
end,
|
|
153
250
|
DigestBytes = digestBytes,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
local ADDON_NAME, ns = ...
|
|
2
|
+
|
|
3
|
+
local function restricted(value) return issecretvalue and issecretvalue(value) end
|
|
4
|
+
local function requestKey(value)
|
|
5
|
+
return not restricted(value) and type(value)=="string" and #value>0 and #value<=128
|
|
6
|
+
and string.match(value,"^[%w_%-]+$")~=nil
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
ns.FaultRunner={
|
|
10
|
+
Run=function(requestId,count)
|
|
11
|
+
if not requestKey(requestId) or restricted(count) or type(count)~="number"
|
|
12
|
+
or count%1~=0 or count<1 or count>100 then return nil,"fault_invalid_request" end
|
|
13
|
+
local session,reason=ns.Session.Current()
|
|
14
|
+
if not session then return nil,reason end
|
|
15
|
+
local receipt,missing=ns.ReportStore.Read(requestId)
|
|
16
|
+
if receipt or missing~="report_unavailable" then return nil,"fault_request_exists" end
|
|
17
|
+
if type(ns.Diagnostics)~="table" or type(ns.Diagnostics.SnapshotRecentErrors)~="function" then
|
|
18
|
+
return nil,"fault_diagnostics_unavailable"
|
|
19
|
+
end
|
|
20
|
+
local snapshot,failure=ns.Diagnostics.SnapshotRecentErrors(count,"provider_storage")
|
|
21
|
+
local body={schema="lycheedev.bugs.v1",requestType="bugs",
|
|
22
|
+
status=snapshot and "completed" or "unavailable",complete=snapshot~=nil,
|
|
23
|
+
snapshot=snapshot,error=failure}
|
|
24
|
+
return ns.ReportStore.Commit(requestId,"",body)
|
|
25
|
+
end,
|
|
26
|
+
Acknowledge=function(requestId,sequence)
|
|
27
|
+
if not requestKey(requestId) or restricted(sequence) or type(sequence)~="number"
|
|
28
|
+
or sequence%1~=0 or sequence<1 or sequence>9007199254740991 then
|
|
29
|
+
return nil,"fault_invalid_acknowledgement"
|
|
30
|
+
end
|
|
31
|
+
local session,reason=ns.Session.Current()
|
|
32
|
+
if not session then return nil,reason end
|
|
33
|
+
local receipt,body=ns.ReportStore.Read(requestId)
|
|
34
|
+
if not receipt then return nil,body end
|
|
35
|
+
return ns.ReportStore.Acknowledge({schema="lycheedev.signal.v1",release=ns.Release,
|
|
36
|
+
kind="reported",sessionNonce=session.sessionNonce,requestId=requestId,
|
|
37
|
+
character=session.character,realm=session.realm,sequence=sequence,
|
|
38
|
+
product=ns.Startup.identity.product,build=ns.Startup.identity.build,
|
|
39
|
+
inputReady=false,reportBytes=#body,reportAdler32=ns.CaptureWriter.DigestBytes(body)})
|
|
40
|
+
end,
|
|
41
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
local ADDON_NAME, ns = ...
|
|
2
2
|
|
|
3
3
|
local definitions = ns.ProbeDefinitions
|
|
4
|
+
-- Bounded by the loaded queue (at most 16 entries). Keep definitions for the
|
|
5
|
+
-- retained cleanup protocol, but acknowledged source no longer owns the UI
|
|
6
|
+
-- and cannot be loaded again in this runtime. Disk retirement stays host-owned.
|
|
7
|
+
local acknowledged = {}
|
|
4
8
|
ns.ProbeDefinitions = nil
|
|
5
9
|
local function restricted(value)
|
|
6
10
|
return issecretvalue and issecretvalue(value)
|
|
@@ -68,8 +72,17 @@ ns.ProbeQueue = {
|
|
|
68
72
|
-- window's queue and display. Unreadable definitions fail closed.
|
|
69
73
|
Busy = function()
|
|
70
74
|
if definitions == nil then return false end
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
local valid, reason = validate()
|
|
76
|
+
if not valid then return nil, reason end
|
|
77
|
+
if next(definitions.entries) == nil then return false end
|
|
78
|
+
local actor, failure = ns.Platform.ObserveActor()
|
|
79
|
+
if not actor then return nil, failure end
|
|
80
|
+
-- The installation queue is shared by windows; another character
|
|
81
|
+
-- cannot own this window merely because its definition is loaded here.
|
|
82
|
+
for id, entry in pairs(definitions.entries) do
|
|
83
|
+
if not acknowledged[id] and entry.character == actor.character
|
|
84
|
+
and entry.realm == actor.realm and entry.guid == actor.guid then return true end
|
|
85
|
+
end
|
|
73
86
|
return false
|
|
74
87
|
end,
|
|
75
88
|
ReloadScope = function(requestId)
|
|
@@ -99,7 +112,7 @@ ns.ProbeQueue = {
|
|
|
99
112
|
if not identity then return nil, identityFailure end
|
|
100
113
|
-- This observes loaded memory, never disk or host ownership. No report,
|
|
101
114
|
-- queue entry or executable is removed to manufacture a success receipt.
|
|
102
|
-
return ns.CaptureWriter.
|
|
115
|
+
return ns.CaptureWriter.EncodeSignal({
|
|
103
116
|
schema = "lycheedev.signal.v1", release = ns.Release, kind = "cleared",
|
|
104
117
|
sessionNonce = identity.sessionNonce, requestId = requestId, cleanupNonce = nonce,
|
|
105
118
|
character = identity.character, realm = identity.realm, guid = identity.guid,
|
|
@@ -110,6 +123,7 @@ ns.ProbeQueue = {
|
|
|
110
123
|
Load = function(requestId)
|
|
111
124
|
local entry, reason = selectEntry(requestId)
|
|
112
125
|
if not entry then return nil, reason end
|
|
126
|
+
if acknowledged[requestId] then return nil, "queue_request_acknowledged" end
|
|
113
127
|
-- SHA-256 is checked by the host. The game checks actual code bytes and
|
|
114
128
|
-- Adler-32; neither a carried digest nor loading is execution permission.
|
|
115
129
|
return ns.ProbeRunner.Load(requestId, entry.code, entry.reloadNonce)
|
|
@@ -124,7 +138,7 @@ ns.ProbeQueue = {
|
|
|
124
138
|
-- Reconstruct only the canonical receipt format generated by Commit.
|
|
125
139
|
-- The store compares its exact bytes before deletion, so neither an
|
|
126
140
|
-- arbitrary sequence nor changed code/body can authorize another report.
|
|
127
|
-
|
|
141
|
+
local acknowledgement, failure = ns.ReportStore.Acknowledge({
|
|
128
142
|
schema = "lycheedev.signal.v1", release = entry.release, kind = "reported",
|
|
129
143
|
sessionNonce = entry.sessionNonce, requestId = requestId,
|
|
130
144
|
character = entry.character, realm = entry.realm, sequence = sequence,
|
|
@@ -132,5 +146,38 @@ ns.ProbeQueue = {
|
|
|
132
146
|
codeBytes = entry.codeBytes, codeAdler32 = entry.codeAdler32,
|
|
133
147
|
reportBytes = #body, reportAdler32 = ns.CaptureWriter.DigestBytes(body),
|
|
134
148
|
})
|
|
149
|
+
if acknowledgement then acknowledged[requestId] = true end
|
|
150
|
+
return acknowledgement, failure
|
|
151
|
+
end,
|
|
152
|
+
-- Host-side recovery for a stuck runtime whose queue blocks identity after
|
|
153
|
+
-- its disk entry was retired (abandon) or its receipt was lost. Session
|
|
154
|
+
-- free and actor scoped exactly like Busy: entries of other characters on
|
|
155
|
+
-- a shared installation are never touched. A pending reentry ticket is
|
|
156
|
+
-- stale residue here by definition; the caller verified no disk owner.
|
|
157
|
+
Reset = function(nonce)
|
|
158
|
+
if not hex(nonce, 32) then return nil, "reset_invalid_nonce" end
|
|
159
|
+
local valid, reason = validate()
|
|
160
|
+
if not valid then return nil, reason end
|
|
161
|
+
local actor, actorFailure = ns.Platform.ObserveActor()
|
|
162
|
+
if not actor then return nil, actorFailure or "no_actor" end
|
|
163
|
+
if ns.Reentry and type(ns.Reentry.Cancel) == "function" then ns.Reentry.Cancel(true) end
|
|
164
|
+
local reset = 0
|
|
165
|
+
for id, entry in pairs(definitions.entries) do
|
|
166
|
+
if not acknowledged[id] and entry.character == actor.character
|
|
167
|
+
and entry.realm == actor.realm and entry.guid == actor.guid then
|
|
168
|
+
acknowledged[id] = true
|
|
169
|
+
reset = reset + 1
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
local identity, identityFailure = ns.Platform.ObserveBuild()
|
|
173
|
+
if not identity then return nil, identityFailure end
|
|
174
|
+
return ns.CaptureWriter.EncodeSignal({
|
|
175
|
+
schema = "lycheedev.signal.v1", release = ns.Release, kind = "reset",
|
|
176
|
+
sessionNonce = "", probeNonce = nonce,
|
|
177
|
+
requestId = "", character = actor.character, realm = actor.realm,
|
|
178
|
+
guid = actor.guid, product = identity.product,
|
|
179
|
+
build = identity.build, sequence = 0,
|
|
180
|
+
inputReady = false,
|
|
181
|
+
}, 4096)
|
|
135
182
|
end,
|
|
136
183
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ADDON_NAME, ns = ...
|
|
2
2
|
|
|
3
3
|
local requests, owner, count, bytes
|
|
4
|
+
local MAX_ASYNC_SECONDS,MAX_LOG_BYTES,MAX_LOG_ENTRIES,MAX_CLEANUPS=120,32768,100,16
|
|
4
5
|
local function restricted(value)
|
|
5
6
|
return issecretvalue and issecretvalue(value)
|
|
6
7
|
end
|
|
@@ -22,7 +23,7 @@ end
|
|
|
22
23
|
local function loadedSignal(requestId, code, reloadNonce, ready)
|
|
23
24
|
local identity, failure = ns.Session.NextIdentity()
|
|
24
25
|
if not identity then return nil, failure end
|
|
25
|
-
return ns.CaptureWriter.
|
|
26
|
+
return ns.CaptureWriter.EncodeSignal({
|
|
26
27
|
schema = "lycheedev.signal.v1", release = ns.Release, kind = "loaded",
|
|
27
28
|
sessionNonce = identity.sessionNonce, requestId = requestId, reloadNonce = reloadNonce,
|
|
28
29
|
character = identity.character, realm = identity.realm, sequence = identity.sequence,
|
|
@@ -30,6 +31,93 @@ local function loadedSignal(requestId, code, reloadNonce, ready)
|
|
|
30
31
|
inputReady = ready, codeBytes = #code, codeAdler32 = ns.CaptureWriter.DigestBytes(code),
|
|
31
32
|
}, 4096)
|
|
32
33
|
end
|
|
34
|
+
local function safeMessage(value,fallback)
|
|
35
|
+
if restricted(value) or type(value)~="string" or #value==0 or #value>4096 then return fallback end
|
|
36
|
+
return value
|
|
37
|
+
end
|
|
38
|
+
local function cleanup(request)
|
|
39
|
+
if request.timer and type(request.timer.Cancel)=="function" then pcall(request.timer.Cancel,request.timer) end
|
|
40
|
+
request.timer=nil
|
|
41
|
+
local callbacks=request.cleanups or {}
|
|
42
|
+
request.cleanups={}
|
|
43
|
+
for index=#callbacks,1,-1 do pcall(callbacks[index]) end
|
|
44
|
+
end
|
|
45
|
+
local function publish(request,receipt)
|
|
46
|
+
local function refresh()
|
|
47
|
+
if request.state~="reported" then return nil end
|
|
48
|
+
local current,_,signal=ns.Session.ReadyReceipt()
|
|
49
|
+
if current then return receipt,current,signal end
|
|
50
|
+
end
|
|
51
|
+
local visible=ns.ReceiptView.Show(receipt,nil,refresh)
|
|
52
|
+
if not visible then return end
|
|
53
|
+
ns.Session.WhenInputReady(function(ready)
|
|
54
|
+
if not ready or request.state~="reported" then return end
|
|
55
|
+
local current,_,signal=ns.Session.ReadyReceipt()
|
|
56
|
+
if current then ns.ReceiptView.Show(receipt,current,refresh,signal) end
|
|
57
|
+
end)
|
|
58
|
+
end
|
|
59
|
+
local function complete(request,status,value,display)
|
|
60
|
+
if request.state~="running" then return nil,"probe_not_running" end
|
|
61
|
+
local active=ns.Session.Current()
|
|
62
|
+
if not active or active.generation~=request.generation then
|
|
63
|
+
request.state="unresolved";cleanup(request);return nil,"probe_session_changed"
|
|
64
|
+
end
|
|
65
|
+
local body={probeStatus=status,result=status=="completed" and value or nil,
|
|
66
|
+
error=status=="failed" and safeMessage(value,"probe_runtime_error") or nil,
|
|
67
|
+
logs=#request.logs>0 and request.logs or nil,logsTruncated=request.logsTruncated or nil}
|
|
68
|
+
local report,failure=ns.ReportStore.Commit(request.requestId,request.code,body)
|
|
69
|
+
request.state=report and "reported" or "unresolved"
|
|
70
|
+
request.report=report
|
|
71
|
+
if report then
|
|
72
|
+
local _,storedBody=ns.ReportStore.Read(request.requestId)
|
|
73
|
+
request.reportBody=storedBody
|
|
74
|
+
end
|
|
75
|
+
cleanup(request)
|
|
76
|
+
if report and display then publish(request,report) end
|
|
77
|
+
return report,failure
|
|
78
|
+
end
|
|
79
|
+
local function probeAPI(request)
|
|
80
|
+
local api={}
|
|
81
|
+
function api.Async(_,seconds)
|
|
82
|
+
if request.state~="running" or request.async then return nil,"probe_async_state" end
|
|
83
|
+
if restricted(seconds) or type(seconds)~="number" or seconds%1~=0 or seconds<1 or seconds>MAX_ASYNC_SECONDS
|
|
84
|
+
or type(C_Timer)~="table" or type(C_Timer.NewTimer)~="function" then return nil,"probe_async_unavailable" end
|
|
85
|
+
request.async=true
|
|
86
|
+
request.timer=C_Timer.NewTimer(seconds,function()
|
|
87
|
+
if request.state=="running" then complete(request,"failed","probe_timeout",true) end
|
|
88
|
+
end)
|
|
89
|
+
if not request.timer then request.async=false;return nil,"probe_async_unavailable" end
|
|
90
|
+
return true
|
|
91
|
+
end
|
|
92
|
+
function api.Finish(_,value) return complete(request,"completed",value,true) end
|
|
93
|
+
function api.Fail(_,message) return complete(request,"failed",message,true) end
|
|
94
|
+
function api.OnCleanup(_,callback)
|
|
95
|
+
if request.state~="running" or type(callback)~="function" or #request.cleanups>=MAX_CLEANUPS then
|
|
96
|
+
return nil,"probe_cleanup_limit"
|
|
97
|
+
end
|
|
98
|
+
request.cleanups[#request.cleanups+1]=callback
|
|
99
|
+
return true
|
|
100
|
+
end
|
|
101
|
+
function api.Log(_,...)
|
|
102
|
+
if request.state~="running" then return nil,"probe_not_running" end
|
|
103
|
+
if #request.logs>=MAX_LOG_ENTRIES or request.logBytes>=MAX_LOG_BYTES then request.logsTruncated=true;return nil,"probe_log_limit" end
|
|
104
|
+
local values={n=select("#",...),...}
|
|
105
|
+
local parts={}
|
|
106
|
+
for index=1,values.n do
|
|
107
|
+
local value=values[index]
|
|
108
|
+
if restricted(value) then parts[index]="<secret>"
|
|
109
|
+
elseif type(value)=="string" or type(value)=="number" or type(value)=="boolean" then parts[index]=tostring(value)
|
|
110
|
+
else parts[index]="<unsupported>" end
|
|
111
|
+
end
|
|
112
|
+
local line=table.concat(parts," ")
|
|
113
|
+
local remaining=MAX_LOG_BYTES-request.logBytes
|
|
114
|
+
if #line>remaining then line=line:sub(1,remaining);request.logsTruncated=true end
|
|
115
|
+
request.logs[#request.logs+1]=line;request.logBytes=request.logBytes+#line
|
|
116
|
+
return not request.logsTruncated
|
|
117
|
+
end
|
|
118
|
+
function api.IsCancelled() local active=ns.Session.Current();return request.state~="running" or not active or active.generation~=request.generation end
|
|
119
|
+
return api
|
|
120
|
+
end
|
|
33
121
|
|
|
34
122
|
ns.ProbeRunner = {
|
|
35
123
|
Reported = function(requestId)
|
|
@@ -70,7 +158,7 @@ ns.ProbeRunner = {
|
|
|
70
158
|
if not executable then return nil, "probe_syntax_error" end
|
|
71
159
|
local signal, encodeFailure = loadedSignal(requestId, code, reloadNonce, false)
|
|
72
160
|
if not signal then return nil, encodeFailure end
|
|
73
|
-
requests[requestId] = { code = code, executable = executable, state = "loaded", reloadNonce = reloadNonce }
|
|
161
|
+
requests[requestId] = { requestId=requestId,code = code, executable = executable, state = "loaded", reloadNonce = reloadNonce }
|
|
74
162
|
count, bytes = count + 1, bytes + #code
|
|
75
163
|
return signal
|
|
76
164
|
end,
|
|
@@ -100,29 +188,20 @@ ns.ProbeRunner = {
|
|
|
100
188
|
request.state = "running"
|
|
101
189
|
local executable = request.executable
|
|
102
190
|
request.executable = nil
|
|
103
|
-
|
|
191
|
+
request.generation=session.generation
|
|
192
|
+
request.logs,request.logBytes,request.cleanups={},0,{}
|
|
193
|
+
local ok, result = pcall(executable,probeAPI(request))
|
|
104
194
|
local active = ns.Session.Current()
|
|
105
195
|
if not active or active.generation ~= session.generation then
|
|
106
|
-
request.state = "unresolved"
|
|
196
|
+
request.state = "unresolved";cleanup(request)
|
|
107
197
|
return nil, "probe_session_changed"
|
|
108
198
|
end
|
|
109
|
-
|
|
110
|
-
if
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
local message = "probe_runtime_error"
|
|
115
|
-
if not restricted(result) and type(result) == "string" and #result <= 4096 then message = result end
|
|
116
|
-
body = { probeStatus = "failed", error = message }
|
|
117
|
-
end
|
|
118
|
-
local report, reportFailure = ns.ReportStore.Commit(requestId, request.code, body)
|
|
119
|
-
request.state = report and "reported" or "unresolved"
|
|
120
|
-
request.report = report
|
|
121
|
-
if report then
|
|
122
|
-
local _, storedBody = ns.ReportStore.Read(requestId)
|
|
123
|
-
request.reportBody = storedBody
|
|
199
|
+
if not ok then return complete(request,"failed",result,false) end
|
|
200
|
+
if request.async then
|
|
201
|
+
if request.state=="reported" then return request.report end
|
|
202
|
+
if request.state~="running" then return nil,"probe_async_unresolved" end
|
|
203
|
+
return loadedSignal(requestId,request.code,request.reloadNonce,false)
|
|
124
204
|
end
|
|
125
|
-
|
|
126
|
-
return report, reportFailure
|
|
205
|
+
return complete(request,"completed",result,false)
|
|
127
206
|
end,
|
|
128
207
|
}
|