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.
Files changed (115) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +45 -0
  3. package/THIRD_PARTY_NOTICES +812 -0
  4. package/bin/lycheedev.mjs +56 -0
  5. package/native/windows-amd64/lycheedev.exe +0 -0
  6. package/package.json +12 -33
  7. package/payload/addon/Bridge/CaptureWriter.lua +154 -0
  8. package/payload/addon/Bridge/Definitions.lua +3 -0
  9. package/payload/addon/Bridge/Identity.lua +127 -0
  10. package/{vendor/addon/Libs/AutomationQR.lua → payload/addon/Bridge/MatrixSymbol.lua} +23 -30
  11. package/payload/addon/Bridge/ProbeQueue.lua +136 -0
  12. package/payload/addon/Bridge/ProbeRunner.lua +128 -0
  13. package/payload/addon/Bridge/ReceiptView.lua +160 -0
  14. package/payload/addon/Bridge/Reentry.lua +192 -0
  15. package/payload/addon/Bridge/ReportStore.lua +153 -0
  16. package/payload/addon/Bridge/Session.lua +163 -0
  17. package/payload/addon/Clients/Evergreen.lua +2 -0
  18. package/payload/addon/Clients/Live.lua +2 -0
  19. package/payload/addon/Clients/Pandaria.lua +2 -0
  20. package/payload/addon/Clients/Titan.lua +2 -0
  21. package/payload/addon/Core/Compat.lua +59 -0
  22. package/payload/addon/Core/Controls.lua +168 -0
  23. package/{vendor/addon/Core/Bootstrap.lua → payload/addon/Core/Execute.lua} +12 -23
  24. package/{vendor → payload}/addon/Core/Inspector.lua +19 -235
  25. package/{vendor → payload}/addon/Core/Locale.lua +129 -94
  26. package/{vendor → payload}/addon/Core/Locale_enUS.lua +129 -96
  27. package/payload/addon/Core/Persistence.lua +58 -0
  28. package/payload/addon/Core/Platform.lua +58 -0
  29. package/payload/addon/Core/Runtime.lua +25 -0
  30. package/payload/addon/Core/Safety.lua +56 -0
  31. package/{vendor → payload}/addon/Core/Serializer.lua +18 -6
  32. package/payload/addon/Core/Stores.lua +611 -0
  33. package/payload/addon/Lychee Dev_Forever.toc +52 -0
  34. package/payload/addon/Lychee Dev_Mainline.toc +52 -0
  35. package/payload/addon/Lychee Dev_Mists.toc +52 -0
  36. package/payload/addon/Lychee Dev_Wrath.toc +52 -0
  37. package/payload/addon/Modules/AutomationView.lua +393 -0
  38. package/{vendor → payload}/addon/Modules/Diagnostics.lua +92 -36
  39. package/{vendor → payload}/addon/Modules/Events/Catalog.lua +9 -0
  40. package/{vendor → payload}/addon/Modules/Events/Monitor.lua +45 -5
  41. package/payload/addon/Modules/FunctionTrace.lua +150 -0
  42. package/{vendor → payload}/addon/Modules/ObjectInspector.lua +105 -31
  43. package/{vendor → payload}/addon/UI/Export.lua +64 -34
  44. package/{vendor → payload}/addon/UI/Pages/About.lua +26 -14
  45. package/payload/addon/UI/Pages/Automation.lua +446 -0
  46. package/payload/addon/UI/Pages/Diagnostics.lua +402 -0
  47. package/{vendor/addon/UI/Features.lua → payload/addon/UI/Pages/Events.lua} +192 -302
  48. package/{vendor → payload}/addon/UI/Pages/ExportRecords.lua +213 -132
  49. package/{vendor → payload}/addon/UI/Pages/Object.lua +229 -121
  50. package/payload/addon/UI/Pages/Run.lua +423 -0
  51. package/payload/addon/UI/Pages/Trace.lua +314 -0
  52. package/payload/addon/UI/TreeView.lua +246 -0
  53. package/{vendor/addon/UI/MainWindow.lua → payload/addon/UI/Widgets.lua} +89 -529
  54. package/payload/addon/UI/Window.lua +425 -0
  55. package/payload/skill/SKILL.md +87 -0
  56. package/payload/skill/agents/openai.yaml +7 -0
  57. package/payload/skill/references/addon-validation.md +42 -0
  58. package/payload/skill/references/asset-export.md +109 -0
  59. package/payload/skill/references/commands.md +169 -0
  60. package/payload/skill/references/data-investigation.md +242 -0
  61. package/payload/skill/references/error-diagnosis.md +41 -0
  62. package/payload/skill/references/installation.md +18 -0
  63. package/payload/skill/references/live-investigation.md +129 -0
  64. package/payload/skill/references/source-research.md +82 -0
  65. package/payload/skill/scripts/lycheedev.mjs +59 -0
  66. package/release.json +346 -0
  67. package/bin/lycheedev.js +0 -742
  68. package/src/addon.js +0 -95
  69. package/src/config.js +0 -68
  70. package/src/doctor.js +0 -126
  71. package/src/install.js +0 -145
  72. package/src/paths.js +0 -93
  73. package/src/py/instances.py +0 -165
  74. package/src/python.js +0 -111
  75. package/src/skill.js +0 -48
  76. package/src/wow.js +0 -541
  77. package/vendor/addon/Core/Clients/Forever.lua +0 -9
  78. package/vendor/addon/Core/Clients/Mainline.lua +0 -9
  79. package/vendor/addon/Core/Clients/Mists.lua +0 -9
  80. package/vendor/addon/Core/Clients/Titan.lua +0 -9
  81. package/vendor/addon/Core/Compatibility.lua +0 -43
  82. package/vendor/addon/Core/Database.lua +0 -859
  83. package/vendor/addon/Core/Safety.lua +0 -42
  84. package/vendor/addon/Lychee Dev_Forever.toc +0 -43
  85. package/vendor/addon/Lychee Dev_Mainline.toc +0 -43
  86. package/vendor/addon/Lychee Dev_Mists.toc +0 -43
  87. package/vendor/addon/Lychee Dev_Wrath.toc +0 -43
  88. package/vendor/addon/Modules/Automation/Controller.lua +0 -884
  89. package/vendor/addon/Modules/Automation/Report.lua +0 -409
  90. package/vendor/addon/Modules/Automation/auto/auto.lua +0 -12
  91. package/vendor/addon/Modules/FunctionTrace.lua +0 -85
  92. package/vendor/addon/UI/AutomationOverlay.lua +0 -253
  93. package/vendor/addon/UI/Pages/Automation.lua +0 -417
  94. package/vendor/addon/UI/Pages/Diagnostics.lua +0 -289
  95. package/vendor/addon/UI/Pages/Trace.lua +0 -165
  96. package/vendor/skill/SKILL.md +0 -42
  97. package/vendor/skill/agents/openai.yaml +0 -4
  98. package/vendor/skill/references/automation.md +0 -128
  99. package/vendor/skill/references/clients.md +0 -51
  100. package/vendor/skill/references/runtime-investigations.md +0 -104
  101. package/vendor/skill/scripts/automation/__init__.py +0 -1
  102. package/vendor/skill/scripts/automation/registry.py +0 -516
  103. package/vendor/skill/scripts/automation/saved_variables.py +0 -438
  104. package/vendor/skill/scripts/automation/session.py +0 -207
  105. package/vendor/skill/scripts/automation/windows.py +0 -792
  106. package/vendor/skill/scripts/automation.py +0 -1034
  107. package/vendor/skill/scripts/requirements.txt +0 -13
  108. package/vendor/skill/scripts/selftest_offline.py +0 -1061
  109. package/vendor/skill/scripts/test_input_safety.py +0 -132
  110. /package/{vendor → payload}/addon/Media/GitHub.png +0 -0
  111. /package/{vendor → payload}/addon/Media/Logo.png +0 -0
  112. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Forever.lua +0 -0
  113. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mainline.lua +0 -0
  114. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mists.lua +0 -0
  115. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Titan.lua +0 -0
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import { createHash } from 'node:crypto';
3
+ import { readFileSync, realpathSync, statSync } from 'node:fs';
4
+ import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { spawnSync } from 'node:child_process';
7
+
8
+ // The 2.0 distribution ships a windows-amd64 binary only; every other platform
9
+ // fails closed with distribution.unsupported_platform (no downloads, no fallbacks).
10
+ const targets = new Map([
11
+ ['win32:x64', 'windows-amd64'],
12
+ ]);
13
+
14
+ export function nativePath(root, platform = process.platform, arch = process.arch) {
15
+ const target = targets.get(`${platform}:${arch}`);
16
+ if (!target) throw new Error(`distribution.unsupported_platform: ${platform}/${arch}`);
17
+ const manifest = JSON.parse(readFileSync(resolve(root, 'release.json'), 'utf8'));
18
+ const pkg = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8'));
19
+ if (manifest.schema !== 'lycheedev.release.v1' || manifest.version !== pkg.version) {
20
+ throw new Error('distribution.version_mismatch');
21
+ }
22
+ const expected = `native/${target}/lycheedev${platform === 'win32' ? '.exe' : ''}`;
23
+ const entry = manifest.binaries?.[target];
24
+ if (!entry || entry.path !== expected || !/^[a-f0-9]{64}$/.test(entry.sha256) || !Number.isSafeInteger(entry.bytes) || entry.bytes < 1) {
25
+ throw new Error(`distribution.invalid_binary_record: ${target}`);
26
+ }
27
+ const binary = realpathSync(resolve(root, expected));
28
+ const rel = relative(realpathSync(root), binary);
29
+ if (isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`)) throw new Error('distribution.binary_outside_package');
30
+ const stat = statSync(binary);
31
+ if (!stat.isFile() || stat.size !== entry.bytes || stat.size > 256 * 1024 * 1024) throw new Error('distribution.binary_size');
32
+ const digest = createHash('sha256').update(readFileSync(binary)).digest('hex');
33
+ if (digest !== entry.sha256) throw new Error('distribution.binary_integrity');
34
+ return binary;
35
+ }
36
+
37
+ export function launch(root, args, run = spawnSync) {
38
+ const result = run(nativePath(root), args, { stdio: 'inherit', shell: false, windowsHide: true });
39
+ if (result.error) throw result.error;
40
+ if (result.signal) return { signal: result.signal };
41
+ if (!Number.isInteger(result.status)) throw new Error('distribution.missing_exit_status');
42
+ return { status: result.status };
43
+ }
44
+
45
+ if (process.argv[1] && realpathSync(resolve(process.argv[1])) === fileURLToPath(import.meta.url)) {
46
+ try {
47
+ const [major, minor] = process.versions.node.split('.').map(Number);
48
+ if (major < 22 || (major === 22 && minor < 14)) throw new Error('distribution.node_version: requires Node >=22.14.0');
49
+ const result = launch(resolve(dirname(fileURLToPath(import.meta.url)), '..'), process.argv.slice(2));
50
+ if (result.signal) process.kill(process.pid, result.signal);
51
+ else process.exitCode = result.status;
52
+ } catch (error) {
53
+ process.stderr.write(`lycheedev: ${error.message}\n`);
54
+ process.exitCode = 3;
55
+ }
56
+ }
package/package.json CHANGED
@@ -1,42 +1,21 @@
1
1
  {
2
2
  "name": "lycheedev",
3
- "version": "1.1.1",
4
- "description": "lycheedev: install the World of Warcraft inspection addon, its in-game automation tooling, and drive it from the command line.",
5
- "keywords": [
6
- "wow",
7
- "world-of-warcraft",
8
- "addon",
9
- "automation",
10
- "cli"
11
- ],
3
+ "version": "2.0.0",
4
+ "private": false,
5
+ "description": "Unified native World of Warcraft development toolkit",
12
6
  "license": "MIT",
13
- "author": "Follen",
14
- "homepage": "https://github.com/Follen/Lychee-Dev#readme",
7
+ "type": "module",
8
+ "bin": { "lycheedev": "bin/lycheedev.mjs" },
9
+ "files": ["bin/", "native/", "payload/", "release.json", "README.md", "LICENSE", "THIRD_PARTY_NOTICES"],
10
+ "engines": { "node": ">=22.14.0" },
15
11
  "repository": {
16
12
  "type": "git",
17
13
  "url": "git+https://github.com/Follen/Lychee-Dev.git",
18
- "directory": "packages/cli"
19
- },
20
- "bugs": {
21
- "url": "https://github.com/Follen/Lychee-Dev/issues"
22
- },
23
- "type": "module",
24
- "bin": {
25
- "lycheedev": "bin/lycheedev.js"
26
- },
27
- "files": [
28
- "bin/",
29
- "src/",
30
- "vendor/",
31
- "README.md"
32
- ],
33
- "engines": {
34
- "node": ">=18"
14
+ "directory": "packages/npm/lycheedev"
35
15
  },
36
- "scripts": {
37
- "build": "node scripts/vendor.mjs",
38
- "prepack": "node scripts/vendor.mjs",
39
- "test": "node scripts/selftest.mjs"
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org/"
40
19
  },
41
- "dependencies": {}
20
+ "scripts": { "test": "node --test test/*.test.mjs" }
42
21
  }
@@ -0,0 +1,154 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ local MAX_REPORT_BYTES = 512 * 1024
4
+ local MAX_DEPTH = 32
5
+ local MAX_ENTRIES = 32768
6
+ local escapes = {
7
+ ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f",
8
+ ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t",
9
+ }
10
+
11
+ local function rejectRestricted(value)
12
+ if issecretvalue and issecretvalue(value) then
13
+ error("report_secret_value", 0)
14
+ end
15
+ end
16
+
17
+ local function escapeControl(character)
18
+ return escapes[character] or string.format("\\u%04x", string.byte(character))
19
+ end
20
+
21
+ local function isUTF8(text)
22
+ local offset, size = 1, #text
23
+ while offset <= size do
24
+ local first = string.byte(text, offset)
25
+ local count, minimum, maximum = 0, 128, 191
26
+ if first < 128 then
27
+ count = 0
28
+ elseif first >= 194 and first <= 223 then
29
+ count = 1
30
+ elseif first >= 224 and first <= 239 then
31
+ count = 2
32
+ if first == 224 then minimum = 160 end
33
+ if first == 237 then maximum = 159 end
34
+ elseif first >= 240 and first <= 244 then
35
+ count = 3
36
+ if first == 240 then minimum = 144 end
37
+ if first == 244 then maximum = 143 end
38
+ else
39
+ return false
40
+ end
41
+ if offset + count > size then return false end
42
+ for index = 1, count do
43
+ local byte = string.byte(text, offset + index)
44
+ if index == 1 then
45
+ if byte < minimum or byte > maximum then return false end
46
+ elseif byte < 128 or byte > 191 then
47
+ return false
48
+ end
49
+ end
50
+ offset = offset + count + 1
51
+ end
52
+ return true
53
+ end
54
+
55
+ local function encodeDocument(value, limit)
56
+ local parts, seen, used, entries = {}, {}, 0, 0
57
+ local function append(text)
58
+ if used + #text > limit then error("report_byte_limit", 0) end
59
+ used = used + #text
60
+ parts[#parts + 1] = text
61
+ end
62
+ local function quoted(text)
63
+ if #text > limit - used then error("report_byte_limit", 0) end
64
+ if not isUTF8(text) then error("report_invalid_utf8", 0) end
65
+ append("\"" .. string.gsub(text, '[%z\1-\31\\"]', escapeControl) .. "\"")
66
+ end
67
+ local encode
68
+ encode = function(child, depth)
69
+ rejectRestricted(child)
70
+ if depth > MAX_DEPTH then error("report_depth_limit", 0) end
71
+ local kind = type(child)
72
+ if kind == "nil" then append("null")
73
+ elseif kind == "boolean" then append(child and "true" or "false")
74
+ elseif kind == "string" then quoted(child)
75
+ elseif kind == "number" then
76
+ if child ~= child or child == math.huge or child == -math.huge then
77
+ error("report_nonfinite_number", 0)
78
+ end
79
+ if child % 1 == 0 and math.abs(child) <= 9007199254740991 then
80
+ append(string.format("%.0f", child))
81
+ else append(tostring(child)) end
82
+ elseif kind == "table" then
83
+ if getmetatable(child) then error("report_metatable", 0) end
84
+ if seen[child] then error("report_cycle", 0) end
85
+ seen[child] = true
86
+ local keys, count, highest, array = {}, 0, 0, true
87
+ for key in pairs(child) do
88
+ rejectRestricted(key)
89
+ count = count + 1
90
+ entries = entries + 1
91
+ if entries > MAX_ENTRIES then error("report_entry_limit", 0) end
92
+ keys[count] = key
93
+ if type(key) ~= "number" or key < 1 or key % 1 ~= 0 then
94
+ array = false
95
+ elseif key > highest then highest = key end
96
+ end
97
+ if array and count > 0 and highest == count then
98
+ append("[")
99
+ for index = 1, count do
100
+ if index > 1 then append(",") end
101
+ encode(child[index], depth + 1)
102
+ end
103
+ append("]")
104
+ else
105
+ for _, key in ipairs(keys) do
106
+ if type(key) ~= "string" then error("report_nonstring_key", 0) end
107
+ end
108
+ table.sort(keys)
109
+ append("{")
110
+ for index, key in ipairs(keys) do
111
+ if index > 1 then append(",") end
112
+ quoted(key)
113
+ append(":")
114
+ encode(child[key], depth + 1)
115
+ end
116
+ append("}")
117
+ end
118
+ seen[child] = nil
119
+ else error("report_unsupported_value", 0) end
120
+ end
121
+ encode(value, 0)
122
+ return table.concat(parts)
123
+ end
124
+
125
+ local function digestBytes(text)
126
+ rejectRestricted(text)
127
+ if type(text) ~= "string" then return nil, "checksum_requires_bytes" end
128
+ if #text > MAX_REPORT_BYTES then return nil, "checksum_byte_limit" end
129
+ local low, high, offset = 1, 0, 1
130
+ while offset <= #text do
131
+ local last = math.min(offset + 5551, #text)
132
+ for index = offset, last do
133
+ low = low + string.byte(text, index)
134
+ high = high + low
135
+ end
136
+ low, high = low % 65521, high % 65521
137
+ offset = last + 1
138
+ end
139
+ return string.format("%04x%04x", high, low)
140
+ end
141
+
142
+ ns.CaptureWriter = {
143
+ Encode = function(value, limit)
144
+ if issecretvalue and issecretvalue(limit) then return nil, "report_invalid_budget" end
145
+ limit = limit or MAX_REPORT_BYTES
146
+ if type(limit) ~= "number" or limit < 1 or limit > MAX_REPORT_BYTES or limit % 1 ~= 0 then
147
+ return nil, "report_invalid_budget"
148
+ end
149
+ local ok, result = pcall(encodeDocument, value, limit)
150
+ if not ok then return nil, result end
151
+ return result
152
+ end,
153
+ DigestBytes = digestBytes,
154
+ }
@@ -0,0 +1,3 @@
1
+ local _, ns = ...
2
+ ns.ProbeDefinitions = {schema="lycheedev.queue.v1",entries={
3
+ }}
@@ -0,0 +1,127 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ -- Identity markers answer "who is in this window" for one host trigger. They
4
+ -- bind no session, write no SavedVariables, and grant no input authority. The
5
+ -- module creates nothing until Trigger is called.
6
+ local pending
7
+ local focusEvent = "ChatFrame.OnEditBoxFocusLost"
8
+
9
+ local function restricted(value)
10
+ return issecretvalue and issecretvalue(value)
11
+ end
12
+
13
+ local function validNonce(nonce)
14
+ return not restricted(nonce) and type(nonce) == "string"
15
+ and #nonce == 32 and string.match(nonce, "^[0-9a-f]+$") ~= nil
16
+ end
17
+
18
+ local function cancelWait()
19
+ local watch = pending
20
+ pending = nil
21
+ if watch then watch.registry:UnregisterCallback(focusEvent, watch) end
22
+ end
23
+
24
+ -- A request-scoped operation in flight owns this window's display. Scanning
25
+ -- must never clobber another agent's receipt, so uncertainty fails closed.
26
+ local function idle()
27
+ if type(ns.ProbeQueue) == "table" and type(ns.ProbeQueue.Busy) == "function" then
28
+ local busy, reason = ns.ProbeQueue.Busy()
29
+ if busy == nil then return nil, reason end
30
+ if busy then return nil, "identity_busy" end
31
+ end
32
+ if type(ns.Reentry) == "table" and type(ns.Reentry.Busy) == "function" then
33
+ local busy, reason = ns.Reentry.Busy()
34
+ if busy == nil then return nil, reason end
35
+ if busy then return nil, "identity_busy" end
36
+ end
37
+ return true
38
+ end
39
+
40
+ local function observe(probeNonce)
41
+ local build, buildFailure = ns.Platform.ObserveBuild()
42
+ if not build then return nil, buildFailure end
43
+ local actor, actorFailure = ns.Platform.ObserveActor()
44
+ local actorState = "ok"
45
+ if not actor then
46
+ if actorFailure == "actor_restricted_identity" then
47
+ actorState = "actor_restricted"
48
+ else
49
+ actorState = "no_actor"
50
+ end
51
+ end
52
+ local inputReady, inputReason = true, nil
53
+ if type(ns.Platform.ObserveInputState) == "function" then
54
+ local eligible, reason = ns.Platform.ObserveInputState()
55
+ if eligible == true then
56
+ inputReady = true
57
+ else
58
+ inputReady = false
59
+ if type(reason) == "string" and #reason > 0 and not restricted(reason) then
60
+ inputReason = reason
61
+ else
62
+ inputReason = "input_observation_unavailable"
63
+ end
64
+ end
65
+ else
66
+ inputReady = false
67
+ inputReason = "input_observation_unavailable"
68
+ end
69
+ local marker = {
70
+ schema = "lycheedev.signal.v1", release = ns.Release, kind = "identity",
71
+ probeNonce = probeNonce, actorState = actorState,
72
+ sessionNonce = "", requestId = "",
73
+ product = build.product, build = build.build,
74
+ sequence = 0, inputReady = inputReady,
75
+ }
76
+ if inputReason then marker.inputReason = inputReason end
77
+ if actorState == "ok" then
78
+ marker.character = actor.character
79
+ marker.realm = actor.realm
80
+ marker.guid = actor.guid
81
+ end
82
+ return ns.CaptureWriter.Encode(marker, 4096)
83
+ end
84
+
85
+ ns.Identity = {
86
+ CancelWait = cancelWait,
87
+ -- Returns the encoded identity receipt; the caller displays it. Echoing the
88
+ -- host probe nonce correlates exactly one trigger with one receipt.
89
+ Trigger = function(nonce)
90
+ if not validNonce(nonce) then return nil, "identity_invalid_nonce" end
91
+ local ready, reason = idle()
92
+ if not ready then return nil, reason end
93
+ cancelWait()
94
+ return observe(nonce)
95
+ end,
96
+ -- A fresh observation for the same trigger, used to replace the first
97
+ -- display once keyboard focus has been released.
98
+ Refresh = function(nonce)
99
+ if not validNonce(nonce) then return nil, "identity_invalid_nonce" end
100
+ local ready, reason = idle()
101
+ if not ready then return nil, reason end
102
+ return observe(nonce)
103
+ end,
104
+ -- One request-scoped callback, never a timer or permanent focus listener.
105
+ -- It only prompts a fresh observation; it proves nothing by itself.
106
+ WhenInputReady = function(callback)
107
+ if type(callback) ~= "function" then return nil, "input_invalid_callback" end
108
+ if pending then return nil, "input_wait_busy" end
109
+ if type(ns.Platform.ObserveInputState) ~= "function" then return nil, "input_observation_unavailable" end
110
+ local eligible, reason = ns.Platform.ObserveInputState()
111
+ if eligible then callback(true); return true end
112
+ if reason ~= "input_keyboard_focus" then return nil, reason or "input_observation_unavailable" end
113
+ if type(EventRegistry) ~= "table" or type(EventRegistry.RegisterCallback) ~= "function"
114
+ or type(EventRegistry.UnregisterCallback) ~= "function" then
115
+ return nil, "input_events_unavailable"
116
+ end
117
+ local watch = { registry = EventRegistry }
118
+ pending = watch
119
+ watch.registry:RegisterCallback(focusEvent, function()
120
+ if pending ~= watch then return end
121
+ cancelWait()
122
+ local now, observeFailure = ns.Platform.ObserveInputState()
123
+ callback(now == true, observeFailure)
124
+ end, watch)
125
+ return true
126
+ end,
127
+ }
@@ -27,18 +27,15 @@
27
27
  -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
28
  -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
 
30
- -- Lychee Dev adaptation of luaqrcode (upstream: https://github.com/speedata/luaqrcode).
31
- -- Changes from the reference copy: the encoder is built lazily inside
32
- -- BuildEncoder() so loading this file stays allocation-free (the upstream load
33
- -- constructs a 256x256 xor lookup table immediately), the test-mode and global
34
- -- assignment blocks were removed, and the API is exposed as ns.AutomationQR
35
- -- instead of a global. Encoding behavior is unchanged.
30
+ -- Toolkit adaptation of luaqrcode; upstream algorithm and BSD notice retained.
31
+ -- Codec tables initialize on first use. Byte XOR uses a 16x16 nibble table.
32
+ -- The private interface accepts bounded receipt bytes and fixed M correction.
36
33
 
37
34
  local ADDON_NAME, ns = ...
38
35
 
39
36
  local encode
40
37
 
41
- local function BuildEncoder()
38
+ local function createCodec()
42
39
 
43
40
 
44
41
  --- Overall workflow
@@ -69,11 +66,7 @@ local concat = table.concat
69
66
 
70
67
  local xor_lookup = {}
71
68
  do
72
- -- Build a fast xor helper that stays compatible across Lua versions.
73
- -- We precompute a 256x256 lookup table once at load time using a portable
74
- -- arithmetic xor; the hot path is then a constant-time table lookup without
75
- -- requiring native bitwise operators or external bit libraries.
76
- -- Slow but portable xor used only while populating the lookup table if no native op exists.
69
+ -- Portable nibble XOR, initialized only on first encoding.
77
70
  local function slow_xor(a,b)
78
71
  local result = 0
79
72
  local bitval = 1
@@ -88,16 +81,20 @@ do
88
81
  return result
89
82
  end
90
83
 
91
- -- Always build a 256x256 table once at load time; avoids any reliance on bitwise operators.
92
- for i=0,255 do
84
+ -- Two nibble lookups replace a 65,536-entry byte table.
85
+ for i=0,15 do
93
86
  local row = {}
94
- for j=0,255 do
87
+ for j=0,15 do
95
88
  row[j] = slow_xor(i,j)
96
89
  end
97
90
  xor_lookup[i] = row
98
91
  end
99
92
  end
100
93
 
94
+ local function xorByte(a,b)
95
+ return xor_lookup[a % 16][b % 16] + 16 * xor_lookup[floor(a / 16)][floor(b / 16)]
96
+ end
97
+
101
98
  local decToHexTable={
102
99
  ["0"]="0000",["1"]="0001",["2"]="0010",["3"]="0011",
103
100
  ["4"]="0100",["5"]="0101",["6"]="0110",["7"]="0111",
@@ -512,7 +509,7 @@ local function calculate_error_correction(data,num_ec_codewords)
512
509
  end
513
510
 
514
511
  for i=highest_exponent,0,-1 do
515
- mp_int[i] = xor_lookup[alpha_int[gp_alpha[i]]][mp_int[i]]
512
+ mp_int[i] = xorByte(alpha_int[gp_alpha[i]],mp_int[i])
516
513
  end
517
514
  -- remove leading 0's
518
515
  for i=highest_exponent,num_ec_codewords,-1 do
@@ -1159,18 +1156,14 @@ end
1159
1156
  return qrcode
1160
1157
  end
1161
1158
 
1162
- ns.AutomationQR = ns.AutomationQR or {}
1159
+ ns.MatrixSymbol = {
1160
+ Encode = function(text)
1161
+ if (issecretvalue and issecretvalue(text)) or type(text) ~= "string"
1162
+ or #text == 0 or #text > 2048 then return nil, "symbol_invalid_payload" end
1163
+ if not encode then encode = createCodec() end
1164
+ local called, ok, matrix = pcall(encode, text, 2)
1165
+ if not called or not ok then return nil, "symbol_encoding_failed" end
1166
+ return matrix
1167
+ end,
1168
+ }
1163
1169
 
1164
- function ns.AutomationQR.Encode(text, ecLevel)
1165
- if type(text) ~= "string" or text == "" then
1166
- return nil, "empty payload"
1167
- end
1168
- if not encode then
1169
- encode = BuildEncoder()
1170
- end
1171
- local ok, matrix = encode(text, tonumber(ecLevel) or 2)
1172
- if not ok then
1173
- return nil, tostring(matrix)
1174
- end
1175
- return matrix
1176
- end
@@ -0,0 +1,136 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ local definitions = ns.ProbeDefinitions
4
+ ns.ProbeDefinitions = nil
5
+ local function restricted(value)
6
+ return issecretvalue and issecretvalue(value)
7
+ end
8
+ local function plain(value)
9
+ return not restricted(value) and type(value) == "table" and getmetatable(value) == nil
10
+ end
11
+ local function label(value)
12
+ return not restricted(value) and type(value) == "string" and #value > 0
13
+ and #value <= 128 and not string.find(value, "[%z\1-\31\127]")
14
+ end
15
+ local function hex(value, size)
16
+ return not restricted(value) and type(value) == "string" and #value == size
17
+ and string.match(value, "^[0-9a-f]+$") ~= nil
18
+ end
19
+ local fields = { release = true, sessionNonce = true, reloadNonce = true, character = true,
20
+ realm = true, guid = true, product = true, build = true, code = true,
21
+ codeSHA256 = true, codeAdler32 = true, codeBytes = true }
22
+ local function validate()
23
+ if not plain(definitions) or restricted(definitions.schema) or definitions.schema ~= "lycheedev.queue.v1"
24
+ or not plain(definitions.entries) then return nil, "queue_invalid_format" end
25
+ for field in pairs(definitions) do
26
+ if restricted(field) or (field ~= "schema" and field ~= "entries") then return nil, "queue_invalid_format" end
27
+ end
28
+ local count, bytes = 0, 0
29
+ for id, entry in pairs(definitions.entries) do
30
+ count = count + 1
31
+ if count > 16 then return nil, "queue_limit" end
32
+ if not label(id) or not string.match(id, "^[%w_%-]+$") or not plain(entry) then return nil, "queue_invalid_entry" end
33
+ for field in pairs(entry) do
34
+ if restricted(field) or not fields[field] then return nil, "queue_invalid_entry" end
35
+ end
36
+ for _, field in ipairs({ "release", "character", "realm", "guid", "product", "build" }) do
37
+ if not label(entry[field]) then return nil, "queue_invalid_identity" end
38
+ end
39
+ if not hex(entry.sessionNonce, 32) or not hex(entry.reloadNonce, 32)
40
+ or not hex(entry.codeSHA256, 64) or not hex(entry.codeAdler32, 8) then return nil, "queue_invalid_digest" end
41
+ if restricted(entry.code) or type(entry.code) ~= "string" or #entry.code == 0 or #entry.code > 256 * 1024
42
+ or string.byte(entry.code, 1) == 27 or string.find(entry.code, "%z")
43
+ or restricted(entry.codeBytes) or entry.codeBytes ~= #entry.code
44
+ or ns.CaptureWriter.DigestBytes(entry.code) ~= entry.codeAdler32 then return nil, "queue_code_mismatch" end
45
+ bytes = bytes + #entry.code
46
+ if bytes > 1024 * 1024 then return nil, "queue_limit" end
47
+ end
48
+ return true
49
+ end
50
+
51
+ local function selectEntry(requestId)
52
+ local session, failure = ns.Session.Current()
53
+ if not session then return nil, failure end
54
+ if not label(requestId) then return nil, "queue_invalid_request" end
55
+ local valid, reason = validate()
56
+ if not valid then return nil, reason end
57
+ local entry = definitions.entries[requestId]
58
+ if not entry then return nil, "queue_request_missing" end
59
+ local identity = ns.Startup.identity
60
+ if entry.release ~= ns.Release or entry.product ~= identity.product or entry.build ~= identity.build
61
+ or entry.character ~= session.character or entry.realm ~= session.realm or entry.guid ~= session.guid
62
+ or entry.sessionNonce ~= session.sessionNonce then return nil, "queue_identity_mismatch" end
63
+ return entry
64
+ end
65
+
66
+ ns.ProbeQueue = {
67
+ -- Registered entries mean a request-scoped operation still owns this
68
+ -- window's queue and display. Unreadable definitions fail closed.
69
+ Busy = function()
70
+ if definitions == nil then return false end
71
+ if not plain(definitions) or not plain(definitions.entries) then return nil, "queue_invalid_format" end
72
+ for _ in pairs(definitions.entries) do return true end
73
+ return false
74
+ end,
75
+ ReloadScope = function(requestId)
76
+ local entry, reason = selectEntry(requestId)
77
+ if not entry then return nil, reason end
78
+ return { requestId = requestId, sessionNonce = entry.sessionNonce, reloadNonce = entry.reloadNonce,
79
+ release = entry.release, product = entry.product, build = entry.build,
80
+ character = entry.character, realm = entry.realm, guid = entry.guid,
81
+ codeSHA256 = entry.codeSHA256, codeAdler32 = entry.codeAdler32, codeBytes = entry.codeBytes }
82
+ end,
83
+ VerifyRetired = function(requestId, nonce)
84
+ local session, failure = ns.Session.Current()
85
+ if not session then return nil, failure end
86
+ if not label(requestId) or not string.match(requestId, "^[%w_%-]+$") then
87
+ return nil, "queue_invalid_request"
88
+ end
89
+ if not hex(nonce, 32) then return nil, "queue_invalid_cleanup_nonce" end
90
+ local valid, reason = validate()
91
+ if not valid then return nil, reason end
92
+ if definitions.entries[requestId] ~= nil then return nil, "queue_request_retained" end
93
+ local receipt, reportFailure = ns.ReportStore.Read(requestId)
94
+ if receipt ~= nil then return nil, "report_still_retained" end
95
+ if reportFailure ~= "report_unavailable" then return nil, reportFailure end
96
+ local absent, probeFailure = ns.ProbeRunner.VerifyAbsent(requestId)
97
+ if not absent then return nil, probeFailure end
98
+ local identity, identityFailure = ns.Session.NextIdentity()
99
+ if not identity then return nil, identityFailure end
100
+ -- This observes loaded memory, never disk or host ownership. No report,
101
+ -- queue entry or executable is removed to manufacture a success receipt.
102
+ return ns.CaptureWriter.Encode({
103
+ schema = "lycheedev.signal.v1", release = ns.Release, kind = "cleared",
104
+ sessionNonce = identity.sessionNonce, requestId = requestId, cleanupNonce = nonce,
105
+ character = identity.character, realm = identity.realm, guid = identity.guid,
106
+ product = ns.Startup.identity.product, build = ns.Startup.identity.build,
107
+ sequence = identity.sequence, runtimeEpoch = identity.runtimeEpoch, inputReady = false,
108
+ }, 4096)
109
+ end,
110
+ Load = function(requestId)
111
+ local entry, reason = selectEntry(requestId)
112
+ if not entry then return nil, reason end
113
+ -- SHA-256 is checked by the host. The game checks actual code bytes and
114
+ -- Adler-32; neither a carried digest nor loading is execution permission.
115
+ return ns.ProbeRunner.Load(requestId, entry.code, entry.reloadNonce)
116
+ end,
117
+ Acknowledge = function(requestId, sequence)
118
+ local entry, reason = selectEntry(requestId)
119
+ if not entry then return nil, reason end
120
+ if restricted(sequence) or type(sequence) ~= "number" or sequence < 1
121
+ or sequence > 9007199254740991 or sequence % 1 ~= 0 then return nil, "report_invalid_sequence" end
122
+ local receipt, body = ns.ReportStore.Read(requestId)
123
+ if not receipt then return nil, body end
124
+ -- Reconstruct only the canonical receipt format generated by Commit.
125
+ -- The store compares its exact bytes before deletion, so neither an
126
+ -- arbitrary sequence nor changed code/body can authorize another report.
127
+ return ns.ReportStore.Acknowledge({
128
+ schema = "lycheedev.signal.v1", release = entry.release, kind = "reported",
129
+ sessionNonce = entry.sessionNonce, requestId = requestId,
130
+ character = entry.character, realm = entry.realm, sequence = sequence,
131
+ product = entry.product, build = entry.build, inputReady = false,
132
+ codeBytes = entry.codeBytes, codeAdler32 = entry.codeAdler32,
133
+ reportBytes = #body, reportAdler32 = ns.CaptureWriter.DigestBytes(body),
134
+ })
135
+ end,
136
+ }