lycheedev 2.5.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lycheedev.mjs +39 -3
- package/bin/update.mjs +168 -0
- package/native/windows-amd64/lycheedev.exe +0 -0
- package/package.json +1 -1
- package/payload/addon/Bridge/ActivityView.lua +26 -12
- package/payload/addon/Bridge/InputProtection.lua +63 -0
- package/payload/addon/Bridge/InputState.lua +45 -0
- package/payload/addon/Bridge/MemoryProtocol.lua +31 -0
- package/payload/addon/Bridge/ProbeExecution.lua +147 -0
- package/payload/addon/Bridge/ReceiverBindings.lua +6 -0
- package/payload/addon/Bridge/SlotProtocol.lua +165 -0
- package/payload/addon/Bridge/SlotRuntime.lua +106 -0
- package/payload/addon/Bridge/StartupBeacon.lua +8 -11
- package/payload/addon/Core/Compat.lua +7 -0
- package/payload/addon/Core/Controls.lua +16 -0
- package/payload/addon/Core/Locale.lua +6 -4
- package/payload/addon/Core/Locale_enUS.lua +4 -2
- package/payload/addon/Core/Platform.lua +4 -2
- package/payload/addon/Core/Runtime.lua +17 -6
- package/payload/addon/Lychee Dev.toc +8 -2
- package/payload/addon/Modules/AutomationHistory.lua +119 -0
- package/payload/addon/Modules/AutomationView.lua +26 -6
- package/payload/addon/UI/Pages/About.lua +0 -3
- package/payload/addon/UI/Pages/Automation.lua +40 -27
- package/payload/addon/UI/Pages/Diagnostics.lua +2 -4
- package/payload/addon/UI/Pages/Object.lua +0 -1
- package/payload/addon/UI/Pages/Run.lua +2 -1
- package/payload/addon/UI/Pages/Trace.lua +0 -1
- package/payload/addon/UI/Theme.lua +3 -2
- package/payload/addon/UI/Widgets.lua +32 -22
- package/payload/addon/UI/Window.lua +3 -35
- package/payload/skill/SKILL.md +40 -60
- package/payload/skill/agents/openai.yaml +1 -1
- package/payload/skill/references/commands.md +22 -15
- package/payload/skill/references/error-diagnosis.md +7 -11
- package/payload/skill/references/installation.md +64 -13
- package/payload/skill/references/live-investigation.md +193 -252
- package/payload/skill/references/live-startup.md +62 -132
- package/release.json +97 -67
- package/payload/addon/UI/Pages/Settings.lua +0 -82
package/bin/lycheedev.mjs
CHANGED
|
@@ -43,14 +43,50 @@ export function launch(root, args, run = spawnSync) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (process.argv[1] && realpathSync(resolve(process.argv[1])) === fileURLToPath(import.meta.url)) {
|
|
46
|
+
let activeArgs = process.argv.slice(2);
|
|
46
47
|
try {
|
|
47
48
|
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
48
49
|
if (major < 22 || (major === 22 && minor < 14)) throw new Error('distribution.node_version: requires Node >=22.14.0');
|
|
49
|
-
const
|
|
50
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
51
|
+
let args = process.argv.slice(2);
|
|
52
|
+
// Common flags may precede the command. Normalize only those two shared
|
|
53
|
+
// flags; leave command admission and every other flag to the native parser.
|
|
54
|
+
let commandIndex = 0;
|
|
55
|
+
while (commandIndex < args.length) {
|
|
56
|
+
const flag = args[commandIndex];
|
|
57
|
+
if (flag === '--home' || flag === '--format') commandIndex += 2;
|
|
58
|
+
else if (flag.startsWith('--home=') || flag.startsWith('--format=')) commandIndex++;
|
|
59
|
+
else break;
|
|
60
|
+
}
|
|
61
|
+
if (args[commandIndex] === 'update') args = ['update', ...args.slice(0, commandIndex), ...args.slice(commandIndex + 1)];
|
|
62
|
+
activeArgs = args;
|
|
63
|
+
const managedUpdate = args[0] === 'update' && !args.some(arg => ['--help', '-h', '--plan', '--release'].includes(arg) || arg.startsWith('--release='));
|
|
64
|
+
let result;
|
|
65
|
+
if (managedUpdate) {
|
|
66
|
+
const { update } = await import('./update.mjs');
|
|
67
|
+
const formatIndex = args.indexOf('--format');
|
|
68
|
+
const format = args.find(arg => arg.startsWith('--format='))?.split('=')[1] ?? (formatIndex >= 0 ? args[formatIndex + 1] : 'text');
|
|
69
|
+
const forwarded = args.filter((arg, index) => arg !== '--format' && !arg.startsWith('--format=') && args[index - 1] !== '--format');
|
|
70
|
+
// Keep native argument validation authoritative, including output format.
|
|
71
|
+
if (!['json', 'jsonl', 'text'].includes(format) || args.filter(arg => arg === '--format' || arg.startsWith('--format=')).length > 1) throw Object.assign(new Error('update.invalid_format'), { exit: 2 });
|
|
72
|
+
result = update(root, forwarded, nativePath);
|
|
73
|
+
if (format === 'jsonl') {
|
|
74
|
+
process.stdout.write(`${JSON.stringify({ type: 'begin', schema: result.envelope.schema })}\n`);
|
|
75
|
+
if (result.envelope.ok) process.stdout.write(`${JSON.stringify({ type: 'record', result: result.envelope.result })}\n${JSON.stringify({ type: 'end', envelope: result.envelope })}\n`);
|
|
76
|
+
else process.stdout.write(`${JSON.stringify({ type: 'error', envelope: result.envelope })}\n`);
|
|
77
|
+
} else if (format === 'text' && result.envelope.ok) process.stdout.write(`${JSON.stringify(result.envelope.result, null, 2)}\n`);
|
|
78
|
+
else process.stdout.write(`${JSON.stringify(result.envelope, null, 2)}\n`);
|
|
79
|
+
} else result = launch(root, args);
|
|
50
80
|
if (result.signal) process.kill(process.pid, result.signal);
|
|
51
81
|
else process.exitCode = result.status;
|
|
52
82
|
} catch (error) {
|
|
53
|
-
|
|
54
|
-
|
|
83
|
+
const args = activeArgs;
|
|
84
|
+
if (args[0] === 'update' && (args.includes('json') || args.includes('--format=json') || args.includes('jsonl') || args.includes('--format=jsonl'))) {
|
|
85
|
+
const envelope = error.envelope ?? { schema: 'lycheedev.result.v1', ok: false, operationId: '', context: {}, result: { complete: false }, captures: [], warnings: [], error: { code: 'update.failed', message: error.message, stage: 'update', retryable: false } };
|
|
86
|
+
const jsonl = args.includes('jsonl') || args.includes('--format=jsonl');
|
|
87
|
+
if (jsonl) process.stdout.write(`${JSON.stringify({ type: 'begin', schema: envelope.schema })}\n${JSON.stringify({ type: 'error', envelope })}\n`);
|
|
88
|
+
else process.stdout.write(`${JSON.stringify(envelope)}\n`);
|
|
89
|
+
} else process.stderr.write(`lycheedev: ${error.message}\n`);
|
|
90
|
+
process.exitCode = error.exit || 3;
|
|
55
91
|
}
|
|
56
92
|
}
|
package/bin/update.mjs
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// npm owns replacement of the CLI package. Native delivery owns target identity,
|
|
2
|
+
// receipts and recoverable addon/skill replacement. No native process stays alive
|
|
3
|
+
// while npm replaces its executable (Windows denies replacing a running image).
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { createHash } from 'node:crypto';
|
|
6
|
+
import { existsSync, lstatSync, mkdirSync, openSync, closeSync, readFileSync, writeFileSync, renameSync, rmSync, realpathSync } from 'node:fs';
|
|
7
|
+
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
8
|
+
|
|
9
|
+
function readJSON(file) {
|
|
10
|
+
const info = lstatSync(file);
|
|
11
|
+
if (!info.isFile() || info.size > 1024 * 1024) throw new Error('update.invalid_state_file');
|
|
12
|
+
return JSON.parse(readFileSync(file, 'utf8'));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function npmEntry() {
|
|
16
|
+
for (const directory of [dirname(process.execPath), ...(process.env.PATH ?? '').split(delimiter)]) {
|
|
17
|
+
const path = join(directory, 'node_modules', 'npm', 'bin', 'npm-cli.js');
|
|
18
|
+
if (existsSync(path)) return path;
|
|
19
|
+
}
|
|
20
|
+
throw new Error('update.npm_missing: npm-cli.js was not found beside Node or a PATH entry');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function command(file, args, timeout = 600000) {
|
|
24
|
+
const result = spawnSync(file, args, { encoding: 'utf8', shell: false, windowsHide: true, timeout, maxBuffer: 16 * 1024 * 1024 });
|
|
25
|
+
if (result.error) throw result.error;
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function nativeResult(binary, args) {
|
|
30
|
+
const run = command(binary, args);
|
|
31
|
+
let envelope;
|
|
32
|
+
try { envelope = JSON.parse(run.stdout); } catch { throw new Error(`update.invalid_native_result: ${run.stderr.slice(0, 2000)}`); }
|
|
33
|
+
if (run.status !== 0 || !envelope.ok) {
|
|
34
|
+
const error = new Error(envelope.error?.message ?? 'update.native_failed');
|
|
35
|
+
error.envelope = envelope; error.exit = run.status || 5;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
return envelope;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function frozenTargets(plan) {
|
|
42
|
+
if (!Array.isArray(plan?.targets) || plan.targets.length > 64) throw new Error('update.invalid_targets');
|
|
43
|
+
return plan.targets.map(target => {
|
|
44
|
+
if (!['skill', 'addon'].includes(target.component) || typeof target.path !== 'string' || !target.path) throw new Error('update.invalid_target');
|
|
45
|
+
return { component: target.component, path: target.path };
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function takeLock(directory) {
|
|
50
|
+
const file = join(directory, 'lock.json');
|
|
51
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
52
|
+
try {
|
|
53
|
+
const descriptor = openSync(file, 'wx');
|
|
54
|
+
writeFileSync(descriptor, JSON.stringify({ pid: process.pid })); closeSync(descriptor);
|
|
55
|
+
return () => rmSync(file);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error.code !== 'EEXIST') throw error;
|
|
58
|
+
const owner = readJSON(file);
|
|
59
|
+
if (!Number.isSafeInteger(owner.pid) || owner.pid < 1) throw new Error('update.invalid_lock');
|
|
60
|
+
try { process.kill(owner.pid, 0); } catch (error) {
|
|
61
|
+
if (error.code === 'ESRCH') {
|
|
62
|
+
// Serialize stale reclamation separately. Two retriers must not remove
|
|
63
|
+
// each other's newly acquired owner file after observing one dead PID.
|
|
64
|
+
const reclaim = join(directory, 'reclaim.lock');
|
|
65
|
+
let descriptor;
|
|
66
|
+
try { descriptor = openSync(reclaim, 'wx'); } catch { throw new Error('update.busy: stale-lock recovery is already in progress'); }
|
|
67
|
+
try {
|
|
68
|
+
const current = readJSON(file);
|
|
69
|
+
if (current.pid !== owner.pid) throw new Error('update.busy: owner changed during recovery');
|
|
70
|
+
try { process.kill(current.pid, 0); throw new Error('update.busy'); } catch (error) {
|
|
71
|
+
if (error.code !== 'ESRCH') throw error;
|
|
72
|
+
}
|
|
73
|
+
rmSync(file);
|
|
74
|
+
} finally { closeSync(descriptor); rmSync(reclaim); }
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
throw new Error('update.busy: another updater owns this npm prefix');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
throw new Error('update.busy');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function update(root, args, nativePath) {
|
|
85
|
+
root = realpathSync(root);
|
|
86
|
+
const prefix = dirname(dirname(root));
|
|
87
|
+
if (root.toLowerCase() !== join(prefix, 'node_modules', 'lycheedev').toLowerCase() || !existsSync(join(prefix, 'lycheedev.cmd'))) {
|
|
88
|
+
throw new Error('update.global_install_required: use a global npm installation, or update --release for native payloads');
|
|
89
|
+
}
|
|
90
|
+
const npm = npmEntry();
|
|
91
|
+
// Validate arguments and all existing targets before downloads or npm writes.
|
|
92
|
+
const plan = nativeResult(nativePath(root), [...args, '--plan', '--format=json']);
|
|
93
|
+
const directory = join(prefix, '.lycheedev-update');
|
|
94
|
+
mkdirSync(directory, { recursive: true });
|
|
95
|
+
if (lstatSync(directory).isSymbolicLink() || realpathSync(directory).toLowerCase() !== resolve(directory).toLowerCase()) throw new Error('update.redirected_state');
|
|
96
|
+
const unlock = takeLock(directory);
|
|
97
|
+
const journal = join(directory, 'transaction.json');
|
|
98
|
+
const save = value => {
|
|
99
|
+
writeFileSync(`${journal}.next`, JSON.stringify(value));
|
|
100
|
+
renameSync(`${journal}.next`, journal);
|
|
101
|
+
};
|
|
102
|
+
const runNpm = flags => {
|
|
103
|
+
const output = command(process.execPath, [npm, ...flags]);
|
|
104
|
+
if (output.status !== 0) throw new Error(`update.npm_failed: ${output.stderr.slice(-4000)}`);
|
|
105
|
+
return output;
|
|
106
|
+
};
|
|
107
|
+
let transaction;
|
|
108
|
+
try {
|
|
109
|
+
if (existsSync(journal)) {
|
|
110
|
+
transaction = readJSON(journal);
|
|
111
|
+
if (transaction.schema !== 'lycheedev.npm-update.v1' || transaction.prefix !== prefix || JSON.stringify(transaction.args) !== JSON.stringify(args)) {
|
|
112
|
+
throw new Error('update.pending_conflict: retry the original update arguments before selecting other targets');
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
process.stderr.write('lycheedev: preparing the latest release in an isolated directory\n');
|
|
116
|
+
const packed = JSON.parse(runNpm(['pack', 'lycheedev@latest', '--ignore-scripts', '--json', '--pack-destination', directory]).stdout);
|
|
117
|
+
const entry = packed[0];
|
|
118
|
+
if (packed.length !== 1 || entry.name !== 'lycheedev' || !/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/.test(entry.version) || entry.filename !== `lycheedev-${entry.version}.tgz`) throw new Error('update.invalid_package');
|
|
119
|
+
transaction = { schema: 'lycheedev.npm-update.v1', prefix, args, version: entry.version, integrity: entry.integrity, targets: plan.result.targets };
|
|
120
|
+
save(transaction);
|
|
121
|
+
}
|
|
122
|
+
if (!/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/.test(transaction.version)) throw new Error('update.invalid_version');
|
|
123
|
+
const tarball = join(directory, `lycheedev-${transaction.version}.tgz`);
|
|
124
|
+
const tarInfo = lstatSync(tarball);
|
|
125
|
+
if (!tarInfo.isFile() || tarInfo.size > 512 * 1024 * 1024) throw new Error('update.package_size');
|
|
126
|
+
const integrity = `sha512-${createHash('sha512').update(readFileSync(tarball)).digest('base64')}`;
|
|
127
|
+
if (integrity !== transaction.integrity) throw new Error('update.package_integrity');
|
|
128
|
+
const staging = join(directory, 'staging');
|
|
129
|
+
runNpm(['install', '--prefix', staging, '--ignore-scripts', '--no-audit', '--no-fund', '--package-lock=false', tarball]);
|
|
130
|
+
const stagedRoot = join(staging, 'node_modules', 'lycheedev');
|
|
131
|
+
const stagedPackage = JSON.parse(readFileSync(join(stagedRoot, 'package.json'), 'utf8'));
|
|
132
|
+
if (stagedPackage.version !== transaction.version || stagedPackage.name !== 'lycheedev') throw new Error('update.version_mismatch');
|
|
133
|
+
const selected = frozenTargets({ targets: transaction.targets });
|
|
134
|
+
const targetFile = join(directory, 'targets.json');
|
|
135
|
+
writeFileSync(targetFile, JSON.stringify(selected));
|
|
136
|
+
// Preserve only --home from the validated original args; target discovery is
|
|
137
|
+
// frozen in the journal, output rendering belongs to this launcher.
|
|
138
|
+
const home = [];
|
|
139
|
+
for (let i = 1; i < args.length; i++) {
|
|
140
|
+
if (args[i] === '--home') home.push('--home', args[++i]);
|
|
141
|
+
else if (args[i].startsWith('--home=')) home.push(args[i]);
|
|
142
|
+
}
|
|
143
|
+
const nativeArgs = ['update', '--file', targetFile, ...home, '--format=json'];
|
|
144
|
+
nativeResult(nativePath(stagedRoot), [...nativeArgs, '--release', stagedRoot, '--plan']);
|
|
145
|
+
process.stderr.write(`lycheedev: installing ${transaction.version} and synchronizing ${transaction.targets.length} target(s)\n`);
|
|
146
|
+
runNpm(['install', '--global', '--prefix', prefix, '--ignore-scripts', '--no-audit', '--no-fund', tarball]);
|
|
147
|
+
const installed = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
148
|
+
if (installed.version !== transaction.version) throw new Error('update.installed_version_mismatch');
|
|
149
|
+
const outcome = nativeResult(nativePath(root), [...nativeArgs, '--release', root]);
|
|
150
|
+
outcome.result.cli = { version: transaction.version, state: 'current', prefix };
|
|
151
|
+
// Remove only the updater-owned staging and pinned archive after native
|
|
152
|
+
// verification. A failure retains the exact release and targets for retry.
|
|
153
|
+
// Commit success first: a cache deletion failure must not leave a journal
|
|
154
|
+
// pointing at a tarball which has already been removed.
|
|
155
|
+
rmSync(journal);
|
|
156
|
+
try {
|
|
157
|
+
if (realpathSync(staging).toLowerCase() !== resolve(staging).toLowerCase()) throw new Error('redirected staging directory');
|
|
158
|
+
rmSync(staging, { recursive: true, force: true });
|
|
159
|
+
rmSync(tarball);
|
|
160
|
+
rmSync(targetFile);
|
|
161
|
+
} catch (error) { outcome.warnings.push(`Update completed; temporary download cleanup needs attention at ${directory}: ${error.message}`); }
|
|
162
|
+
return { envelope: outcome, status: 0 };
|
|
163
|
+
} catch (error) {
|
|
164
|
+
const envelope = error.envelope ?? { schema: 'lycheedev.result.v1', ok: false, operationId: '', context: {}, result: { complete: false }, captures: [], warnings: [], error: { code: 'update.failed', message: error.message, stage: 'update', retryable: true } };
|
|
165
|
+
envelope.context.updateRecovery = journal;
|
|
166
|
+
return { envelope, status: error.exit || 5 };
|
|
167
|
+
} finally { unlock(); }
|
|
168
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,14 +2,17 @@ local _, ns = ...
|
|
|
2
2
|
|
|
3
3
|
-- Presentation has no input authority. The receiver owns the short input
|
|
4
4
|
-- shield; this independent, click-through companion owns only task feedback.
|
|
5
|
-
local frame, receiving, requestId, startedAt, failed
|
|
5
|
+
local frame, receiving, requestId, startedAt, failed, collecting, collectionTimer
|
|
6
|
+
local function clearTimer()
|
|
7
|
+
if collectionTimer then collectionTimer:Cancel();collectionTimer=nil end
|
|
8
|
+
end
|
|
6
9
|
local function create()
|
|
7
10
|
frame = CreateFrame("Frame", nil, UIParent)
|
|
8
11
|
frame:Hide()
|
|
9
|
-
frame:SetSize(120,
|
|
12
|
+
frame:SetSize(120, 120)
|
|
10
13
|
frame:SetFrameStrata("DIALOG")
|
|
11
14
|
frame:EnableMouse(false)
|
|
12
|
-
frame:SetPoint("TOPLEFT", UIParent, "TOPLEFT",
|
|
15
|
+
frame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 8, -8)
|
|
13
16
|
local anchor = CreateFrame("Frame", nil, frame)
|
|
14
17
|
anchor:SetSize(96, 96)
|
|
15
18
|
anchor:SetPoint("TOP", frame, "TOP", 0, 0)
|
|
@@ -19,13 +22,11 @@ local function create()
|
|
|
19
22
|
frame.logo:SetTexture(ns.Widgets.LOGO_TEXTURE)
|
|
20
23
|
frame.logo:SetTexCoord(0, 1, 0, 1)
|
|
21
24
|
frame.label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
|
|
22
|
-
ns.Theme.SetFont(frame.label,
|
|
25
|
+
ns.Theme.SetFont(frame.label, 14, ns.Theme.text)
|
|
23
26
|
frame.label:SetPoint("TOP", anchor, "BOTTOM", 0, 0)
|
|
24
27
|
frame:SetScript("OnHide", function(self) self:SetScript("OnUpdate", nil) end)
|
|
25
28
|
end
|
|
26
|
-
local function anchor()
|
|
27
|
-
if frame and not failed then ns.ReceiptView.AnchorCompanion(frame) end
|
|
28
|
-
end
|
|
29
|
+
local function anchor() end -- Position belongs to this view, never a receipt.
|
|
29
30
|
local function render()
|
|
30
31
|
if not receiving and not requestId then
|
|
31
32
|
if frame then frame:SetScript("OnUpdate", nil); frame:Hide() end
|
|
@@ -34,7 +35,7 @@ local function render()
|
|
|
34
35
|
end
|
|
35
36
|
if not frame then create() end
|
|
36
37
|
startedAt = startedAt or GetTime()
|
|
37
|
-
frame.label:SetText(receiving and ns.L.ACTIVITY_CONNECTING or ns.L.ACTIVITY_PROBE)
|
|
38
|
+
frame.label:SetText(receiving and ns.L.ACTIVITY_CONNECTING or collecting and ns.L.ACTIVITY_COLLECTING or ns.L.ACTIVITY_PROBE)
|
|
38
39
|
anchor()
|
|
39
40
|
local current = ns.Persistence.Current()
|
|
40
41
|
local reduced = current and current.options and current.options.reducedMotion == true
|
|
@@ -51,6 +52,7 @@ local function update()
|
|
|
51
52
|
-- Cosmetic failure cannot interrupt execution or retain an input
|
|
52
53
|
-- shield. Fence repeated construction attempts for this runtime.
|
|
53
54
|
failed = true
|
|
55
|
+
clearTimer()
|
|
54
56
|
if frame then
|
|
55
57
|
if frame.SetScript then pcall(frame.SetScript,frame,"OnUpdate",nil) end
|
|
56
58
|
if frame.Hide then pcall(frame.Hide,frame) end
|
|
@@ -59,12 +61,24 @@ local function update()
|
|
|
59
61
|
end
|
|
60
62
|
ns.ActivityView = {
|
|
61
63
|
Receiving = function(value) receiving = value == true; update() end,
|
|
62
|
-
Begin = function(id) requestId = id; update() end,
|
|
64
|
+
Begin = function(id) clearTimer();collecting=false;requestId = id; update() end,
|
|
65
|
+
Collecting = function(id)
|
|
66
|
+
clearTimer();requestId=id;collecting=true;update()
|
|
67
|
+
if C_Timer and C_Timer.NewTimer then collectionTimer=C_Timer.NewTimer(20,function()
|
|
68
|
+
collectionTimer=nil
|
|
69
|
+
if requestId~=id or not collecting then return end
|
|
70
|
+
if frame then frame:SetScript("OnUpdate",nil) end
|
|
71
|
+
collectionTimer=C_Timer.NewTimer(5,function()
|
|
72
|
+
collectionTimer=nil
|
|
73
|
+
if requestId==id and collecting then requestId=nil;collecting=false;update() end
|
|
74
|
+
end)
|
|
75
|
+
end) end
|
|
76
|
+
end,
|
|
63
77
|
Finish = function(id)
|
|
64
|
-
if requestId == id then requestId = nil; update() end
|
|
78
|
+
if requestId == id then clearTimer();requestId = nil;collecting=false; update() end
|
|
65
79
|
end,
|
|
66
|
-
Stop = function() receiving, requestId = false, nil; update() end,
|
|
80
|
+
Stop = function() clearTimer();receiving, requestId, collecting = false, nil, false; update() end,
|
|
67
81
|
Refresh = update,
|
|
68
82
|
Anchor = anchor,
|
|
69
|
-
Current = function() return receiving and "connecting" or requestId and "probe" or nil, requestId end,
|
|
83
|
+
Current = function() return receiving and "connecting" or collecting and "collecting" or requestId and "probe" or nil, requestId end,
|
|
70
84
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
local _, ns = ...
|
|
2
|
+
|
|
3
|
+
-- One short, runtime-local lease. No UI or event work until explicitly acquired.
|
|
4
|
+
-- This shields this game's UI; it is not a system-wide keyboard/mouse lock.
|
|
5
|
+
local frame, active, unavailable
|
|
6
|
+
local function release(token, reason)
|
|
7
|
+
if not active or active ~= token then return false end
|
|
8
|
+
local prior=active;active=nil
|
|
9
|
+
if prior.timer then pcall(prior.timer.Cancel,prior.timer) end
|
|
10
|
+
frame:Hide();frame:UnregisterAllEvents();frame:SetScript("OnEvent",nil)
|
|
11
|
+
if ns.ActivityView then pcall(ns.ActivityView.Receiving,false) end
|
|
12
|
+
if reason and prior.interrupted then prior.interrupted(reason) end
|
|
13
|
+
return true
|
|
14
|
+
end
|
|
15
|
+
ns.InputProtection={
|
|
16
|
+
Acquire=function(seconds, interrupted, transport)
|
|
17
|
+
if unavailable then return nil,"input_protection_unavailable" end
|
|
18
|
+
if active then return nil,"input_protection_busy" end
|
|
19
|
+
if (issecretvalue and issecretvalue(seconds)) or type(seconds)~="number"
|
|
20
|
+
or seconds~=seconds or seconds<=0 or seconds==math.huge then return nil,"input_protection_invalid_budget" end
|
|
21
|
+
if ns.Platform.ObserveInputState(transport==true)~=true then return nil,"input_protection_not_ready" end
|
|
22
|
+
if not C_Timer or type(C_Timer.NewTimer)~="function" then return nil,"input_protection_timer_unavailable" end
|
|
23
|
+
if not frame then
|
|
24
|
+
local candidate
|
|
25
|
+
local created=pcall(function()
|
|
26
|
+
candidate=CreateFrame("Frame",nil,UIParent)
|
|
27
|
+
candidate:Hide();candidate:SetAllPoints(UIParent);candidate:SetFrameStrata("TOOLTIP")
|
|
28
|
+
candidate:EnableMouse(true);candidate:EnableMouseWheel(true);candidate:EnableKeyboard(true)
|
|
29
|
+
candidate:SetScript("OnKeyDown",function(self,key)
|
|
30
|
+
local chord=ns.Compat.ReceiverChord(key)
|
|
31
|
+
local token=active
|
|
32
|
+
self:SetPropagateKeyboardInput(false)
|
|
33
|
+
if chord=="ALT-CTRL-[" then release(token,"input_protection_cancelled");return end
|
|
34
|
+
if token and token.transport then
|
|
35
|
+
self:SetPropagateKeyboardInput(chord=="ALT-CTRL-F12" or chord=="ALT-CTRL-SHIFT-F12")
|
|
36
|
+
end
|
|
37
|
+
end)
|
|
38
|
+
end)
|
|
39
|
+
if not created then
|
|
40
|
+
unavailable=true
|
|
41
|
+
if candidate then pcall(candidate.Hide,candidate) end
|
|
42
|
+
return nil,"input_protection_unavailable"
|
|
43
|
+
end
|
|
44
|
+
frame=candidate
|
|
45
|
+
end
|
|
46
|
+
local token={interrupted=interrupted,transport=transport==true}
|
|
47
|
+
active=token
|
|
48
|
+
local ok=pcall(function()
|
|
49
|
+
token.timer=C_Timer.NewTimer(seconds,function()release(token,"input_protection_timeout")end)
|
|
50
|
+
assert(token.timer,"input_protection_timer_unavailable")
|
|
51
|
+
frame:RegisterEvent("PLAYER_REGEN_DISABLED");frame:RegisterEvent("PLAYER_LEAVING_WORLD")
|
|
52
|
+
frame:SetScript("OnEvent",function(_,event)release(token,event=="PLAYER_REGEN_DISABLED"
|
|
53
|
+
and "input_protection_combat" or "input_protection_world_changed")end)
|
|
54
|
+
frame:Show()
|
|
55
|
+
if ns.ActivityView then ns.ActivityView.Receiving(true) end
|
|
56
|
+
end)
|
|
57
|
+
if not ok then release(token);return nil,"input_protection_unavailable" end
|
|
58
|
+
return token
|
|
59
|
+
end,
|
|
60
|
+
Release=function(token)return release(token)end,
|
|
61
|
+
Cancel=function()return release(active,"input_protection_cancelled")end,
|
|
62
|
+
IsActive=function()return active~=nil end,
|
|
63
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
local _, ns = ...
|
|
2
|
+
|
|
3
|
+
-- Owner-approved native transport telemetry. One invisible sampler, no input
|
|
4
|
+
-- hooks or focus mutation. Explicit bridge-off removes all recurring work.
|
|
5
|
+
local frame, provider, record, last, sequence
|
|
6
|
+
local zero=string.rep("0",32)
|
|
7
|
+
local function sample()
|
|
8
|
+
local identity=provider and provider()
|
|
9
|
+
if not identity then record=nil;return end
|
|
10
|
+
local tick=ns.Compat.MonotonicSeconds()
|
|
11
|
+
if not tick then record=nil;return end
|
|
12
|
+
local ready,reason=ns.Platform.ObserveInputState()
|
|
13
|
+
sequence=sequence+1
|
|
14
|
+
if sequence>=4294967295 then ns.InputState.Stop();return end
|
|
15
|
+
identity.schema="lycheedev.input.v1"
|
|
16
|
+
identity.sampleMillis=math.floor(tick*1000)
|
|
17
|
+
identity.inputBlocked=ready~=true
|
|
18
|
+
identity.reason=reason or ""
|
|
19
|
+
local text=ns.CaptureWriter.Encode(identity,2048)
|
|
20
|
+
if not text then record=nil;return end
|
|
21
|
+
record=ns.MemoryProtocol.Encode(identity.runtime,identity.runtime,zero,5,1,sequence,text)
|
|
22
|
+
end
|
|
23
|
+
ns.InputState={
|
|
24
|
+
Start=function(observe)
|
|
25
|
+
provider=observe
|
|
26
|
+
if frame and frame:GetScript("OnUpdate") then return true end
|
|
27
|
+
sequence,last=sequence or 0,0
|
|
28
|
+
if not frame then frame=CreateFrame("Frame") end
|
|
29
|
+
frame:SetScript("OnUpdate",function(_,elapsed)
|
|
30
|
+
last=last+elapsed
|
|
31
|
+
if last<0.1 then return end
|
|
32
|
+
last=0
|
|
33
|
+
local ok=pcall(sample)
|
|
34
|
+
if not ok then record=nil end
|
|
35
|
+
end)
|
|
36
|
+
local ok=pcall(sample)
|
|
37
|
+
if not ok then record=nil end
|
|
38
|
+
return true
|
|
39
|
+
end,
|
|
40
|
+
Stop=function()
|
|
41
|
+
if frame then frame:SetScript("OnUpdate",nil) end
|
|
42
|
+
provider,record=nil,nil
|
|
43
|
+
end,
|
|
44
|
+
Snapshot=function()return record end,
|
|
45
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
local _, ns = ...
|
|
2
|
+
|
|
3
|
+
-- Immutable binary strings are retained by the transport. Finding one is not
|
|
4
|
+
-- publication proof: the host must request a fresh confirmation of live state.
|
|
5
|
+
local function u32(n)
|
|
6
|
+
return string.char(n%256,math.floor(n/256)%256,math.floor(n/65536)%256,math.floor(n/16777216)%256)
|
|
7
|
+
end
|
|
8
|
+
local function token(value)
|
|
9
|
+
return not (issecretvalue and issecretvalue(value)) and type(value)=="string"
|
|
10
|
+
and #value==32 and value:match("^[0-9a-f]+$")~=nil
|
|
11
|
+
end
|
|
12
|
+
local function raw(hex)
|
|
13
|
+
return (hex:gsub("..",function(pair)return string.char(tonumber(pair,16))end))
|
|
14
|
+
end
|
|
15
|
+
local function checksum(value)
|
|
16
|
+
return tonumber(ns.CaptureWriter.DigestBytes(value),16)
|
|
17
|
+
end
|
|
18
|
+
ns.MemoryProtocol = {
|
|
19
|
+
Token=token, Checksum=checksum,
|
|
20
|
+
Encode=function(nonce,runtime,ticket,kind,state,sequence,payload)
|
|
21
|
+
if not token(nonce) or not token(runtime) or not token(ticket)
|
|
22
|
+
or type(payload)~="string" or #payload>524288
|
|
23
|
+
or kind<1 or kind>5 or state<1 or state>255
|
|
24
|
+
or type(sequence)~="number" or sequence<0 or sequence>=4294967296 or sequence%1~=0 then
|
|
25
|
+
return nil,"memory_record_invalid"
|
|
26
|
+
end
|
|
27
|
+
local header="LYCMEM05"..raw(nonce)..raw(runtime)..raw(ticket)
|
|
28
|
+
..string.char(kind,state,0,0)..u32(sequence)..u32(#payload)..u32(checksum(payload))..u32(80)
|
|
29
|
+
return header..u32(checksum(header))..payload.."LYCEND05"..raw(nonce)..raw(runtime)
|
|
30
|
+
end,
|
|
31
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
local _, ns = ...
|
|
2
|
+
|
|
3
|
+
-- Runtime-local execution, independent of transport, display and persistence.
|
|
4
|
+
-- Async callbacks are bounded; Lua pcall is not a synchronous CPU sandbox.
|
|
5
|
+
ns.ProbeExecution={Run=function(fn,budget,done)
|
|
6
|
+
local live,async,depth=true,false,0
|
|
7
|
+
local started=ns.Compat.MonotonicSeconds()
|
|
8
|
+
local timer,pending
|
|
9
|
+
local cleanups,logs={},{}
|
|
10
|
+
local callbacks,logBytes=0,0
|
|
11
|
+
local protection,protectionUsed,guardFrame
|
|
12
|
+
local guards,events={},{}
|
|
13
|
+
local api={}
|
|
14
|
+
local function finish()
|
|
15
|
+
if not live or not pending or depth>0 then return end
|
|
16
|
+
live=false
|
|
17
|
+
local outcome=pending;pending=nil
|
|
18
|
+
if timer then pcall(timer.Cancel,timer);timer=nil end
|
|
19
|
+
local clean=true
|
|
20
|
+
-- Release our lease before user cleanup, even if that cleanup throws.
|
|
21
|
+
if protection then
|
|
22
|
+
if not pcall(ns.InputProtection.Release,protection) then clean=false end
|
|
23
|
+
protection=nil
|
|
24
|
+
end
|
|
25
|
+
if guardFrame then
|
|
26
|
+
if not pcall(function()guardFrame:UnregisterAllEvents();guardFrame:SetScript("OnEvent",nil)end) then clean=false end
|
|
27
|
+
end
|
|
28
|
+
for i=#cleanups,1,-1 do if not pcall(cleanups[i]) then clean=false end end
|
|
29
|
+
cleanups={}
|
|
30
|
+
done(outcome.ok,outcome.value,{resourcesReleased=clean,logs=logs})
|
|
31
|
+
end
|
|
32
|
+
local function settle(ok,value)
|
|
33
|
+
if not live then return nil,"probe_not_running" end
|
|
34
|
+
if not pending or not ok then pending={ok=ok,value=value} end
|
|
35
|
+
finish();return true
|
|
36
|
+
end
|
|
37
|
+
local function checkGuards()
|
|
38
|
+
for _,guard in ipairs(guards) do
|
|
39
|
+
local ok,value=pcall(guard.check)
|
|
40
|
+
if not ok or (issecretvalue and issecretvalue(value)) or value~=true then
|
|
41
|
+
settle(false,guard.reason);return nil,guard.reason
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
return true
|
|
45
|
+
end
|
|
46
|
+
function api:Guard(check, watchedEvents, reason)
|
|
47
|
+
if not live or pending or type(check)~="function" or #guards>=8
|
|
48
|
+
or (issecretvalue and issecretvalue(reason)) or type(reason)~="string" or #reason==0 or #reason>128
|
|
49
|
+
or type(watchedEvents)~="table" or getmetatable(watchedEvents) then return nil,"probe_invalid_guard" end
|
|
50
|
+
local newEvents={}
|
|
51
|
+
for i,event in ipairs(watchedEvents) do
|
|
52
|
+
if i>8 or (issecretvalue and issecretvalue(event)) or type(event)~="string"
|
|
53
|
+
or #event>80 or not event:match("^[A-Z][A-Z0-9_]+$") then return nil,"probe_invalid_guard_event" end
|
|
54
|
+
newEvents[event]=true
|
|
55
|
+
end
|
|
56
|
+
local count=0
|
|
57
|
+
for _ in pairs(events) do count=count+1 end
|
|
58
|
+
for event in pairs(newEvents) do if not events[event] then count=count+1 end end
|
|
59
|
+
if count>8 then return nil,"probe_guard_event_limit" end
|
|
60
|
+
guards[#guards+1]={check=check,reason=reason}
|
|
61
|
+
local ok,failure=checkGuards();if not ok then return nil,failure end
|
|
62
|
+
if next(newEvents) then
|
|
63
|
+
local registered=pcall(function()
|
|
64
|
+
if not guardFrame then
|
|
65
|
+
guardFrame=CreateFrame("Frame")
|
|
66
|
+
guardFrame:SetScript("OnEvent",function()if live and not pending then checkGuards() end end)
|
|
67
|
+
end
|
|
68
|
+
for event in pairs(newEvents) do guardFrame:RegisterEvent(event);events[event]=true end
|
|
69
|
+
end)
|
|
70
|
+
if not registered then settle(false,"probe_guard_event_unavailable");return nil,"probe_guard_event_unavailable" end
|
|
71
|
+
end
|
|
72
|
+
return true
|
|
73
|
+
end
|
|
74
|
+
function api:ProtectInput(seconds)
|
|
75
|
+
if not live or pending or protectionUsed then return nil,"probe_input_protection_used" end
|
|
76
|
+
if (issecretvalue and issecretvalue(seconds)) or type(seconds)~="number" or seconds~=seconds
|
|
77
|
+
or seconds<=0 or seconds==math.huge or not started then return nil,"probe_invalid_protection_budget" end
|
|
78
|
+
local remaining=budget-(ns.Compat.MonotonicSeconds()-started)
|
|
79
|
+
if seconds>remaining then return nil,"probe_budget_exhausted" end
|
|
80
|
+
local ok,reason=checkGuards();if not ok then return nil,reason end
|
|
81
|
+
if not ns.InputProtection then return nil,"probe_input_protection_unavailable" end
|
|
82
|
+
protection,reason=ns.InputProtection.Acquire(seconds,function(failure)
|
|
83
|
+
protection=nil;settle(false,failure)
|
|
84
|
+
end)
|
|
85
|
+
if not protection then return nil,reason end
|
|
86
|
+
protectionUsed=true;return true
|
|
87
|
+
end
|
|
88
|
+
function api:ReleaseInput()
|
|
89
|
+
if not protection then return false end
|
|
90
|
+
local token=protection;protection=nil
|
|
91
|
+
return ns.InputProtection.Release(token)
|
|
92
|
+
end
|
|
93
|
+
function api:IsInputProtected()return protection~=nil end
|
|
94
|
+
function api:Async(seconds)
|
|
95
|
+
if not live or async or not started or type(seconds)~="number" or seconds<1 or seconds>budget then return nil,"probe_invalid_async_budget" end
|
|
96
|
+
if type(C_Timer)~="table" or type(C_Timer.NewTimer)~="function" then return nil,"probe_async_unavailable" end
|
|
97
|
+
local remaining=seconds-(ns.Compat.MonotonicSeconds()-started)
|
|
98
|
+
if remaining<=0 then return nil,"probe_budget_exhausted" end
|
|
99
|
+
timer=C_Timer.NewTimer(remaining,function()settle(false,"probe_timeout")end)
|
|
100
|
+
if not timer then return nil,"probe_async_unavailable" end
|
|
101
|
+
async=true;return true
|
|
102
|
+
end
|
|
103
|
+
function api:Finish(value)
|
|
104
|
+
if not live then return nil,"probe_not_running" end
|
|
105
|
+
local valid,reason=checkGuards();if not valid then return nil,reason end
|
|
106
|
+
return settle(true,value)
|
|
107
|
+
end
|
|
108
|
+
function api:Fail(value)
|
|
109
|
+
if (issecretvalue and issecretvalue(value)) or type(value)~="string" or #value>4096 then value="probe_runtime_error" end
|
|
110
|
+
return settle(false,value)
|
|
111
|
+
end
|
|
112
|
+
function api:Callback(callback)
|
|
113
|
+
if not live or type(callback)~="function" or callbacks>=16 then return nil,"probe_callback_limit" end
|
|
114
|
+
callbacks=callbacks+1
|
|
115
|
+
return function(...)
|
|
116
|
+
if not live or pending then return nil,"probe_callback_inactive" end
|
|
117
|
+
local valid,reason=checkGuards();if not valid then return nil,reason end
|
|
118
|
+
depth=depth+1;local ok,result=pcall(callback,...);depth=depth-1
|
|
119
|
+
if not ok then api:Fail(result) else finish() end
|
|
120
|
+
return ok,result
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
function api:OnCleanup(callback)
|
|
124
|
+
if not live or type(callback)~="function" or #cleanups>=16 then return nil,"probe_cleanup_limit" end
|
|
125
|
+
cleanups[#cleanups+1]=callback;return true
|
|
126
|
+
end
|
|
127
|
+
function api:Log(...)
|
|
128
|
+
if not live or #logs>=100 or logBytes>=32768 then return nil,"probe_log_limit" end
|
|
129
|
+
local parts={}
|
|
130
|
+
for i=1,select("#",...) do
|
|
131
|
+
local value=select(i,...)
|
|
132
|
+
if issecretvalue and issecretvalue(value) then parts[i]="<secret>"
|
|
133
|
+
elseif type(value)=="string" or type(value)=="number" or type(value)=="boolean" then parts[i]=tostring(value)
|
|
134
|
+
else parts[i]="<unsupported>" end
|
|
135
|
+
end
|
|
136
|
+
local line=table.concat(parts," "):sub(1,32768-logBytes)
|
|
137
|
+
logs[#logs+1]=line;logBytes=logBytes+#line;return true
|
|
138
|
+
end
|
|
139
|
+
function api:IsCancelled()return not live end
|
|
140
|
+
depth=1;local ok,result=pcall(fn,api);depth=0
|
|
141
|
+
if not ok then api:Fail(result)
|
|
142
|
+
elseif pending then finish()
|
|
143
|
+
elseif not async then
|
|
144
|
+
local valid=checkGuards();if valid then settle(true,result) end
|
|
145
|
+
end
|
|
146
|
+
return api
|
|
147
|
+
end}
|
|
@@ -126,6 +126,7 @@ local function apply(profile)
|
|
|
126
126
|
return copy(valid)
|
|
127
127
|
end
|
|
128
128
|
local function stored()
|
|
129
|
+
if ns.SlotRuntime then return copy(defaults) end
|
|
129
130
|
local state, failure = ns.Persistence.Current()
|
|
130
131
|
if not state then return nil, failure end
|
|
131
132
|
local profile = state.options and state.options.receiverBindings
|
|
@@ -172,6 +173,7 @@ ns.ReceiverBindings = {
|
|
|
172
173
|
return key == terminal(effective[action])
|
|
173
174
|
end,
|
|
174
175
|
ConfigureProfile = function(profile)
|
|
176
|
+
if ns.SlotRuntime then return nil,"receiver_bindings_fixed" end
|
|
175
177
|
if ns.Receiver and ns.Receiver.IsActive and ns.Receiver.IsActive() then return nil,"receiver_active" end
|
|
176
178
|
if not owner then return nil,"receiver_bindings_unavailable" end
|
|
177
179
|
local state,failure=ns.Persistence.Current()
|
|
@@ -183,6 +185,7 @@ ns.ReceiverBindings = {
|
|
|
183
185
|
return copy(applied)
|
|
184
186
|
end,
|
|
185
187
|
Configure = function(action, chord)
|
|
188
|
+
if ns.SlotRuntime then return nil,"receiver_bindings_fixed" end
|
|
186
189
|
if action ~= "wake" and action ~= "submit" and action ~= "close" then return nil, "receiver_binding_action_invalid" end
|
|
187
190
|
if ns.Receiver and type(ns.Receiver.IsActive) == "function" and ns.Receiver.IsActive() then
|
|
188
191
|
return nil, "receiver_active"
|
|
@@ -223,6 +226,9 @@ ns.ReceiverBindings = {
|
|
|
223
226
|
if type(SetOverrideBindingClick) ~= "function" or type(CreateFrame) ~= "function" then
|
|
224
227
|
return nil, "receiver_bindings_unavailable"
|
|
225
228
|
end
|
|
229
|
+
if ns.SlotRuntime then
|
|
230
|
+
defaults = {wake="ALT-CTRL-F12",submit="ALT-CTRL-SHIFT-F12",close="ALT-CTRL-["}
|
|
231
|
+
end
|
|
226
232
|
handlers = callbacks
|
|
227
233
|
owner = CreateFrame("Frame", nil, UIParent)
|
|
228
234
|
local loggedIn = true
|