lycheedev 1.1.1 → 2.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.
- package/LICENSE +49 -0
- package/README.md +45 -0
- package/THIRD_PARTY_NOTICES +812 -0
- package/bin/lycheedev.mjs +56 -0
- package/native/windows-amd64/lycheedev.exe +0 -0
- package/package.json +12 -33
- package/payload/addon/Bridge/CaptureWriter.lua +154 -0
- package/payload/addon/Bridge/Definitions.lua +3 -0
- package/payload/addon/Bridge/Identity.lua +127 -0
- package/{vendor/addon/Libs/AutomationQR.lua → payload/addon/Bridge/MatrixSymbol.lua} +23 -30
- package/payload/addon/Bridge/ProbeQueue.lua +136 -0
- package/payload/addon/Bridge/ProbeRunner.lua +128 -0
- package/payload/addon/Bridge/ReceiptView.lua +160 -0
- package/payload/addon/Bridge/Reentry.lua +192 -0
- package/payload/addon/Bridge/ReportStore.lua +153 -0
- package/payload/addon/Bridge/Session.lua +163 -0
- package/payload/addon/Clients/Evergreen.lua +2 -0
- package/payload/addon/Clients/Live.lua +2 -0
- package/payload/addon/Clients/Pandaria.lua +2 -0
- package/payload/addon/Clients/Titan.lua +2 -0
- package/payload/addon/Core/Compat.lua +59 -0
- package/payload/addon/Core/Controls.lua +168 -0
- package/{vendor/addon/Core/Bootstrap.lua → payload/addon/Core/Execute.lua} +12 -23
- package/{vendor → payload}/addon/Core/Inspector.lua +19 -235
- package/{vendor → payload}/addon/Core/Locale.lua +129 -94
- package/{vendor → payload}/addon/Core/Locale_enUS.lua +129 -96
- package/payload/addon/Core/Persistence.lua +58 -0
- package/payload/addon/Core/Platform.lua +58 -0
- package/payload/addon/Core/Runtime.lua +25 -0
- package/payload/addon/Core/Safety.lua +56 -0
- package/{vendor → payload}/addon/Core/Serializer.lua +18 -6
- package/payload/addon/Core/Stores.lua +611 -0
- package/payload/addon/Lychee Dev_Forever.toc +52 -0
- package/payload/addon/Lychee Dev_Mainline.toc +52 -0
- package/payload/addon/Lychee Dev_Mists.toc +52 -0
- package/payload/addon/Lychee Dev_Wrath.toc +52 -0
- package/payload/addon/Modules/AutomationView.lua +393 -0
- package/{vendor → payload}/addon/Modules/Diagnostics.lua +92 -36
- package/{vendor → payload}/addon/Modules/Events/Catalog.lua +9 -0
- package/{vendor → payload}/addon/Modules/Events/Monitor.lua +45 -5
- package/payload/addon/Modules/FunctionTrace.lua +150 -0
- package/{vendor → payload}/addon/Modules/ObjectInspector.lua +105 -31
- package/{vendor → payload}/addon/UI/Export.lua +64 -34
- package/{vendor → payload}/addon/UI/Pages/About.lua +26 -14
- package/payload/addon/UI/Pages/Automation.lua +446 -0
- package/payload/addon/UI/Pages/Diagnostics.lua +402 -0
- package/{vendor/addon/UI/Features.lua → payload/addon/UI/Pages/Events.lua} +192 -302
- package/{vendor → payload}/addon/UI/Pages/ExportRecords.lua +213 -132
- package/{vendor → payload}/addon/UI/Pages/Object.lua +229 -121
- package/payload/addon/UI/Pages/Run.lua +423 -0
- package/payload/addon/UI/Pages/Trace.lua +314 -0
- package/payload/addon/UI/TreeView.lua +246 -0
- package/{vendor/addon/UI/MainWindow.lua → payload/addon/UI/Widgets.lua} +89 -529
- package/payload/addon/UI/Window.lua +425 -0
- package/payload/skill/SKILL.md +87 -0
- package/payload/skill/agents/openai.yaml +7 -0
- package/payload/skill/references/addon-validation.md +42 -0
- package/payload/skill/references/asset-export.md +109 -0
- package/payload/skill/references/commands.md +169 -0
- package/payload/skill/references/data-investigation.md +242 -0
- package/payload/skill/references/error-diagnosis.md +41 -0
- package/payload/skill/references/installation.md +18 -0
- package/payload/skill/references/live-investigation.md +129 -0
- package/payload/skill/references/source-research.md +82 -0
- package/payload/skill/scripts/lycheedev.mjs +59 -0
- package/release.json +346 -0
- package/bin/lycheedev.js +0 -742
- package/src/addon.js +0 -95
- package/src/config.js +0 -68
- package/src/doctor.js +0 -126
- package/src/install.js +0 -145
- package/src/paths.js +0 -93
- package/src/py/instances.py +0 -165
- package/src/python.js +0 -111
- package/src/skill.js +0 -48
- package/src/wow.js +0 -541
- package/vendor/addon/Core/Clients/Forever.lua +0 -9
- package/vendor/addon/Core/Clients/Mainline.lua +0 -9
- package/vendor/addon/Core/Clients/Mists.lua +0 -9
- package/vendor/addon/Core/Clients/Titan.lua +0 -9
- package/vendor/addon/Core/Compatibility.lua +0 -43
- package/vendor/addon/Core/Database.lua +0 -859
- package/vendor/addon/Core/Safety.lua +0 -42
- package/vendor/addon/Lychee Dev_Forever.toc +0 -43
- package/vendor/addon/Lychee Dev_Mainline.toc +0 -43
- package/vendor/addon/Lychee Dev_Mists.toc +0 -43
- package/vendor/addon/Lychee Dev_Wrath.toc +0 -43
- package/vendor/addon/Modules/Automation/Controller.lua +0 -884
- package/vendor/addon/Modules/Automation/Report.lua +0 -409
- package/vendor/addon/Modules/Automation/auto/auto.lua +0 -12
- package/vendor/addon/Modules/FunctionTrace.lua +0 -85
- package/vendor/addon/UI/AutomationOverlay.lua +0 -253
- package/vendor/addon/UI/Pages/Automation.lua +0 -417
- package/vendor/addon/UI/Pages/Diagnostics.lua +0 -289
- package/vendor/addon/UI/Pages/Trace.lua +0 -165
- package/vendor/skill/SKILL.md +0 -42
- package/vendor/skill/agents/openai.yaml +0 -4
- package/vendor/skill/references/automation.md +0 -128
- package/vendor/skill/references/clients.md +0 -51
- package/vendor/skill/references/runtime-investigations.md +0 -104
- package/vendor/skill/scripts/automation/__init__.py +0 -1
- package/vendor/skill/scripts/automation/registry.py +0 -516
- package/vendor/skill/scripts/automation/saved_variables.py +0 -438
- package/vendor/skill/scripts/automation/session.py +0 -207
- package/vendor/skill/scripts/automation/windows.py +0 -792
- package/vendor/skill/scripts/automation.py +0 -1034
- package/vendor/skill/scripts/requirements.txt +0 -13
- package/vendor/skill/scripts/selftest_offline.py +0 -1061
- package/vendor/skill/scripts/test_input_safety.py +0 -132
- /package/{vendor → payload}/addon/Media/GitHub.png +0 -0
- /package/{vendor → payload}/addon/Media/Logo.png +0 -0
- /package/{vendor → payload}/addon/Modules/Events/CatalogData_Forever.lua +0 -0
- /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mainline.lua +0 -0
- /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mists.lua +0 -0
- /package/{vendor → payload}/addon/Modules/Events/CatalogData_Titan.lua +0 -0
|
@@ -1,884 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
local L = ns.L
|
|
3
|
-
|
|
4
|
-
-- Automation controller: command dispatch, task identity, execution context,
|
|
5
|
-
-- terminal state freezing, result commit and completion notice triggering.
|
|
6
|
-
|
|
7
|
-
local Controller = {}
|
|
8
|
-
ns.Automation = Controller
|
|
9
|
-
|
|
10
|
-
local TASK_SCHEMA_VERSION = 1
|
|
11
|
-
local NOTICE_PROTOCOL_VERSION = 1
|
|
12
|
-
local MAX_NOTICE_BYTES = 512
|
|
13
|
-
local MAX_TASK_ID_BYTES = 64
|
|
14
|
-
local MAX_REQUEST_ID_BYTES = 128
|
|
15
|
-
local DEFAULT_OUTPUT_LIMIT = 384 * 1024
|
|
16
|
-
local MAX_OUTPUT_LIMIT = 512 * 1024
|
|
17
|
-
local RESULT_SCHEMA = "lychee.automation.result.v1"
|
|
18
|
-
local BUG_TASK_ID = "bug"
|
|
19
|
-
|
|
20
|
-
local TASK_ID_PATTERN = "^([A-Za-z0-9_%-]+)$"
|
|
21
|
-
local REQUEST_ID_PATTERN = "^([A-Za-z0-9%.%-]+)$"
|
|
22
|
-
local TICKET_PATTERN = "^LYCHEE%-([A-Za-z0-9%-]+)$"
|
|
23
|
-
|
|
24
|
-
-- How many finished results may sit unacknowledged before new requests are
|
|
25
|
-
-- refused. One is enough to guarantee no result is silently overwritten; a
|
|
26
|
-
-- small backlog keeps a missed acknowledgement from blocking the whole session.
|
|
27
|
-
local MAX_UNACKNOWLEDGED_RESULTS = 3
|
|
28
|
-
|
|
29
|
-
local activeContext
|
|
30
|
-
local awaitingNotice
|
|
31
|
-
local identityReceiptNonce
|
|
32
|
-
local unacknowledgedResults = 0
|
|
33
|
-
local executedRequests = {}
|
|
34
|
-
|
|
35
|
-
local Finalize
|
|
36
|
-
|
|
37
|
-
local function Print(message)
|
|
38
|
-
print("|cffd83b4eLychee Dev:|r " .. tostring(message))
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
local function Pack(...)
|
|
42
|
-
return { n = select("#", ...), ... }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
local function IsValidTaskId(taskId)
|
|
46
|
-
return type(taskId) == "string" and #taskId >= 1 and #taskId <= MAX_TASK_ID_BYTES
|
|
47
|
-
and taskId:match(TASK_ID_PATTERN) == taskId
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
local function IsValidRequestId(requestId)
|
|
51
|
-
return type(requestId) == "string" and #requestId >= 1 and #requestId <= MAX_REQUEST_ID_BYTES
|
|
52
|
-
and requestId:match(REQUEST_ID_PATTERN) == requestId
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
local function IsValidTicket(ticket)
|
|
56
|
-
return type(ticket) == "string" and ticket:match(TICKET_PATTERN) ~= nil
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
local function GenerateLocalExecutionId()
|
|
60
|
-
local sequence = ns.NextAutomationLocalRequestId() or 0
|
|
61
|
-
return string.format("bug-%s-%04d", date("%Y%m%d-%H%M%S"), sequence)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
local function EnsureReady()
|
|
65
|
-
if ns.IsCombatBlocked() then
|
|
66
|
-
ns.PrintCombatBlocked()
|
|
67
|
-
return false
|
|
68
|
-
end
|
|
69
|
-
ns.InitializeDatabase()
|
|
70
|
-
return true
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
local function ValidateTaskDefinition(taskId, definition)
|
|
74
|
-
if type(definition) ~= "table" then
|
|
75
|
-
return false, "not_table"
|
|
76
|
-
end
|
|
77
|
-
if definition.schema ~= TASK_SCHEMA_VERSION then
|
|
78
|
-
return false, "schema"
|
|
79
|
-
end
|
|
80
|
-
if definition.kind ~= "lua" then
|
|
81
|
-
return false, "kind"
|
|
82
|
-
end
|
|
83
|
-
if not IsValidRequestId(definition.requestId) then
|
|
84
|
-
return false, "request_id"
|
|
85
|
-
end
|
|
86
|
-
if type(definition.revision) ~= "string" or #definition.revision == 0
|
|
87
|
-
or #definition.revision > MAX_REQUEST_ID_BYTES then
|
|
88
|
-
return false, "revision"
|
|
89
|
-
end
|
|
90
|
-
if type(definition.source) ~= "string" or #definition.source == 0 then
|
|
91
|
-
return false, "source"
|
|
92
|
-
end
|
|
93
|
-
if type(definition.createdAt) ~= "number" then
|
|
94
|
-
return false, "created_at"
|
|
95
|
-
end
|
|
96
|
-
if definition.sourceBytes ~= #definition.source then
|
|
97
|
-
return false, "source_bytes"
|
|
98
|
-
end
|
|
99
|
-
if definition.sourceChecksum ~= ns.AutomationReport.Adler32(definition.source) then
|
|
100
|
-
return false, "source_checksum"
|
|
101
|
-
end
|
|
102
|
-
if definition.outputLimit ~= nil
|
|
103
|
-
and (type(definition.outputLimit) ~= "number" or definition.outputLimit < 1
|
|
104
|
-
or definition.outputLimit > MAX_OUTPUT_LIMIT) then
|
|
105
|
-
return false, "output_limit"
|
|
106
|
-
end
|
|
107
|
-
if definition.expectedClient ~= nil then
|
|
108
|
-
if type(definition.expectedClient) ~= "table" then
|
|
109
|
-
return false, "expected_client"
|
|
110
|
-
end
|
|
111
|
-
local expectedInterface = tonumber(definition.expectedClient.interface)
|
|
112
|
-
if expectedInterface and ns.Client and ns.Client.interface ~= expectedInterface then
|
|
113
|
-
return false, "client_mismatch"
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
return true
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
-- Notice payloads are validated ASCII subsets, so plain embedding is safe.
|
|
120
|
-
local function BuildNoticeJson(notice)
|
|
121
|
-
local json = string.format('{"v":%d,"ticket":"%s","task":"%s","run":"%s","ts":%d}',
|
|
122
|
-
NOTICE_PROTOCOL_VERSION, notice.ticket, notice.taskId, notice.executionId,
|
|
123
|
-
math.floor(tonumber(notice.createdAt) or 0))
|
|
124
|
-
if #json > MAX_NOTICE_BYTES then
|
|
125
|
-
return nil
|
|
126
|
-
end
|
|
127
|
-
return json
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
local function ShowNotice(notice)
|
|
131
|
-
if not notice or not notice.ticket then
|
|
132
|
-
return false
|
|
133
|
-
end
|
|
134
|
-
local json = BuildNoticeJson(notice)
|
|
135
|
-
if not json then
|
|
136
|
-
Print(L.AUTO_NOTICE_FAILED)
|
|
137
|
-
ns.AutomationOverlay.ShowError()
|
|
138
|
-
return false
|
|
139
|
-
end
|
|
140
|
-
ns.AutomationOverlay.ShowNotice(json)
|
|
141
|
-
return true
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
local function BuildEnvironmentInfo()
|
|
145
|
-
local version, build, buildDate, interfaceVersion
|
|
146
|
-
if GetBuildInfo then
|
|
147
|
-
version, build, buildDate, interfaceVersion = GetBuildInfo()
|
|
148
|
-
end
|
|
149
|
-
local character, realm
|
|
150
|
-
local succeeded, name = pcall(UnitName, "player")
|
|
151
|
-
if succeeded and type(name) == "string" and not (issecretvalue and issecretvalue(name)) then
|
|
152
|
-
character = name
|
|
153
|
-
end
|
|
154
|
-
succeeded, name = pcall(GetRealmName)
|
|
155
|
-
if succeeded and type(name) == "string" and not (issecretvalue and issecretvalue(name)) then
|
|
156
|
-
realm = name
|
|
157
|
-
end
|
|
158
|
-
return {
|
|
159
|
-
clientId = ns.Client and ns.Client.id or nil,
|
|
160
|
-
version = version,
|
|
161
|
-
build = build,
|
|
162
|
-
buildDate = buildDate,
|
|
163
|
-
interface = interfaceVersion,
|
|
164
|
-
locale = GetLocale and GetLocale() or nil,
|
|
165
|
-
character = character,
|
|
166
|
-
realm = realm,
|
|
167
|
-
}
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
local function CommitContext(context, terminal)
|
|
171
|
-
local spec = {
|
|
172
|
-
taskId = context.taskId,
|
|
173
|
-
executionId = context.executionId,
|
|
174
|
-
revision = context.revision,
|
|
175
|
-
kind = context.kind,
|
|
176
|
-
status = terminal.status,
|
|
177
|
-
startedAt = context.startedAt,
|
|
178
|
-
finishedAt = time(),
|
|
179
|
-
requestType = context.requestType,
|
|
180
|
-
params = context.params,
|
|
181
|
-
source = context.source,
|
|
182
|
-
stdout = #context.outputParts > 0 and table.concat(context.outputParts) or nil,
|
|
183
|
-
outputTruncated = context.outputTruncated,
|
|
184
|
-
returns = terminal.returns,
|
|
185
|
-
error = terminal.error,
|
|
186
|
-
lifecycleLog = context.log,
|
|
187
|
-
bugSnapshot = context.bugSnapshot,
|
|
188
|
-
environment = BuildEnvironmentInfo(),
|
|
189
|
-
complete = not context.outputTruncated,
|
|
190
|
-
incompleteReasons = context.outputTruncated and { "output_truncated" } or nil,
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
local content, metadata, errorCode = ns.AutomationReportBuild(spec)
|
|
194
|
-
if not content then
|
|
195
|
-
-- The report exceeded its budget; commit a small explicit failure report
|
|
196
|
-
-- instead of a silently truncated success.
|
|
197
|
-
terminal.status = "failed"
|
|
198
|
-
if not terminal.error then
|
|
199
|
-
terminal.error = { message = "report_build_failed: " .. tostring(errorCode), stage = "report" }
|
|
200
|
-
end
|
|
201
|
-
terminal.errorCode = terminal.errorCode or "report_build_failed"
|
|
202
|
-
spec.status = "failed"
|
|
203
|
-
spec.complete = false
|
|
204
|
-
spec.incompleteReasons = { "output_limit" }
|
|
205
|
-
spec.stdout = nil
|
|
206
|
-
spec.returns = nil
|
|
207
|
-
spec.bugSnapshot = nil
|
|
208
|
-
spec.source = nil
|
|
209
|
-
spec.params = nil
|
|
210
|
-
spec.error = terminal.error
|
|
211
|
-
content, metadata, errorCode = ns.AutomationReportBuild(spec)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
if not content then
|
|
215
|
-
ns.FailAutomationExecution(context.executionId, "failed", "report_unavailable")
|
|
216
|
-
ns.AutomationOverlay.ShowError()
|
|
217
|
-
Print(L.AUTO_COMMIT_FAILED:format(tostring(errorCode or "unknown")))
|
|
218
|
-
return nil
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
local ticket, entryOrError = ns.CommitAutomationResult(context.executionId, content, {
|
|
222
|
-
status = terminal.status,
|
|
223
|
-
complete = metadata.complete,
|
|
224
|
-
resultSchema = RESULT_SCHEMA,
|
|
225
|
-
checksumAlgorithm = "adler32",
|
|
226
|
-
contentChecksum = metadata.contentChecksum,
|
|
227
|
-
title = context.title,
|
|
228
|
-
evidenceKind = context.evidenceKind,
|
|
229
|
-
errorCode = terminal.errorCode or errorCode,
|
|
230
|
-
})
|
|
231
|
-
if not ticket then
|
|
232
|
-
-- A failed commit must still reach a terminal index state: the request
|
|
233
|
-
-- id is already spent, so an active record would strand the index until
|
|
234
|
-
-- the next reload (spec 5.4 step 3).
|
|
235
|
-
ns.FailAutomationExecution(context.executionId, "failed", "commit_failed")
|
|
236
|
-
ns.AutomationOverlay.ShowError()
|
|
237
|
-
Print(L.AUTO_COMMIT_FAILED:format(tostring(entryOrError or errorCode or "unknown")))
|
|
238
|
-
return nil
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
awaitingNotice = {
|
|
242
|
-
ticket = ticket,
|
|
243
|
-
taskId = context.taskId,
|
|
244
|
-
executionId = context.executionId,
|
|
245
|
-
createdAt = entryOrError.createdAt,
|
|
246
|
-
}
|
|
247
|
-
unacknowledgedResults = unacknowledgedResults + 1
|
|
248
|
-
ns.AutomationOverlay.HideStatus()
|
|
249
|
-
if ShowNotice(awaitingNotice) then
|
|
250
|
-
Print(L.AUTO_RESULT_READY:format(ticket))
|
|
251
|
-
end
|
|
252
|
-
return ticket
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
Finalize = function(context, terminal)
|
|
256
|
-
if context.terminal then
|
|
257
|
-
return
|
|
258
|
-
end
|
|
259
|
-
context.terminal = terminal
|
|
260
|
-
if activeContext == context then
|
|
261
|
-
activeContext = nil
|
|
262
|
-
end
|
|
263
|
-
context.record.status = "finalizing"
|
|
264
|
-
for index = 1, #context.cleanups do
|
|
265
|
-
local succeeded, errorText = pcall(context.cleanups[index])
|
|
266
|
-
if not succeeded then
|
|
267
|
-
context.log[#context.log + 1] = { at = time(), message = "cleanup_failed: " .. tostring(errorText) }
|
|
268
|
-
end
|
|
269
|
-
end
|
|
270
|
-
context.finishedAt = time()
|
|
271
|
-
CommitContext(context, terminal)
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
local function AddContextOutput(context, text)
|
|
275
|
-
if context.outputTruncated then
|
|
276
|
-
return
|
|
277
|
-
end
|
|
278
|
-
text = tostring(text or "")
|
|
279
|
-
local prefix = #context.outputParts > 0 and "\n" or ""
|
|
280
|
-
local remaining = context.outputLimit - context.outputBytes - #prefix
|
|
281
|
-
if #text > remaining then
|
|
282
|
-
context.outputParts[#context.outputParts + 1] = prefix
|
|
283
|
-
.. text:sub(1, math.max(0, remaining))
|
|
284
|
-
.. "\n... <output truncated>"
|
|
285
|
-
context.outputTruncated = true
|
|
286
|
-
return
|
|
287
|
-
end
|
|
288
|
-
context.outputParts[#context.outputParts + 1] = prefix .. text
|
|
289
|
-
context.outputBytes = context.outputBytes + #prefix + #text
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
local function AddLifecycleLog(context, message)
|
|
293
|
-
message = tostring(message or "")
|
|
294
|
-
if #message > 512 then
|
|
295
|
-
message = message:sub(1, 512) .. "... <truncated>"
|
|
296
|
-
end
|
|
297
|
-
context.log[#context.log + 1] = { at = time(), message = message }
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
local function BuildContextEnvironment(context)
|
|
301
|
-
local environment = {}
|
|
302
|
-
|
|
303
|
-
environment.print = function(...)
|
|
304
|
-
local values = Pack(...)
|
|
305
|
-
local parts = {}
|
|
306
|
-
for index = 1, values.n do
|
|
307
|
-
if issecretvalue and issecretvalue(values[index]) then
|
|
308
|
-
parts[index] = "<secret>"
|
|
309
|
-
else
|
|
310
|
-
parts[index] = tostring(values[index])
|
|
311
|
-
end
|
|
312
|
-
end
|
|
313
|
-
AddContextOutput(context, table.concat(parts, " "))
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
environment.Finish = function(...)
|
|
317
|
-
local count = select("#", ...)
|
|
318
|
-
local returns
|
|
319
|
-
if count > 0 then
|
|
320
|
-
returns = {}
|
|
321
|
-
for index = 1, count do
|
|
322
|
-
returns[index] = select(index, ...)
|
|
323
|
-
end
|
|
324
|
-
end
|
|
325
|
-
Finalize(context, { status = "succeeded", returns = returns })
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
environment.Fail = function(message, errorCode)
|
|
329
|
-
Finalize(context, {
|
|
330
|
-
status = "failed",
|
|
331
|
-
error = { message = tostring(message or "failed"), stage = "task" },
|
|
332
|
-
errorCode = type(errorCode) == "string" and errorCode or "task_failed",
|
|
333
|
-
})
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
environment.IsCancelled = function()
|
|
337
|
-
return context.cancelRequested
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
environment.OnCleanup = function(handler)
|
|
341
|
-
if type(handler) == "function" then
|
|
342
|
-
context.cleanups[#context.cleanups + 1] = handler
|
|
343
|
-
end
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
environment.Log = function(message)
|
|
347
|
-
AddLifecycleLog(context, message)
|
|
348
|
-
end
|
|
349
|
-
|
|
350
|
-
environment.SetAsync = function()
|
|
351
|
-
context.asyncRequested = true
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
setmetatable(environment, { __index = _G, __newindex = _G })
|
|
355
|
-
return environment
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
local function ExecuteTask(taskId, definition)
|
|
359
|
-
local record, beginError = ns.BeginAutomationExecution(definition.requestId, {
|
|
360
|
-
taskId = taskId,
|
|
361
|
-
revision = definition.revision,
|
|
362
|
-
kind = "lua",
|
|
363
|
-
})
|
|
364
|
-
if not record then
|
|
365
|
-
Print(beginError or L.AUTO_REQUEST_REPEATED)
|
|
366
|
-
return
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
local context = {
|
|
370
|
-
taskId = taskId,
|
|
371
|
-
title = taskId,
|
|
372
|
-
executionId = definition.requestId,
|
|
373
|
-
revision = definition.revision,
|
|
374
|
-
kind = "lua",
|
|
375
|
-
requestType = "task",
|
|
376
|
-
evidenceKind = "automation_result",
|
|
377
|
-
record = record,
|
|
378
|
-
outputLimit = math.floor(math.min(tonumber(definition.outputLimit) or DEFAULT_OUTPUT_LIMIT,
|
|
379
|
-
MAX_OUTPUT_LIMIT)),
|
|
380
|
-
outputParts = {},
|
|
381
|
-
outputBytes = 0,
|
|
382
|
-
outputTruncated = false,
|
|
383
|
-
log = {},
|
|
384
|
-
cleanups = {},
|
|
385
|
-
terminal = nil,
|
|
386
|
-
asyncRequested = false,
|
|
387
|
-
cancelRequested = false,
|
|
388
|
-
startedAt = time(),
|
|
389
|
-
source = {
|
|
390
|
-
sourceBytes = definition.sourceBytes,
|
|
391
|
-
sourceChecksum = definition.sourceChecksum,
|
|
392
|
-
requestId = definition.requestId,
|
|
393
|
-
},
|
|
394
|
-
params = nil,
|
|
395
|
-
bugSnapshot = nil,
|
|
396
|
-
}
|
|
397
|
-
context.environment = BuildContextEnvironment(context)
|
|
398
|
-
activeContext = context
|
|
399
|
-
executedRequests[definition.requestId] = true
|
|
400
|
-
ns.AutomationOverlay.ShowRunning()
|
|
401
|
-
|
|
402
|
-
local chunk, compileError = loadstring(definition.source, "LycheeDevAutomation:" .. taskId)
|
|
403
|
-
if not chunk then
|
|
404
|
-
Finalize(context, {
|
|
405
|
-
status = "failed",
|
|
406
|
-
error = { message = tostring(compileError), stage = "compile" },
|
|
407
|
-
errorCode = "compile_error",
|
|
408
|
-
})
|
|
409
|
-
return
|
|
410
|
-
end
|
|
411
|
-
setfenv(chunk, context.environment)
|
|
412
|
-
|
|
413
|
-
local packed = Pack(pcall(chunk))
|
|
414
|
-
if not packed[1] then
|
|
415
|
-
Finalize(context, {
|
|
416
|
-
status = "failed",
|
|
417
|
-
error = { message = tostring(packed[2]), stage = "runtime" },
|
|
418
|
-
errorCode = "runtime_error",
|
|
419
|
-
})
|
|
420
|
-
elseif not context.terminal and not context.asyncRequested then
|
|
421
|
-
-- Sync task: returning completes it with the returned values.
|
|
422
|
-
local returns
|
|
423
|
-
if packed.n > 1 then
|
|
424
|
-
returns = {}
|
|
425
|
-
for index = 2, packed.n do
|
|
426
|
-
returns[index - 1] = packed[index]
|
|
427
|
-
end
|
|
428
|
-
end
|
|
429
|
-
Finalize(context, { status = "succeeded", returns = returns })
|
|
430
|
-
end
|
|
431
|
-
-- Async tasks stay active until their callbacks finish or fail explicitly.
|
|
432
|
-
end
|
|
433
|
-
|
|
434
|
-
function Controller.Run(taskId)
|
|
435
|
-
if not EnsureReady() then
|
|
436
|
-
return
|
|
437
|
-
end
|
|
438
|
-
if not IsValidTaskId(taskId) then
|
|
439
|
-
Print(L.AUTO_TASK_INVALID:format(tostring(taskId), "task_id"))
|
|
440
|
-
return
|
|
441
|
-
end
|
|
442
|
-
local definitions = ns.AutomationTaskDefinitions
|
|
443
|
-
local definition = type(definitions) == "table" and definitions[taskId] or nil
|
|
444
|
-
if not definition then
|
|
445
|
-
Print(L.AUTO_TASK_NOT_LOADED:format(taskId))
|
|
446
|
-
return
|
|
447
|
-
end
|
|
448
|
-
local valid, reason = ValidateTaskDefinition(taskId, definition)
|
|
449
|
-
if not valid then
|
|
450
|
-
Print(L.AUTO_TASK_INVALID:format(taskId, tostring(reason)))
|
|
451
|
-
return
|
|
452
|
-
end
|
|
453
|
-
local expiresAt = tonumber(definition.expiresAt) or 0
|
|
454
|
-
if expiresAt > 0 and expiresAt <= time() then
|
|
455
|
-
Print(L.AUTO_TASK_EXPIRED:format(taskId))
|
|
456
|
-
return
|
|
457
|
-
end
|
|
458
|
-
if not ns.AutomationWritesEnabled() then
|
|
459
|
-
Print(L.AUTO_DATABASE_UNSUPPORTED)
|
|
460
|
-
return
|
|
461
|
-
end
|
|
462
|
-
if executedRequests[definition.requestId] then
|
|
463
|
-
-- Same request may not run twice in one session; re-show its notice.
|
|
464
|
-
local record = ns.GetAutomationRecord(definition.requestId)
|
|
465
|
-
local entry = record and record.ticket and ns.GetExport(record.ticket) or nil
|
|
466
|
-
if entry and not activeContext then
|
|
467
|
-
ShowNotice({
|
|
468
|
-
ticket = record.ticket,
|
|
469
|
-
taskId = record.taskId,
|
|
470
|
-
executionId = record.executionId,
|
|
471
|
-
createdAt = entry.createdAt,
|
|
472
|
-
})
|
|
473
|
-
else
|
|
474
|
-
Print(L.AUTO_REQUEST_REPEATED)
|
|
475
|
-
end
|
|
476
|
-
return
|
|
477
|
-
end
|
|
478
|
-
if activeContext or unacknowledgedResults >= MAX_UNACKNOWLEDGED_RESULTS then
|
|
479
|
-
Print(L.AUTO_BUSY)
|
|
480
|
-
return
|
|
481
|
-
end
|
|
482
|
-
ExecuteTask(taskId, definition)
|
|
483
|
-
end
|
|
484
|
-
|
|
485
|
-
function Controller.Bug(countText, requestIdText)
|
|
486
|
-
if not EnsureReady() then
|
|
487
|
-
return
|
|
488
|
-
end
|
|
489
|
-
local count = tonumber(countText)
|
|
490
|
-
if not count or count ~= math.floor(count) or count < 1 or count > 100 then
|
|
491
|
-
Print(L.AUTO_INVALID_COUNT)
|
|
492
|
-
return
|
|
493
|
-
end
|
|
494
|
-
requestIdText = requestIdText or ""
|
|
495
|
-
if requestIdText ~= "" and not IsValidRequestId(requestIdText) then
|
|
496
|
-
Print(L.AUTO_TASK_INVALID:format(requestIdText, "request_id"))
|
|
497
|
-
return
|
|
498
|
-
end
|
|
499
|
-
if not ns.AutomationWritesEnabled() then
|
|
500
|
-
Print(L.AUTO_DATABASE_UNSUPPORTED)
|
|
501
|
-
return
|
|
502
|
-
end
|
|
503
|
-
local executionId = requestIdText ~= "" and requestIdText or GenerateLocalExecutionId()
|
|
504
|
-
if executedRequests[executionId] then
|
|
505
|
-
Print(L.AUTO_REQUEST_REPEATED)
|
|
506
|
-
return
|
|
507
|
-
end
|
|
508
|
-
if activeContext or unacknowledgedResults >= MAX_UNACKNOWLEDGED_RESULTS then
|
|
509
|
-
Print(L.AUTO_BUSY)
|
|
510
|
-
return
|
|
511
|
-
end
|
|
512
|
-
local snapshot, snapshotError = ns.Diagnostics.SnapshotRecentErrors(count, "all")
|
|
513
|
-
if not snapshot then
|
|
514
|
-
Print(L.AUTO_PROVIDER_FAILED:format(tostring(snapshotError)))
|
|
515
|
-
return
|
|
516
|
-
end
|
|
517
|
-
|
|
518
|
-
local record, beginError = ns.BeginAutomationExecution(executionId, {
|
|
519
|
-
taskId = BUG_TASK_ID,
|
|
520
|
-
kind = "bug_snapshot",
|
|
521
|
-
})
|
|
522
|
-
if not record then
|
|
523
|
-
Print(beginError or L.AUTO_REQUEST_REPEATED)
|
|
524
|
-
return
|
|
525
|
-
end
|
|
526
|
-
executedRequests[executionId] = true
|
|
527
|
-
|
|
528
|
-
local context = {
|
|
529
|
-
taskId = BUG_TASK_ID,
|
|
530
|
-
title = L.AUTO_BUG_TITLE:format(count),
|
|
531
|
-
executionId = executionId,
|
|
532
|
-
kind = "bug_snapshot",
|
|
533
|
-
requestType = "bug",
|
|
534
|
-
evidenceKind = "error_log",
|
|
535
|
-
record = record,
|
|
536
|
-
outputLimit = DEFAULT_OUTPUT_LIMIT,
|
|
537
|
-
outputParts = {},
|
|
538
|
-
outputBytes = 0,
|
|
539
|
-
outputTruncated = false,
|
|
540
|
-
log = {},
|
|
541
|
-
cleanups = {},
|
|
542
|
-
terminal = nil,
|
|
543
|
-
asyncRequested = false,
|
|
544
|
-
cancelRequested = false,
|
|
545
|
-
startedAt = time(),
|
|
546
|
-
source = nil,
|
|
547
|
-
params = { count = count, scope = "provider_storage" },
|
|
548
|
-
bugSnapshot = snapshot,
|
|
549
|
-
}
|
|
550
|
-
activeContext = context
|
|
551
|
-
ns.AutomationOverlay.ShowRunning()
|
|
552
|
-
Finalize(context, { status = "succeeded" })
|
|
553
|
-
end
|
|
554
|
-
|
|
555
|
-
function Controller.Status(taskId)
|
|
556
|
-
if not EnsureReady() then
|
|
557
|
-
return
|
|
558
|
-
end
|
|
559
|
-
if not IsValidTaskId(taskId) then
|
|
560
|
-
Print(L.AUTO_TASK_INVALID:format(tostring(taskId), "task_id"))
|
|
561
|
-
return
|
|
562
|
-
end
|
|
563
|
-
local automation = ns.GetAutomationIndex()
|
|
564
|
-
local latest
|
|
565
|
-
if automation then
|
|
566
|
-
for index = 1, #automation.order do
|
|
567
|
-
local record = automation.records[automation.order[index]]
|
|
568
|
-
if record and record.taskId == taskId then
|
|
569
|
-
latest = record
|
|
570
|
-
break
|
|
571
|
-
end
|
|
572
|
-
end
|
|
573
|
-
end
|
|
574
|
-
if not latest then
|
|
575
|
-
Print(L.AUTO_TASK_NOT_LOADED:format(taskId))
|
|
576
|
-
return
|
|
577
|
-
end
|
|
578
|
-
local resultText
|
|
579
|
-
if latest.ticket and ns.GetExport(latest.ticket) then
|
|
580
|
-
resultText = latest.ticket
|
|
581
|
-
elseif latest.ticket then
|
|
582
|
-
resultText = L.AUTO_RESULT_EXPIRED
|
|
583
|
-
else
|
|
584
|
-
resultText = "-"
|
|
585
|
-
end
|
|
586
|
-
Print(L.AUTO_STATUS_LINE:format(taskId, latest.executionId, latest.status, resultText))
|
|
587
|
-
if latest.ticket and resultText == latest.ticket and not activeContext then
|
|
588
|
-
ShowNotice({
|
|
589
|
-
ticket = latest.ticket,
|
|
590
|
-
taskId = latest.taskId,
|
|
591
|
-
executionId = latest.executionId,
|
|
592
|
-
createdAt = ns.GetExport(latest.ticket).createdAt,
|
|
593
|
-
})
|
|
594
|
-
end
|
|
595
|
-
end
|
|
596
|
-
|
|
597
|
-
function Controller.Show(ticket)
|
|
598
|
-
if not EnsureReady() then
|
|
599
|
-
return
|
|
600
|
-
end
|
|
601
|
-
if not IsValidTicket(ticket) then
|
|
602
|
-
Print(L.AUTO_INVALID_TICKET)
|
|
603
|
-
return
|
|
604
|
-
end
|
|
605
|
-
local entry = ns.GetExport(ticket)
|
|
606
|
-
local record = entry and ns.FindAutomationByTicket(ticket) or nil
|
|
607
|
-
if not entry or not record then
|
|
608
|
-
Print(L.AUTO_RESULT_MISSING:format(ticket))
|
|
609
|
-
return
|
|
610
|
-
end
|
|
611
|
-
ShowNotice({
|
|
612
|
-
ticket = ticket,
|
|
613
|
-
taskId = record.taskId,
|
|
614
|
-
executionId = record.executionId,
|
|
615
|
-
createdAt = entry.createdAt,
|
|
616
|
-
})
|
|
617
|
-
end
|
|
618
|
-
|
|
619
|
-
function Controller.Cancel(taskId)
|
|
620
|
-
if not EnsureReady() then
|
|
621
|
-
return
|
|
622
|
-
end
|
|
623
|
-
if not IsValidTaskId(taskId) then
|
|
624
|
-
Print(L.AUTO_TASK_INVALID:format(tostring(taskId), "task_id"))
|
|
625
|
-
return
|
|
626
|
-
end
|
|
627
|
-
if not activeContext or activeContext.taskId ~= taskId then
|
|
628
|
-
Print(L.AUTO_NO_ACTIVE:format(taskId))
|
|
629
|
-
return
|
|
630
|
-
end
|
|
631
|
-
activeContext.cancelRequested = true
|
|
632
|
-
Finalize(activeContext, {
|
|
633
|
-
status = "cancelled",
|
|
634
|
-
errorCode = "cancelled_by_request",
|
|
635
|
-
})
|
|
636
|
-
end
|
|
637
|
-
|
|
638
|
-
function Controller.Stop()
|
|
639
|
-
ns.AutomationOverlay.HideNotice()
|
|
640
|
-
ns.AutomationOverlay.HideStatus()
|
|
641
|
-
ns.AutomationOverlay.HideIdentity()
|
|
642
|
-
Print(L.AUTO_STOPPED)
|
|
643
|
-
end
|
|
644
|
-
|
|
645
|
-
function Controller.StopIdentify(nonce)
|
|
646
|
-
if nonce and nonce ~= identityReceiptNonce then
|
|
647
|
-
return
|
|
648
|
-
end
|
|
649
|
-
identityReceiptNonce = nil
|
|
650
|
-
ns.AutomationOverlay.HideIdentity()
|
|
651
|
-
Print(L.AUTO_IDENTITY_HIDDEN)
|
|
652
|
-
end
|
|
653
|
-
|
|
654
|
-
-- Identity marker for host-side window discovery.
|
|
655
|
-
--
|
|
656
|
-
-- The host can capture several game windows but cannot tell which character is
|
|
657
|
-
-- behind each one; nothing observable from outside the game says so. This shows
|
|
658
|
-
-- a tiny QR code carrying the character identity and build, so a host can map
|
|
659
|
-
-- every running window to a name and let the user choose. It appears only on
|
|
660
|
-
-- explicit request because it shares the top-left corner with the completion
|
|
661
|
-
-- notice and would otherwise sit on screen permanently.
|
|
662
|
-
function Controller.Identify()
|
|
663
|
-
if not EnsureReady() then
|
|
664
|
-
return
|
|
665
|
-
end
|
|
666
|
-
|
|
667
|
-
local character, realm
|
|
668
|
-
local succeeded, name = pcall(UnitName, "player")
|
|
669
|
-
if succeeded and type(name) == "string" and name ~= ""
|
|
670
|
-
and not (issecretvalue and issecretvalue(name)) then
|
|
671
|
-
character = name
|
|
672
|
-
end
|
|
673
|
-
succeeded, name = pcall(GetRealmName)
|
|
674
|
-
if succeeded and type(name) == "string" and name ~= ""
|
|
675
|
-
and not (issecretvalue and issecretvalue(name)) then
|
|
676
|
-
realm = name
|
|
677
|
-
end
|
|
678
|
-
|
|
679
|
-
if not character then
|
|
680
|
-
Print(L.AUTO_IDENTITY_UNAVAILABLE)
|
|
681
|
-
return
|
|
682
|
-
end
|
|
683
|
-
|
|
684
|
-
-- The marker and the completion notice share one corner. Replacing a notice
|
|
685
|
-
-- would take away the only on-screen reference to its Ticket, so refuse
|
|
686
|
-
-- instead of hiding evidence the user may still need.
|
|
687
|
-
if awaitingNotice then
|
|
688
|
-
Print(L.AUTO_IDENTITY_NOTICE_SHOWN)
|
|
689
|
-
return
|
|
690
|
-
end
|
|
691
|
-
|
|
692
|
-
local version = GetBuildInfo and select(1, GetBuildInfo()) or nil
|
|
693
|
-
if issecretvalue and issecretvalue(version) then
|
|
694
|
-
version = nil
|
|
695
|
-
end
|
|
696
|
-
|
|
697
|
-
-- Character names and realm names are plain text, so escape them before
|
|
698
|
-
-- embedding rather than assuming they are JSON-safe.
|
|
699
|
-
local function EscapeJson(value)
|
|
700
|
-
value = tostring(value or "")
|
|
701
|
-
value = value:gsub("\\", "\\\\"):gsub('"', '\\"'):gsub("[%c]", " ")
|
|
702
|
-
return value
|
|
703
|
-
end
|
|
704
|
-
|
|
705
|
-
local json = string.format('{"v":1,"id":"%s","realm":"%s","client":"%s","build":"%s"}',
|
|
706
|
-
EscapeJson(character),
|
|
707
|
-
EscapeJson(realm or ""),
|
|
708
|
-
EscapeJson(ns.Client and ns.Client.id or ""),
|
|
709
|
-
EscapeJson(version or ""))
|
|
710
|
-
|
|
711
|
-
if #json > MAX_NOTICE_BYTES then
|
|
712
|
-
Print(L.AUTO_IDENTITY_UNAVAILABLE)
|
|
713
|
-
return
|
|
714
|
-
end
|
|
715
|
-
|
|
716
|
-
identityReceiptNonce = nil
|
|
717
|
-
if ns.AutomationOverlay.ShowIdentity(json) then
|
|
718
|
-
Print(L.AUTO_IDENTITY_SHOWN:format(character, realm or "-"))
|
|
719
|
-
else
|
|
720
|
-
Print(L.AUTO_IDENTITY_UNAVAILABLE)
|
|
721
|
-
end
|
|
722
|
-
end
|
|
723
|
-
|
|
724
|
-
-- The plugin cannot observe whether the host read a result, so the host reports
|
|
725
|
-
-- it back as a chat command: `/dev auto ack <ticket> <received|failed>`. That
|
|
726
|
-
-- clears the pending-flush block immediately (no reload needed) and records the
|
|
727
|
-
-- outcome so the page can show it and a later session keeps it.
|
|
728
|
-
function Controller.Ack(ticket, outcome, nonce)
|
|
729
|
-
if not EnsureReady() then
|
|
730
|
-
return
|
|
731
|
-
end
|
|
732
|
-
if not IsValidTicket(ticket) then
|
|
733
|
-
Print(L.AUTO_INVALID_TICKET)
|
|
734
|
-
return
|
|
735
|
-
end
|
|
736
|
-
if outcome ~= "received" and outcome ~= "failed" then
|
|
737
|
-
Print(L.AUTO_ACK_STATUS_INVALID)
|
|
738
|
-
return
|
|
739
|
-
end
|
|
740
|
-
local record = ns.FindAutomationByTicket(ticket)
|
|
741
|
-
if not record then
|
|
742
|
-
Print(L.AUTO_ACK_TICKET_UNKNOWN:format(ticket))
|
|
743
|
-
return
|
|
744
|
-
end
|
|
745
|
-
if nonce then
|
|
746
|
-
if not IsValidRequestId(nonce) or #ticket > 64 then
|
|
747
|
-
Print(L.AUTO_USAGE)
|
|
748
|
-
return
|
|
749
|
-
end
|
|
750
|
-
if awaitingNotice and awaitingNotice.ticket ~= ticket then
|
|
751
|
-
Print(L.AUTO_IDENTITY_NOTICE_SHOWN)
|
|
752
|
-
return
|
|
753
|
-
end
|
|
754
|
-
end
|
|
755
|
-
record.receivedAt = time()
|
|
756
|
-
record.receivedStatus = outcome
|
|
757
|
-
-- Only the first acknowledgement of a result frees a backlog slot; a repeat
|
|
758
|
-
-- ack must not shrink the count twice.
|
|
759
|
-
if not record.acknowledged then
|
|
760
|
-
record.acknowledged = true
|
|
761
|
-
if unacknowledgedResults > 0 then
|
|
762
|
-
unacknowledgedResults = unacknowledgedResults - 1
|
|
763
|
-
end
|
|
764
|
-
end
|
|
765
|
-
if awaitingNotice and awaitingNotice.ticket == ticket then
|
|
766
|
-
awaitingNotice = nil
|
|
767
|
-
ns.AutomationOverlay.HideNotice()
|
|
768
|
-
end
|
|
769
|
-
if nonce then
|
|
770
|
-
-- Echo only validated identifiers. A fresh nonce separates this receipt
|
|
771
|
-
-- from an older acknowledgement still visible on screen.
|
|
772
|
-
local receipt = string.format(
|
|
773
|
-
'{"v":1,"ticket":"%s","task":"ack","run":"%s","ts":%d,"status":"%s"}',
|
|
774
|
-
ticket, nonce, record.receivedAt, outcome)
|
|
775
|
-
if ns.AutomationOverlay.ShowIdentity(receipt) then
|
|
776
|
-
identityReceiptNonce = nonce
|
|
777
|
-
end
|
|
778
|
-
end
|
|
779
|
-
Print(L.AUTO_ACK_DONE:format(ticket, outcome))
|
|
780
|
-
end
|
|
781
|
-
|
|
782
|
-
function Controller.HandleCommand(text)
|
|
783
|
-
local action, rest = tostring(text or ""):match("^(%S+)%s*(.-)%s*$")
|
|
784
|
-
action = action and action:lower() or ""
|
|
785
|
-
if action == "run" then
|
|
786
|
-
local taskId = rest:match("^(%S+)$")
|
|
787
|
-
if not taskId then
|
|
788
|
-
Print(L.AUTO_USAGE)
|
|
789
|
-
return
|
|
790
|
-
end
|
|
791
|
-
Controller.Run(taskId)
|
|
792
|
-
elseif action == "bug" then
|
|
793
|
-
local count, requestId = rest:match("^(%S+)%s+(%S+)$")
|
|
794
|
-
if not count then
|
|
795
|
-
count = rest:match("^(%S+)$")
|
|
796
|
-
end
|
|
797
|
-
if not count then
|
|
798
|
-
Print(L.AUTO_USAGE)
|
|
799
|
-
return
|
|
800
|
-
end
|
|
801
|
-
Controller.Bug(count, requestId)
|
|
802
|
-
elseif action == "status" then
|
|
803
|
-
local taskId = rest:match("^(%S+)$")
|
|
804
|
-
if not taskId then
|
|
805
|
-
Print(L.AUTO_USAGE)
|
|
806
|
-
return
|
|
807
|
-
end
|
|
808
|
-
Controller.Status(taskId)
|
|
809
|
-
elseif action == "show" then
|
|
810
|
-
local ticket = rest:match("^(%S+)$")
|
|
811
|
-
if not ticket then
|
|
812
|
-
Print(L.AUTO_USAGE)
|
|
813
|
-
return
|
|
814
|
-
end
|
|
815
|
-
Controller.Show(ticket)
|
|
816
|
-
elseif action == "cancel" then
|
|
817
|
-
local taskId = rest:match("^(%S+)$")
|
|
818
|
-
if not taskId then
|
|
819
|
-
Print(L.AUTO_USAGE)
|
|
820
|
-
return
|
|
821
|
-
end
|
|
822
|
-
Controller.Cancel(taskId)
|
|
823
|
-
elseif action == "stop" then
|
|
824
|
-
if rest ~= "" then
|
|
825
|
-
Print(L.AUTO_USAGE)
|
|
826
|
-
return
|
|
827
|
-
end
|
|
828
|
-
Controller.Stop()
|
|
829
|
-
elseif action == "identify" then
|
|
830
|
-
if rest ~= "" then
|
|
831
|
-
Print(L.AUTO_USAGE)
|
|
832
|
-
return
|
|
833
|
-
end
|
|
834
|
-
Controller.Identify()
|
|
835
|
-
elseif action == "unidentify" then
|
|
836
|
-
local nonce = rest ~= "" and rest:match("^(%S+)$") or nil
|
|
837
|
-
if rest ~= "" and not IsValidRequestId(nonce) then
|
|
838
|
-
Print(L.AUTO_USAGE)
|
|
839
|
-
return
|
|
840
|
-
end
|
|
841
|
-
Controller.StopIdentify(nonce)
|
|
842
|
-
elseif action == "ack" then
|
|
843
|
-
local ticket, outcome, nonce = rest:match("^(%S+)%s+(%S+)%s+(%S+)$")
|
|
844
|
-
if not ticket then
|
|
845
|
-
ticket, outcome = rest:match("^(%S+)%s+(%S+)$")
|
|
846
|
-
end
|
|
847
|
-
if not ticket or not outcome then
|
|
848
|
-
Print(L.AUTO_USAGE)
|
|
849
|
-
return
|
|
850
|
-
end
|
|
851
|
-
Controller.Ack(ticket, outcome:lower(), nonce)
|
|
852
|
-
else
|
|
853
|
-
Print(L.AUTO_USAGE)
|
|
854
|
-
end
|
|
855
|
-
end
|
|
856
|
-
|
|
857
|
-
function Controller.IsBusy()
|
|
858
|
-
-- Busy means "a new request would be refused", not "a notice is on screen":
|
|
859
|
-
-- a few unacknowledged results may queue before the cap blocks new runs.
|
|
860
|
-
return activeContext ~= nil
|
|
861
|
-
or unacknowledgedResults >= MAX_UNACKNOWLEDGED_RESULTS
|
|
862
|
-
end
|
|
863
|
-
|
|
864
|
-
function Controller.GetUnacknowledgedCount()
|
|
865
|
-
return unacknowledgedResults
|
|
866
|
-
end
|
|
867
|
-
|
|
868
|
-
function Controller.MaxUnacknowledgedResults()
|
|
869
|
-
return MAX_UNACKNOWLEDGED_RESULTS
|
|
870
|
-
end
|
|
871
|
-
|
|
872
|
-
function Controller.GetAwaitingNotice()
|
|
873
|
-
return awaitingNotice
|
|
874
|
-
end
|
|
875
|
-
|
|
876
|
-
-- The identity marker is own UI and must not survive a combat lockout, matching
|
|
877
|
-
-- the notice and status blocks. The callback is constant time while the overlay
|
|
878
|
-
-- has never been built, so registering it costs nothing for users who never use
|
|
879
|
-
-- the automation page.
|
|
880
|
-
ns.RegisterCombatShutdown(function()
|
|
881
|
-
if ns.AutomationOverlay then
|
|
882
|
-
ns.AutomationOverlay.HideIdentity()
|
|
883
|
-
end
|
|
884
|
-
end)
|