@rubytech/create-maxy 1.0.720 → 1.0.722
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/package.json +1 -1
- package/payload/platform/plugins/admin/mcp/dist/index.js +2 -3
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/admin/skills/plugin-management/SKILL.md +0 -1
- package/payload/platform/plugins/docs/PLUGIN.md +1 -1
- package/payload/platform/plugins/docs/references/settings.md +0 -13
- package/payload/platform/templates/account.json +0 -1
- package/payload/server/chunk-7ODDM7L4.js +12370 -0
- package/payload/server/chunk-FM5JMRED.js +12033 -0
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/assets/admin-GdSFnwBR.js +352 -0
- package/payload/server/public/index.html +1 -1
- package/payload/server/server.js +183 -218
- package/payload/server/public/assets/admin-yP0pMsyg.js +0 -352
package/payload/server/server.js
CHANGED
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
vncLog,
|
|
99
99
|
waitForExit,
|
|
100
100
|
writeChromiumWrapper
|
|
101
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-FM5JMRED.js";
|
|
102
102
|
|
|
103
103
|
// ../lib/graph-trash/dist/index.js
|
|
104
104
|
var require_dist = __commonJS({
|
|
@@ -597,8 +597,8 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
597
597
|
};
|
|
598
598
|
|
|
599
599
|
// server/index.ts
|
|
600
|
-
import { readFileSync as
|
|
601
|
-
import { resolve as
|
|
600
|
+
import { readFileSync as readFileSync16, existsSync as existsSync19, watchFile } from "fs";
|
|
601
|
+
import { resolve as resolve20, join as join10, basename as basename7 } from "path";
|
|
602
602
|
import { homedir as homedir2 } from "os";
|
|
603
603
|
|
|
604
604
|
// app/lib/agent-slug-pattern.ts
|
|
@@ -2683,7 +2683,7 @@ var credsSaveQueue = Promise.resolve();
|
|
|
2683
2683
|
async function drainCredsSaveQueue(timeoutMs = 5e3) {
|
|
2684
2684
|
console.error(`${TAG3} draining credential save queue\u2026`);
|
|
2685
2685
|
const timer2 = new Promise(
|
|
2686
|
-
(
|
|
2686
|
+
(resolve21) => setTimeout(() => resolve21("timeout"), timeoutMs)
|
|
2687
2687
|
);
|
|
2688
2688
|
const result = await Promise.race([
|
|
2689
2689
|
credsSaveQueue.then(() => "drained"),
|
|
@@ -2811,11 +2811,11 @@ async function createWaSocket(opts) {
|
|
|
2811
2811
|
return sock;
|
|
2812
2812
|
}
|
|
2813
2813
|
async function waitForConnection(sock) {
|
|
2814
|
-
return new Promise((
|
|
2814
|
+
return new Promise((resolve21, reject) => {
|
|
2815
2815
|
const handler = (update) => {
|
|
2816
2816
|
if (update.connection === "open") {
|
|
2817
2817
|
sock.ev.off("connection.update", handler);
|
|
2818
|
-
|
|
2818
|
+
resolve21();
|
|
2819
2819
|
}
|
|
2820
2820
|
if (update.connection === "close") {
|
|
2821
2821
|
sock.ev.off("connection.update", handler);
|
|
@@ -2929,14 +2929,14 @@ ${inspected}`;
|
|
|
2929
2929
|
return inspect2(err, INSPECT_OPTS2);
|
|
2930
2930
|
}
|
|
2931
2931
|
function withTimeout(label, promise, timeoutMs) {
|
|
2932
|
-
return new Promise((
|
|
2932
|
+
return new Promise((resolve21, reject) => {
|
|
2933
2933
|
const timer2 = setTimeout(() => {
|
|
2934
2934
|
reject(new Error(`${label} timed out after ${timeoutMs}ms`));
|
|
2935
2935
|
}, timeoutMs);
|
|
2936
2936
|
promise.then(
|
|
2937
2937
|
(value) => {
|
|
2938
2938
|
clearTimeout(timer2);
|
|
2939
|
-
|
|
2939
|
+
resolve21(value);
|
|
2940
2940
|
},
|
|
2941
2941
|
(err) => {
|
|
2942
2942
|
clearTimeout(timer2);
|
|
@@ -4150,11 +4150,11 @@ async function connectWithReconnect(conn) {
|
|
|
4150
4150
|
console.error(
|
|
4151
4151
|
`${TAG11} reconnecting account=${conn.accountId} in ${delay}ms (attempt ${decision.nextAttempts}/${maxAttempts})`
|
|
4152
4152
|
);
|
|
4153
|
-
await new Promise((
|
|
4154
|
-
const timer2 = setTimeout(
|
|
4153
|
+
await new Promise((resolve21) => {
|
|
4154
|
+
const timer2 = setTimeout(resolve21, delay);
|
|
4155
4155
|
conn.abortController.signal.addEventListener("abort", () => {
|
|
4156
4156
|
clearTimeout(timer2);
|
|
4157
|
-
|
|
4157
|
+
resolve21();
|
|
4158
4158
|
}, { once: true });
|
|
4159
4159
|
});
|
|
4160
4160
|
}
|
|
@@ -4162,16 +4162,16 @@ async function connectWithReconnect(conn) {
|
|
|
4162
4162
|
}
|
|
4163
4163
|
}
|
|
4164
4164
|
function waitForDisconnectEvent(conn) {
|
|
4165
|
-
return new Promise((
|
|
4165
|
+
return new Promise((resolve21) => {
|
|
4166
4166
|
if (!conn.sock) {
|
|
4167
|
-
|
|
4167
|
+
resolve21();
|
|
4168
4168
|
return;
|
|
4169
4169
|
}
|
|
4170
4170
|
const sock = conn.sock;
|
|
4171
4171
|
const handler = (update) => {
|
|
4172
4172
|
if (update.connection === "close") {
|
|
4173
4173
|
sock.ev.off("connection.update", handler);
|
|
4174
|
-
|
|
4174
|
+
resolve21();
|
|
4175
4175
|
}
|
|
4176
4176
|
};
|
|
4177
4177
|
sock.ev.on("connection.update", handler);
|
|
@@ -4388,8 +4388,8 @@ async function handleInboundMessage(conn, msg) {
|
|
|
4388
4388
|
const conversationKey = isGroup ? remoteJid : senderPhone;
|
|
4389
4389
|
const debounceKey = `${conn.accountId}:${conversationKey}:${senderPhone}`;
|
|
4390
4390
|
let resolvePending;
|
|
4391
|
-
const sttPending = new Promise((
|
|
4392
|
-
resolvePending =
|
|
4391
|
+
const sttPending = new Promise((resolve21) => {
|
|
4392
|
+
resolvePending = resolve21;
|
|
4393
4393
|
});
|
|
4394
4394
|
if (conn.debouncer) conn.debouncer.registerPending(debounceKey, sttPending);
|
|
4395
4395
|
try {
|
|
@@ -4502,20 +4502,20 @@ async function probeApiKey() {
|
|
|
4502
4502
|
return result.status;
|
|
4503
4503
|
}
|
|
4504
4504
|
function checkPort(port2, timeoutMs = 500) {
|
|
4505
|
-
return new Promise((
|
|
4505
|
+
return new Promise((resolve21) => {
|
|
4506
4506
|
const socket = createConnection(port2, "127.0.0.1");
|
|
4507
4507
|
socket.setTimeout(timeoutMs);
|
|
4508
4508
|
socket.once("connect", () => {
|
|
4509
4509
|
socket.destroy();
|
|
4510
|
-
|
|
4510
|
+
resolve21(true);
|
|
4511
4511
|
});
|
|
4512
4512
|
socket.once("error", () => {
|
|
4513
4513
|
socket.destroy();
|
|
4514
|
-
|
|
4514
|
+
resolve21(false);
|
|
4515
4515
|
});
|
|
4516
4516
|
socket.once("timeout", () => {
|
|
4517
4517
|
socket.destroy();
|
|
4518
|
-
|
|
4518
|
+
resolve21(false);
|
|
4519
4519
|
});
|
|
4520
4520
|
});
|
|
4521
4521
|
}
|
|
@@ -6717,8 +6717,8 @@ async function startLogin(opts) {
|
|
|
6717
6717
|
resetActiveLogin(accountId);
|
|
6718
6718
|
let resolveQr = null;
|
|
6719
6719
|
let rejectQr = null;
|
|
6720
|
-
const qrPromise = new Promise((
|
|
6721
|
-
resolveQr =
|
|
6720
|
+
const qrPromise = new Promise((resolve21, reject) => {
|
|
6721
|
+
resolveQr = resolve21;
|
|
6722
6722
|
rejectQr = reject;
|
|
6723
6723
|
});
|
|
6724
6724
|
const qrTimer = setTimeout(
|
|
@@ -8595,9 +8595,8 @@ app14.get("/", (c) => {
|
|
|
8595
8595
|
}
|
|
8596
8596
|
const resolvedAccount = resolveAccount();
|
|
8597
8597
|
const model = resolvedAccount?.config.adminModel ?? "unknown";
|
|
8598
|
-
const contextMode = resolvedAccount?.config.contextMode ?? "managed";
|
|
8599
8598
|
const thinkingView = resolvedAccount?.config.thinkingView ?? "default";
|
|
8600
|
-
return c.json({ version, account, model,
|
|
8599
|
+
return c.json({ version, account, model, thinkingView });
|
|
8601
8600
|
});
|
|
8602
8601
|
var claude_info_default = app14;
|
|
8603
8602
|
|
|
@@ -8647,47 +8646,14 @@ app15.get("/:attachmentId", requireAdminSession, async (c) => {
|
|
|
8647
8646
|
});
|
|
8648
8647
|
var attachment_default = app15;
|
|
8649
8648
|
|
|
8650
|
-
// server/routes/admin/
|
|
8651
|
-
import { readFileSync as readFileSync13, writeFileSync as writeFileSync8 } from "fs";
|
|
8649
|
+
// server/routes/admin/agents.ts
|
|
8652
8650
|
import { resolve as resolve15 } from "path";
|
|
8653
|
-
|
|
8651
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync13, existsSync as existsSync17, rmSync } from "fs";
|
|
8654
8652
|
var app16 = new Hono();
|
|
8655
|
-
app16.
|
|
8656
|
-
let body;
|
|
8657
|
-
try {
|
|
8658
|
-
body = await c.req.json();
|
|
8659
|
-
} catch {
|
|
8660
|
-
return c.json({ error: "Invalid request" }, 400);
|
|
8661
|
-
}
|
|
8662
|
-
const { contextMode } = body;
|
|
8663
|
-
if (!contextMode || !VALID_CONTEXT_MODES.includes(contextMode)) {
|
|
8664
|
-
return c.json({ error: `Invalid contextMode. Valid values: ${VALID_CONTEXT_MODES.join(", ")}` }, 400);
|
|
8665
|
-
}
|
|
8666
|
-
const account = resolveAccount();
|
|
8667
|
-
if (!account) return c.json({ error: "No account configured" }, 500);
|
|
8668
|
-
const configPath2 = resolve15(account.accountDir, "account.json");
|
|
8669
|
-
try {
|
|
8670
|
-
const raw = readFileSync13(configPath2, "utf-8");
|
|
8671
|
-
const config = JSON.parse(raw);
|
|
8672
|
-
config.contextMode = contextMode;
|
|
8673
|
-
writeFileSync8(configPath2, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
8674
|
-
console.error(`[account-update] contextMode=${contextMode}`);
|
|
8675
|
-
return c.json({ ok: true, contextMode });
|
|
8676
|
-
} catch (err) {
|
|
8677
|
-
console.error(`[account-update] failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
8678
|
-
return c.json({ error: "Failed to update account" }, 500);
|
|
8679
|
-
}
|
|
8680
|
-
});
|
|
8681
|
-
var account_default = app16;
|
|
8682
|
-
|
|
8683
|
-
// server/routes/admin/agents.ts
|
|
8684
|
-
import { resolve as resolve16 } from "path";
|
|
8685
|
-
import { readdirSync as readdirSync4, readFileSync as readFileSync14, existsSync as existsSync17, rmSync } from "fs";
|
|
8686
|
-
var app17 = new Hono();
|
|
8687
|
-
app17.get("/", (c) => {
|
|
8653
|
+
app16.get("/", (c) => {
|
|
8688
8654
|
const account = resolveAccount();
|
|
8689
8655
|
if (!account) return c.json({ agents: [] });
|
|
8690
|
-
const agentsDir =
|
|
8656
|
+
const agentsDir = resolve15(account.accountDir, "agents");
|
|
8691
8657
|
if (!existsSync17(agentsDir)) return c.json({ agents: [] });
|
|
8692
8658
|
const agents = [];
|
|
8693
8659
|
try {
|
|
@@ -8695,10 +8661,10 @@ app17.get("/", (c) => {
|
|
|
8695
8661
|
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
8696
8662
|
if (!entry.isDirectory()) continue;
|
|
8697
8663
|
if (entry.name === "admin") continue;
|
|
8698
|
-
const configPath2 =
|
|
8664
|
+
const configPath2 = resolve15(agentsDir, entry.name, "config.json");
|
|
8699
8665
|
if (!existsSync17(configPath2)) continue;
|
|
8700
8666
|
try {
|
|
8701
|
-
const config = JSON.parse(
|
|
8667
|
+
const config = JSON.parse(readFileSync13(configPath2, "utf-8"));
|
|
8702
8668
|
agents.push({
|
|
8703
8669
|
slug: entry.name,
|
|
8704
8670
|
displayName: config.displayName ?? entry.name,
|
|
@@ -8714,7 +8680,7 @@ app17.get("/", (c) => {
|
|
|
8714
8680
|
}
|
|
8715
8681
|
return c.json({ agents });
|
|
8716
8682
|
});
|
|
8717
|
-
|
|
8683
|
+
app16.delete("/:slug", (c) => {
|
|
8718
8684
|
const slug = c.req.param("slug");
|
|
8719
8685
|
const account = resolveAccount();
|
|
8720
8686
|
if (!account) return c.json({ error: "No account resolved" }, 400);
|
|
@@ -8724,7 +8690,7 @@ app17.delete("/:slug", (c) => {
|
|
|
8724
8690
|
if (slug.includes("/") || slug.includes("..") || slug.includes("\\")) {
|
|
8725
8691
|
return c.json({ error: "Invalid agent slug" }, 400);
|
|
8726
8692
|
}
|
|
8727
|
-
const agentDir =
|
|
8693
|
+
const agentDir = resolve15(account.accountDir, "agents", slug);
|
|
8728
8694
|
if (!existsSync17(agentDir)) {
|
|
8729
8695
|
return c.json({ error: "Agent not found" }, 404);
|
|
8730
8696
|
}
|
|
@@ -8737,7 +8703,7 @@ app17.delete("/:slug", (c) => {
|
|
|
8737
8703
|
return c.json({ error: "Failed to delete agent" }, 500);
|
|
8738
8704
|
}
|
|
8739
8705
|
});
|
|
8740
|
-
var agents_default =
|
|
8706
|
+
var agents_default = app16;
|
|
8741
8707
|
|
|
8742
8708
|
// server/routes/admin/sessions.ts
|
|
8743
8709
|
import crypto2 from "crypto";
|
|
@@ -8759,8 +8725,8 @@ function formatAge(updatedAtStr) {
|
|
|
8759
8725
|
return "unknown";
|
|
8760
8726
|
}
|
|
8761
8727
|
}
|
|
8762
|
-
var
|
|
8763
|
-
|
|
8728
|
+
var app17 = new Hono();
|
|
8729
|
+
app17.get("/", requireAdminSession, async (c) => {
|
|
8764
8730
|
const sessionKey = c.var.sessionKey;
|
|
8765
8731
|
const accountId = getAccountIdForSession(sessionKey);
|
|
8766
8732
|
if (!accountId) return c.json({ error: "Account not found for session" }, 401);
|
|
@@ -8790,7 +8756,7 @@ app18.get("/", requireAdminSession, async (c) => {
|
|
|
8790
8756
|
return c.json({ error: "Failed to fetch sessions" }, 500);
|
|
8791
8757
|
}
|
|
8792
8758
|
});
|
|
8793
|
-
|
|
8759
|
+
app17.post("/new", requireAdminSession, async (c) => {
|
|
8794
8760
|
const oldSessionKey = c.var.sessionKey;
|
|
8795
8761
|
const accountId = getAccountIdForSession(oldSessionKey);
|
|
8796
8762
|
const userId = getUserIdForSession(oldSessionKey);
|
|
@@ -8805,7 +8771,7 @@ app18.post("/new", requireAdminSession, async (c) => {
|
|
|
8805
8771
|
console.log(`[session] ${(/* @__PURE__ */ new Date()).toISOString()} session reset for new conversation: oldSessionKey=${oldSessionKey.slice(0, 8)}\u2026 newSessionKey=${newSessionKey.slice(0, 8)}\u2026 previousConversationId=${previousConversationId?.slice(0, 8) ?? "none"}\u2026 newConversationId=deferred`);
|
|
8806
8772
|
return c.json({ session_key: newSessionKey, conversationId: null });
|
|
8807
8773
|
});
|
|
8808
|
-
|
|
8774
|
+
app17.delete("/:id", requireAdminSession, async (c) => {
|
|
8809
8775
|
const conversationId = c.req.param("id");
|
|
8810
8776
|
const sessionKey = c.var.sessionKey;
|
|
8811
8777
|
const accountId = getAccountIdForSession(sessionKey);
|
|
@@ -8820,7 +8786,7 @@ app18.delete("/:id", requireAdminSession, async (c) => {
|
|
|
8820
8786
|
return c.json({ error: "Failed to delete session" }, 500);
|
|
8821
8787
|
}
|
|
8822
8788
|
});
|
|
8823
|
-
|
|
8789
|
+
app17.get("/:id/messages", requireAdminSession, async (c) => {
|
|
8824
8790
|
const conversationId = c.req.param("id");
|
|
8825
8791
|
const sessionKey = c.var.sessionKey;
|
|
8826
8792
|
const accountId = getAccountIdForSession(sessionKey);
|
|
@@ -8835,7 +8801,7 @@ app18.get("/:id/messages", requireAdminSession, async (c) => {
|
|
|
8835
8801
|
return c.json({ error: "Failed to fetch messages" }, 500);
|
|
8836
8802
|
}
|
|
8837
8803
|
});
|
|
8838
|
-
|
|
8804
|
+
app17.post("/:id/resume", requireAdminSession, async (c) => {
|
|
8839
8805
|
const conversationId = c.req.param("id");
|
|
8840
8806
|
const sessionKey = c.var.sessionKey;
|
|
8841
8807
|
const accountId = getAccountIdForSession(sessionKey);
|
|
@@ -8863,7 +8829,7 @@ app18.post("/:id/resume", requireAdminSession, async (c) => {
|
|
|
8863
8829
|
console.log(`[session-resume] ${(/* @__PURE__ */ new Date()).toISOString()} conversationId=${conversationId.slice(0, 8)}\u2026 age=${age} loaded=${messages.length} messages (${estimatedTokens} estimated tokens) previousConversationId=${previousConversationId?.slice(0, 8) ?? "none"}\u2026 sessionKey=${sessionKey.slice(0, 8)}\u2026`);
|
|
8864
8830
|
return c.json({ conversationId, messages });
|
|
8865
8831
|
});
|
|
8866
|
-
|
|
8832
|
+
app17.post("/:id/label", requireAdminSession, async (c) => {
|
|
8867
8833
|
const conversationId = c.req.param("id");
|
|
8868
8834
|
const sessionKey = c.var.sessionKey;
|
|
8869
8835
|
const accountId = getAccountIdForSession(sessionKey);
|
|
@@ -8890,7 +8856,7 @@ app18.post("/:id/label", requireAdminSession, async (c) => {
|
|
|
8890
8856
|
return c.json({ label: null });
|
|
8891
8857
|
}
|
|
8892
8858
|
});
|
|
8893
|
-
|
|
8859
|
+
app17.put("/:id/label", requireAdminSession, async (c) => {
|
|
8894
8860
|
const conversationId = c.req.param("id");
|
|
8895
8861
|
const sessionKey = c.var.sessionKey;
|
|
8896
8862
|
let body;
|
|
@@ -8916,11 +8882,11 @@ app18.put("/:id/label", requireAdminSession, async (c) => {
|
|
|
8916
8882
|
return c.json({ error: "Failed to rename session" }, 500);
|
|
8917
8883
|
}
|
|
8918
8884
|
});
|
|
8919
|
-
var sessions_default =
|
|
8885
|
+
var sessions_default = app17;
|
|
8920
8886
|
|
|
8921
8887
|
// server/routes/admin/browser.ts
|
|
8922
|
-
var
|
|
8923
|
-
|
|
8888
|
+
var app18 = new Hono();
|
|
8889
|
+
app18.post("/launch", async (c) => {
|
|
8924
8890
|
try {
|
|
8925
8891
|
const transport = resolveBrowserTransport(c.req.raw, c.env?.incoming?.socket?.remoteAddress);
|
|
8926
8892
|
if (transport === "vnc") {
|
|
@@ -8942,7 +8908,7 @@ app19.post("/launch", async (c) => {
|
|
|
8942
8908
|
);
|
|
8943
8909
|
}
|
|
8944
8910
|
});
|
|
8945
|
-
var browser_default =
|
|
8911
|
+
var browser_default = app18;
|
|
8946
8912
|
|
|
8947
8913
|
// app/lib/cdp-client.ts
|
|
8948
8914
|
var CDP_HOST = "127.0.0.1";
|
|
@@ -8985,8 +8951,8 @@ async function cdpNavigateNewTab(url, opts = {}) {
|
|
|
8985
8951
|
}
|
|
8986
8952
|
|
|
8987
8953
|
// server/routes/admin/device-browser.ts
|
|
8988
|
-
var
|
|
8989
|
-
|
|
8954
|
+
var app19 = new Hono();
|
|
8955
|
+
app19.post("/navigate", async (c) => {
|
|
8990
8956
|
const TAG17 = "[device-url:click]";
|
|
8991
8957
|
let body;
|
|
8992
8958
|
try {
|
|
@@ -9073,7 +9039,7 @@ app20.post("/navigate", async (c) => {
|
|
|
9073
9039
|
targetId: outcome.targetId
|
|
9074
9040
|
});
|
|
9075
9041
|
});
|
|
9076
|
-
var device_browser_default =
|
|
9042
|
+
var device_browser_default = app19;
|
|
9077
9043
|
|
|
9078
9044
|
// server/routes/admin/events.ts
|
|
9079
9045
|
var ALLOWED_EVENTS = /* @__PURE__ */ new Set([
|
|
@@ -9082,8 +9048,8 @@ var ALLOWED_EVENTS = /* @__PURE__ */ new Set([
|
|
|
9082
9048
|
"device-url:vnc-surface-shown",
|
|
9083
9049
|
"device-url:malformed"
|
|
9084
9050
|
]);
|
|
9085
|
-
var
|
|
9086
|
-
|
|
9051
|
+
var app20 = new Hono();
|
|
9052
|
+
app20.post("/", async (c) => {
|
|
9087
9053
|
const TAG17 = "[admin:events]";
|
|
9088
9054
|
let body;
|
|
9089
9055
|
try {
|
|
@@ -9114,12 +9080,12 @@ app21.post("/", async (c) => {
|
|
|
9114
9080
|
console.error(`[${event}] ${formatted}`);
|
|
9115
9081
|
return c.json({ ok: true });
|
|
9116
9082
|
});
|
|
9117
|
-
var events_default =
|
|
9083
|
+
var events_default = app20;
|
|
9118
9084
|
|
|
9119
9085
|
// server/routes/admin/cloudflare.ts
|
|
9120
9086
|
import { homedir } from "os";
|
|
9121
|
-
import { resolve as
|
|
9122
|
-
import { readFileSync as
|
|
9087
|
+
import { resolve as resolve17 } from "path";
|
|
9088
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
9123
9089
|
|
|
9124
9090
|
// app/lib/dns-label.ts
|
|
9125
9091
|
var VALID_LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
@@ -9135,14 +9101,14 @@ function isValidDomain(value) {
|
|
|
9135
9101
|
}
|
|
9136
9102
|
|
|
9137
9103
|
// app/lib/alias-domains.ts
|
|
9138
|
-
import { existsSync as existsSync18, mkdirSync as mkdirSync8, readFileSync as
|
|
9104
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync8, readFileSync as readFileSync14, writeFileSync as writeFileSync8 } from "fs";
|
|
9139
9105
|
import { dirname as dirname7 } from "path";
|
|
9140
|
-
import { resolve as
|
|
9141
|
-
var ALIAS_DOMAINS_PATH =
|
|
9106
|
+
import { resolve as resolve16 } from "path";
|
|
9107
|
+
var ALIAS_DOMAINS_PATH = resolve16(MAXY_DIR, "alias-domains.json");
|
|
9142
9108
|
function readExisting() {
|
|
9143
9109
|
if (!existsSync18(ALIAS_DOMAINS_PATH)) return /* @__PURE__ */ new Set();
|
|
9144
9110
|
try {
|
|
9145
|
-
const parsed = JSON.parse(
|
|
9111
|
+
const parsed = JSON.parse(readFileSync14(ALIAS_DOMAINS_PATH, "utf-8"));
|
|
9146
9112
|
if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
|
|
9147
9113
|
return new Set(parsed.filter((h) => typeof h === "string"));
|
|
9148
9114
|
} catch {
|
|
@@ -9154,17 +9120,17 @@ function addAliasDomain(hostname2) {
|
|
|
9154
9120
|
if (existing.has(hostname2)) return;
|
|
9155
9121
|
existing.add(hostname2);
|
|
9156
9122
|
mkdirSync8(dirname7(ALIAS_DOMAINS_PATH), { recursive: true });
|
|
9157
|
-
|
|
9123
|
+
writeFileSync8(ALIAS_DOMAINS_PATH, JSON.stringify([...existing], null, 2) + "\n", "utf-8");
|
|
9158
9124
|
}
|
|
9159
9125
|
|
|
9160
9126
|
// server/routes/admin/cloudflare.ts
|
|
9161
9127
|
var SETUP_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
9162
9128
|
var DOMAINS_TIMEOUT_MS = 40 * 1e3;
|
|
9163
9129
|
function loadBrandInfo() {
|
|
9164
|
-
const platformRoot2 = process.env.MAXY_PLATFORM_ROOT ??
|
|
9165
|
-
const brandPath =
|
|
9130
|
+
const platformRoot2 = process.env.MAXY_PLATFORM_ROOT ?? resolve17(process.cwd(), "..");
|
|
9131
|
+
const brandPath = resolve17(platformRoot2, "config", "brand.json");
|
|
9166
9132
|
try {
|
|
9167
|
-
const parsed = JSON.parse(
|
|
9133
|
+
const parsed = JSON.parse(readFileSync15(brandPath, "utf-8"));
|
|
9168
9134
|
const hostname2 = typeof parsed.hostname === "string" && parsed.hostname ? parsed.hostname : "maxy";
|
|
9169
9135
|
const configDir2 = typeof parsed.configDir === "string" && parsed.configDir ? parsed.configDir : ".maxy";
|
|
9170
9136
|
return { hostname: hostname2, configDir: configDir2 };
|
|
@@ -9207,7 +9173,7 @@ function validateBody(body) {
|
|
|
9207
9173
|
}
|
|
9208
9174
|
return null;
|
|
9209
9175
|
}
|
|
9210
|
-
var
|
|
9176
|
+
var app21 = new Hono();
|
|
9211
9177
|
function fieldFromReason(reason) {
|
|
9212
9178
|
switch (reason) {
|
|
9213
9179
|
case "not-signed-in":
|
|
@@ -9224,7 +9190,7 @@ function fieldFromReason(reason) {
|
|
|
9224
9190
|
return "script";
|
|
9225
9191
|
}
|
|
9226
9192
|
}
|
|
9227
|
-
|
|
9193
|
+
app21.get("/domains", requireAdminSession, async (c) => {
|
|
9228
9194
|
const started = Date.now();
|
|
9229
9195
|
const sessionKey = c.var.sessionKey;
|
|
9230
9196
|
let correlationId;
|
|
@@ -9267,7 +9233,7 @@ app22.get("/domains", requireAdminSession, async (c) => {
|
|
|
9267
9233
|
streamLogPath = streamLogPathFor(accountId, correlationId).streamLogPath;
|
|
9268
9234
|
log(`phase=stream-log-resolved path=${streamLogPath}`);
|
|
9269
9235
|
const brand = loadBrandInfo();
|
|
9270
|
-
const scriptPath =
|
|
9236
|
+
const scriptPath = resolve17(homedir(), "list-cf-domains.sh");
|
|
9271
9237
|
const result = await runFormSpawn({
|
|
9272
9238
|
scriptPath,
|
|
9273
9239
|
args: [brand.hostname],
|
|
@@ -9317,7 +9283,7 @@ ${result.stderr}` : ""}`;
|
|
|
9317
9283
|
);
|
|
9318
9284
|
return c.json(success, 200);
|
|
9319
9285
|
});
|
|
9320
|
-
|
|
9286
|
+
app21.post("/setup", requireAdminSession, async (c) => {
|
|
9321
9287
|
const started = Date.now();
|
|
9322
9288
|
const sessionKey = c.var.sessionKey;
|
|
9323
9289
|
let correlationId;
|
|
@@ -9452,23 +9418,23 @@ actionId: ${actionId}`,
|
|
|
9452
9418
|
};
|
|
9453
9419
|
return ok(success);
|
|
9454
9420
|
});
|
|
9455
|
-
var cloudflare_default =
|
|
9421
|
+
var cloudflare_default = app21;
|
|
9456
9422
|
|
|
9457
9423
|
// server/routes/admin/files.ts
|
|
9458
9424
|
import { createReadStream as createReadStream3 } from "fs";
|
|
9459
9425
|
import { readdir as readdir2, readFile as readFile4, stat as stat4, mkdir as mkdir3, writeFile as writeFile4, unlink as unlink2 } from "fs/promises";
|
|
9460
9426
|
import { realpathSync as realpathSync4 } from "fs";
|
|
9461
|
-
import { basename as basename6, dirname as dirname8, join as join9, resolve as
|
|
9427
|
+
import { basename as basename6, dirname as dirname8, join as join9, resolve as resolve19, sep as sep2 } from "path";
|
|
9462
9428
|
import { Readable as Readable2 } from "stream";
|
|
9463
9429
|
|
|
9464
9430
|
// app/lib/data-path.ts
|
|
9465
9431
|
import { realpathSync as realpathSync3 } from "fs";
|
|
9466
|
-
import { resolve as
|
|
9467
|
-
var PLATFORM_ROOT5 = process.env.MAXY_PLATFORM_ROOT ??
|
|
9468
|
-
var DATA_ROOT =
|
|
9432
|
+
import { resolve as resolve18, normalize, sep, relative } from "path";
|
|
9433
|
+
var PLATFORM_ROOT5 = process.env.MAXY_PLATFORM_ROOT ?? resolve18(process.cwd(), "../platform");
|
|
9434
|
+
var DATA_ROOT = resolve18(PLATFORM_ROOT5, "..", "data");
|
|
9469
9435
|
function resolveDataPath(raw) {
|
|
9470
9436
|
const cleaned = normalize("/" + (raw ?? "").replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
9471
|
-
const absolute =
|
|
9437
|
+
const absolute = resolve18(DATA_ROOT, cleaned);
|
|
9472
9438
|
let dataRootReal;
|
|
9473
9439
|
try {
|
|
9474
9440
|
dataRootReal = realpathSync3(DATA_ROOT);
|
|
@@ -9827,7 +9793,7 @@ async function readMeta(absDir, baseName) {
|
|
|
9827
9793
|
}
|
|
9828
9794
|
async function readAccountNames() {
|
|
9829
9795
|
const map = /* @__PURE__ */ new Map();
|
|
9830
|
-
const accountsDir =
|
|
9796
|
+
const accountsDir = resolve19(DATA_ROOT, "accounts");
|
|
9831
9797
|
let names;
|
|
9832
9798
|
try {
|
|
9833
9799
|
names = await readdir2(accountsDir);
|
|
@@ -9836,7 +9802,7 @@ async function readAccountNames() {
|
|
|
9836
9802
|
}
|
|
9837
9803
|
for (const name of names) {
|
|
9838
9804
|
if (!UUID_RE3.test(name)) continue;
|
|
9839
|
-
const configPath2 =
|
|
9805
|
+
const configPath2 = resolve19(accountsDir, name, "account.json");
|
|
9840
9806
|
try {
|
|
9841
9807
|
const raw = await readFile4(configPath2, "utf8");
|
|
9842
9808
|
const parsed = JSON.parse(raw);
|
|
@@ -9885,8 +9851,8 @@ function buildDisplayPath(relPath, accountNames) {
|
|
|
9885
9851
|
return dn ? { name: seg, displayName: dn } : { name: seg };
|
|
9886
9852
|
});
|
|
9887
9853
|
}
|
|
9888
|
-
var
|
|
9889
|
-
|
|
9854
|
+
var app22 = new Hono();
|
|
9855
|
+
app22.get("/", requireAdminSession, async (c) => {
|
|
9890
9856
|
const sessionKey = c.var.sessionKey;
|
|
9891
9857
|
if (!getAccountIdForSession(sessionKey)) {
|
|
9892
9858
|
console.error(`[data] auth-rejected endpoint="/api/admin/files" reason="no account for session"`);
|
|
@@ -9947,7 +9913,7 @@ app23.get("/", requireAdminSession, async (c) => {
|
|
|
9947
9913
|
return c.json({ error: message }, 500);
|
|
9948
9914
|
}
|
|
9949
9915
|
});
|
|
9950
|
-
|
|
9916
|
+
app22.get("/download", requireAdminSession, async (c) => {
|
|
9951
9917
|
const sessionKey = c.var.sessionKey;
|
|
9952
9918
|
if (!getAccountIdForSession(sessionKey)) {
|
|
9953
9919
|
console.error(`[data] auth-rejected endpoint="/api/admin/files/download" reason="no account for session"`);
|
|
@@ -9995,7 +9961,7 @@ app23.get("/download", requireAdminSession, async (c) => {
|
|
|
9995
9961
|
return c.json({ error: message }, 500);
|
|
9996
9962
|
}
|
|
9997
9963
|
});
|
|
9998
|
-
|
|
9964
|
+
app22.post("/upload", requireAdminSession, async (c) => {
|
|
9999
9965
|
const sessionKey = c.var.sessionKey;
|
|
10000
9966
|
const accountId = getAccountIdForSession(sessionKey);
|
|
10001
9967
|
if (!accountId) {
|
|
@@ -10027,8 +9993,8 @@ app23.post("/upload", requireAdminSession, async (c) => {
|
|
|
10027
9993
|
}
|
|
10028
9994
|
const safeName = basename6(file.name).replace(/[\0/\\]/g, "_");
|
|
10029
9995
|
const finalName = `${Date.now()}-${safeName}`;
|
|
10030
|
-
const destDir =
|
|
10031
|
-
const destPath =
|
|
9996
|
+
const destDir = resolve19(DATA_ROOT, "uploads", accountId);
|
|
9997
|
+
const destPath = resolve19(destDir, finalName);
|
|
10032
9998
|
try {
|
|
10033
9999
|
await mkdir3(destDir, { recursive: true });
|
|
10034
10000
|
const dataRootReal = realpathSync4(DATA_ROOT);
|
|
@@ -10053,7 +10019,7 @@ app23.post("/upload", requireAdminSession, async (c) => {
|
|
|
10053
10019
|
mimeType: file.type
|
|
10054
10020
|
});
|
|
10055
10021
|
});
|
|
10056
|
-
|
|
10022
|
+
app22.delete("/", requireAdminSession, async (c) => {
|
|
10057
10023
|
const sessionKey = c.var.sessionKey;
|
|
10058
10024
|
const accountId = getAccountIdForSession(sessionKey);
|
|
10059
10025
|
if (!accountId) {
|
|
@@ -10120,7 +10086,7 @@ app23.delete("/", requireAdminSession, async (c) => {
|
|
|
10120
10086
|
return c.json({ error: message }, 500);
|
|
10121
10087
|
}
|
|
10122
10088
|
});
|
|
10123
|
-
var files_default =
|
|
10089
|
+
var files_default = app22;
|
|
10124
10090
|
|
|
10125
10091
|
// ../lib/graph-search/src/index.ts
|
|
10126
10092
|
var import_dist = __toESM(require_dist());
|
|
@@ -10437,8 +10403,8 @@ function plainProperties(properties) {
|
|
|
10437
10403
|
// server/routes/admin/graph-search.ts
|
|
10438
10404
|
var DEFAULT_LIMIT = 20;
|
|
10439
10405
|
var MAX_LIMIT = 2e3;
|
|
10440
|
-
var
|
|
10441
|
-
|
|
10406
|
+
var app23 = new Hono();
|
|
10407
|
+
app23.get("/", requireAdminSession, async (c) => {
|
|
10442
10408
|
const sessionKey = c.var.sessionKey;
|
|
10443
10409
|
const q = (c.req.query("q") ?? "").trim();
|
|
10444
10410
|
const rawLimit = c.req.query("limit");
|
|
@@ -10488,7 +10454,7 @@ app24.get("/", requireAdminSession, async (c) => {
|
|
|
10488
10454
|
await session.close();
|
|
10489
10455
|
}
|
|
10490
10456
|
});
|
|
10491
|
-
var graph_search_default =
|
|
10457
|
+
var graph_search_default = app23;
|
|
10492
10458
|
|
|
10493
10459
|
// server/routes/admin/graph-subgraph.ts
|
|
10494
10460
|
import neo4j2 from "neo4j-driver";
|
|
@@ -10643,8 +10609,8 @@ var STRIPPED_PROPERTIES = /* @__PURE__ */ new Set([
|
|
|
10643
10609
|
"otpCode",
|
|
10644
10610
|
"sessionKey"
|
|
10645
10611
|
]);
|
|
10646
|
-
var
|
|
10647
|
-
|
|
10612
|
+
var app24 = new Hono();
|
|
10613
|
+
app24.get("/", requireAdminSession, async (c) => {
|
|
10648
10614
|
const sessionKey = c.var.sessionKey;
|
|
10649
10615
|
const accountId = getAccountIdForSession(sessionKey);
|
|
10650
10616
|
if (!accountId) {
|
|
@@ -11071,12 +11037,12 @@ function pruneNode(node, warnedClasses, conversationWarnings) {
|
|
|
11071
11037
|
}
|
|
11072
11038
|
return trashed ? { id: node.id, labels, properties, trashed: true } : { id: node.id, labels, properties };
|
|
11073
11039
|
}
|
|
11074
|
-
var graph_subgraph_default =
|
|
11040
|
+
var graph_subgraph_default = app24;
|
|
11075
11041
|
|
|
11076
11042
|
// server/routes/admin/graph-delete.ts
|
|
11077
11043
|
var ALLOWED_BY = ["graph-page", "graph-drag-trash"];
|
|
11078
|
-
var
|
|
11079
|
-
|
|
11044
|
+
var app25 = new Hono();
|
|
11045
|
+
app25.post("/", requireAdminSession, async (c) => {
|
|
11080
11046
|
const sessionKey = c.var.sessionKey;
|
|
11081
11047
|
const accountId = getAccountIdForSession(sessionKey);
|
|
11082
11048
|
if (!accountId) {
|
|
@@ -11147,11 +11113,11 @@ app26.post("/", requireAdminSession, async (c) => {
|
|
|
11147
11113
|
}
|
|
11148
11114
|
}
|
|
11149
11115
|
});
|
|
11150
|
-
var graph_delete_default =
|
|
11116
|
+
var graph_delete_default = app25;
|
|
11151
11117
|
|
|
11152
11118
|
// server/routes/admin/graph-restore.ts
|
|
11153
|
-
var
|
|
11154
|
-
|
|
11119
|
+
var app26 = new Hono();
|
|
11120
|
+
app26.post("/", requireAdminSession, async (c) => {
|
|
11155
11121
|
const sessionKey = c.var.sessionKey;
|
|
11156
11122
|
const accountId = getAccountIdForSession(sessionKey);
|
|
11157
11123
|
if (!accountId) {
|
|
@@ -11215,11 +11181,11 @@ app27.post("/", requireAdminSession, async (c) => {
|
|
|
11215
11181
|
}
|
|
11216
11182
|
}
|
|
11217
11183
|
});
|
|
11218
|
-
var graph_restore_default =
|
|
11184
|
+
var graph_restore_default = app26;
|
|
11219
11185
|
|
|
11220
11186
|
// server/routes/admin/graph-labels-in-graph.ts
|
|
11221
|
-
var
|
|
11222
|
-
|
|
11187
|
+
var app27 = new Hono();
|
|
11188
|
+
app27.get("/", requireAdminSession, async (c) => {
|
|
11223
11189
|
const sessionKey = c.var.sessionKey;
|
|
11224
11190
|
const accountId = getAccountIdForSession(sessionKey);
|
|
11225
11191
|
if (!accountId) {
|
|
@@ -11285,11 +11251,11 @@ var LABELS_IN_GRAPH_CYPHER = `
|
|
|
11285
11251
|
sum(halfEdges) AS relDegree
|
|
11286
11252
|
RETURN label, nodeCount, relDegree
|
|
11287
11253
|
`;
|
|
11288
|
-
var graph_labels_in_graph_default =
|
|
11254
|
+
var graph_labels_in_graph_default = app27;
|
|
11289
11255
|
|
|
11290
11256
|
// server/routes/admin/graph-default-view.ts
|
|
11291
|
-
var
|
|
11292
|
-
|
|
11257
|
+
var app28 = new Hono();
|
|
11258
|
+
app28.get("/", requireAdminSession, async (c) => {
|
|
11293
11259
|
const sessionKey = c.var.sessionKey;
|
|
11294
11260
|
const accountId = getAccountIdForSession(sessionKey);
|
|
11295
11261
|
const userId = getUserIdForSession(sessionKey);
|
|
@@ -11327,7 +11293,7 @@ app29.get("/", requireAdminSession, async (c) => {
|
|
|
11327
11293
|
}
|
|
11328
11294
|
}
|
|
11329
11295
|
});
|
|
11330
|
-
|
|
11296
|
+
app28.put("/", requireAdminSession, async (c) => {
|
|
11331
11297
|
const sessionKey = c.var.sessionKey;
|
|
11332
11298
|
const accountId = getAccountIdForSession(sessionKey);
|
|
11333
11299
|
const userId = getUserIdForSession(sessionKey);
|
|
@@ -11416,11 +11382,11 @@ var WRITE_CYPHER = `
|
|
|
11416
11382
|
p.updatedAt = $updatedAt
|
|
11417
11383
|
RETURN p.labels AS labels
|
|
11418
11384
|
`;
|
|
11419
|
-
var graph_default_view_default =
|
|
11385
|
+
var graph_default_view_default = app28;
|
|
11420
11386
|
|
|
11421
11387
|
// server/routes/admin/file-attach.ts
|
|
11422
|
-
var
|
|
11423
|
-
|
|
11388
|
+
var app29 = new Hono();
|
|
11389
|
+
app29.post("/", async (c) => {
|
|
11424
11390
|
try {
|
|
11425
11391
|
const body = await c.req.json();
|
|
11426
11392
|
const { filePath, accountId } = body;
|
|
@@ -11443,11 +11409,11 @@ app30.post("/", async (c) => {
|
|
|
11443
11409
|
return c.json({ error: message }, 500);
|
|
11444
11410
|
}
|
|
11445
11411
|
});
|
|
11446
|
-
var file_attach_default =
|
|
11412
|
+
var file_attach_default = app29;
|
|
11447
11413
|
|
|
11448
11414
|
// server/routes/admin/adherence.ts
|
|
11449
|
-
var
|
|
11450
|
-
|
|
11415
|
+
var app30 = new Hono();
|
|
11416
|
+
app30.get("/", requireAdminSession, async (c) => {
|
|
11451
11417
|
const agent = c.req.query("agent") ?? "admin";
|
|
11452
11418
|
const includeBlock = c.req.query("block") === "1";
|
|
11453
11419
|
const account = resolveAccount();
|
|
@@ -11468,33 +11434,32 @@ app31.get("/", requireAdminSession, async (c) => {
|
|
|
11468
11434
|
return c.json({ error: "Failed to read adherence ledger", agent }, 500);
|
|
11469
11435
|
}
|
|
11470
11436
|
});
|
|
11471
|
-
var adherence_default =
|
|
11437
|
+
var adherence_default = app30;
|
|
11472
11438
|
|
|
11473
11439
|
// server/routes/admin/index.ts
|
|
11474
|
-
var
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
var admin_default = app32;
|
|
11440
|
+
var app31 = new Hono();
|
|
11441
|
+
app31.route("/session", session_default2);
|
|
11442
|
+
app31.route("/chat", chat_default2);
|
|
11443
|
+
app31.route("/compact", compact_default);
|
|
11444
|
+
app31.route("/logs", logs_default);
|
|
11445
|
+
app31.route("/claude-info", claude_info_default);
|
|
11446
|
+
app31.route("/attachment", attachment_default);
|
|
11447
|
+
app31.route("/agents", agents_default);
|
|
11448
|
+
app31.route("/sessions", sessions_default);
|
|
11449
|
+
app31.route("/browser", browser_default);
|
|
11450
|
+
app31.route("/device-browser", device_browser_default);
|
|
11451
|
+
app31.route("/events", events_default);
|
|
11452
|
+
app31.route("/cloudflare", cloudflare_default);
|
|
11453
|
+
app31.route("/files", files_default);
|
|
11454
|
+
app31.route("/graph-search", graph_search_default);
|
|
11455
|
+
app31.route("/graph-subgraph", graph_subgraph_default);
|
|
11456
|
+
app31.route("/graph-delete", graph_delete_default);
|
|
11457
|
+
app31.route("/graph-restore", graph_restore_default);
|
|
11458
|
+
app31.route("/graph-labels-in-graph", graph_labels_in_graph_default);
|
|
11459
|
+
app31.route("/graph-default-view", graph_default_view_default);
|
|
11460
|
+
app31.route("/file-attach", file_attach_default);
|
|
11461
|
+
app31.route("/adherence", adherence_default);
|
|
11462
|
+
var admin_default = app31;
|
|
11498
11463
|
|
|
11499
11464
|
// app/lib/graph-health.ts
|
|
11500
11465
|
var HOUR_MS = 60 * 60 * 1e3;
|
|
@@ -11561,7 +11526,7 @@ if (BRAND_JSON_PATH && !existsSync19(BRAND_JSON_PATH)) {
|
|
|
11561
11526
|
}
|
|
11562
11527
|
if (BRAND_JSON_PATH && existsSync19(BRAND_JSON_PATH)) {
|
|
11563
11528
|
try {
|
|
11564
|
-
const parsed = JSON.parse(
|
|
11529
|
+
const parsed = JSON.parse(readFileSync16(BRAND_JSON_PATH, "utf-8"));
|
|
11565
11530
|
BRAND = { ...BRAND, ...parsed };
|
|
11566
11531
|
} catch (err) {
|
|
11567
11532
|
console.error(`[brand] Failed to parse brand.json: ${err.message}`);
|
|
@@ -11584,7 +11549,7 @@ var ALIAS_DOMAINS_PATH2 = join10(homedir2(), BRAND.configDir, "alias-domains.jso
|
|
|
11584
11549
|
function loadAliasDomains() {
|
|
11585
11550
|
try {
|
|
11586
11551
|
if (!existsSync19(ALIAS_DOMAINS_PATH2)) return null;
|
|
11587
|
-
const parsed = JSON.parse(
|
|
11552
|
+
const parsed = JSON.parse(readFileSync16(ALIAS_DOMAINS_PATH2, "utf-8"));
|
|
11588
11553
|
if (!Array.isArray(parsed)) {
|
|
11589
11554
|
console.error("[alias-domains] malformed alias-domains.json \u2014 expected array");
|
|
11590
11555
|
return null;
|
|
@@ -11608,9 +11573,9 @@ watchFile(ALIAS_DOMAINS_PATH2, { interval: 2e3 }, () => {
|
|
|
11608
11573
|
function isPublicHost(host) {
|
|
11609
11574
|
return host.startsWith("public.") || aliasDomains.has(host);
|
|
11610
11575
|
}
|
|
11611
|
-
var
|
|
11612
|
-
|
|
11613
|
-
|
|
11576
|
+
var app32 = new Hono();
|
|
11577
|
+
app32.use("*", clientIpMiddleware);
|
|
11578
|
+
app32.use("*", async (c, next) => {
|
|
11614
11579
|
await next();
|
|
11615
11580
|
c.header("X-Content-Type-Options", "nosniff");
|
|
11616
11581
|
c.header("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
@@ -11633,7 +11598,7 @@ var PUBLIC_ALLOWED_PREFIXES = [
|
|
|
11633
11598
|
"/g/"
|
|
11634
11599
|
];
|
|
11635
11600
|
var PUBLIC_ALLOWED_EXACT = ["/favicon.ico"];
|
|
11636
|
-
|
|
11601
|
+
app32.use("*", async (c, next) => {
|
|
11637
11602
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
11638
11603
|
if (!isPublicHost(host)) {
|
|
11639
11604
|
await next();
|
|
@@ -11673,7 +11638,7 @@ function resolveRemoteAuthOpts() {
|
|
|
11673
11638
|
return brandLoginOpts;
|
|
11674
11639
|
}
|
|
11675
11640
|
var MAX_LOGIN_BODY = 8 * 1024;
|
|
11676
|
-
|
|
11641
|
+
app32.post("/__remote-auth/login", async (c) => {
|
|
11677
11642
|
const client = clientFrom(c);
|
|
11678
11643
|
const clientIp = client.ip || "unknown";
|
|
11679
11644
|
if (!requestIsTlsTerminated(c)) {
|
|
@@ -11717,7 +11682,7 @@ app33.post("/__remote-auth/login", async (c) => {
|
|
|
11717
11682
|
}
|
|
11718
11683
|
});
|
|
11719
11684
|
});
|
|
11720
|
-
|
|
11685
|
+
app32.get("/__remote-auth/logout", (c) => {
|
|
11721
11686
|
return new Response(null, {
|
|
11722
11687
|
status: 302,
|
|
11723
11688
|
headers: {
|
|
@@ -11727,7 +11692,7 @@ app33.get("/__remote-auth/logout", (c) => {
|
|
|
11727
11692
|
}
|
|
11728
11693
|
});
|
|
11729
11694
|
});
|
|
11730
|
-
|
|
11695
|
+
app32.post("/__remote-auth/change-password", async (c) => {
|
|
11731
11696
|
const client = clientFrom(c);
|
|
11732
11697
|
const clientIp = client.ip || "unknown";
|
|
11733
11698
|
const rateLimited = checkRateLimit(client);
|
|
@@ -11777,13 +11742,13 @@ app33.post("/__remote-auth/change-password", async (c) => {
|
|
|
11777
11742
|
return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(), mode: "change", changeError: "Failed to save password", redirect }), 200);
|
|
11778
11743
|
}
|
|
11779
11744
|
});
|
|
11780
|
-
|
|
11745
|
+
app32.get("/__remote-auth/setup", (c) => {
|
|
11781
11746
|
if (isRemoteAuthConfigured()) {
|
|
11782
11747
|
return c.redirect("/");
|
|
11783
11748
|
}
|
|
11784
11749
|
return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(), mode: "setup" }), 200);
|
|
11785
11750
|
});
|
|
11786
|
-
|
|
11751
|
+
app32.post("/__remote-auth/set-initial-password", async (c) => {
|
|
11787
11752
|
if (isRemoteAuthConfigured()) {
|
|
11788
11753
|
return c.redirect("/");
|
|
11789
11754
|
}
|
|
@@ -11819,10 +11784,10 @@ app33.post("/__remote-auth/set-initial-password", async (c) => {
|
|
|
11819
11784
|
return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(), mode: "setup", setupError: "Failed to save password. Please try again." }), 200);
|
|
11820
11785
|
}
|
|
11821
11786
|
});
|
|
11822
|
-
|
|
11787
|
+
app32.get("/api/remote-auth/status", (c) => {
|
|
11823
11788
|
return c.json({ configured: isRemoteAuthConfigured() });
|
|
11824
11789
|
});
|
|
11825
|
-
|
|
11790
|
+
app32.post("/api/remote-auth/set-password", async (c) => {
|
|
11826
11791
|
let body;
|
|
11827
11792
|
try {
|
|
11828
11793
|
body = await c.req.json();
|
|
@@ -11852,9 +11817,9 @@ app33.post("/api/remote-auth/set-password", async (c) => {
|
|
|
11852
11817
|
return c.json({ error: "Failed to save password" }, 500);
|
|
11853
11818
|
}
|
|
11854
11819
|
});
|
|
11855
|
-
|
|
11820
|
+
app32.route("/api/_client-error", client_error_default);
|
|
11856
11821
|
console.log("[client-error-route] mounted");
|
|
11857
|
-
|
|
11822
|
+
app32.use("*", async (c, next) => {
|
|
11858
11823
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
11859
11824
|
const path2 = c.req.path;
|
|
11860
11825
|
if (path2 === "/favicon.ico" || path2.startsWith("/assets/") || path2.startsWith("/brand/")) {
|
|
@@ -11887,15 +11852,15 @@ app33.use("*", async (c, next) => {
|
|
|
11887
11852
|
console.error(`[remote-auth] login required ip=${clientIp} path=${path2} ${disambig}`);
|
|
11888
11853
|
return c.html(renderLoginPage({ ...resolveRemoteAuthOpts(), redirect: path2 }), 200);
|
|
11889
11854
|
});
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11855
|
+
app32.route("/api/health", health_default);
|
|
11856
|
+
app32.route("/api/session", session_default);
|
|
11857
|
+
app32.route("/api/chat", chat_default);
|
|
11858
|
+
app32.route("/api/group", group_default);
|
|
11859
|
+
app32.route("/api/access", access_default);
|
|
11860
|
+
app32.route("/api/telegram", telegram_default);
|
|
11861
|
+
app32.route("/api/whatsapp", whatsapp_default);
|
|
11862
|
+
app32.route("/api/onboarding", onboarding_default);
|
|
11863
|
+
app32.route("/api/admin", admin_default);
|
|
11899
11864
|
var SAFE_SLUG_RE = /^[a-z][a-z0-9-]{2,49}$/;
|
|
11900
11865
|
var SAFE_FILENAME_RE = /^[a-z0-9_][a-z0-9_.-]{0,99}$/i;
|
|
11901
11866
|
var IMAGE_MIME = {
|
|
@@ -11907,7 +11872,7 @@ var IMAGE_MIME = {
|
|
|
11907
11872
|
".svg": "image/svg+xml",
|
|
11908
11873
|
".ico": "image/x-icon"
|
|
11909
11874
|
};
|
|
11910
|
-
|
|
11875
|
+
app32.get("/agent-assets/:slug/:filename", (c) => {
|
|
11911
11876
|
const slug = c.req.param("slug");
|
|
11912
11877
|
const filename = c.req.param("filename");
|
|
11913
11878
|
if (!SAFE_SLUG_RE.test(slug)) {
|
|
@@ -11923,8 +11888,8 @@ app33.get("/agent-assets/:slug/:filename", (c) => {
|
|
|
11923
11888
|
console.error(`[agent-assets] no-account slug=${slug} file=${filename}`);
|
|
11924
11889
|
return c.text("Not found", 404);
|
|
11925
11890
|
}
|
|
11926
|
-
const filePath =
|
|
11927
|
-
const expectedDir =
|
|
11891
|
+
const filePath = resolve20(account.accountDir, "agents", slug, "assets", filename);
|
|
11892
|
+
const expectedDir = resolve20(account.accountDir, "agents", slug, "assets");
|
|
11928
11893
|
if (!filePath.startsWith(expectedDir + "/")) {
|
|
11929
11894
|
console.error(`[agent-assets] path-traversal-rejected slug=${slug} file=${filename}`);
|
|
11930
11895
|
return c.text("Forbidden", 403);
|
|
@@ -11936,13 +11901,13 @@ app33.get("/agent-assets/:slug/:filename", (c) => {
|
|
|
11936
11901
|
const ext = "." + filename.split(".").pop()?.toLowerCase();
|
|
11937
11902
|
const contentType = IMAGE_MIME[ext] || "application/octet-stream";
|
|
11938
11903
|
console.log(`[agent-assets] serve slug=${slug} file=${filename} status=200`);
|
|
11939
|
-
const body =
|
|
11904
|
+
const body = readFileSync16(filePath);
|
|
11940
11905
|
return c.body(body, 200, {
|
|
11941
11906
|
"Content-Type": contentType,
|
|
11942
11907
|
"Cache-Control": "public, max-age=3600"
|
|
11943
11908
|
});
|
|
11944
11909
|
});
|
|
11945
|
-
|
|
11910
|
+
app32.get("/generated/:filename", (c) => {
|
|
11946
11911
|
const filename = c.req.param("filename");
|
|
11947
11912
|
if (!SAFE_FILENAME_RE.test(filename) || filename.includes("..")) {
|
|
11948
11913
|
console.error(`[generated] serve file=${filename} status=403`);
|
|
@@ -11953,8 +11918,8 @@ app33.get("/generated/:filename", (c) => {
|
|
|
11953
11918
|
console.error(`[generated] serve file=${filename} status=404`);
|
|
11954
11919
|
return c.text("Not found", 404);
|
|
11955
11920
|
}
|
|
11956
|
-
const filePath =
|
|
11957
|
-
const expectedDir =
|
|
11921
|
+
const filePath = resolve20(account.accountDir, "generated", filename);
|
|
11922
|
+
const expectedDir = resolve20(account.accountDir, "generated");
|
|
11958
11923
|
if (!filePath.startsWith(expectedDir + "/")) {
|
|
11959
11924
|
console.error(`[generated] serve file=${filename} status=403`);
|
|
11960
11925
|
return c.text("Forbidden", 403);
|
|
@@ -11966,7 +11931,7 @@ app33.get("/generated/:filename", (c) => {
|
|
|
11966
11931
|
const ext = "." + filename.split(".").pop()?.toLowerCase();
|
|
11967
11932
|
const contentType = IMAGE_MIME[ext] || "application/octet-stream";
|
|
11968
11933
|
console.log(`[generated] serve file=${filename} status=200`);
|
|
11969
|
-
const body =
|
|
11934
|
+
const body = readFileSync16(filePath);
|
|
11970
11935
|
return c.body(body, 200, {
|
|
11971
11936
|
"Content-Type": contentType,
|
|
11972
11937
|
"Cache-Control": "public, max-age=86400"
|
|
@@ -11977,7 +11942,7 @@ var brandLogoPath = "/brand/maxy-monochrome.png";
|
|
|
11977
11942
|
var brandIconPath = "/brand/maxy-monochrome.png";
|
|
11978
11943
|
if (BRAND_JSON_PATH && existsSync19(BRAND_JSON_PATH)) {
|
|
11979
11944
|
try {
|
|
11980
|
-
const fullBrand = JSON.parse(
|
|
11945
|
+
const fullBrand = JSON.parse(readFileSync16(BRAND_JSON_PATH, "utf-8"));
|
|
11981
11946
|
if (fullBrand.assets?.logo) brandLogoPath = `/brand/${fullBrand.assets.logo}`;
|
|
11982
11947
|
brandIconPath = fullBrand.assets?.icon ? `/brand/${fullBrand.assets.icon}` : brandLogoPath;
|
|
11983
11948
|
} catch {
|
|
@@ -11996,7 +11961,7 @@ function readInstalledVersion() {
|
|
|
11996
11961
|
if (!PLATFORM_ROOT6) return "unknown";
|
|
11997
11962
|
const versionFile = join10(PLATFORM_ROOT6, "config", `.${BRAND.hostname}-version`);
|
|
11998
11963
|
if (!existsSync19(versionFile)) return "unknown";
|
|
11999
|
-
const content =
|
|
11964
|
+
const content = readFileSync16(versionFile, "utf-8").trim();
|
|
12000
11965
|
return content || "unknown";
|
|
12001
11966
|
} catch {
|
|
12002
11967
|
return "unknown";
|
|
@@ -12037,7 +12002,7 @@ var clientErrorReporterScript = `<script>
|
|
|
12037
12002
|
function cachedHtml(file) {
|
|
12038
12003
|
let html = htmlCache.get(file);
|
|
12039
12004
|
if (!html) {
|
|
12040
|
-
html =
|
|
12005
|
+
html = readFileSync16(resolve20(process.cwd(), "public", file), "utf-8");
|
|
12041
12006
|
html = html.replace("<title>Maxy</title>", `<title>${escapeHtml(BRAND.productName)}</title>`);
|
|
12042
12007
|
html = html.replace('href="/favicon.ico"', `href="${escapeHtml(brandFaviconPath)}"`);
|
|
12043
12008
|
const headInjection = file === "index.html" ? `${brandScript}
|
|
@@ -12056,12 +12021,12 @@ function loadBrandingCache(agentSlug) {
|
|
|
12056
12021
|
try {
|
|
12057
12022
|
const accountJsonPath = join10(configDir2, "account.json");
|
|
12058
12023
|
if (!existsSync19(accountJsonPath)) return null;
|
|
12059
|
-
const account = JSON.parse(
|
|
12024
|
+
const account = JSON.parse(readFileSync16(accountJsonPath, "utf-8"));
|
|
12060
12025
|
const accountId = account.accountId;
|
|
12061
12026
|
if (!accountId) return null;
|
|
12062
12027
|
const cachePath = join10(configDir2, "branding-cache", accountId, `${agentSlug}.json`);
|
|
12063
12028
|
if (!existsSync19(cachePath)) return null;
|
|
12064
|
-
return JSON.parse(
|
|
12029
|
+
return JSON.parse(readFileSync16(cachePath, "utf-8"));
|
|
12065
12030
|
} catch {
|
|
12066
12031
|
return null;
|
|
12067
12032
|
}
|
|
@@ -12071,7 +12036,7 @@ function resolveDefaultSlug() {
|
|
|
12071
12036
|
const configDir2 = join10(homedir2(), BRAND.configDir);
|
|
12072
12037
|
const accountJsonPath = join10(configDir2, "account.json");
|
|
12073
12038
|
if (!existsSync19(accountJsonPath)) return null;
|
|
12074
|
-
const account = JSON.parse(
|
|
12039
|
+
const account = JSON.parse(readFileSync16(accountJsonPath, "utf-8"));
|
|
12075
12040
|
return account.defaultAgent || null;
|
|
12076
12041
|
} catch {
|
|
12077
12042
|
return null;
|
|
@@ -12107,7 +12072,7 @@ function brandedPublicHtml(agentSlug) {
|
|
|
12107
12072
|
function escapeHtml(s) {
|
|
12108
12073
|
return s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
12109
12074
|
}
|
|
12110
|
-
|
|
12075
|
+
app32.get("/", (c) => {
|
|
12111
12076
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
12112
12077
|
if (isPublicHost(host)) {
|
|
12113
12078
|
const defaultSlug = resolveDefaultSlug();
|
|
@@ -12115,12 +12080,12 @@ app33.get("/", (c) => {
|
|
|
12115
12080
|
}
|
|
12116
12081
|
return c.html(cachedHtml("index.html"));
|
|
12117
12082
|
});
|
|
12118
|
-
|
|
12083
|
+
app32.get("/public", (c) => {
|
|
12119
12084
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
12120
12085
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
12121
12086
|
return c.html(cachedHtml("public.html"));
|
|
12122
12087
|
});
|
|
12123
|
-
|
|
12088
|
+
app32.get("/chat", (c) => {
|
|
12124
12089
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
12125
12090
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
12126
12091
|
return c.html(cachedHtml("public.html"));
|
|
@@ -12139,12 +12104,12 @@ async function logViewerFetch(c, next) {
|
|
|
12139
12104
|
duration_ms: Date.now() - start
|
|
12140
12105
|
});
|
|
12141
12106
|
}
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12107
|
+
app32.use("/vnc-viewer.html", logViewerFetch);
|
|
12108
|
+
app32.use("/vnc-popout.html", logViewerFetch);
|
|
12109
|
+
app32.get("/vnc-popout.html", (c) => {
|
|
12145
12110
|
let html = htmlCache.get("vnc-popout.html");
|
|
12146
12111
|
if (!html) {
|
|
12147
|
-
html =
|
|
12112
|
+
html = readFileSync16(resolve20(process.cwd(), "public", "vnc-popout.html"), "utf-8");
|
|
12148
12113
|
const name = escapeHtml(BRAND.productName);
|
|
12149
12114
|
html = html.replace("<title>Browser \u2014 Maxy</title>", `<title>${name}</title>`);
|
|
12150
12115
|
html = html.replace("</head>", ` ${brandScript}
|
|
@@ -12154,7 +12119,7 @@ app33.get("/vnc-popout.html", (c) => {
|
|
|
12154
12119
|
}
|
|
12155
12120
|
return c.html(html);
|
|
12156
12121
|
});
|
|
12157
|
-
|
|
12122
|
+
app32.post("/api/vnc/client-event", async (c) => {
|
|
12158
12123
|
let body;
|
|
12159
12124
|
try {
|
|
12160
12125
|
body = await c.req.json();
|
|
@@ -12175,20 +12140,20 @@ app33.post("/api/vnc/client-event", async (c) => {
|
|
|
12175
12140
|
});
|
|
12176
12141
|
return c.json({ ok: true });
|
|
12177
12142
|
});
|
|
12178
|
-
|
|
12143
|
+
app32.get("/g/:slug", (c) => {
|
|
12179
12144
|
return c.html(brandedPublicHtml());
|
|
12180
12145
|
});
|
|
12181
|
-
|
|
12146
|
+
app32.get("/graph", (c) => {
|
|
12182
12147
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
12183
12148
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
12184
12149
|
return c.html(cachedHtml("graph.html"));
|
|
12185
12150
|
});
|
|
12186
|
-
|
|
12151
|
+
app32.get("/data", (c) => {
|
|
12187
12152
|
const host = (c.req.header("host") ?? "").split(":")[0];
|
|
12188
12153
|
if (isPublicHost(host)) return c.text("Not found", 404);
|
|
12189
12154
|
return c.html(cachedHtml("data.html"));
|
|
12190
12155
|
});
|
|
12191
|
-
|
|
12156
|
+
app32.get("/:slug", async (c, next) => {
|
|
12192
12157
|
const slug = c.req.param("slug");
|
|
12193
12158
|
if (AGENT_SLUG_PATTERN.test(`/${slug}`)) {
|
|
12194
12159
|
const branding = loadBrandingCache(slug);
|
|
@@ -12197,10 +12162,10 @@ app33.get("/:slug", async (c, next) => {
|
|
|
12197
12162
|
}
|
|
12198
12163
|
await next();
|
|
12199
12164
|
});
|
|
12200
|
-
|
|
12165
|
+
app32.use("/*", serveStatic({ root: "./public" }));
|
|
12201
12166
|
var port = parseInt(process.env.MAXY_UI_INTERNAL_PORT ?? process.env.PORT ?? "19199", 10);
|
|
12202
12167
|
var hostname = process.env.HOSTNAME ?? "127.0.0.1";
|
|
12203
|
-
var httpServer = serve({ fetch:
|
|
12168
|
+
var httpServer = serve({ fetch: app32.fetch, port, hostname });
|
|
12204
12169
|
console.log(`${BRAND.productName} listening on http://${hostname}:${port}`);
|
|
12205
12170
|
var SUBAPP_MANIFEST = [
|
|
12206
12171
|
{ prefix: "/api/health", file: "server/routes/health.ts", subapp: health_default },
|
|
@@ -12220,7 +12185,7 @@ for (const m of SUBAPP_MANIFEST) {
|
|
|
12220
12185
|
}
|
|
12221
12186
|
try {
|
|
12222
12187
|
const registered = [];
|
|
12223
|
-
for (const r of
|
|
12188
|
+
for (const r of app32.routes ?? []) {
|
|
12224
12189
|
if (typeof r.path !== "string" || r.path.includes(":") || r.path.includes("*")) continue;
|
|
12225
12190
|
if (AGENT_SLUG_PATTERN.test(r.path)) {
|
|
12226
12191
|
registered.push({ method: (r.method ?? "ALL").toUpperCase(), path: r.path });
|
|
@@ -12235,7 +12200,7 @@ try {
|
|
|
12235
12200
|
try {
|
|
12236
12201
|
let userId = "";
|
|
12237
12202
|
if (existsSync19(USERS_FILE)) {
|
|
12238
|
-
const users = JSON.parse(
|
|
12203
|
+
const users = JSON.parse(readFileSync16(USERS_FILE, "utf-8").trim() || "[]");
|
|
12239
12204
|
userId = users[0]?.userId ?? "";
|
|
12240
12205
|
}
|
|
12241
12206
|
await backfillNullUserIdConversations(userId);
|
|
@@ -12262,7 +12227,7 @@ if (bootAccountConfig?.whatsapp) {
|
|
|
12262
12227
|
}
|
|
12263
12228
|
init({
|
|
12264
12229
|
configDir: configDirForWhatsApp,
|
|
12265
|
-
platformRoot:
|
|
12230
|
+
platformRoot: resolve20(process.env.MAXY_PLATFORM_ROOT ?? join10(__dirname, "..")),
|
|
12266
12231
|
accountConfig: bootAccountConfig,
|
|
12267
12232
|
onMessage: async (msg) => {
|
|
12268
12233
|
try {
|