lycheedev 1.0.0 → 1.0.1
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/bin/lycheedev.js +21 -6
- package/package.json +1 -1
- package/vendor/addon/Core/Bootstrap.lua +131 -131
- package/vendor/addon/Core/Clients/Mainline.lua +9 -9
- package/vendor/addon/Core/Clients/Mists.lua +9 -9
- package/vendor/addon/Core/Clients/Titan.lua +9 -9
- package/vendor/addon/Core/Compatibility.lua +43 -43
- package/vendor/addon/Core/Database.lua +859 -859
- package/vendor/addon/Core/Inspector.lua +647 -647
- package/vendor/addon/Core/Locale.lua +307 -307
- package/vendor/addon/Core/Locale_enUS.lua +318 -318
- package/vendor/addon/Core/Safety.lua +42 -42
- package/vendor/addon/Core/Serializer.lua +324 -324
- package/vendor/addon/Libs/AutomationQR.lua +1176 -1176
- package/vendor/addon/Lychee Dev_Mainline.toc +43 -43
- package/vendor/addon/Lychee Dev_Mists.toc +43 -43
- package/vendor/addon/Lychee Dev_Wrath.toc +43 -43
- package/vendor/addon/Modules/Automation/Controller.lua +757 -757
- package/vendor/addon/Modules/Automation/Report.lua +409 -409
- package/vendor/addon/Modules/Automation/auto/auto.lua +12 -12
- package/vendor/addon/Modules/Diagnostics.lua +238 -238
- package/vendor/addon/Modules/Events/Catalog.lua +184 -184
- package/vendor/addon/Modules/Events/CatalogData_Mainline.lua +1788 -1788
- package/vendor/addon/Modules/Events/CatalogData_Mists.lua +1489 -1489
- package/vendor/addon/Modules/Events/CatalogData_Titan.lua +1492 -1492
- package/vendor/addon/Modules/Events/Monitor.lua +181 -181
- package/vendor/addon/Modules/FunctionTrace.lua +85 -85
- package/vendor/addon/Modules/ObjectInspector.lua +329 -329
- package/vendor/addon/UI/AutomationOverlay.lua +183 -183
- package/vendor/addon/UI/Export.lua +140 -140
- package/vendor/addon/UI/Features.lua +890 -890
- package/vendor/addon/UI/MainWindow.lua +1145 -1145
- package/vendor/addon/UI/Pages/About.lua +223 -223
- package/vendor/addon/UI/Pages/Automation.lua +417 -417
- package/vendor/addon/UI/Pages/Diagnostics.lua +289 -289
- package/vendor/addon/UI/Pages/ExportRecords.lua +387 -387
- package/vendor/addon/UI/Pages/Object.lua +573 -573
- package/vendor/addon/UI/Pages/Trace.lua +165 -165
- package/vendor/skill/SKILL.md +94 -94
- package/vendor/skill/agents/openai.yaml +4 -4
- package/vendor/skill/references/automation.md +327 -327
- package/vendor/skill/references/runtime-investigations.md +97 -97
- package/vendor/skill/scripts/automation/__init__.py +1 -1
- package/vendor/skill/scripts/automation/registry.py +516 -516
- package/vendor/skill/scripts/automation/saved_variables.py +438 -438
- package/vendor/skill/scripts/automation/session.py +207 -207
- package/vendor/skill/scripts/automation/windows.py +573 -573
- package/vendor/skill/scripts/automation.py +865 -865
- package/vendor/skill/scripts/requirements.txt +13 -13
- package/vendor/skill/scripts/selftest_offline.py +981 -981
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
-- Automation task registry. This file contains generated data only; loading it
|
|
4
|
-
-- must never execute task source. Task blocks are written between the
|
|
5
|
-
-- BEGIN/END markers by the Lychee Dev skill tooling and are removed before
|
|
6
|
-
-- release packaging ships an empty registry.
|
|
7
|
-
|
|
8
|
-
ns.AutomationTaskDefinitions = ns.AutomationTaskDefinitions or {}
|
|
9
|
-
|
|
10
|
-
-- Task blocks use exactly this marker shape (task id may not contain the
|
|
11
|
-
-- marker text): "-- BEGIN LYCHEE DEV TASK <task-id>" ... "-- END LYCHEE DEV TASK <task-id>".
|
|
12
|
-
-- The skill tooling inserts and replaces them; releases ship this file empty.
|
|
1
|
+
local ADDON_NAME, ns = ...
|
|
2
|
+
|
|
3
|
+
-- Automation task registry. This file contains generated data only; loading it
|
|
4
|
+
-- must never execute task source. Task blocks are written between the
|
|
5
|
+
-- BEGIN/END markers by the Lychee Dev skill tooling and are removed before
|
|
6
|
+
-- release packaging ships an empty registry.
|
|
7
|
+
|
|
8
|
+
ns.AutomationTaskDefinitions = ns.AutomationTaskDefinitions or {}
|
|
9
|
+
|
|
10
|
+
-- Task blocks use exactly this marker shape (task id may not contain the
|
|
11
|
+
-- marker text): "-- BEGIN LYCHEE DEV TASK <task-id>" ... "-- END LYCHEE DEV TASK <task-id>".
|
|
12
|
+
-- The skill tooling inserts and replaces them; releases ship this file empty.
|
|
@@ -1,238 +1,238 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
local diagnostics = {}
|
|
4
|
-
local MAX_REPORT_BYTES = 48000
|
|
5
|
-
local SNAPSHOT_MAX_ERRORS = 100
|
|
6
|
-
local SNAPSHOT_TEXT_FIELDS = { "message", "stack", "locals", "source" }
|
|
7
|
-
|
|
8
|
-
-- Stable machine codes for snapshot failures; the caller reports them as data.
|
|
9
|
-
local SNAPSHOT_ERROR_COMBAT = "combat_blocked"
|
|
10
|
-
local SNAPSHOT_ERROR_COUNT = "invalid_count"
|
|
11
|
-
local SNAPSHOT_ERROR_PROVIDER = "provider_unavailable"
|
|
12
|
-
local SNAPSHOT_ERROR_PROVIDER_CALL = "provider_error"
|
|
13
|
-
|
|
14
|
-
local function IsSecret(value)
|
|
15
|
-
return issecretvalue and issecretvalue(value)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
local function SafeText(value)
|
|
19
|
-
if value == nil then return "" end
|
|
20
|
-
if IsSecret(value) then return "<secret>" end
|
|
21
|
-
local text = type(value) == "string" and value or tostring(value)
|
|
22
|
-
if #text > MAX_REPORT_BYTES then
|
|
23
|
-
return text:sub(1, MAX_REPORT_BYTES) .. "\n... <truncated>"
|
|
24
|
-
end
|
|
25
|
-
return text
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
local function GetGrabber()
|
|
29
|
-
local grabber = _G.BugGrabber
|
|
30
|
-
if type(grabber) ~= "table" or type(grabber.GetDB) ~= "function" then
|
|
31
|
-
return nil
|
|
32
|
-
end
|
|
33
|
-
return grabber
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
local function GetSessionId(grabber)
|
|
37
|
-
if type(grabber.GetSessionId) ~= "function" then return -1 end
|
|
38
|
-
local succeeded, session = pcall(grabber.GetSessionId, grabber)
|
|
39
|
-
if not succeeded or IsSecret(session) then return -1 end
|
|
40
|
-
return tonumber(session) or -1
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
local function MatchesQuery(entry, query)
|
|
44
|
-
if query == "" then return true end
|
|
45
|
-
local searchable = table.concat({
|
|
46
|
-
SafeText(entry.message),
|
|
47
|
-
SafeText(entry.stack),
|
|
48
|
-
SafeText(entry.source),
|
|
49
|
-
}, "\n"):lower()
|
|
50
|
-
return searchable:find(query, 1, true) ~= nil
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
local function CollectErrors(scope, query)
|
|
54
|
-
local grabber = GetGrabber()
|
|
55
|
-
if not grabber then return {}, -1, false end
|
|
56
|
-
local succeeded, database = pcall(grabber.GetDB, grabber)
|
|
57
|
-
if not succeeded or type(database) ~= "table" then return {}, -1, false end
|
|
58
|
-
|
|
59
|
-
local session = GetSessionId(grabber)
|
|
60
|
-
query = SafeText(query):match("^%s*(.-)%s*$"):lower()
|
|
61
|
-
local errors = {}
|
|
62
|
-
for index = #database, 1, -1 do
|
|
63
|
-
local entry = database[index]
|
|
64
|
-
if type(entry) == "table"
|
|
65
|
-
and (scope == "all" or tonumber(entry.session) == session)
|
|
66
|
-
and MatchesQuery(entry, query) then
|
|
67
|
-
errors[#errors + 1] = entry
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
return errors, session, true
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
local function DetectSource(entry)
|
|
74
|
-
local source = SafeText(entry.source)
|
|
75
|
-
if source ~= "" then return source end
|
|
76
|
-
local combined = (SafeText(entry.message) .. "\n" .. SafeText(entry.stack)):gsub("\\", "/")
|
|
77
|
-
return combined:match("[Aa]dd[Oo]ns/([^/%s]+)") or ns.L.UNKNOWN_SOURCE
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
function diagnostics.GetErrors(scope, query)
|
|
81
|
-
if ns.IsCombatBlocked() then return false, nil, ns.L.COMBAT_BLOCKED end
|
|
82
|
-
local errors, session, available = CollectErrors(scope, query)
|
|
83
|
-
if not available then return false, nil, ns.L.BUGGRABBER_UNAVAILABLE end
|
|
84
|
-
return true, { errors = errors, session = session }
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
function diagnostics.FormatAgentReport(entry)
|
|
88
|
-
if type(entry) ~= "table" then return ns.L.SELECT_ERROR_DETAIL end
|
|
89
|
-
local version, build, buildDate = GetBuildInfo()
|
|
90
|
-
local timestamp = tonumber(entry.time) and date("%Y-%m-%d %H:%M:%S", entry.time) or ns.L.UNKNOWN_TIME
|
|
91
|
-
local sections = {
|
|
92
|
-
ns.L.AGENT_REPORT_TITLE,
|
|
93
|
-
"",
|
|
94
|
-
ns.L.REPORT_CONTEXT,
|
|
95
|
-
string.format(ns.L.REPORT_TIME, timestamp),
|
|
96
|
-
string.format(ns.L.REPORT_SOURCE, DetectSource(entry)),
|
|
97
|
-
string.format(ns.L.REPORT_COUNT, tonumber(entry.counter) or 1),
|
|
98
|
-
string.format(ns.L.REPORT_SESSION, tonumber(entry.session) or -1),
|
|
99
|
-
"",
|
|
100
|
-
ns.L.REPORT_ENVIRONMENT,
|
|
101
|
-
string.format(ns.L.REPORT_CLIENT, SafeText(version)),
|
|
102
|
-
string.format(ns.L.REPORT_BUILD, SafeText(build), SafeText(buildDate)),
|
|
103
|
-
string.format(ns.L.REPORT_LOCALE, SafeText(GetLocale())),
|
|
104
|
-
"",
|
|
105
|
-
ns.L.REPORT_ERROR,
|
|
106
|
-
SafeText(entry.message),
|
|
107
|
-
"",
|
|
108
|
-
ns.L.REPORT_STACK,
|
|
109
|
-
SafeText(entry.stack) ~= "" and SafeText(entry.stack) or ns.L.REPORT_NOT_AVAILABLE,
|
|
110
|
-
}
|
|
111
|
-
local locals = SafeText(entry.locals)
|
|
112
|
-
if locals ~= "" then
|
|
113
|
-
sections[#sections + 1] = ""
|
|
114
|
-
sections[#sections + 1] = ns.L.REPORT_LOCALS
|
|
115
|
-
sections[#sections + 1] = locals
|
|
116
|
-
end
|
|
117
|
-
return table.concat(sections, "\n")
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
function diagnostics.FormatError(entry)
|
|
121
|
-
return diagnostics.FormatAgentReport(entry)
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
function diagnostics.ResetErrors()
|
|
125
|
-
if ns.IsCombatBlocked() then return false, ns.L.COMBAT_BLOCKED end
|
|
126
|
-
local grabber = GetGrabber()
|
|
127
|
-
if not grabber or type(grabber.Reset) ~= "function" then
|
|
128
|
-
return false, ns.L.BUGGRABBER_UNAVAILABLE
|
|
129
|
-
end
|
|
130
|
-
local succeeded = pcall(grabber.Reset, grabber)
|
|
131
|
-
return succeeded, succeeded and ns.L.ERRORS_CLEARED or ns.L.ERRORS_CLEAR_FAILED
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
local function GetProviderVersion(grabber)
|
|
135
|
-
if type(grabber.version) == "string" and grabber.version ~= "" then
|
|
136
|
-
return grabber.version
|
|
137
|
-
end
|
|
138
|
-
local metadata = ns.Client and ns.Client.GetAddOnMetadata
|
|
139
|
-
if type(metadata) == "function" then
|
|
140
|
-
local succeeded, version = pcall(metadata, "!BugGrabber", "Version")
|
|
141
|
-
if succeeded and type(version) == "string" and not IsSecret(version) then
|
|
142
|
-
return version
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
return nil
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
-- Copy one error entry immediately so later BugGrabber updates cannot change it.
|
|
149
|
-
local function CopyErrorEntry(entry)
|
|
150
|
-
local missing = {}
|
|
151
|
-
local copy = {}
|
|
152
|
-
for index = 1, #SNAPSHOT_TEXT_FIELDS do
|
|
153
|
-
local field = SNAPSHOT_TEXT_FIELDS[index]
|
|
154
|
-
local value = entry[field]
|
|
155
|
-
if value == nil then
|
|
156
|
-
-- source is optional; message/stack/locals are reported missing when absent.
|
|
157
|
-
if field ~= "source" then
|
|
158
|
-
missing[#missing + 1] = field
|
|
159
|
-
end
|
|
160
|
-
elseif IsSecret(value) then
|
|
161
|
-
missing[#missing + 1] = field
|
|
162
|
-
elseif type(value) ~= "string" then
|
|
163
|
-
-- Never substitute tostring(table) for real content.
|
|
164
|
-
missing[#missing + 1] = field
|
|
165
|
-
else
|
|
166
|
-
copy[field] = value
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
local timeValue = tonumber(entry.time)
|
|
170
|
-
local sessionValue = tonumber(entry.session)
|
|
171
|
-
local counterValue = tonumber(entry.counter)
|
|
172
|
-
if not timeValue or IsSecret(entry.time) then missing[#missing + 1] = "time" end
|
|
173
|
-
if not sessionValue or IsSecret(entry.session) then missing[#missing + 1] = "session" end
|
|
174
|
-
if not counterValue or IsSecret(entry.counter) then missing[#missing + 1] = "counter" end
|
|
175
|
-
copy.time = timeValue
|
|
176
|
-
copy.session = sessionValue
|
|
177
|
-
copy.counter = counterValue
|
|
178
|
-
copy.missingFields = missing
|
|
179
|
-
return copy
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
-- Machine snapshot for automation exports; never calls FormatAgentReport and
|
|
183
|
-
-- never truncates fields silently. Returns nil plus a stable error code on failure.
|
|
184
|
-
function diagnostics.SnapshotRecentErrors(count, scope)
|
|
185
|
-
if ns.IsCombatBlocked() then
|
|
186
|
-
return nil, SNAPSHOT_ERROR_COMBAT
|
|
187
|
-
end
|
|
188
|
-
if type(count) ~= "number" or count ~= math.floor(count)
|
|
189
|
-
or count < 1 or count > SNAPSHOT_MAX_ERRORS then
|
|
190
|
-
return nil, SNAPSHOT_ERROR_COUNT
|
|
191
|
-
end
|
|
192
|
-
local grabber = GetGrabber()
|
|
193
|
-
if not grabber then
|
|
194
|
-
return nil, SNAPSHOT_ERROR_PROVIDER
|
|
195
|
-
end
|
|
196
|
-
local succeeded, database = pcall(grabber.GetDB, grabber)
|
|
197
|
-
if not succeeded or type(database) ~= "table" then
|
|
198
|
-
return nil, SNAPSHOT_ERROR_PROVIDER_CALL
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
local session = GetSessionId(grabber)
|
|
202
|
-
local allSessions = scope ~= "current_session"
|
|
203
|
-
local availableCount = 0
|
|
204
|
-
local errors = {}
|
|
205
|
-
local incompleteReasons = {}
|
|
206
|
-
for index = #database, 1, -1 do
|
|
207
|
-
local entry = database[index]
|
|
208
|
-
if type(entry) == "table" then
|
|
209
|
-
if allSessions or tonumber(entry.session) == session then
|
|
210
|
-
availableCount = availableCount + 1
|
|
211
|
-
if #errors < count then
|
|
212
|
-
local copy = CopyErrorEntry(entry)
|
|
213
|
-
errors[#errors + 1] = copy
|
|
214
|
-
for fieldIndex = 1, #copy.missingFields do
|
|
215
|
-
incompleteReasons[#incompleteReasons + 1]
|
|
216
|
-
= "error[" .. #errors .. "]." .. copy.missingFields[fieldIndex]
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
return {
|
|
224
|
-
scope = allSessions and "provider_storage" or "current_session",
|
|
225
|
-
requestedCount = count,
|
|
226
|
-
returnedCount = #errors,
|
|
227
|
-
availableCount = availableCount,
|
|
228
|
-
ordering = "provider_storage_reverse",
|
|
229
|
-
session = session,
|
|
230
|
-
providerVersion = GetProviderVersion(grabber),
|
|
231
|
-
capturedAt = time(),
|
|
232
|
-
complete = #incompleteReasons == 0,
|
|
233
|
-
incompleteReasons = incompleteReasons,
|
|
234
|
-
errors = errors,
|
|
235
|
-
}, nil
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
ns.Diagnostics = diagnostics
|
|
1
|
+
local ADDON_NAME, ns = ...
|
|
2
|
+
|
|
3
|
+
local diagnostics = {}
|
|
4
|
+
local MAX_REPORT_BYTES = 48000
|
|
5
|
+
local SNAPSHOT_MAX_ERRORS = 100
|
|
6
|
+
local SNAPSHOT_TEXT_FIELDS = { "message", "stack", "locals", "source" }
|
|
7
|
+
|
|
8
|
+
-- Stable machine codes for snapshot failures; the caller reports them as data.
|
|
9
|
+
local SNAPSHOT_ERROR_COMBAT = "combat_blocked"
|
|
10
|
+
local SNAPSHOT_ERROR_COUNT = "invalid_count"
|
|
11
|
+
local SNAPSHOT_ERROR_PROVIDER = "provider_unavailable"
|
|
12
|
+
local SNAPSHOT_ERROR_PROVIDER_CALL = "provider_error"
|
|
13
|
+
|
|
14
|
+
local function IsSecret(value)
|
|
15
|
+
return issecretvalue and issecretvalue(value)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
local function SafeText(value)
|
|
19
|
+
if value == nil then return "" end
|
|
20
|
+
if IsSecret(value) then return "<secret>" end
|
|
21
|
+
local text = type(value) == "string" and value or tostring(value)
|
|
22
|
+
if #text > MAX_REPORT_BYTES then
|
|
23
|
+
return text:sub(1, MAX_REPORT_BYTES) .. "\n... <truncated>"
|
|
24
|
+
end
|
|
25
|
+
return text
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
local function GetGrabber()
|
|
29
|
+
local grabber = _G.BugGrabber
|
|
30
|
+
if type(grabber) ~= "table" or type(grabber.GetDB) ~= "function" then
|
|
31
|
+
return nil
|
|
32
|
+
end
|
|
33
|
+
return grabber
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
local function GetSessionId(grabber)
|
|
37
|
+
if type(grabber.GetSessionId) ~= "function" then return -1 end
|
|
38
|
+
local succeeded, session = pcall(grabber.GetSessionId, grabber)
|
|
39
|
+
if not succeeded or IsSecret(session) then return -1 end
|
|
40
|
+
return tonumber(session) or -1
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
local function MatchesQuery(entry, query)
|
|
44
|
+
if query == "" then return true end
|
|
45
|
+
local searchable = table.concat({
|
|
46
|
+
SafeText(entry.message),
|
|
47
|
+
SafeText(entry.stack),
|
|
48
|
+
SafeText(entry.source),
|
|
49
|
+
}, "\n"):lower()
|
|
50
|
+
return searchable:find(query, 1, true) ~= nil
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
local function CollectErrors(scope, query)
|
|
54
|
+
local grabber = GetGrabber()
|
|
55
|
+
if not grabber then return {}, -1, false end
|
|
56
|
+
local succeeded, database = pcall(grabber.GetDB, grabber)
|
|
57
|
+
if not succeeded or type(database) ~= "table" then return {}, -1, false end
|
|
58
|
+
|
|
59
|
+
local session = GetSessionId(grabber)
|
|
60
|
+
query = SafeText(query):match("^%s*(.-)%s*$"):lower()
|
|
61
|
+
local errors = {}
|
|
62
|
+
for index = #database, 1, -1 do
|
|
63
|
+
local entry = database[index]
|
|
64
|
+
if type(entry) == "table"
|
|
65
|
+
and (scope == "all" or tonumber(entry.session) == session)
|
|
66
|
+
and MatchesQuery(entry, query) then
|
|
67
|
+
errors[#errors + 1] = entry
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
return errors, session, true
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
local function DetectSource(entry)
|
|
74
|
+
local source = SafeText(entry.source)
|
|
75
|
+
if source ~= "" then return source end
|
|
76
|
+
local combined = (SafeText(entry.message) .. "\n" .. SafeText(entry.stack)):gsub("\\", "/")
|
|
77
|
+
return combined:match("[Aa]dd[Oo]ns/([^/%s]+)") or ns.L.UNKNOWN_SOURCE
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
function diagnostics.GetErrors(scope, query)
|
|
81
|
+
if ns.IsCombatBlocked() then return false, nil, ns.L.COMBAT_BLOCKED end
|
|
82
|
+
local errors, session, available = CollectErrors(scope, query)
|
|
83
|
+
if not available then return false, nil, ns.L.BUGGRABBER_UNAVAILABLE end
|
|
84
|
+
return true, { errors = errors, session = session }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
function diagnostics.FormatAgentReport(entry)
|
|
88
|
+
if type(entry) ~= "table" then return ns.L.SELECT_ERROR_DETAIL end
|
|
89
|
+
local version, build, buildDate = GetBuildInfo()
|
|
90
|
+
local timestamp = tonumber(entry.time) and date("%Y-%m-%d %H:%M:%S", entry.time) or ns.L.UNKNOWN_TIME
|
|
91
|
+
local sections = {
|
|
92
|
+
ns.L.AGENT_REPORT_TITLE,
|
|
93
|
+
"",
|
|
94
|
+
ns.L.REPORT_CONTEXT,
|
|
95
|
+
string.format(ns.L.REPORT_TIME, timestamp),
|
|
96
|
+
string.format(ns.L.REPORT_SOURCE, DetectSource(entry)),
|
|
97
|
+
string.format(ns.L.REPORT_COUNT, tonumber(entry.counter) or 1),
|
|
98
|
+
string.format(ns.L.REPORT_SESSION, tonumber(entry.session) or -1),
|
|
99
|
+
"",
|
|
100
|
+
ns.L.REPORT_ENVIRONMENT,
|
|
101
|
+
string.format(ns.L.REPORT_CLIENT, SafeText(version)),
|
|
102
|
+
string.format(ns.L.REPORT_BUILD, SafeText(build), SafeText(buildDate)),
|
|
103
|
+
string.format(ns.L.REPORT_LOCALE, SafeText(GetLocale())),
|
|
104
|
+
"",
|
|
105
|
+
ns.L.REPORT_ERROR,
|
|
106
|
+
SafeText(entry.message),
|
|
107
|
+
"",
|
|
108
|
+
ns.L.REPORT_STACK,
|
|
109
|
+
SafeText(entry.stack) ~= "" and SafeText(entry.stack) or ns.L.REPORT_NOT_AVAILABLE,
|
|
110
|
+
}
|
|
111
|
+
local locals = SafeText(entry.locals)
|
|
112
|
+
if locals ~= "" then
|
|
113
|
+
sections[#sections + 1] = ""
|
|
114
|
+
sections[#sections + 1] = ns.L.REPORT_LOCALS
|
|
115
|
+
sections[#sections + 1] = locals
|
|
116
|
+
end
|
|
117
|
+
return table.concat(sections, "\n")
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
function diagnostics.FormatError(entry)
|
|
121
|
+
return diagnostics.FormatAgentReport(entry)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
function diagnostics.ResetErrors()
|
|
125
|
+
if ns.IsCombatBlocked() then return false, ns.L.COMBAT_BLOCKED end
|
|
126
|
+
local grabber = GetGrabber()
|
|
127
|
+
if not grabber or type(grabber.Reset) ~= "function" then
|
|
128
|
+
return false, ns.L.BUGGRABBER_UNAVAILABLE
|
|
129
|
+
end
|
|
130
|
+
local succeeded = pcall(grabber.Reset, grabber)
|
|
131
|
+
return succeeded, succeeded and ns.L.ERRORS_CLEARED or ns.L.ERRORS_CLEAR_FAILED
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
local function GetProviderVersion(grabber)
|
|
135
|
+
if type(grabber.version) == "string" and grabber.version ~= "" then
|
|
136
|
+
return grabber.version
|
|
137
|
+
end
|
|
138
|
+
local metadata = ns.Client and ns.Client.GetAddOnMetadata
|
|
139
|
+
if type(metadata) == "function" then
|
|
140
|
+
local succeeded, version = pcall(metadata, "!BugGrabber", "Version")
|
|
141
|
+
if succeeded and type(version) == "string" and not IsSecret(version) then
|
|
142
|
+
return version
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
return nil
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
-- Copy one error entry immediately so later BugGrabber updates cannot change it.
|
|
149
|
+
local function CopyErrorEntry(entry)
|
|
150
|
+
local missing = {}
|
|
151
|
+
local copy = {}
|
|
152
|
+
for index = 1, #SNAPSHOT_TEXT_FIELDS do
|
|
153
|
+
local field = SNAPSHOT_TEXT_FIELDS[index]
|
|
154
|
+
local value = entry[field]
|
|
155
|
+
if value == nil then
|
|
156
|
+
-- source is optional; message/stack/locals are reported missing when absent.
|
|
157
|
+
if field ~= "source" then
|
|
158
|
+
missing[#missing + 1] = field
|
|
159
|
+
end
|
|
160
|
+
elseif IsSecret(value) then
|
|
161
|
+
missing[#missing + 1] = field
|
|
162
|
+
elseif type(value) ~= "string" then
|
|
163
|
+
-- Never substitute tostring(table) for real content.
|
|
164
|
+
missing[#missing + 1] = field
|
|
165
|
+
else
|
|
166
|
+
copy[field] = value
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
local timeValue = tonumber(entry.time)
|
|
170
|
+
local sessionValue = tonumber(entry.session)
|
|
171
|
+
local counterValue = tonumber(entry.counter)
|
|
172
|
+
if not timeValue or IsSecret(entry.time) then missing[#missing + 1] = "time" end
|
|
173
|
+
if not sessionValue or IsSecret(entry.session) then missing[#missing + 1] = "session" end
|
|
174
|
+
if not counterValue or IsSecret(entry.counter) then missing[#missing + 1] = "counter" end
|
|
175
|
+
copy.time = timeValue
|
|
176
|
+
copy.session = sessionValue
|
|
177
|
+
copy.counter = counterValue
|
|
178
|
+
copy.missingFields = missing
|
|
179
|
+
return copy
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
-- Machine snapshot for automation exports; never calls FormatAgentReport and
|
|
183
|
+
-- never truncates fields silently. Returns nil plus a stable error code on failure.
|
|
184
|
+
function diagnostics.SnapshotRecentErrors(count, scope)
|
|
185
|
+
if ns.IsCombatBlocked() then
|
|
186
|
+
return nil, SNAPSHOT_ERROR_COMBAT
|
|
187
|
+
end
|
|
188
|
+
if type(count) ~= "number" or count ~= math.floor(count)
|
|
189
|
+
or count < 1 or count > SNAPSHOT_MAX_ERRORS then
|
|
190
|
+
return nil, SNAPSHOT_ERROR_COUNT
|
|
191
|
+
end
|
|
192
|
+
local grabber = GetGrabber()
|
|
193
|
+
if not grabber then
|
|
194
|
+
return nil, SNAPSHOT_ERROR_PROVIDER
|
|
195
|
+
end
|
|
196
|
+
local succeeded, database = pcall(grabber.GetDB, grabber)
|
|
197
|
+
if not succeeded or type(database) ~= "table" then
|
|
198
|
+
return nil, SNAPSHOT_ERROR_PROVIDER_CALL
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
local session = GetSessionId(grabber)
|
|
202
|
+
local allSessions = scope ~= "current_session"
|
|
203
|
+
local availableCount = 0
|
|
204
|
+
local errors = {}
|
|
205
|
+
local incompleteReasons = {}
|
|
206
|
+
for index = #database, 1, -1 do
|
|
207
|
+
local entry = database[index]
|
|
208
|
+
if type(entry) == "table" then
|
|
209
|
+
if allSessions or tonumber(entry.session) == session then
|
|
210
|
+
availableCount = availableCount + 1
|
|
211
|
+
if #errors < count then
|
|
212
|
+
local copy = CopyErrorEntry(entry)
|
|
213
|
+
errors[#errors + 1] = copy
|
|
214
|
+
for fieldIndex = 1, #copy.missingFields do
|
|
215
|
+
incompleteReasons[#incompleteReasons + 1]
|
|
216
|
+
= "error[" .. #errors .. "]." .. copy.missingFields[fieldIndex]
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
scope = allSessions and "provider_storage" or "current_session",
|
|
225
|
+
requestedCount = count,
|
|
226
|
+
returnedCount = #errors,
|
|
227
|
+
availableCount = availableCount,
|
|
228
|
+
ordering = "provider_storage_reverse",
|
|
229
|
+
session = session,
|
|
230
|
+
providerVersion = GetProviderVersion(grabber),
|
|
231
|
+
capturedAt = time(),
|
|
232
|
+
complete = #incompleteReasons == 0,
|
|
233
|
+
incompleteReasons = incompleteReasons,
|
|
234
|
+
errors = errors,
|
|
235
|
+
}, nil
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
ns.Diagnostics = diagnostics
|