larkin 0.5.18 → 0.5.20
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/CHANGELOG.md +6 -0
- package/README.md +2 -9
- package/dist/agent/agent-state-store.cjs +11 -6
- package/dist/agent/agent-state-store.mjs +12 -7
- package/dist/agent/config-cli-contract.cjs +1 -3
- package/dist/agent/config-cli-contract.mjs +1 -3
- package/dist/agent/transport-business-context.cjs +3 -0
- package/dist/agent/transport-business-context.mjs +3 -0
- package/dist/app/agent-cli.mjs +1 -18
- package/dist/app/agent-config.mjs +4 -33
- package/dist/app/cli.mjs +0 -1
- package/dist/app/dashboard.mjs +2 -3
- package/dist/app/lark-cli.mjs +4 -0
- package/dist/app/run.mjs +5 -1
- package/dist/dashboard/dashboard-config-controller.mjs +48 -28
- package/dist/dashboard/dashboard-lifecycle.cjs +29 -0
- package/dist/dashboard/dashboard-lifecycle.mjs +28 -0
- package/dist/dashboard/web/assets/dashboard.js +15 -15
- package/dist/feishu/host-processing-eye.cjs +54 -1
- package/dist/feishu/host-processing-eye.mjs +48 -0
- package/dist/feishu/host-shell.cjs +23 -14
- package/dist/feishu/host-shell.mjs +25 -16
- package/dist/feishu/message-policy.cjs +1 -0
- package/dist/feishu/message-policy.mjs +1 -0
- package/dist/platform/config.cjs +13 -84
- package/dist/platform/config.mjs +13 -82
- package/dist/runtime/runtime-host.cjs +3 -0
- package/dist/runtime/runtime-host.mjs +3 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { acquireProcessLock, readProcessState, terminateOwnedProcess, waitForProcessExit, } from "../platform/process-state.mjs";
|
|
5
5
|
import { processCommandToken } from "../app/internal-command.mjs";
|
|
6
|
+
import { exactMode } from "../platform/secure-metadata.mjs";
|
|
6
7
|
const PUBLISHED_RUNTIME_DIRS = ["dist", "assets"];
|
|
7
8
|
const RUNTIME_EXTENSIONS = new Set([".cjs", ".mjs", ".js", ".css", ".json", ".node", ".svg", ".wasm"]);
|
|
8
9
|
function publishedRuntimeFiles(root) {
|
|
@@ -30,6 +31,33 @@ function publishedRuntimeFiles(root) {
|
|
|
30
31
|
return files.sort((a, b) => a.localeCompare(b, "en"));
|
|
31
32
|
}
|
|
32
33
|
/** Same semver can contain a different local build, so hash every published shell runtime byte. */
|
|
34
|
+
/**
|
|
35
|
+
* The dashboard's CSRF capability, kept in an owned 0600 file so a page opened before a restart keeps working.
|
|
36
|
+
* A missing or unsafe file gets a new value; if it cannot be written, the value lasts for this process only.
|
|
37
|
+
*/
|
|
38
|
+
export function loadDashboardCapability(file) {
|
|
39
|
+
try {
|
|
40
|
+
const stat = fs.lstatSync(file);
|
|
41
|
+
const value = fs.readFileSync(file, "utf8").trim();
|
|
42
|
+
if (stat.isFile() && exactMode(stat, 0o600) && (typeof process.getuid !== "function" || stat.uid === process.getuid())
|
|
43
|
+
&& /^[A-Za-z0-9_-]{43}$/.test(value))
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
catch { /* missing or unreadable: issue a new one */ }
|
|
47
|
+
const value = crypto.randomBytes(32).toString("base64url");
|
|
48
|
+
const temporary = `${file}.${process.pid}.tmp`;
|
|
49
|
+
try {
|
|
50
|
+
fs.writeFileSync(temporary, `${value}\n`, { mode: 0o600, flag: "wx" });
|
|
51
|
+
fs.renameSync(temporary, file);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
try {
|
|
55
|
+
fs.unlinkSync(temporary);
|
|
56
|
+
}
|
|
57
|
+
catch { /* nothing was written */ }
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
33
61
|
export function dashboardBuildFingerprint(root) {
|
|
34
62
|
const hash = crypto.createHash("sha256");
|
|
35
63
|
for (const relative of publishedRuntimeFiles(root)) {
|