@rubytech/create-maxy-code 0.1.475 → 0.1.477
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/lib/storage-broker/dist/cf-exec.d.ts.map +1 -1
- package/payload/platform/lib/storage-broker/dist/cf-exec.js +3 -2
- package/payload/platform/lib/storage-broker/dist/cf-exec.js.map +1 -1
- package/payload/platform/lib/storage-broker/src/cf-exec.ts +3 -2
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +3 -3
- package/payload/platform/plugins/cloudflare/skills/calendar-site/template/schema.sql +13 -3
- package/payload/platform/plugins/docs/references/calendar-booking.md +2 -2
- package/payload/platform/plugins/scheduling/PLUGIN.md +2 -2
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-block-sqlite.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-block-sqlite.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-block-sqlite.test.js +150 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-block-sqlite.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-block.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-block.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-block.test.js +248 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-block.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js +158 -23
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-schema-migration.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-schema-migration.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-schema-migration.test.js +200 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-schema-migration.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-sync-provision.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-sync-provision.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-sync-provision.test.js +309 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/connector-sync-provision.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/d1-command.test.js +219 -19
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/d1-command.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts +184 -11
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js +211 -22
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-sync-provision.d.ts +109 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-sync-provision.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-sync-provision.js +213 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/connector-sync-provision.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/d1-command.d.ts +80 -8
- package/payload/platform/plugins/scheduling/mcp/dist/lib/d1-command.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/d1-command.js +202 -8
- package/payload/platform/plugins/scheduling/mcp/dist/lib/d1-command.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.d.ts +6 -4
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js +411 -141
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js.map +1 -1
- package/payload/platform/scripts/cpu-triage.sh +313 -0
- package/payload/server/{chunk-Y6V45R6M.js → chunk-JECAP3Z2.js} +296 -63
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/activity.html +6 -6
- package/payload/server/public/assets/{AdminLoginScreens-B44KbEuC.js → AdminLoginScreens-mEKP4pDi.js} +1 -1
- package/payload/server/public/assets/{AdminShell-BjxV2qkb.js → AdminShell-BwSaZ88d.js} +1 -1
- package/payload/server/public/assets/{Checkbox-DSeZNGNA.js → Checkbox-CN4uQ80w.js} +1 -1
- package/payload/server/public/assets/activity-CIQ8ozNZ.js +1 -0
- package/payload/server/public/assets/{admin-B4LpTCur.js → admin-BVhgfgs1.js} +1 -1
- package/payload/server/public/assets/{browser-CEFvaWwI.js → browser-D-HMmHcM.js} +1 -1
- package/payload/server/public/assets/{calendar-B3zo6V34.js → calendar-tGWvFyFn.js} +1 -1
- package/payload/server/public/assets/chat-DkttVxAz.js +1 -0
- package/payload/server/public/assets/chevron-left-CZ4ez9G5.js +1 -0
- package/payload/server/public/assets/data-P-mcmnNi.js +1 -0
- package/payload/server/public/assets/{graph-labels-GlTEIYJj.js → graph-labels-qnBleOE6.js} +1 -1
- package/payload/server/public/assets/{graph-RaOrnSf2.js → graph-zEw610xK.js} +1 -1
- package/payload/server/public/assets/{maximize-2-CHDa8p5h.js → maximize-2-BlTjXT_Y.js} +1 -1
- package/payload/server/public/assets/{operator-DtqHY4jV.js → operator-C7oIw2PG.js} +1 -1
- package/payload/server/public/assets/{page-DxnWgPtd.js → page-CTP7OFZa.js} +1 -1
- package/payload/server/public/assets/{page-CkhFj8GQ.js → page-DL6Zsdvk.js} +1 -1
- package/payload/server/public/assets/{public-D5TUfQ3I.js → public-r1A9dqR_.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-BJjVAQQY.js → rotate-ccw-CzkkKx4-.js} +1 -1
- package/payload/server/public/assets/{tasks-CM9pYYG1.js → tasks-fIJwYFWG.js} +1 -1
- package/payload/server/public/assets/{time-entry-format-C5RYEYjM.js → time-entry-format-j669DgXj.js} +1 -1
- package/payload/server/public/assets/{triangle-alert-DLfIsuo_.js → triangle-alert-BPgCgIef.js} +1 -1
- package/payload/server/public/assets/{useCopyFeedback-7yKeiAzV.js → useCopyFeedback-BmLa2aes.js} +1 -1
- package/payload/server/public/assets/{useSelectionMode-CWlh6AEq.js → useSelectionMode-DnnM7A8-.js} +1 -1
- package/payload/server/public/assets/{useSubAccountSwitcher-B2n9QPVI.css → useSubAccountSwitcher-C_E8h07P.css} +1 -1
- package/payload/server/public/assets/{useVoiceRecorder-j3ZArZ2H.js → useVoiceRecorder-u2dwZfen.js} +1 -1
- package/payload/server/public/browser.html +5 -5
- package/payload/server/public/calendar.html +6 -6
- package/payload/server/public/chat.html +12 -12
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +11 -11
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +12 -12
- package/payload/server/public/tasks.html +5 -5
- package/payload/server/server.js +358 -189
- package/payload/server/public/assets/activity-Mz1BhgB1.js +0 -1
- package/payload/server/public/assets/chat-5tJdo9i_.js +0 -1
- package/payload/server/public/assets/chevron-left-BJllrPBj.js +0 -1
- package/payload/server/public/assets/data-Du79EgR-.js +0 -1
- /package/payload/server/public/assets/{useSubAccountSwitcher-CBlKgwms.js → useSubAccountSwitcher-CFa6ZAT1.js} +0 -0
|
@@ -2657,10 +2657,231 @@ var serve = (options, listeningListener) => {
|
|
|
2657
2657
|
return server;
|
|
2658
2658
|
};
|
|
2659
2659
|
|
|
2660
|
+
// server/loop-registry.ts
|
|
2661
|
+
import { readFileSync } from "fs";
|
|
2662
|
+
var TAG = "[loop-registry]";
|
|
2663
|
+
var STALL_INTERVALS = 3;
|
|
2664
|
+
var entries = /* @__PURE__ */ new Map();
|
|
2665
|
+
var defaultCpuIo = {
|
|
2666
|
+
ownCpuUs: () => {
|
|
2667
|
+
const u = process.cpuUsage();
|
|
2668
|
+
return u.user + u.system;
|
|
2669
|
+
},
|
|
2670
|
+
childCpuUs: (pid) => readPidCpuUs(pid)
|
|
2671
|
+
};
|
|
2672
|
+
var cpuIo = defaultCpuIo;
|
|
2673
|
+
function parsePidStatCpuUs(raw2) {
|
|
2674
|
+
const close = raw2.lastIndexOf(")");
|
|
2675
|
+
if (close === -1) return null;
|
|
2676
|
+
const after = raw2.slice(close + 2).split(" ");
|
|
2677
|
+
const utime = Number(after[11]);
|
|
2678
|
+
const stime = Number(after[12]);
|
|
2679
|
+
if (!Number.isFinite(utime) || !Number.isFinite(stime)) return null;
|
|
2680
|
+
return (utime + stime) / 100 * 1e6;
|
|
2681
|
+
}
|
|
2682
|
+
function readPidCpuUs(pid) {
|
|
2683
|
+
if (process.platform !== "linux") return null;
|
|
2684
|
+
try {
|
|
2685
|
+
return parsePidStatCpuUs(readFileSync(`/proc/${pid}/stat`, "utf8"));
|
|
2686
|
+
} catch {
|
|
2687
|
+
return null;
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
function sampleCpu(nowMs = Date.now()) {
|
|
2691
|
+
for (const e of entries.values()) {
|
|
2692
|
+
if (!e.cpuAttributable) {
|
|
2693
|
+
e.cpuPct = null;
|
|
2694
|
+
continue;
|
|
2695
|
+
}
|
|
2696
|
+
let childUs = 0;
|
|
2697
|
+
for (const pid of [...e.children]) {
|
|
2698
|
+
const us = cpuIo.childCpuUs(pid);
|
|
2699
|
+
if (us === null) {
|
|
2700
|
+
e.children.delete(pid);
|
|
2701
|
+
continue;
|
|
2702
|
+
}
|
|
2703
|
+
childUs += us;
|
|
2704
|
+
}
|
|
2705
|
+
e.lastChildCpuUs = Math.max(e.lastChildCpuUs, childUs);
|
|
2706
|
+
const totalUs = e.cumulativeCpuUs + e.lastChildCpuUs;
|
|
2707
|
+
const p = e.prior;
|
|
2708
|
+
if (p) {
|
|
2709
|
+
const wallUs = (nowMs - p.atMs) * 1e3;
|
|
2710
|
+
e.cpuPct = wallUs > 0 && totalUs >= p.cpuUs ? (totalUs - p.cpuUs) / wallUs * 100 : null;
|
|
2711
|
+
} else {
|
|
2712
|
+
e.cpuPct = null;
|
|
2713
|
+
}
|
|
2714
|
+
e.prior = { cpuUs: totalUs, atMs: nowMs };
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
var processPrior = null;
|
|
2718
|
+
function sampleProcessCpu(nowMs = Date.now()) {
|
|
2719
|
+
const cpuUs = cpuIo.ownCpuUs();
|
|
2720
|
+
let processPct = null;
|
|
2721
|
+
if (processPrior) {
|
|
2722
|
+
const wallUs = (nowMs - processPrior.atMs) * 1e3;
|
|
2723
|
+
if (wallUs > 0) processPct = (cpuUs - processPrior.cpuUs) / wallUs * 100;
|
|
2724
|
+
}
|
|
2725
|
+
processPrior = { cpuUs, atMs: nowMs };
|
|
2726
|
+
const rows = [...entries.values()];
|
|
2727
|
+
const measured = rows.filter((e) => e.cpuPct !== null);
|
|
2728
|
+
const attributedPct = measured.length === 0 ? null : measured.reduce((sum, e) => sum + (e.cpuPct ?? 0), 0);
|
|
2729
|
+
const unattributedPct = processPct === null || attributedPct === null ? null : Math.max(0, processPct - attributedPct);
|
|
2730
|
+
return { processPct, attributedPct, unattributedPct };
|
|
2731
|
+
}
|
|
2732
|
+
function messageOf(err) {
|
|
2733
|
+
return err instanceof Error ? err.message : String(err);
|
|
2734
|
+
}
|
|
2735
|
+
function finish(e, startedAt, cpuStart, cpuAttributable, note, err) {
|
|
2736
|
+
const cpu = process.cpuUsage(cpuStart);
|
|
2737
|
+
e.running = false;
|
|
2738
|
+
e.lastDurationMs = Date.now() - startedAt;
|
|
2739
|
+
e.lastCpuMs = cpuAttributable ? (cpu.user + cpu.system) / 1e3 : null;
|
|
2740
|
+
if (err !== null) {
|
|
2741
|
+
e.lastOutcome = "error";
|
|
2742
|
+
e.lastError = messageOf(err);
|
|
2743
|
+
e.lastNote = null;
|
|
2744
|
+
e.consecutiveFailures += 1;
|
|
2745
|
+
console.error(
|
|
2746
|
+
`${TAG} op=run name=${e.spec.name} outcome=error streak=${e.consecutiveFailures} ms=${e.lastDurationMs} err="${e.lastError}"`
|
|
2747
|
+
);
|
|
2748
|
+
return;
|
|
2749
|
+
}
|
|
2750
|
+
e.lastOutcome = "ok";
|
|
2751
|
+
e.lastError = null;
|
|
2752
|
+
e.lastNote = typeof note === "string" && note.length > 0 ? note : null;
|
|
2753
|
+
e.successCount += 1;
|
|
2754
|
+
e.consecutiveFailures = 0;
|
|
2755
|
+
}
|
|
2756
|
+
function invoke(e) {
|
|
2757
|
+
if (e.running) {
|
|
2758
|
+
console.warn(`${TAG} op=skip name=${e.spec.name} reason=still-running`);
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
e.running = true;
|
|
2762
|
+
e.runCount += 1;
|
|
2763
|
+
e.lastStartMs = Date.now();
|
|
2764
|
+
const startedAt = e.lastStartMs;
|
|
2765
|
+
const cpuStart = process.cpuUsage();
|
|
2766
|
+
const ownStartUs = cpuIo.ownCpuUs();
|
|
2767
|
+
const ctx = {
|
|
2768
|
+
child: (pid) => {
|
|
2769
|
+
if (typeof pid === "number" && Number.isFinite(pid)) e.children.add(pid);
|
|
2770
|
+
}
|
|
2771
|
+
};
|
|
2772
|
+
let result;
|
|
2773
|
+
try {
|
|
2774
|
+
result = e.spec.run(ctx);
|
|
2775
|
+
} catch (err) {
|
|
2776
|
+
e.cumulativeCpuUs += Math.max(0, cpuIo.ownCpuUs() - ownStartUs);
|
|
2777
|
+
finish(e, startedAt, cpuStart, true, null, err);
|
|
2778
|
+
return;
|
|
2779
|
+
}
|
|
2780
|
+
if (result instanceof Promise) {
|
|
2781
|
+
e.cpuAttributable = false;
|
|
2782
|
+
result.then(
|
|
2783
|
+
(note) => finish(e, startedAt, cpuStart, false, note, null),
|
|
2784
|
+
(err) => finish(e, startedAt, cpuStart, false, null, err)
|
|
2785
|
+
);
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2788
|
+
e.cumulativeCpuUs += Math.max(0, cpuIo.ownCpuUs() - ownStartUs);
|
|
2789
|
+
finish(e, startedAt, cpuStart, true, result, null);
|
|
2790
|
+
}
|
|
2791
|
+
function registerLoop(spec) {
|
|
2792
|
+
if (entries.has(spec.name)) {
|
|
2793
|
+
throw new Error(`${TAG} loop "${spec.name}" is already registered`);
|
|
2794
|
+
}
|
|
2795
|
+
const e = {
|
|
2796
|
+
spec,
|
|
2797
|
+
armedAtMs: Date.now(),
|
|
2798
|
+
lastStartMs: null,
|
|
2799
|
+
lastDurationMs: null,
|
|
2800
|
+
lastCpuMs: null,
|
|
2801
|
+
lastOutcome: null,
|
|
2802
|
+
lastError: null,
|
|
2803
|
+
lastNote: null,
|
|
2804
|
+
runCount: 0,
|
|
2805
|
+
successCount: 0,
|
|
2806
|
+
consecutiveFailures: 0,
|
|
2807
|
+
running: false,
|
|
2808
|
+
timers: [],
|
|
2809
|
+
cumulativeCpuUs: 0,
|
|
2810
|
+
cpuAttributable: true,
|
|
2811
|
+
children: /* @__PURE__ */ new Set(),
|
|
2812
|
+
lastChildCpuUs: 0,
|
|
2813
|
+
prior: null,
|
|
2814
|
+
cpuPct: null
|
|
2815
|
+
};
|
|
2816
|
+
entries.set(spec.name, e);
|
|
2817
|
+
const interval = setInterval(() => invoke(e), spec.intervalMs);
|
|
2818
|
+
if (typeof interval.unref === "function") interval.unref();
|
|
2819
|
+
e.timers.push(interval);
|
|
2820
|
+
console.log(
|
|
2821
|
+
`${TAG} op=arm name=${spec.name} intervalMs=${spec.intervalMs} firstRunMs=${spec.firstRunDelayMs ?? "interval"} detached=${spec.detached === true} armed=${entries.size}`
|
|
2822
|
+
);
|
|
2823
|
+
if (spec.firstRunDelayMs === 0) {
|
|
2824
|
+
invoke(e);
|
|
2825
|
+
} else if (spec.firstRunDelayMs !== void 0) {
|
|
2826
|
+
const first = setTimeout(() => invoke(e), spec.firstRunDelayMs);
|
|
2827
|
+
if (typeof first.unref === "function") first.unref();
|
|
2828
|
+
e.timers.push(first);
|
|
2829
|
+
}
|
|
2830
|
+
let stopped = false;
|
|
2831
|
+
return () => {
|
|
2832
|
+
if (stopped) return;
|
|
2833
|
+
stopped = true;
|
|
2834
|
+
for (const t of e.timers) clearInterval(t);
|
|
2835
|
+
if (entries.get(spec.name) === e) entries.delete(spec.name);
|
|
2836
|
+
console.log(`${TAG} op=disarm name=${spec.name} armed=${entries.size}`);
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
function stateOf(e, nowMs) {
|
|
2840
|
+
if (e.lastStartMs === null) {
|
|
2841
|
+
return nowMs - e.armedAtMs < e.spec.intervalMs ? "waiting" : "never-run";
|
|
2842
|
+
}
|
|
2843
|
+
const overdue = nowMs - e.lastStartMs > e.spec.intervalMs * STALL_INTERVALS;
|
|
2844
|
+
if (overdue) return "stalled";
|
|
2845
|
+
if (e.running) return "running";
|
|
2846
|
+
if (e.successCount === 0) return "never-succeeded";
|
|
2847
|
+
if (e.consecutiveFailures > 0) return "failing";
|
|
2848
|
+
return "ok";
|
|
2849
|
+
}
|
|
2850
|
+
function nextDueOf(e, nowMs) {
|
|
2851
|
+
const elapsed = Math.max(0, nowMs - e.armedAtMs);
|
|
2852
|
+
const ticks = Math.floor(elapsed / e.spec.intervalMs) + 1;
|
|
2853
|
+
return e.armedAtMs + ticks * e.spec.intervalMs;
|
|
2854
|
+
}
|
|
2855
|
+
function listLoops(nowMs = Date.now()) {
|
|
2856
|
+
return [...entries.values()].map((e) => ({
|
|
2857
|
+
name: e.spec.name,
|
|
2858
|
+
intervalMs: e.spec.intervalMs,
|
|
2859
|
+
detached: e.spec.detached === true,
|
|
2860
|
+
armedAtMs: e.armedAtMs,
|
|
2861
|
+
lastStartMs: e.lastStartMs,
|
|
2862
|
+
lastDurationMs: e.lastDurationMs,
|
|
2863
|
+
lastCpuMs: e.lastCpuMs,
|
|
2864
|
+
cpuPct: e.cpuPct,
|
|
2865
|
+
cpuAttributable: e.cpuAttributable,
|
|
2866
|
+
lastOutcome: e.lastOutcome,
|
|
2867
|
+
lastError: e.lastError,
|
|
2868
|
+
lastNote: e.lastNote,
|
|
2869
|
+
runCount: e.runCount,
|
|
2870
|
+
successCount: e.successCount,
|
|
2871
|
+
consecutiveFailures: e.consecutiveFailures,
|
|
2872
|
+
running: e.running,
|
|
2873
|
+
state: stateOf(e, nowMs),
|
|
2874
|
+
nextDueMs: nextDueOf(e, nowMs)
|
|
2875
|
+
}));
|
|
2876
|
+
}
|
|
2877
|
+
function armedCount() {
|
|
2878
|
+
return entries.size;
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2660
2881
|
// app/lib/paths.ts
|
|
2661
2882
|
import { homedir } from "os";
|
|
2662
2883
|
import { resolve, join } from "path";
|
|
2663
|
-
import { existsSync, readFileSync } from "fs";
|
|
2884
|
+
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
2664
2885
|
var configDirName = ".maxy";
|
|
2665
2886
|
var commercialMode = false;
|
|
2666
2887
|
var bundleMode = "none";
|
|
@@ -2676,7 +2897,7 @@ if (platformRoot) {
|
|
|
2676
2897
|
if (existsSync(brandPath)) {
|
|
2677
2898
|
let brand;
|
|
2678
2899
|
try {
|
|
2679
|
-
brand = JSON.parse(
|
|
2900
|
+
brand = JSON.parse(readFileSync2(brandPath, "utf-8"));
|
|
2680
2901
|
} catch (err) {
|
|
2681
2902
|
const detail = (err instanceof Error ? err.message : String(err)).slice(0, 160);
|
|
2682
2903
|
console.error(`[paths] error reason=brand-config-missing path=${brandPath} detail="parse failed: ${detail.replace(/"/g, "'")}"`);
|
|
@@ -2792,7 +3013,7 @@ function websockifyLog(event, fields = {}) {
|
|
|
2792
3013
|
|
|
2793
3014
|
// ../lib/admin-access-password/src/index.ts
|
|
2794
3015
|
import { scrypt, randomBytes, timingSafeEqual } from "crypto";
|
|
2795
|
-
import { existsSync as existsSync2, readFileSync as
|
|
3016
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync, renameSync, unlinkSync, appendFileSync as appendFileSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
2796
3017
|
import { dirname } from "path";
|
|
2797
3018
|
var SCRYPT_N = 16384;
|
|
2798
3019
|
var SCRYPT_R = 8;
|
|
@@ -2848,7 +3069,7 @@ async function matchesHash(password, stored) {
|
|
|
2848
3069
|
}
|
|
2849
3070
|
function readUsers(usersFile) {
|
|
2850
3071
|
if (!existsSync2(usersFile)) return [];
|
|
2851
|
-
const raw2 =
|
|
3072
|
+
const raw2 = readFileSync3(usersFile, "utf-8").trim();
|
|
2852
3073
|
if (!raw2) return [];
|
|
2853
3074
|
const parsed = JSON.parse(raw2);
|
|
2854
3075
|
if (!Array.isArray(parsed)) throw new Error("users.json is not an array");
|
|
@@ -2920,7 +3141,7 @@ function accessStoreUnreadable(usersFile) {
|
|
|
2920
3141
|
}
|
|
2921
3142
|
function migrateLegacyRemotePassword(usersFile, legacyFile, ownerUserId, audit) {
|
|
2922
3143
|
if (!existsSync2(legacyFile)) return "noop-no-legacy";
|
|
2923
|
-
const legacy =
|
|
3144
|
+
const legacy = readFileSync3(legacyFile, "utf-8").trim();
|
|
2924
3145
|
const users = readUsers(usersFile);
|
|
2925
3146
|
const idx = users.findIndex((u) => u.userId === ownerUserId);
|
|
2926
3147
|
if (idx === -1) return "noop-no-owner";
|
|
@@ -2942,7 +3163,7 @@ function migrateLegacyRemotePassword(usersFile, legacyFile, ownerUserId, audit)
|
|
|
2942
3163
|
}
|
|
2943
3164
|
function readLegacyRemoteHash(legacyFile) {
|
|
2944
3165
|
if (!existsSync2(legacyFile)) return null;
|
|
2945
|
-
const raw2 =
|
|
3166
|
+
const raw2 = readFileSync3(legacyFile, "utf-8").trim();
|
|
2946
3167
|
return raw2.includes(":") ? raw2 : null;
|
|
2947
3168
|
}
|
|
2948
3169
|
|
|
@@ -2961,7 +3182,7 @@ function isPasswordValid(password) {
|
|
|
2961
3182
|
|
|
2962
3183
|
// app/lib/remote-auth.ts
|
|
2963
3184
|
import { scrypt as scrypt2, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual2, createHmac } from "crypto";
|
|
2964
|
-
import { readFileSync as
|
|
3185
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3 } from "fs";
|
|
2965
3186
|
import { dirname as dirname2 } from "path";
|
|
2966
3187
|
var SCRYPT_N2 = 16384;
|
|
2967
3188
|
var SCRYPT_R2 = 8;
|
|
@@ -3007,7 +3228,7 @@ var cachedSecret = null;
|
|
|
3007
3228
|
function getSecret() {
|
|
3008
3229
|
if (cachedSecret) return cachedSecret;
|
|
3009
3230
|
try {
|
|
3010
|
-
const hex2 =
|
|
3231
|
+
const hex2 = readFileSync4(REMOTE_SESSION_SECRET_FILE, "utf-8").trim();
|
|
3011
3232
|
if (hex2.length === SECRET_BYTES * 2) {
|
|
3012
3233
|
cachedSecret = Buffer.from(hex2, "hex");
|
|
3013
3234
|
return cachedSecret;
|
|
@@ -3020,7 +3241,7 @@ function getSecret() {
|
|
|
3020
3241
|
writeFileSync2(REMOTE_SESSION_SECRET_FILE, fresh, { mode: 384, flag: "wx" });
|
|
3021
3242
|
} catch {
|
|
3022
3243
|
}
|
|
3023
|
-
const hex =
|
|
3244
|
+
const hex = readFileSync4(REMOTE_SESSION_SECRET_FILE, "utf-8").trim();
|
|
3024
3245
|
cachedSecret = Buffer.from(hex, "hex");
|
|
3025
3246
|
return cachedSecret;
|
|
3026
3247
|
}
|
|
@@ -3151,14 +3372,21 @@ function recordFailedAttempt(client) {
|
|
|
3151
3372
|
function clearRateLimit(client) {
|
|
3152
3373
|
rateLimitMap.delete(bucketKey(client));
|
|
3153
3374
|
}
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3375
|
+
registerLoop({
|
|
3376
|
+
name: "rate-limit-cleanup",
|
|
3377
|
+
intervalMs: 15 * 60 * 1e3,
|
|
3378
|
+
run: () => {
|
|
3379
|
+
const now = Date.now();
|
|
3380
|
+
let purged = 0;
|
|
3381
|
+
for (const [key, rec] of rateLimitMap) {
|
|
3382
|
+
if (rec.lockedUntil > 0 && rec.lockedUntil <= now) {
|
|
3383
|
+
rateLimitMap.delete(key);
|
|
3384
|
+
purged += 1;
|
|
3385
|
+
}
|
|
3159
3386
|
}
|
|
3387
|
+
return `purged ${purged}, ${rateLimitMap.size} tracked`;
|
|
3160
3388
|
}
|
|
3161
|
-
}
|
|
3389
|
+
});
|
|
3162
3390
|
function renderLoginPage(opts) {
|
|
3163
3391
|
const error = opts?.error ?? "";
|
|
3164
3392
|
const lockout = opts?.lockoutSeconds ?? 0;
|
|
@@ -3678,13 +3906,13 @@ function classifyHost(host, operatorDomains2, isPublicHost) {
|
|
|
3678
3906
|
import { watchFile } from "fs";
|
|
3679
3907
|
|
|
3680
3908
|
// app/lib/operator-domains.ts
|
|
3681
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync4, readFileSync as
|
|
3909
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
3682
3910
|
import { dirname as dirname3, resolve as resolve3 } from "path";
|
|
3683
3911
|
var OPERATOR_DOMAINS_PATH = resolve3(MAXY_DIR, "operator-domains.json");
|
|
3684
3912
|
function loadOperatorDomains() {
|
|
3685
3913
|
if (!existsSync3(OPERATOR_DOMAINS_PATH)) return /* @__PURE__ */ new Set();
|
|
3686
3914
|
try {
|
|
3687
|
-
const parsed = JSON.parse(
|
|
3915
|
+
const parsed = JSON.parse(readFileSync5(OPERATOR_DOMAINS_PATH, "utf-8"));
|
|
3688
3916
|
if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
|
|
3689
3917
|
return new Set(parsed.filter((h) => typeof h === "string"));
|
|
3690
3918
|
} catch {
|
|
@@ -3711,11 +3939,11 @@ function getOperatorDomains() {
|
|
|
3711
3939
|
|
|
3712
3940
|
// app/lib/claude-agent/account.ts
|
|
3713
3941
|
import { resolve as resolve4 } from "path";
|
|
3714
|
-
import { readFileSync as
|
|
3942
|
+
import { readFileSync as readFileSync7, readdirSync, existsSync as existsSync5, statSync } from "fs";
|
|
3715
3943
|
|
|
3716
3944
|
// ../lib/brand-templating/src/index.ts
|
|
3717
3945
|
import { join as join2 } from "path";
|
|
3718
|
-
import { existsSync as existsSync4, readFileSync as
|
|
3946
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
|
|
3719
3947
|
var PLACEHOLDER = "{{productName}}";
|
|
3720
3948
|
var cachedProductName = null;
|
|
3721
3949
|
function brandJsonPath() {
|
|
@@ -3735,7 +3963,7 @@ function getBrandProductName() {
|
|
|
3735
3963
|
}
|
|
3736
3964
|
let parsed;
|
|
3737
3965
|
try {
|
|
3738
|
-
parsed = JSON.parse(
|
|
3966
|
+
parsed = JSON.parse(readFileSync6(path, "utf-8"));
|
|
3739
3967
|
} catch (err) {
|
|
3740
3968
|
throw new Error(
|
|
3741
3969
|
`[skill-loader] brand.json unreadable at ${path}: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -3782,8 +4010,8 @@ var _stubDirsLoggedThisBoot = /* @__PURE__ */ new Set();
|
|
|
3782
4010
|
function listValidAccounts() {
|
|
3783
4011
|
if (!existsSync5(ACCOUNTS_DIR)) return [];
|
|
3784
4012
|
const out = [];
|
|
3785
|
-
const
|
|
3786
|
-
for (const entry of
|
|
4013
|
+
const entries2 = readdirSync(ACCOUNTS_DIR, { withFileTypes: true });
|
|
4014
|
+
for (const entry of entries2) {
|
|
3787
4015
|
if (!entry.isDirectory()) continue;
|
|
3788
4016
|
if (entry.name.startsWith(".")) continue;
|
|
3789
4017
|
const accountDir = resolve4(ACCOUNTS_DIR, entry.name);
|
|
@@ -3799,7 +4027,7 @@ function listValidAccounts() {
|
|
|
3799
4027
|
}
|
|
3800
4028
|
let config;
|
|
3801
4029
|
try {
|
|
3802
|
-
config = JSON.parse(
|
|
4030
|
+
config = JSON.parse(readFileSync7(configPath, "utf-8"));
|
|
3803
4031
|
} catch {
|
|
3804
4032
|
console.error(
|
|
3805
4033
|
`[platform] accounts-state CORRUPT-JSON id=${entry.name} \u2014 account.json failed to parse; treating as stub`
|
|
@@ -3818,7 +4046,7 @@ function resolveAccount() {
|
|
|
3818
4046
|
let usersJsonUserId = null;
|
|
3819
4047
|
if (existsSync5(USERS_FILE)) {
|
|
3820
4048
|
try {
|
|
3821
|
-
const raw2 =
|
|
4049
|
+
const raw2 = readFileSync7(USERS_FILE, "utf-8").trim();
|
|
3822
4050
|
if (raw2) {
|
|
3823
4051
|
const users = JSON.parse(raw2);
|
|
3824
4052
|
if (users.length > 0) {
|
|
@@ -3828,13 +4056,13 @@ function resolveAccount() {
|
|
|
3828
4056
|
} catch {
|
|
3829
4057
|
}
|
|
3830
4058
|
}
|
|
3831
|
-
const
|
|
4059
|
+
const entries2 = readdirSync(ACCOUNTS_DIR, { withFileTypes: true });
|
|
3832
4060
|
let fallback = null;
|
|
3833
|
-
for (const entry of
|
|
4061
|
+
for (const entry of entries2) {
|
|
3834
4062
|
if (!entry.isDirectory()) continue;
|
|
3835
4063
|
const configPath = resolve4(ACCOUNTS_DIR, entry.name, "account.json");
|
|
3836
4064
|
if (!existsSync5(configPath)) continue;
|
|
3837
|
-
const raw2 =
|
|
4065
|
+
const raw2 = readFileSync7(configPath, "utf-8");
|
|
3838
4066
|
let config;
|
|
3839
4067
|
try {
|
|
3840
4068
|
config = JSON.parse(raw2);
|
|
@@ -3869,7 +4097,7 @@ function resolveAccount() {
|
|
|
3869
4097
|
function readAgentFile(accountDir, agentName, filename) {
|
|
3870
4098
|
const filePath = resolve4(accountDir, "agents", agentName, filename);
|
|
3871
4099
|
if (!existsSync5(filePath)) return null;
|
|
3872
|
-
const raw2 =
|
|
4100
|
+
const raw2 = readFileSync7(filePath, "utf-8");
|
|
3873
4101
|
if (filename.endsWith(".md")) {
|
|
3874
4102
|
return substituteBrandPlaceholders(raw2, filePath);
|
|
3875
4103
|
}
|
|
@@ -3898,7 +4126,7 @@ function resolveDefaultAgentSlug(accountDir) {
|
|
|
3898
4126
|
}
|
|
3899
4127
|
let config;
|
|
3900
4128
|
try {
|
|
3901
|
-
config = JSON.parse(
|
|
4129
|
+
config = JSON.parse(readFileSync7(configPath, "utf-8"));
|
|
3902
4130
|
} catch (err) {
|
|
3903
4131
|
console.error("[agent-resolve] failed to read account.json:", err);
|
|
3904
4132
|
return null;
|
|
@@ -3973,14 +4201,14 @@ function resolveAgentConfig(accountDir, agentName) {
|
|
|
3973
4201
|
const knowledgeMtime = statSync(knowledgePath).mtimeMs;
|
|
3974
4202
|
const summaryMtime = statSync(summaryPath).mtimeMs;
|
|
3975
4203
|
if (summaryMtime >= knowledgeMtime) {
|
|
3976
|
-
knowledge =
|
|
4204
|
+
knowledge = readFileSync7(summaryPath, "utf-8");
|
|
3977
4205
|
} else {
|
|
3978
4206
|
console.warn(`[agent-config] ${agentName}: KNOWLEDGE-SUMMARY.md is stale (KNOWLEDGE.md is newer) \u2014 using full knowledge`);
|
|
3979
|
-
knowledge =
|
|
4207
|
+
knowledge = readFileSync7(knowledgePath, "utf-8");
|
|
3980
4208
|
}
|
|
3981
4209
|
knowledgeBaked = true;
|
|
3982
4210
|
} else if (hasKnowledge) {
|
|
3983
|
-
knowledge =
|
|
4211
|
+
knowledge = readFileSync7(knowledgePath, "utf-8");
|
|
3984
4212
|
knowledgeBaked = true;
|
|
3985
4213
|
}
|
|
3986
4214
|
let budget = null;
|
|
@@ -4074,7 +4302,7 @@ function getSessionKeyBySessionId(_sessionId) {
|
|
|
4074
4302
|
// app/lib/claude-agent/plugin-manifest.ts
|
|
4075
4303
|
import { resolve as resolve5, join as join3 } from "path";
|
|
4076
4304
|
import {
|
|
4077
|
-
readFileSync as
|
|
4305
|
+
readFileSync as readFileSync8,
|
|
4078
4306
|
writeFileSync as writeFileSync4,
|
|
4079
4307
|
readdirSync as readdirSync2,
|
|
4080
4308
|
existsSync as existsSync6,
|
|
@@ -4096,7 +4324,7 @@ function readBundleSubPlugins(bundlePath) {
|
|
|
4096
4324
|
if (!existsSync6(bundlePath)) return [];
|
|
4097
4325
|
let raw2;
|
|
4098
4326
|
try {
|
|
4099
|
-
raw2 =
|
|
4327
|
+
raw2 = readFileSync8(bundlePath, "utf-8");
|
|
4100
4328
|
} catch {
|
|
4101
4329
|
return [];
|
|
4102
4330
|
}
|
|
@@ -4118,14 +4346,14 @@ function readBundleSubPlugins(bundlePath) {
|
|
|
4118
4346
|
return subs;
|
|
4119
4347
|
}
|
|
4120
4348
|
function walkPremiumBundles() {
|
|
4121
|
-
const
|
|
4349
|
+
const TAG2 = "[premium-auto-deliver]";
|
|
4122
4350
|
if (BUNDLE_MODE === "none") {
|
|
4123
|
-
console.log(`${
|
|
4351
|
+
console.log(`${TAG2} gate brand=${BRAND_NAME} mode=none bundles=[]`);
|
|
4124
4352
|
return [];
|
|
4125
4353
|
}
|
|
4126
4354
|
const onDisk = walkPremiumBundlesOnDisk();
|
|
4127
4355
|
if (BUNDLE_MODE === "all") {
|
|
4128
|
-
console.log(`${
|
|
4356
|
+
console.log(`${TAG2} gate brand=${BRAND_NAME} mode=all bundles=[${onDisk.map((b) => b.bundle).join(",")}]`);
|
|
4129
4357
|
return onDisk;
|
|
4130
4358
|
}
|
|
4131
4359
|
const allow = new Set(BUNDLE_ALLOWLIST);
|
|
@@ -4133,21 +4361,21 @@ function walkPremiumBundles() {
|
|
|
4133
4361
|
const onDiskNames = new Set(onDisk.map((b) => b.bundle));
|
|
4134
4362
|
const missing = BUNDLE_ALLOWLIST.filter((name) => !onDiskNames.has(name));
|
|
4135
4363
|
console.log(
|
|
4136
|
-
`${
|
|
4364
|
+
`${TAG2} gate brand=${BRAND_NAME} mode=allowlist bundles=[${kept.map((b) => b.bundle).join(",")}]` + (missing.length > 0 ? ` missing=[${missing.join(",")}]` : "")
|
|
4137
4365
|
);
|
|
4138
4366
|
return kept;
|
|
4139
4367
|
}
|
|
4140
4368
|
function walkPremiumBundlesOnDisk() {
|
|
4141
4369
|
const stagingRoot = resolve5(PLATFORM_ROOT2, "../premium-plugins");
|
|
4142
4370
|
if (!existsSync6(stagingRoot)) return [];
|
|
4143
|
-
let
|
|
4371
|
+
let entries2;
|
|
4144
4372
|
try {
|
|
4145
|
-
|
|
4373
|
+
entries2 = readdirSync2(stagingRoot);
|
|
4146
4374
|
} catch {
|
|
4147
4375
|
return [];
|
|
4148
4376
|
}
|
|
4149
4377
|
const result = [];
|
|
4150
|
-
for (const bundle of
|
|
4378
|
+
for (const bundle of entries2) {
|
|
4151
4379
|
if (bundle.startsWith(".")) continue;
|
|
4152
4380
|
const bundleDir = resolve5(stagingRoot, bundle);
|
|
4153
4381
|
try {
|
|
@@ -4161,7 +4389,7 @@ function walkPremiumBundlesOnDisk() {
|
|
|
4161
4389
|
return result;
|
|
4162
4390
|
}
|
|
4163
4391
|
function reapDuplicateFlatPremiumSubs(bundles, stagingRoot, pluginsDir) {
|
|
4164
|
-
const
|
|
4392
|
+
const TAG2 = "[premium-auto-deliver]";
|
|
4165
4393
|
for (const { bundle, subs } of bundles) {
|
|
4166
4394
|
const isBundle = existsSync6(join3(stagingRoot, bundle, "BUNDLE.md"));
|
|
4167
4395
|
for (const sub of subs) {
|
|
@@ -4169,25 +4397,25 @@ function reapDuplicateFlatPremiumSubs(bundles, stagingRoot, pluginsDir) {
|
|
|
4169
4397
|
const flatDir = resolve5(pluginsDir, sub);
|
|
4170
4398
|
const flatManifest = resolve5(flatDir, "PLUGIN.md");
|
|
4171
4399
|
if (!existsSync6(premiumManifest) || !existsSync6(flatManifest)) continue;
|
|
4172
|
-
const premiumSha = createHash2("sha256").update(
|
|
4173
|
-
const flatSha = createHash2("sha256").update(
|
|
4400
|
+
const premiumSha = createHash2("sha256").update(readFileSync8(premiumManifest)).digest("hex");
|
|
4401
|
+
const flatSha = createHash2("sha256").update(readFileSync8(flatManifest)).digest("hex");
|
|
4174
4402
|
if (isBundle) {
|
|
4175
4403
|
if (premiumSha === flatSha) {
|
|
4176
4404
|
try {
|
|
4177
4405
|
rmSync(flatDir, { recursive: true });
|
|
4178
|
-
console.log(`${
|
|
4406
|
+
console.log(`${TAG2} reaped sub=${sub} reason=duplicate-of-premium-tree`);
|
|
4179
4407
|
} catch (err) {
|
|
4180
|
-
console.log(`${
|
|
4408
|
+
console.log(`${TAG2} reap-failed sub=${sub} err=${err instanceof Error ? err.message : String(err)}`);
|
|
4181
4409
|
}
|
|
4182
4410
|
} else {
|
|
4183
|
-
console.log(`${
|
|
4411
|
+
console.log(`${TAG2} flat-copy-divergent sub=${sub} action=skip-keep`);
|
|
4184
4412
|
}
|
|
4185
4413
|
} else {
|
|
4186
4414
|
try {
|
|
4187
4415
|
rmSync(flatDir, { recursive: true });
|
|
4188
|
-
console.log(`${
|
|
4416
|
+
console.log(`${TAG2} reaped standalone=${sub} matches-source=${flatSha === premiumSha}`);
|
|
4189
4417
|
} catch (err) {
|
|
4190
|
-
console.log(`${
|
|
4418
|
+
console.log(`${TAG2} reap-failed standalone=${sub} err=${err instanceof Error ? err.message : String(err)}`);
|
|
4191
4419
|
}
|
|
4192
4420
|
}
|
|
4193
4421
|
}
|
|
@@ -4201,7 +4429,7 @@ function autoDeliverPremiumPlugins() {
|
|
|
4201
4429
|
reapDuplicateFlatPremiumSubs(bundles, stagingRoot, pluginsDir);
|
|
4202
4430
|
}
|
|
4203
4431
|
function reconcileEnabledPlugins(accountDir, config, accountId) {
|
|
4204
|
-
const
|
|
4432
|
+
const TAG2 = "[premium-auto-deliver]";
|
|
4205
4433
|
if (!accountDir || !config) return;
|
|
4206
4434
|
const bundles = walkPremiumBundles();
|
|
4207
4435
|
const stagingRoot = resolve5(PLATFORM_ROOT2, "../premium-plugins");
|
|
@@ -4226,19 +4454,19 @@ function reconcileEnabledPlugins(accountDir, config, accountId) {
|
|
|
4226
4454
|
added.push(sub);
|
|
4227
4455
|
}
|
|
4228
4456
|
console.log(
|
|
4229
|
-
`${
|
|
4457
|
+
`${TAG2} stamp accountId=${accountId ?? "unknown"} brand=${BRAND_NAME} mode=${BUNDLE_MODE} bundles=[${bundleNames.join(",")}] added=[${added.join(",")}]`
|
|
4230
4458
|
);
|
|
4231
4459
|
if (added.length === 0) return;
|
|
4232
4460
|
const merged = [...currentSet];
|
|
4233
4461
|
const configPath = resolve5(accountDir, "account.json");
|
|
4234
4462
|
try {
|
|
4235
|
-
const raw2 =
|
|
4463
|
+
const raw2 = readFileSync8(configPath, "utf-8");
|
|
4236
4464
|
const parsed = JSON.parse(raw2);
|
|
4237
4465
|
parsed.enabledPlugins = merged;
|
|
4238
4466
|
writeFileSync4(configPath, JSON.stringify(parsed, null, 2) + "\n");
|
|
4239
4467
|
config.enabledPlugins = merged;
|
|
4240
4468
|
} catch (err) {
|
|
4241
|
-
console.error(`${
|
|
4469
|
+
console.error(`${TAG2} enabled-stamp write failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
4242
4470
|
}
|
|
4243
4471
|
}
|
|
4244
4472
|
function reconcileEnabledPluginsForAccounts(accounts) {
|
|
@@ -4247,7 +4475,7 @@ function reconcileEnabledPluginsForAccounts(accounts) {
|
|
|
4247
4475
|
}
|
|
4248
4476
|
}
|
|
4249
4477
|
function cleanupLeakedPremiumSubs(accountDir, config, accountId) {
|
|
4250
|
-
const
|
|
4478
|
+
const TAG2 = "[premium-auto-deliver]";
|
|
4251
4479
|
if (!accountDir || !config) return;
|
|
4252
4480
|
if (BUNDLE_MODE === "all") return;
|
|
4253
4481
|
const current = Array.isArray(config.enabledPlugins) ? config.enabledPlugins : [];
|
|
@@ -4268,14 +4496,14 @@ function cleanupLeakedPremiumSubs(accountDir, config, accountId) {
|
|
|
4268
4496
|
if (removed.length === 0) return;
|
|
4269
4497
|
const configPath = resolve5(accountDir, "account.json");
|
|
4270
4498
|
try {
|
|
4271
|
-
const raw2 =
|
|
4499
|
+
const raw2 = readFileSync8(configPath, "utf-8");
|
|
4272
4500
|
const parsed = JSON.parse(raw2);
|
|
4273
4501
|
parsed.enabledPlugins = kept;
|
|
4274
4502
|
writeFileSync4(configPath, JSON.stringify(parsed, null, 2) + "\n");
|
|
4275
4503
|
config.enabledPlugins = kept;
|
|
4276
|
-
console.log(`${
|
|
4504
|
+
console.log(`${TAG2} cleanup accountId=${accountId ?? "unknown"} removed=[${removed.join(",")}]`);
|
|
4277
4505
|
} catch (err) {
|
|
4278
|
-
console.error(`${
|
|
4506
|
+
console.error(`${TAG2} cleanup write failed accountId=${accountId ?? "unknown"}: ${err instanceof Error ? err.message : String(err)}`);
|
|
4279
4507
|
}
|
|
4280
4508
|
}
|
|
4281
4509
|
|
|
@@ -4319,7 +4547,7 @@ function requirePortEnv(envName, options = {}) {
|
|
|
4319
4547
|
// app/lib/neo4j-store.ts
|
|
4320
4548
|
import neo4j from "neo4j-driver";
|
|
4321
4549
|
import { randomUUID } from "crypto";
|
|
4322
|
-
import { readFileSync as
|
|
4550
|
+
import { readFileSync as readFileSync9, readdirSync as readdirSync3, existsSync as existsSync7, openSync, readSync, closeSync, statSync as statSync3 } from "fs";
|
|
4323
4551
|
import { resolve as resolve6 } from "path";
|
|
4324
4552
|
var PLATFORM_ROOT3 = process.env.MAXY_PLATFORM_ROOT ?? resolve6(process.cwd(), "..");
|
|
4325
4553
|
var driver = null;
|
|
@@ -4327,7 +4555,7 @@ function readPassword() {
|
|
|
4327
4555
|
if (process.env.NEO4J_PASSWORD) return process.env.NEO4J_PASSWORD;
|
|
4328
4556
|
const passwordFile = resolve6(PLATFORM_ROOT3, "config/.neo4j-password");
|
|
4329
4557
|
try {
|
|
4330
|
-
return
|
|
4558
|
+
return readFileSync9(passwordFile, "utf-8").trim();
|
|
4331
4559
|
} catch {
|
|
4332
4560
|
throw new Error(
|
|
4333
4561
|
`Neo4j password not found. Expected at ${passwordFile} or in NEO4J_PASSWORD env var.`
|
|
@@ -5444,7 +5672,7 @@ function loadEnabledPluginProfileKeys(accountId) {
|
|
|
5444
5672
|
if (!existsSync7(accountFile)) return {};
|
|
5445
5673
|
let enabled;
|
|
5446
5674
|
try {
|
|
5447
|
-
const raw2 =
|
|
5675
|
+
const raw2 = readFileSync9(accountFile, "utf-8");
|
|
5448
5676
|
const parsed = JSON.parse(raw2);
|
|
5449
5677
|
enabled = Array.isArray(parsed.enabledPlugins) ? parsed.enabledPlugins.filter((p) => typeof p === "string") : [];
|
|
5450
5678
|
} catch (err) {
|
|
@@ -5459,7 +5687,7 @@ function loadEnabledPluginProfileKeys(accountId) {
|
|
|
5459
5687
|
if (!existsSync7(manifestPath)) continue;
|
|
5460
5688
|
let manifest;
|
|
5461
5689
|
try {
|
|
5462
|
-
manifest =
|
|
5690
|
+
manifest = readFileSync9(manifestPath, "utf-8");
|
|
5463
5691
|
} catch {
|
|
5464
5692
|
continue;
|
|
5465
5693
|
}
|
|
@@ -5717,11 +5945,11 @@ async function projectAgent(accountId, accountDir, slug) {
|
|
|
5717
5945
|
);
|
|
5718
5946
|
return;
|
|
5719
5947
|
}
|
|
5720
|
-
config = JSON.parse(
|
|
5948
|
+
config = JSON.parse(readFileSync9(configPath, "utf-8"));
|
|
5721
5949
|
for (const { filename, role } of AGENT_FILE_ROLES) {
|
|
5722
5950
|
const filePath = resolve6(agentDir, filename);
|
|
5723
5951
|
if (!existsSync7(filePath)) continue;
|
|
5724
|
-
const body =
|
|
5952
|
+
const body = readFileSync9(filePath, "utf-8");
|
|
5725
5953
|
presentRoles.push({ role, body, edge: ROLE_TO_EDGE[role] });
|
|
5726
5954
|
}
|
|
5727
5955
|
} catch (err) {
|
|
@@ -5971,6 +6199,11 @@ export {
|
|
|
5971
6199
|
Hono2 as Hono,
|
|
5972
6200
|
getRequestListener,
|
|
5973
6201
|
serve,
|
|
6202
|
+
sampleCpu,
|
|
6203
|
+
sampleProcessCpu,
|
|
6204
|
+
registerLoop,
|
|
6205
|
+
listLoops,
|
|
6206
|
+
armedCount,
|
|
5974
6207
|
MAXY_DIR,
|
|
5975
6208
|
BRAND_NAME,
|
|
5976
6209
|
COMMERCIAL_MODE,
|