@markus-global/cli 0.2.1 → 0.2.3
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/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/markus.mjs +184 -160
- package/dist/web-ui/assets/{index-CWMRUBM6.js → index-DuLIQUDd.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
package/dist/markus.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -3854,17 +3854,32 @@ var init_text = __esm({
|
|
|
3854
3854
|
});
|
|
3855
3855
|
|
|
3856
3856
|
// ../shared/dist/version.js
|
|
3857
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
3857
|
+
import { readFileSync as readFileSync2, existsSync as existsSync2 } from "node:fs";
|
|
3858
3858
|
import { dirname, resolve as resolve2 } from "node:path";
|
|
3859
3859
|
import { fileURLToPath } from "node:url";
|
|
3860
|
-
|
|
3860
|
+
function findVersion() {
|
|
3861
|
+
const candidates = [
|
|
3862
|
+
resolve2(__dirname, "..", "package.json"),
|
|
3863
|
+
// npm global: dist/ → ../package.json
|
|
3864
|
+
resolve2(__dirname, "..", "..", "..", "package.json")
|
|
3865
|
+
// monorepo: packages/shared/dist/ → root
|
|
3866
|
+
];
|
|
3867
|
+
for (const p of candidates) {
|
|
3868
|
+
if (existsSync2(p)) {
|
|
3869
|
+
try {
|
|
3870
|
+
return JSON.parse(readFileSync2(p, "utf-8")).version;
|
|
3871
|
+
} catch {
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
return "0.0.0";
|
|
3876
|
+
}
|
|
3877
|
+
var __dirname, APP_VERSION;
|
|
3861
3878
|
var init_version = __esm({
|
|
3862
3879
|
"../shared/dist/version.js"() {
|
|
3863
3880
|
"use strict";
|
|
3864
3881
|
__dirname = dirname(fileURLToPath(import.meta.url));
|
|
3865
|
-
|
|
3866
|
-
rootPkg = JSON.parse(readFileSync2(rootPkgPath, "utf-8"));
|
|
3867
|
-
APP_VERSION = rootPkg.version;
|
|
3882
|
+
APP_VERSION = findVersion();
|
|
3868
3883
|
}
|
|
3869
3884
|
});
|
|
3870
3885
|
|
|
@@ -4027,33 +4042,33 @@ var init_output = __esm({
|
|
|
4027
4042
|
|
|
4028
4043
|
// src/paths.ts
|
|
4029
4044
|
import { resolve as resolve3, join as join2, dirname as dirname2 } from "node:path";
|
|
4030
|
-
import { existsSync as
|
|
4045
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
4031
4046
|
import { homedir as homedir2 } from "node:os";
|
|
4032
4047
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4033
4048
|
function resolveTemplatesDir(sub) {
|
|
4034
4049
|
const userDir = join2(homedir2(), ".markus", "templates", sub);
|
|
4035
|
-
if (
|
|
4050
|
+
if (existsSync3(userDir)) return userDir;
|
|
4036
4051
|
const cwdDir = resolve3(process.cwd(), "templates", sub);
|
|
4037
|
-
if (
|
|
4052
|
+
if (existsSync3(cwdDir)) return cwdDir;
|
|
4038
4053
|
const pkgDir = resolve3(__dirname2, "..", "templates", sub);
|
|
4039
|
-
if (
|
|
4054
|
+
if (existsSync3(pkgDir)) return pkgDir;
|
|
4040
4055
|
return cwdDir;
|
|
4041
4056
|
}
|
|
4042
4057
|
function allTemplateDirs(sub) {
|
|
4043
4058
|
const dirs = [];
|
|
4044
4059
|
const userDir = join2(homedir2(), ".markus", "templates", sub);
|
|
4045
|
-
if (
|
|
4060
|
+
if (existsSync3(userDir)) dirs.push(userDir);
|
|
4046
4061
|
const cwdDir = resolve3(process.cwd(), "templates", sub);
|
|
4047
|
-
if (
|
|
4062
|
+
if (existsSync3(cwdDir)) dirs.push(cwdDir);
|
|
4048
4063
|
const pkgDir = resolve3(__dirname2, "..", "templates", sub);
|
|
4049
|
-
if (
|
|
4064
|
+
if (existsSync3(pkgDir) && !dirs.includes(pkgDir)) dirs.push(pkgDir);
|
|
4050
4065
|
return dirs;
|
|
4051
4066
|
}
|
|
4052
4067
|
function resolveWebUiDir() {
|
|
4053
4068
|
const pkgDir = resolve3(__dirname2, "web-ui");
|
|
4054
|
-
if (
|
|
4069
|
+
if (existsSync3(pkgDir)) return pkgDir;
|
|
4055
4070
|
const devDir = resolve3(__dirname2, "../../web-ui/dist");
|
|
4056
|
-
if (
|
|
4071
|
+
if (existsSync3(devDir)) return devDir;
|
|
4057
4072
|
return void 0;
|
|
4058
4073
|
}
|
|
4059
4074
|
var __filename, __dirname2;
|
|
@@ -4396,7 +4411,7 @@ var init_heartbeat = __esm({
|
|
|
4396
4411
|
});
|
|
4397
4412
|
|
|
4398
4413
|
// ../core/dist/memory/store.js
|
|
4399
|
-
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as
|
|
4414
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync, appendFileSync } from "node:fs";
|
|
4400
4415
|
import { join as join3 } from "node:path";
|
|
4401
4416
|
var log5, MemoryStore;
|
|
4402
4417
|
var init_store = __esm({
|
|
@@ -4530,7 +4545,7 @@ ${summary}
|
|
|
4530
4545
|
getDailyLog(date2) {
|
|
4531
4546
|
const d = date2 ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
4532
4547
|
const logFile = join3(this.logsDir, `${d}.md`);
|
|
4533
|
-
if (!
|
|
4548
|
+
if (!existsSync4(logFile))
|
|
4534
4549
|
return "";
|
|
4535
4550
|
return readFileSync3(logFile, "utf-8");
|
|
4536
4551
|
}
|
|
@@ -4549,7 +4564,7 @@ ${content}`);
|
|
|
4549
4564
|
// --- Long-term: MEMORY.md ---
|
|
4550
4565
|
addLongTermMemory(key2, content) {
|
|
4551
4566
|
let existing = "";
|
|
4552
|
-
if (
|
|
4567
|
+
if (existsSync4(this.longTermFile)) {
|
|
4553
4568
|
existing = readFileSync3(this.longTermFile, "utf-8");
|
|
4554
4569
|
}
|
|
4555
4570
|
const sectionHeader = `## ${key2}`;
|
|
@@ -4572,7 +4587,7 @@ ${content}
|
|
|
4572
4587
|
}
|
|
4573
4588
|
}
|
|
4574
4589
|
getLongTermMemory() {
|
|
4575
|
-
if (!
|
|
4590
|
+
if (!existsSync4(this.longTermFile))
|
|
4576
4591
|
return "";
|
|
4577
4592
|
return readFileSync3(this.longTermFile, "utf-8");
|
|
4578
4593
|
}
|
|
@@ -4664,7 +4679,7 @@ ${tail}`;
|
|
|
4664
4679
|
}
|
|
4665
4680
|
loadFromDisk() {
|
|
4666
4681
|
const memFile = join3(this.dataDir, "memories.json");
|
|
4667
|
-
if (
|
|
4682
|
+
if (existsSync4(memFile)) {
|
|
4668
4683
|
try {
|
|
4669
4684
|
this.entries = JSON.parse(readFileSync3(memFile, "utf-8"));
|
|
4670
4685
|
log5.info(`Loaded ${this.entries.length} memory entries`);
|
|
@@ -4721,7 +4736,7 @@ ${tail}`;
|
|
|
4721
4736
|
});
|
|
4722
4737
|
|
|
4723
4738
|
// ../core/dist/enhanced-memory-system.js
|
|
4724
|
-
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as
|
|
4739
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync3 } from "node:fs";
|
|
4725
4740
|
import { join as join4 } from "node:path";
|
|
4726
4741
|
var log6, EnhancedMemorySystem;
|
|
4727
4742
|
var init_enhanced_memory_system = __esm({
|
|
@@ -5040,7 +5055,7 @@ ${summaryParts.join("\n")}`;
|
|
|
5040
5055
|
loadKnowledgeBase() {
|
|
5041
5056
|
try {
|
|
5042
5057
|
const indexPath = join4(this.knowledgeBaseDir, "index.json");
|
|
5043
|
-
if (
|
|
5058
|
+
if (existsSync5(indexPath)) {
|
|
5044
5059
|
const indexData = JSON.parse(readFileSync4(indexPath, "utf-8"));
|
|
5045
5060
|
indexData.forEach((entry) => {
|
|
5046
5061
|
this.knowledgeIndex.set(entry.id, entry);
|
|
@@ -5077,7 +5092,7 @@ ${summaryParts.join("\n")}`;
|
|
|
5077
5092
|
});
|
|
5078
5093
|
|
|
5079
5094
|
// ../core/dist/agent-metrics.js
|
|
5080
|
-
import { readFileSync as readFileSync5, writeFileSync as writeFileSync4, existsSync as
|
|
5095
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync4 } from "node:fs";
|
|
5081
5096
|
import { join as join5 } from "node:path";
|
|
5082
5097
|
function freshCounters() {
|
|
5083
5098
|
return {
|
|
@@ -5304,7 +5319,7 @@ var init_agent_metrics = __esm({
|
|
|
5304
5319
|
return;
|
|
5305
5320
|
try {
|
|
5306
5321
|
const file = join5(this.dataDir, "metrics.json");
|
|
5307
|
-
if (!
|
|
5322
|
+
if (!existsSync6(file))
|
|
5308
5323
|
return;
|
|
5309
5324
|
const raw = JSON.parse(readFileSync5(file, "utf-8"));
|
|
5310
5325
|
if (raw.startTime)
|
|
@@ -5957,7 +5972,7 @@ var init_token_counter = __esm({
|
|
|
5957
5972
|
});
|
|
5958
5973
|
|
|
5959
5974
|
// ../core/dist/context-engine.js
|
|
5960
|
-
import { readFileSync as readFileSync6, existsSync as
|
|
5975
|
+
import { readFileSync as readFileSync6, existsSync as existsSync7 } from "node:fs";
|
|
5961
5976
|
function estimateTokens(text2, counter) {
|
|
5962
5977
|
return (counter ?? getDefaultTokenCounter()).countTokens(text2);
|
|
5963
5978
|
}
|
|
@@ -6076,7 +6091,7 @@ var init_context_engine = __esm({
|
|
|
6076
6091
|
if (opts.agentWorkspace?.sharedWorkspace) {
|
|
6077
6092
|
const userMdPath = `${opts.agentWorkspace.sharedWorkspace}/USER.md`;
|
|
6078
6093
|
try {
|
|
6079
|
-
if (
|
|
6094
|
+
if (existsSync7(userMdPath)) {
|
|
6080
6095
|
const userProfile = readFileSync6(userMdPath, "utf-8").trim();
|
|
6081
6096
|
if (userProfile) {
|
|
6082
6097
|
parts.push("\n## About the Owner");
|
|
@@ -6940,7 +6955,7 @@ ${tail}`
|
|
|
6940
6955
|
return result;
|
|
6941
6956
|
}
|
|
6942
6957
|
buildOrgContextSection(orgContext, contextMdPath) {
|
|
6943
|
-
if (contextMdPath &&
|
|
6958
|
+
if (contextMdPath && existsSync7(contextMdPath)) {
|
|
6944
6959
|
try {
|
|
6945
6960
|
const content = readFileSync6(contextMdPath, "utf-8");
|
|
6946
6961
|
return `
|
|
@@ -7030,7 +7045,7 @@ ${orgContext.customContext}`);
|
|
|
7030
7045
|
|
|
7031
7046
|
// ../core/dist/environment-profile.js
|
|
7032
7047
|
import { execSync } from "node:child_process";
|
|
7033
|
-
import { existsSync as
|
|
7048
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
7034
7049
|
import { platform, arch, release, homedir as homedir3, cpus, totalmem } from "node:os";
|
|
7035
7050
|
function tryExec(cmd, timeoutMs = 5e3) {
|
|
7036
7051
|
try {
|
|
@@ -7112,7 +7127,7 @@ function detectBrowsers() {
|
|
|
7112
7127
|
{ name: "edge", path: "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" }
|
|
7113
7128
|
];
|
|
7114
7129
|
for (const b of macBrowsers) {
|
|
7115
|
-
if (
|
|
7130
|
+
if (existsSync8(b.path))
|
|
7116
7131
|
browsers.push(b);
|
|
7117
7132
|
}
|
|
7118
7133
|
} else if (p === "linux") {
|
|
@@ -7129,7 +7144,7 @@ function detectBrowsers() {
|
|
|
7129
7144
|
{ name: "edge", path: "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe" }
|
|
7130
7145
|
];
|
|
7131
7146
|
for (const b of winPaths) {
|
|
7132
|
-
if (
|
|
7147
|
+
if (existsSync8(b.path))
|
|
7133
7148
|
browsers.push(b);
|
|
7134
7149
|
}
|
|
7135
7150
|
}
|
|
@@ -7807,7 +7822,7 @@ var init_shell = __esm({
|
|
|
7807
7822
|
});
|
|
7808
7823
|
|
|
7809
7824
|
// ../core/dist/tools/file.js
|
|
7810
|
-
import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as
|
|
7825
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync9, statSync } from "node:fs";
|
|
7811
7826
|
import { dirname as dirname3, resolve as resolve5 } from "node:path";
|
|
7812
7827
|
function resolveAndCheckAccess(rawPath, workspacePath, policy) {
|
|
7813
7828
|
const resolved = workspacePath ? resolve5(workspacePath, rawPath) : resolve5(rawPath);
|
|
@@ -7861,7 +7876,7 @@ function createFileReadTool(security, workspacePath, policy) {
|
|
|
7861
7876
|
return JSON.stringify({ status: "denied", error: check.reason });
|
|
7862
7877
|
}
|
|
7863
7878
|
try {
|
|
7864
|
-
if (!
|
|
7879
|
+
if (!existsSync9(path)) {
|
|
7865
7880
|
return JSON.stringify({ status: "error", error: `File not found: ${path}` });
|
|
7866
7881
|
}
|
|
7867
7882
|
const stat = statSync(path);
|
|
@@ -7974,7 +7989,7 @@ function createFileEditTool(security, workspacePath, policy) {
|
|
|
7974
7989
|
return JSON.stringify({ status: "denied", error: check.reason });
|
|
7975
7990
|
}
|
|
7976
7991
|
try {
|
|
7977
|
-
if (!
|
|
7992
|
+
if (!existsSync9(path)) {
|
|
7978
7993
|
return JSON.stringify({ status: "error", error: `File not found: ${path}` });
|
|
7979
7994
|
}
|
|
7980
7995
|
const content = readFileSync7(path, "utf-8");
|
|
@@ -40587,7 +40602,7 @@ var init_web_extract = __esm({
|
|
|
40587
40602
|
// ../core/dist/tools/search.js
|
|
40588
40603
|
import { execFile } from "node:child_process";
|
|
40589
40604
|
import { resolve as resolve6, relative } from "node:path";
|
|
40590
|
-
import { readdirSync as readdirSync2, statSync as statSync2, existsSync as
|
|
40605
|
+
import { readdirSync as readdirSync2, statSync as statSync2, existsSync as existsSync10 } from "node:fs";
|
|
40591
40606
|
import { promisify } from "node:util";
|
|
40592
40607
|
function isPathAccessible(_resolvedPath, _workspacePath, _policy) {
|
|
40593
40608
|
return true;
|
|
@@ -40743,7 +40758,7 @@ function createListDirectoryTool(workspacePath, policy) {
|
|
|
40743
40758
|
if (!isPathAccessible(target, workspacePath, policy)) {
|
|
40744
40759
|
return JSON.stringify({ status: "denied", error: "Path must be within an accessible workspace zone" });
|
|
40745
40760
|
}
|
|
40746
|
-
if (!
|
|
40761
|
+
if (!existsSync10(target)) {
|
|
40747
40762
|
return JSON.stringify({ status: "error", error: `Directory not found: ${target}` });
|
|
40748
40763
|
}
|
|
40749
40764
|
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", ".next", "__pycache__", ".cache", "coverage", ".turbo"]);
|
|
@@ -40805,7 +40820,7 @@ var init_search = __esm({
|
|
|
40805
40820
|
});
|
|
40806
40821
|
|
|
40807
40822
|
// ../core/dist/tools/patch.js
|
|
40808
|
-
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as
|
|
40823
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync11, unlinkSync } from "node:fs";
|
|
40809
40824
|
import { dirname as dirname4, resolve as resolve7 } from "node:path";
|
|
40810
40825
|
function createPatchTool(security, workspacePath, policy) {
|
|
40811
40826
|
const guard = security ?? defaultSecurityGuard;
|
|
@@ -40872,7 +40887,7 @@ function createPatchTool(security, workspacePath, policy) {
|
|
|
40872
40887
|
if (!patch.hunks || patch.hunks.length === 0) {
|
|
40873
40888
|
return JSON.stringify({ status: "error", error: `edit action requires hunks for ${patch.file}` });
|
|
40874
40889
|
}
|
|
40875
|
-
if (!
|
|
40890
|
+
if (!existsSync11(filePath)) {
|
|
40876
40891
|
return JSON.stringify({ status: "error", error: `File not found for edit: ${patch.file}` });
|
|
40877
40892
|
}
|
|
40878
40893
|
let content = readFileSync8(filePath, "utf-8");
|
|
@@ -40935,7 +40950,7 @@ function createPatchTool(security, workspacePath, policy) {
|
|
|
40935
40950
|
break;
|
|
40936
40951
|
}
|
|
40937
40952
|
case "delete": {
|
|
40938
|
-
if (
|
|
40953
|
+
if (existsSync11(filePath)) {
|
|
40939
40954
|
unlinkSync(filePath);
|
|
40940
40955
|
results.push({ file: patch.file, action: "delete", status: "success" });
|
|
40941
40956
|
} else {
|
|
@@ -42050,7 +42065,7 @@ var init_tool_loop_detector = __esm({
|
|
|
42050
42065
|
});
|
|
42051
42066
|
|
|
42052
42067
|
// ../core/dist/agent.js
|
|
42053
|
-
import { writeFileSync as writeFileSync7, readFileSync as readFileSync9, existsSync as
|
|
42068
|
+
import { writeFileSync as writeFileSync7, readFileSync as readFileSync9, existsSync as existsSync12, mkdirSync as mkdirSync7 } from "node:fs";
|
|
42054
42069
|
import { join as join6 } from "node:path";
|
|
42055
42070
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
42056
42071
|
function isErrorResult(result) {
|
|
@@ -42289,7 +42304,7 @@ var init_agent2 = __esm({
|
|
|
42289
42304
|
*/
|
|
42290
42305
|
reloadRole() {
|
|
42291
42306
|
const roleFile = join6(this.dataDir, "role", "ROLE.md");
|
|
42292
|
-
if (!
|
|
42307
|
+
if (!existsSync12(roleFile))
|
|
42293
42308
|
return;
|
|
42294
42309
|
try {
|
|
42295
42310
|
const content = readFileSync9(roleFile, "utf-8");
|
|
@@ -42715,8 +42730,8 @@ ${conversationText}`
|
|
|
42715
42730
|
return {};
|
|
42716
42731
|
const annPath = join6(this.teamDataDir, "ANNOUNCEMENT.md");
|
|
42717
42732
|
const normsPath = join6(this.teamDataDir, "NORMS.md");
|
|
42718
|
-
const ann =
|
|
42719
|
-
const norms =
|
|
42733
|
+
const ann = existsSync12(annPath) ? readFileSync9(annPath, "utf-8").trim() : "";
|
|
42734
|
+
const norms = existsSync12(normsPath) ? readFileSync9(normsPath, "utf-8").trim() : "";
|
|
42720
42735
|
return {
|
|
42721
42736
|
teamAnnouncements: ann || void 0,
|
|
42722
42737
|
teamNorms: norms || void 0,
|
|
@@ -44993,7 +45008,7 @@ ${e.content.slice(0, 200)}`;
|
|
|
44993
45008
|
});
|
|
44994
45009
|
|
|
44995
45010
|
// ../core/dist/role-loader.js
|
|
44996
|
-
import { readFileSync as readFileSync10, existsSync as
|
|
45011
|
+
import { readFileSync as readFileSync10, existsSync as existsSync13, readdirSync as readdirSync3 } from "node:fs";
|
|
44997
45012
|
import { join as join7, resolve as resolve9 } from "node:path";
|
|
44998
45013
|
var RoleLoader;
|
|
44999
45014
|
var init_role_loader = __esm({
|
|
@@ -45011,10 +45026,10 @@ var init_role_loader = __esm({
|
|
|
45011
45026
|
listAvailableRoles() {
|
|
45012
45027
|
const roles = [];
|
|
45013
45028
|
for (const dir of this.templateDirs) {
|
|
45014
|
-
if (!
|
|
45029
|
+
if (!existsSync13(dir))
|
|
45015
45030
|
continue;
|
|
45016
45031
|
for (const entry of readdirSync3(dir, { withFileTypes: true })) {
|
|
45017
|
-
if (entry.isDirectory() &&
|
|
45032
|
+
if (entry.isDirectory() && existsSync13(join7(dir, entry.name, "ROLE.md"))) {
|
|
45018
45033
|
roles.push(entry.name);
|
|
45019
45034
|
}
|
|
45020
45035
|
}
|
|
@@ -45026,12 +45041,12 @@ var init_role_loader = __esm({
|
|
|
45026
45041
|
* Returns the absolute path to the role's template directory, or undefined if not found.
|
|
45027
45042
|
*/
|
|
45028
45043
|
resolveTemplateDir(roleNameOrPath) {
|
|
45029
|
-
if (
|
|
45044
|
+
if (existsSync13(join7(roleNameOrPath, "ROLE.md"))) {
|
|
45030
45045
|
return roleNameOrPath;
|
|
45031
45046
|
}
|
|
45032
45047
|
for (const dir of this.templateDirs) {
|
|
45033
45048
|
const candidate = join7(dir, roleNameOrPath);
|
|
45034
|
-
if (
|
|
45049
|
+
if (existsSync13(join7(candidate, "ROLE.md"))) {
|
|
45035
45050
|
return candidate;
|
|
45036
45051
|
}
|
|
45037
45052
|
}
|
|
@@ -45061,19 +45076,19 @@ ${sharedContent}` : roleContent;
|
|
|
45061
45076
|
loadSharedInstructions() {
|
|
45062
45077
|
for (const dir of this.templateDirs) {
|
|
45063
45078
|
const p = join7(dir, "SHARED.md");
|
|
45064
|
-
if (
|
|
45079
|
+
if (existsSync13(p))
|
|
45065
45080
|
return readFileSync10(p, "utf-8");
|
|
45066
45081
|
}
|
|
45067
45082
|
return void 0;
|
|
45068
45083
|
}
|
|
45069
45084
|
resolveRoleFiles(nameOrPath) {
|
|
45070
45085
|
let roleDir;
|
|
45071
|
-
if (
|
|
45086
|
+
if (existsSync13(join7(nameOrPath, "ROLE.md"))) {
|
|
45072
45087
|
roleDir = nameOrPath;
|
|
45073
45088
|
} else {
|
|
45074
45089
|
for (const dir of this.templateDirs) {
|
|
45075
45090
|
const candidate = join7(dir, nameOrPath);
|
|
45076
|
-
if (
|
|
45091
|
+
if (existsSync13(join7(candidate, "ROLE.md"))) {
|
|
45077
45092
|
roleDir = candidate;
|
|
45078
45093
|
break;
|
|
45079
45094
|
}
|
|
@@ -45084,7 +45099,7 @@ ${sharedContent}` : roleContent;
|
|
|
45084
45099
|
}
|
|
45085
45100
|
const read = (file) => {
|
|
45086
45101
|
const p = join7(roleDir, file);
|
|
45087
|
-
return
|
|
45102
|
+
return existsSync13(p) ? readFileSync10(p, "utf-8") : void 0;
|
|
45088
45103
|
};
|
|
45089
45104
|
return {
|
|
45090
45105
|
role: readFileSync10(join7(roleDir, "ROLE.md"), "utf-8"),
|
|
@@ -47228,7 +47243,7 @@ var init_memory = __esm({
|
|
|
47228
47243
|
});
|
|
47229
47244
|
|
|
47230
47245
|
// ../core/dist/memory/semantic-search.js
|
|
47231
|
-
import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, existsSync as
|
|
47246
|
+
import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, existsSync as existsSync14, mkdirSync as mkdirSync8 } from "node:fs";
|
|
47232
47247
|
import { join as join8 } from "node:path";
|
|
47233
47248
|
function cosineSimilarity(a, b) {
|
|
47234
47249
|
if (a.length !== b.length)
|
|
@@ -47406,7 +47421,7 @@ var init_semantic_search = __esm({
|
|
|
47406
47421
|
}
|
|
47407
47422
|
load() {
|
|
47408
47423
|
try {
|
|
47409
|
-
if (
|
|
47424
|
+
if (existsSync14(this.storePath)) {
|
|
47410
47425
|
const data = JSON.parse(readFileSync11(this.storePath, "utf-8"));
|
|
47411
47426
|
this.vectors = new Map(data);
|
|
47412
47427
|
log21.info("Local vector store loaded", { entries: this.vectors.size });
|
|
@@ -47745,7 +47760,7 @@ var init_dist3 = __esm({
|
|
|
47745
47760
|
|
|
47746
47761
|
// ../core/dist/agent-manager.js
|
|
47747
47762
|
import { join as join9 } from "node:path";
|
|
47748
|
-
import { mkdirSync as mkdirSync9, readFileSync as readFileSync12, existsSync as
|
|
47763
|
+
import { mkdirSync as mkdirSync9, readFileSync as readFileSync12, existsSync as existsSync15, copyFileSync, rmSync, readdirSync as readdirSync4 } from "node:fs";
|
|
47749
47764
|
import { homedir as homedir4 } from "node:os";
|
|
47750
47765
|
function resolveCurrentTaskId(agentObj, ts, agentId2) {
|
|
47751
47766
|
const activeTasks = agentObj?.getActiveTasks?.() ?? [];
|
|
@@ -48048,7 +48063,7 @@ Priority: ${delegation.priority}`, envelope.from, { name: envelope.from, role: "
|
|
|
48048
48063
|
if (templateDir) {
|
|
48049
48064
|
for (const file of ["ROLE.md", "HEARTBEAT.md", "POLICIES.md", "CONTEXT.md"]) {
|
|
48050
48065
|
const src = join9(templateDir, file);
|
|
48051
|
-
if (
|
|
48066
|
+
if (existsSync15(src))
|
|
48052
48067
|
copyFileSync(src, join9(agentRoleDir, file));
|
|
48053
48068
|
}
|
|
48054
48069
|
}
|
|
@@ -48497,7 +48512,7 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
48497
48512
|
mkdirSync9(agentDataDir, { recursive: true });
|
|
48498
48513
|
const agentRoleDir = join9(agentDataDir, "role");
|
|
48499
48514
|
let role;
|
|
48500
|
-
if (
|
|
48515
|
+
if (existsSync15(join9(agentRoleDir, "ROLE.md"))) {
|
|
48501
48516
|
role = this.roleLoader.loadRole(agentRoleDir);
|
|
48502
48517
|
} else {
|
|
48503
48518
|
role = (() => {
|
|
@@ -48525,7 +48540,7 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
48525
48540
|
mkdirSync9(agentRoleDir, { recursive: true });
|
|
48526
48541
|
for (const file of ["ROLE.md", "HEARTBEAT.md", "POLICIES.md", "CONTEXT.md"]) {
|
|
48527
48542
|
const src = join9(templateDir, file);
|
|
48528
|
-
if (
|
|
48543
|
+
if (existsSync15(src))
|
|
48529
48544
|
copyFileSync(src, join9(agentRoleDir, file));
|
|
48530
48545
|
}
|
|
48531
48546
|
}
|
|
@@ -48978,7 +48993,7 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
48978
48993
|
}
|
|
48979
48994
|
if (opts?.purgeFiles) {
|
|
48980
48995
|
const agentDir = join9(this.dataDir, agentId2);
|
|
48981
|
-
if (
|
|
48996
|
+
if (existsSync15(agentDir)) {
|
|
48982
48997
|
try {
|
|
48983
48998
|
rmSync(agentDir, { recursive: true, force: true });
|
|
48984
48999
|
log26.info(`Agent data directory purged: ${agentDir}`);
|
|
@@ -48993,7 +49008,7 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
48993
49008
|
purgeOrphanedAgentDirs(knownAgentIds) {
|
|
48994
49009
|
const removed = [];
|
|
48995
49010
|
const failed = [];
|
|
48996
|
-
if (!
|
|
49011
|
+
if (!existsSync15(this.dataDir))
|
|
48997
49012
|
return { removed, failed };
|
|
48998
49013
|
for (const entry of readdirSync4(this.dataDir, { withFileTypes: true })) {
|
|
48999
49014
|
if (!entry.isDirectory() || entry.name === "vector-store")
|
|
@@ -49254,7 +49269,7 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
49254
49269
|
const { roleId } = agent.config;
|
|
49255
49270
|
const agentRoleDir = join9(this.dataDir, agentId2, "role");
|
|
49256
49271
|
const originPath = join9(agentRoleDir, ".role-origin.json");
|
|
49257
|
-
if (
|
|
49272
|
+
if (existsSync15(originPath)) {
|
|
49258
49273
|
try {
|
|
49259
49274
|
const origin = JSON.parse(readFileSync12(originPath, "utf-8"));
|
|
49260
49275
|
if (origin.customRole) {
|
|
@@ -49269,7 +49284,7 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
49269
49284
|
}
|
|
49270
49285
|
const agentRolePath = join9(agentRoleDir, "ROLE.md");
|
|
49271
49286
|
const templateRolePath = join9(templateDir, "ROLE.md");
|
|
49272
|
-
if (
|
|
49287
|
+
if (existsSync15(agentRolePath) && existsSync15(templateRolePath)) {
|
|
49273
49288
|
const headingOf = (text2) => text2.match(/^#\s+(.+)/m)?.[1]?.trim();
|
|
49274
49289
|
const agentTitle = headingOf(readFileSync12(agentRolePath, "utf-8"));
|
|
49275
49290
|
const templateTitle = headingOf(readFileSync12(templateRolePath, "utf-8"));
|
|
@@ -49282,8 +49297,8 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
49282
49297
|
for (const file of _AgentManager.ROLE_FILES) {
|
|
49283
49298
|
const tPath = join9(templateDir, file);
|
|
49284
49299
|
const aPath = join9(agentRoleDir, file);
|
|
49285
|
-
const tExists =
|
|
49286
|
-
const aExists =
|
|
49300
|
+
const tExists = existsSync15(tPath);
|
|
49301
|
+
const aExists = existsSync15(aPath);
|
|
49287
49302
|
if (!tExists && !aExists)
|
|
49288
49303
|
continue;
|
|
49289
49304
|
if (tExists && !aExists) {
|
|
@@ -49313,8 +49328,8 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
49313
49328
|
const tPath = templateDir ? join9(templateDir, fileName) : null;
|
|
49314
49329
|
return {
|
|
49315
49330
|
file: fileName,
|
|
49316
|
-
agentContent:
|
|
49317
|
-
templateContent: tPath &&
|
|
49331
|
+
agentContent: existsSync15(aPath) ? readFileSync12(aPath, "utf-8") : null,
|
|
49332
|
+
templateContent: tPath && existsSync15(tPath) ? readFileSync12(tPath, "utf-8") : null
|
|
49318
49333
|
};
|
|
49319
49334
|
}
|
|
49320
49335
|
syncRoleFromTemplate(agentId2, fileNames) {
|
|
@@ -49330,7 +49345,7 @@ Known issues: ${knownIssues}` : ""}`
|
|
|
49330
49345
|
const synced = [];
|
|
49331
49346
|
for (const file of filesToSync) {
|
|
49332
49347
|
const src = join9(templateDir, file);
|
|
49333
|
-
if (
|
|
49348
|
+
if (existsSync15(src)) {
|
|
49334
49349
|
copyFileSync(src, join9(agentRoleDir, file));
|
|
49335
49350
|
synced.push(file);
|
|
49336
49351
|
}
|
|
@@ -50466,7 +50481,7 @@ var init_ollama = __esm({
|
|
|
50466
50481
|
});
|
|
50467
50482
|
|
|
50468
50483
|
// ../core/dist/llm/auth-profiles.js
|
|
50469
|
-
import { readFileSync as readFileSync13, writeFileSync as writeFileSync9, mkdirSync as mkdirSync10, existsSync as
|
|
50484
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync9, mkdirSync as mkdirSync10, existsSync as existsSync16, unlinkSync as unlinkSync2 } from "node:fs";
|
|
50470
50485
|
import { join as join10 } from "node:path";
|
|
50471
50486
|
import { homedir as homedir5 } from "node:os";
|
|
50472
50487
|
var log27, AuthProfileStore;
|
|
@@ -50485,7 +50500,7 @@ var init_auth_profiles = __esm({
|
|
|
50485
50500
|
mkdirSync10(dir, { recursive: true });
|
|
50486
50501
|
}
|
|
50487
50502
|
read() {
|
|
50488
|
-
if (!
|
|
50503
|
+
if (!existsSync16(this.filePath)) {
|
|
50489
50504
|
return { version: 1, profiles: [] };
|
|
50490
50505
|
}
|
|
50491
50506
|
try {
|
|
@@ -52409,7 +52424,7 @@ var init_registry = __esm({
|
|
|
52409
52424
|
});
|
|
52410
52425
|
|
|
52411
52426
|
// ../core/dist/skills/loader.js
|
|
52412
|
-
import { readFileSync as readFileSync14, readdirSync as readdirSync5, existsSync as
|
|
52427
|
+
import { readFileSync as readFileSync14, readdirSync as readdirSync5, existsSync as existsSync17 } from "node:fs";
|
|
52413
52428
|
import { join as join12, resolve as resolve10 } from "node:path";
|
|
52414
52429
|
function resolveMcpServerPaths(servers, skillDir) {
|
|
52415
52430
|
if (!servers)
|
|
@@ -52426,7 +52441,7 @@ function resolveMcpServerPaths(servers, skillDir) {
|
|
|
52426
52441
|
}
|
|
52427
52442
|
function readSkillInstructions(skillDir) {
|
|
52428
52443
|
const skillMdPath = join12(skillDir, "SKILL.md");
|
|
52429
|
-
if (!
|
|
52444
|
+
if (!existsSync17(skillMdPath))
|
|
52430
52445
|
return void 0;
|
|
52431
52446
|
try {
|
|
52432
52447
|
const content = readFileSync14(skillMdPath, "utf-8");
|
|
@@ -52448,7 +52463,7 @@ var init_loader = __esm({
|
|
|
52448
52463
|
// ../core/dist/skills/index.js
|
|
52449
52464
|
import { homedir as homedir7 } from "node:os";
|
|
52450
52465
|
import { join as join13 } from "node:path";
|
|
52451
|
-
import { existsSync as
|
|
52466
|
+
import { existsSync as existsSync18, readFileSync as readFileSync15, readdirSync as readdirSync6, statSync as statSync3 } from "node:fs";
|
|
52452
52467
|
function parseSkillMd(content, dirName) {
|
|
52453
52468
|
const fmMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);
|
|
52454
52469
|
if (!fmMatch) {
|
|
@@ -52479,7 +52494,7 @@ function parseSkillMd(content, dirName) {
|
|
|
52479
52494
|
};
|
|
52480
52495
|
}
|
|
52481
52496
|
function discoverSkillsInDir(dir) {
|
|
52482
|
-
if (!
|
|
52497
|
+
if (!existsSync18(dir))
|
|
52483
52498
|
return [];
|
|
52484
52499
|
const results = [];
|
|
52485
52500
|
let names;
|
|
@@ -52496,7 +52511,7 @@ function discoverSkillsInDir(dir) {
|
|
|
52496
52511
|
} catch {
|
|
52497
52512
|
continue;
|
|
52498
52513
|
}
|
|
52499
|
-
const fsHelper = { existsSync:
|
|
52514
|
+
const fsHelper = { existsSync: existsSync18, readFileSync: (p, _enc) => readFileSync15(p, "utf-8"), join: join13 };
|
|
52500
52515
|
const pkg = readManifest(skillDir, "skill", fsHelper);
|
|
52501
52516
|
if (pkg && pkg.type === "skill") {
|
|
52502
52517
|
const instructions = readSkillInstructions(skillDir);
|
|
@@ -52517,7 +52532,7 @@ function discoverSkillsInDir(dir) {
|
|
|
52517
52532
|
continue;
|
|
52518
52533
|
}
|
|
52519
52534
|
const skillMdPath = join13(skillDir, "SKILL.md");
|
|
52520
|
-
if (
|
|
52535
|
+
if (existsSync18(skillMdPath)) {
|
|
52521
52536
|
try {
|
|
52522
52537
|
const content = readFileSync15(skillMdPath, "utf-8");
|
|
52523
52538
|
const manifest = parseSkillMd(content, name);
|
|
@@ -53374,11 +53389,11 @@ var init_composition = __esm({
|
|
|
53374
53389
|
});
|
|
53375
53390
|
|
|
53376
53391
|
// ../core/dist/workflow/team-template.js
|
|
53377
|
-
import { readdirSync as readdirSync7, readFileSync as readFileSync16, existsSync as
|
|
53392
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync16, existsSync as existsSync19 } from "node:fs";
|
|
53378
53393
|
import { join as join14, resolve as resolve11, dirname as dirname5 } from "node:path";
|
|
53379
53394
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
53380
53395
|
function loadTeamTemplateFromDir(dirPath) {
|
|
53381
|
-
const fsHelper = { existsSync:
|
|
53396
|
+
const fsHelper = { existsSync: existsSync19, readFileSync: (p, _enc) => readFileSync16(p, "utf-8"), join: join14 };
|
|
53382
53397
|
const manifest = readManifest(dirPath, "team", fsHelper);
|
|
53383
53398
|
if (!manifest || manifest.type !== "team")
|
|
53384
53399
|
return null;
|
|
@@ -53401,8 +53416,8 @@ function loadTeamTemplateFromDir(dirPath) {
|
|
|
53401
53416
|
tags: manifest.tags ?? [],
|
|
53402
53417
|
category: manifest.category,
|
|
53403
53418
|
icon: manifest.icon,
|
|
53404
|
-
announcements:
|
|
53405
|
-
norms:
|
|
53419
|
+
announcements: existsSync19(annPath) ? readFileSync16(annPath, "utf-8") : void 0,
|
|
53420
|
+
norms: existsSync19(normsPath) ? readFileSync16(normsPath, "utf-8") : void 0
|
|
53406
53421
|
};
|
|
53407
53422
|
} catch (err) {
|
|
53408
53423
|
log41.warn(`Failed to load team template from ${dirPath}`, { error: String(err) });
|
|
@@ -53414,11 +53429,20 @@ function createDefaultTeamTemplates() {
|
|
|
53414
53429
|
let templatesDir;
|
|
53415
53430
|
try {
|
|
53416
53431
|
const thisFile = fileURLToPath3(import.meta.url);
|
|
53417
|
-
|
|
53432
|
+
const thisDir = dirname5(thisFile);
|
|
53433
|
+
const candidates = [
|
|
53434
|
+
resolve11(thisDir, "..", "templates", "teams"),
|
|
53435
|
+
// npm global: dist/ → ../templates/teams
|
|
53436
|
+
resolve11(thisDir, "..", "..", "..", "..", "templates", "teams"),
|
|
53437
|
+
// monorepo: packages/core/dist/workflow/ → root
|
|
53438
|
+
resolve11(process.cwd(), "templates", "teams")
|
|
53439
|
+
// cwd fallback
|
|
53440
|
+
];
|
|
53441
|
+
templatesDir = candidates.find((d) => existsSync19(d)) ?? candidates[candidates.length - 1];
|
|
53418
53442
|
} catch {
|
|
53419
53443
|
templatesDir = resolve11(process.cwd(), "templates", "teams");
|
|
53420
53444
|
}
|
|
53421
|
-
if (!
|
|
53445
|
+
if (!existsSync19(templatesDir)) {
|
|
53422
53446
|
log41.warn(`Team templates directory not found: ${templatesDir}`);
|
|
53423
53447
|
return registry;
|
|
53424
53448
|
}
|
|
@@ -53613,10 +53637,10 @@ var init_prompt_studio = __esm({
|
|
|
53613
53637
|
const prompt = this.prompts.get(opts.promptId);
|
|
53614
53638
|
if (!prompt)
|
|
53615
53639
|
throw new Error(`Prompt ${opts.promptId} not found`);
|
|
53616
|
-
const
|
|
53617
|
-
if (!
|
|
53640
|
+
const findVersion2 = (v) => prompt.versions.find((pv) => pv.version === v);
|
|
53641
|
+
if (!findVersion2(opts.variantA))
|
|
53618
53642
|
throw new Error(`Variant A (v${opts.variantA}) not found`);
|
|
53619
|
-
if (!
|
|
53643
|
+
if (!findVersion2(opts.variantB))
|
|
53620
53644
|
throw new Error(`Variant B (v${opts.variantB}) not found`);
|
|
53621
53645
|
const test = {
|
|
53622
53646
|
id: generateId("ab-test"),
|
|
@@ -53816,7 +53840,7 @@ var init_dist4 = __esm({
|
|
|
53816
53840
|
});
|
|
53817
53841
|
|
|
53818
53842
|
// ../org-manager/dist/org-service.js
|
|
53819
|
-
import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync10, existsSync as
|
|
53843
|
+
import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync10, existsSync as existsSync20, rmSync as rmSync2 } from "node:fs";
|
|
53820
53844
|
import { join as join15 } from "node:path";
|
|
53821
53845
|
import { homedir as homedir8 } from "node:os";
|
|
53822
53846
|
var log45, OrganizationService;
|
|
@@ -53951,13 +53975,13 @@ var init_org_service = __esm({
|
|
|
53951
53975
|
const annPath = join15(dir, "ANNOUNCEMENT.md");
|
|
53952
53976
|
if (announcements) {
|
|
53953
53977
|
writeFileSync10(annPath, announcements, "utf-8");
|
|
53954
|
-
} else if (!
|
|
53978
|
+
} else if (!existsSync20(annPath)) {
|
|
53955
53979
|
writeFileSync10(annPath, "", "utf-8");
|
|
53956
53980
|
}
|
|
53957
53981
|
const normsPath = join15(dir, "NORMS.md");
|
|
53958
53982
|
if (norms) {
|
|
53959
53983
|
writeFileSync10(normsPath, norms, "utf-8");
|
|
53960
|
-
} else if (!
|
|
53984
|
+
} else if (!existsSync20(normsPath)) {
|
|
53961
53985
|
writeFileSync10(normsPath, "", "utf-8");
|
|
53962
53986
|
}
|
|
53963
53987
|
}
|
|
@@ -54060,7 +54084,7 @@ var init_org_service = __esm({
|
|
|
54060
54084
|
this.teams.delete(teamId);
|
|
54061
54085
|
if (opts?.purgeFiles) {
|
|
54062
54086
|
const teamDir = join15(homedir8(), ".markus", "teams", teamId);
|
|
54063
|
-
if (
|
|
54087
|
+
if (existsSync20(teamDir)) {
|
|
54064
54088
|
try {
|
|
54065
54089
|
rmSync2(teamDir, { recursive: true, force: true });
|
|
54066
54090
|
log45.info(`Team data directory purged: ${teamDir}`);
|
|
@@ -54696,7 +54720,7 @@ var init_org_service = __esm({
|
|
|
54696
54720
|
});
|
|
54697
54721
|
|
|
54698
54722
|
// ../org-manager/dist/task-service.js
|
|
54699
|
-
import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync11, readFileSync as readFileSync17, existsSync as
|
|
54723
|
+
import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync11, readFileSync as readFileSync17, existsSync as existsSync21, cpSync } from "node:fs";
|
|
54700
54724
|
import { join as join16, resolve as resolve12 } from "node:path";
|
|
54701
54725
|
import { homedir as homedir9 } from "node:os";
|
|
54702
54726
|
function formatLocalTimestamp(d = /* @__PURE__ */ new Date()) {
|
|
@@ -54828,7 +54852,7 @@ var init_task_service = __esm({
|
|
|
54828
54852
|
mkdirSync13(join16(dir, "tasks"), { recursive: true });
|
|
54829
54853
|
mkdirSync13(join16(dir, "knowledge"), { recursive: true });
|
|
54830
54854
|
const userMdPath = join16(dir, "USER.md");
|
|
54831
|
-
if (!
|
|
54855
|
+
if (!existsSync21(userMdPath)) {
|
|
54832
54856
|
writeFileSync11(userMdPath, [
|
|
54833
54857
|
"# About the Owner",
|
|
54834
54858
|
"",
|
|
@@ -56456,9 +56480,9 @@ ${c.content}`;
|
|
|
56456
56480
|
const dirMap = { agent: "agents", team: "teams", skill: "skills" };
|
|
56457
56481
|
const artBase = join16(homedir9(), ".markus", "builder-artifacts", dirMap[builderMode]);
|
|
56458
56482
|
const ref = d.reference;
|
|
56459
|
-
if (ref.startsWith(artBase) &&
|
|
56483
|
+
if (ref.startsWith(artBase) && existsSync21(ref)) {
|
|
56460
56484
|
const mfPath = join16(ref, manifestFilename(builderMode));
|
|
56461
|
-
if (
|
|
56485
|
+
if (existsSync21(mfPath)) {
|
|
56462
56486
|
artifactType = builderMode;
|
|
56463
56487
|
try {
|
|
56464
56488
|
artifactData = JSON.parse(readFileSync17(mfPath, "utf-8"));
|
|
@@ -56639,7 +56663,7 @@ ${c.content}`;
|
|
|
56639
56663
|
for (const d of deliverables2) {
|
|
56640
56664
|
if (d.type === "file" && d.reference) {
|
|
56641
56665
|
const src = resolve12(d.reference);
|
|
56642
|
-
if (
|
|
56666
|
+
if (existsSync21(src)) {
|
|
56643
56667
|
try {
|
|
56644
56668
|
const destName = src.split("/").pop() ?? "deliverable";
|
|
56645
56669
|
cpSync(src, join16(taskSharedDir, destName), { recursive: true });
|
|
@@ -56648,7 +56672,7 @@ ${c.content}`;
|
|
|
56648
56672
|
}
|
|
56649
56673
|
}
|
|
56650
56674
|
}
|
|
56651
|
-
if (d.type === "file" && d.summary && !
|
|
56675
|
+
if (d.type === "file" && d.summary && !existsSync21(d.reference)) {
|
|
56652
56676
|
const safeName = d.reference.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
56653
56677
|
writeFileSync11(join16(taskSharedDir, `${safeName}.md`), d.summary);
|
|
56654
56678
|
}
|
|
@@ -58027,7 +58051,7 @@ var init_sse_handler = __esm({
|
|
|
58027
58051
|
|
|
58028
58052
|
// ../org-manager/dist/skill-service.js
|
|
58029
58053
|
import { join as join17, resolve as resolve13 } from "node:path";
|
|
58030
|
-
import { existsSync as
|
|
58054
|
+
import { existsSync as existsSync22, writeFileSync as writeFileSync12, mkdirSync as mkdirSync14, readFileSync as readFileSync18, readdirSync as readdirSync8, copyFileSync as copyFileSync2 } from "node:fs";
|
|
58031
58055
|
import { homedir as homedir10 } from "node:os";
|
|
58032
58056
|
import { execSync as execSync2 } from "node:child_process";
|
|
58033
58057
|
async function searchSkillHub(query2) {
|
|
@@ -58162,7 +58186,7 @@ async function installSkill(request, skillRegistry) {
|
|
|
58162
58186
|
let installMethod = "metadata-only";
|
|
58163
58187
|
if (source === "builtin") {
|
|
58164
58188
|
const builtinDir = resolve13(process.cwd(), "templates", "skills", safeName);
|
|
58165
|
-
if (
|
|
58189
|
+
if (existsSync22(builtinDir)) {
|
|
58166
58190
|
mkdirSync14(targetDir, { recursive: true });
|
|
58167
58191
|
for (const file of readdirSync8(builtinDir)) {
|
|
58168
58192
|
copyFileSync2(join17(builtinDir, file), join17(targetDir, file));
|
|
@@ -58257,7 +58281,7 @@ async function installSkill(request, skillRegistry) {
|
|
|
58257
58281
|
}
|
|
58258
58282
|
const skillMfPath = join17(targetDir, manifestFilename("skill"));
|
|
58259
58283
|
const skillSource = { type: source ?? "local", url: sourceUrl ?? "" };
|
|
58260
|
-
if (!
|
|
58284
|
+
if (!existsSync22(skillMfPath)) {
|
|
58261
58285
|
const raw = {
|
|
58262
58286
|
name: skillName,
|
|
58263
58287
|
version: version2 ?? "1.0.0",
|
|
@@ -58306,7 +58330,7 @@ var init_skill_service = __esm({
|
|
|
58306
58330
|
// ../org-manager/dist/api-server.js
|
|
58307
58331
|
import { createServer as createServer2 } from "node:http";
|
|
58308
58332
|
import { join as join18, resolve as resolve14, dirname as dirname6 } from "node:path";
|
|
58309
|
-
import { readdirSync as readdirSync9, readFileSync as readFileSync19, existsSync as
|
|
58333
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync19, existsSync as existsSync23, writeFileSync as writeFileSync13, mkdirSync as mkdirSync15, copyFileSync as copyFileSync3, rmSync as rmSync3, statSync as statSync4 } from "node:fs";
|
|
58310
58334
|
import { homedir as homedir11 } from "node:os";
|
|
58311
58335
|
import { execSync as execSync3 } from "node:child_process";
|
|
58312
58336
|
async function signToken(payload, secret) {
|
|
@@ -59566,7 +59590,7 @@ var init_api_server = __esm({
|
|
|
59566
59590
|
if (path.match(/^\/api\/teams\/[^/]+\/files$/) && req.method === "GET") {
|
|
59567
59591
|
const teamId = path.split("/")[3];
|
|
59568
59592
|
const dir = this.orgService.getTeamDataDir(teamId);
|
|
59569
|
-
if (!
|
|
59593
|
+
if (!existsSync23(dir)) {
|
|
59570
59594
|
this.json(res, 200, { files: [] });
|
|
59571
59595
|
return;
|
|
59572
59596
|
}
|
|
@@ -59583,7 +59607,7 @@ var init_api_server = __esm({
|
|
|
59583
59607
|
return;
|
|
59584
59608
|
}
|
|
59585
59609
|
const filePath = join18(this.orgService.getTeamDataDir(teamId), filename);
|
|
59586
|
-
if (!
|
|
59610
|
+
if (!existsSync23(filePath)) {
|
|
59587
59611
|
this.json(res, 404, { error: "File not found" });
|
|
59588
59612
|
return;
|
|
59589
59613
|
}
|
|
@@ -60067,7 +60091,7 @@ var init_api_server = __esm({
|
|
|
60067
60091
|
}
|
|
60068
60092
|
const teamDataDir = this.orgService.getTeamDataDir(teamId);
|
|
60069
60093
|
const files = {};
|
|
60070
|
-
if (teamDataDir &&
|
|
60094
|
+
if (teamDataDir && existsSync23(teamDataDir)) {
|
|
60071
60095
|
for (const fname of readdirSync9(teamDataDir)) {
|
|
60072
60096
|
const fpath = join18(teamDataDir, fname);
|
|
60073
60097
|
try {
|
|
@@ -60087,7 +60111,7 @@ var init_api_server = __esm({
|
|
|
60087
60111
|
const slug = agent.config.name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "") || agentId2;
|
|
60088
60112
|
for (const fname of roleFileNames) {
|
|
60089
60113
|
const fpath = join18(roleDir, fname);
|
|
60090
|
-
if (
|
|
60114
|
+
if (existsSync23(fpath)) {
|
|
60091
60115
|
try {
|
|
60092
60116
|
files[`members/${slug}/${fname}`] = readFileSync19(fpath, "utf-8");
|
|
60093
60117
|
} catch {
|
|
@@ -60107,7 +60131,7 @@ var init_api_server = __esm({
|
|
|
60107
60131
|
const skillName = decodeURIComponent(path.split("/")[3]);
|
|
60108
60132
|
const skillDir = join18(homedir11(), ".markus", "skills", skillName);
|
|
60109
60133
|
const files = {};
|
|
60110
|
-
if (
|
|
60134
|
+
if (existsSync23(skillDir)) {
|
|
60111
60135
|
for (const fname of readdirSync9(skillDir)) {
|
|
60112
60136
|
const fpath = join18(skillDir, fname);
|
|
60113
60137
|
try {
|
|
@@ -60280,7 +60304,7 @@ var init_api_server = __esm({
|
|
|
60280
60304
|
const filesMap = {};
|
|
60281
60305
|
for (const name of allowedNames) {
|
|
60282
60306
|
const filePath = join18(roleDir, name);
|
|
60283
|
-
if (
|
|
60307
|
+
if (existsSync23(filePath)) {
|
|
60284
60308
|
const content = readFileSync19(filePath, "utf-8");
|
|
60285
60309
|
files.push({ name, content });
|
|
60286
60310
|
filesMap[name] = content;
|
|
@@ -61449,7 +61473,7 @@ var init_api_server = __esm({
|
|
|
61449
61473
|
const skillsDir = join18(homedir11(), ".markus", "skills");
|
|
61450
61474
|
const safeName = skillName.replace(/[^a-zA-Z0-9_-]/g, "-").toLowerCase();
|
|
61451
61475
|
const targetDir = join18(skillsDir, safeName);
|
|
61452
|
-
if (
|
|
61476
|
+
if (existsSync23(targetDir)) {
|
|
61453
61477
|
try {
|
|
61454
61478
|
execSync3(`rm -rf "${targetDir}"`, { timeout: 1e4 });
|
|
61455
61479
|
deletedFs = true;
|
|
@@ -61491,10 +61515,10 @@ var init_api_server = __esm({
|
|
|
61491
61515
|
const baseDir = join18(homedir11(), ".markus", "builder-artifacts");
|
|
61492
61516
|
const types = ["agents", "teams", "skills"];
|
|
61493
61517
|
const artifacts = [];
|
|
61494
|
-
const fsHelper = { existsSync:
|
|
61518
|
+
const fsHelper = { existsSync: existsSync23, readFileSync: (p, _enc) => readFileSync19(p, "utf-8"), join: join18 };
|
|
61495
61519
|
for (const typeDir of types) {
|
|
61496
61520
|
const dir = join18(baseDir, typeDir);
|
|
61497
|
-
if (!
|
|
61521
|
+
if (!existsSync23(dir))
|
|
61498
61522
|
continue;
|
|
61499
61523
|
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
61500
61524
|
if (!entry.isDirectory())
|
|
@@ -61525,7 +61549,7 @@ var init_api_server = __esm({
|
|
|
61525
61549
|
const name = decodeURIComponent(artMatch[2]);
|
|
61526
61550
|
const typeDir = rawType.endsWith("s") ? rawType : rawType + "s";
|
|
61527
61551
|
const artDir = join18(homedir11(), ".markus", "builder-artifacts", typeDir, name);
|
|
61528
|
-
if (!
|
|
61552
|
+
if (!existsSync23(artDir)) {
|
|
61529
61553
|
this.json(res, 404, { error: "Artifact not found" });
|
|
61530
61554
|
return;
|
|
61531
61555
|
}
|
|
@@ -61560,7 +61584,7 @@ var init_api_server = __esm({
|
|
|
61560
61584
|
const dataDir = agentManager.getDataDir();
|
|
61561
61585
|
for (const agentInfo of agentManager.listAgents()) {
|
|
61562
61586
|
const originPath = join18(dataDir, agentInfo.id, "role", ".role-origin.json");
|
|
61563
|
-
if (
|
|
61587
|
+
if (existsSync23(originPath)) {
|
|
61564
61588
|
try {
|
|
61565
61589
|
const origin = JSON.parse(readFileSync19(originPath, "utf-8"));
|
|
61566
61590
|
if (origin.source === "builder-artifact" && origin.artifact) {
|
|
@@ -61597,17 +61621,17 @@ var init_api_server = __esm({
|
|
|
61597
61621
|
}
|
|
61598
61622
|
const skillArtDir = join18(homedir11(), ".markus", "builder-artifacts", "skills");
|
|
61599
61623
|
const skillsDir = join18(homedir11(), ".markus", "skills");
|
|
61600
|
-
if (
|
|
61624
|
+
if (existsSync23(skillArtDir)) {
|
|
61601
61625
|
try {
|
|
61602
61626
|
for (const entry of readdirSync9(skillArtDir, { withFileTypes: true })) {
|
|
61603
|
-
if (entry.isDirectory() &&
|
|
61627
|
+
if (entry.isDirectory() && existsSync23(join18(skillsDir, entry.name))) {
|
|
61604
61628
|
installed[`skill/${entry.name}`] = {};
|
|
61605
61629
|
}
|
|
61606
61630
|
}
|
|
61607
61631
|
} catch {
|
|
61608
61632
|
}
|
|
61609
61633
|
}
|
|
61610
|
-
if (
|
|
61634
|
+
if (existsSync23(skillsDir)) {
|
|
61611
61635
|
try {
|
|
61612
61636
|
for (const entry of readdirSync9(skillsDir, { withFileTypes: true })) {
|
|
61613
61637
|
const key2 = `skill/${entry.name}`;
|
|
@@ -61732,7 +61756,7 @@ var init_api_server = __esm({
|
|
|
61732
61756
|
if (source) {
|
|
61733
61757
|
const mfName = manifestFilename(type);
|
|
61734
61758
|
const mfPath = join18(artDir, mfName);
|
|
61735
|
-
if (
|
|
61759
|
+
if (existsSync23(mfPath)) {
|
|
61736
61760
|
try {
|
|
61737
61761
|
const mf = JSON.parse(readFileSync19(mfPath, "utf-8"));
|
|
61738
61762
|
mf.source = source;
|
|
@@ -61755,12 +61779,12 @@ var init_api_server = __esm({
|
|
|
61755
61779
|
const typeDir = rawType.endsWith("s") ? rawType : rawType + "s";
|
|
61756
61780
|
const type = typeDir === "agents" ? "agent" : typeDir === "teams" ? "team" : "skill";
|
|
61757
61781
|
const artDir = join18(homedir11(), ".markus", "builder-artifacts", typeDir, name);
|
|
61758
|
-
if (!
|
|
61782
|
+
if (!existsSync23(artDir)) {
|
|
61759
61783
|
this.json(res, 404, { error: "Artifact not found" });
|
|
61760
61784
|
return;
|
|
61761
61785
|
}
|
|
61762
61786
|
try {
|
|
61763
|
-
const fsHelper = { existsSync:
|
|
61787
|
+
const fsHelper = { existsSync: existsSync23, readFileSync: (p, _enc) => readFileSync19(p, "utf-8"), join: join18 };
|
|
61764
61788
|
const installType = type;
|
|
61765
61789
|
const manifest = readManifest(artDir, installType, fsHelper);
|
|
61766
61790
|
if (!manifest) {
|
|
@@ -61813,8 +61837,8 @@ var init_api_server = __esm({
|
|
|
61813
61837
|
});
|
|
61814
61838
|
const announcementPath = join18(artDir, "ANNOUNCEMENT.md");
|
|
61815
61839
|
const normsPath = join18(artDir, "NORMS.md");
|
|
61816
|
-
const announcements =
|
|
61817
|
-
const norms =
|
|
61840
|
+
const announcements = existsSync23(announcementPath) ? readFileSync19(announcementPath, "utf-8") : "";
|
|
61841
|
+
const norms = existsSync23(normsPath) ? readFileSync19(normsPath, "utf-8") : "";
|
|
61818
61842
|
this.orgService.ensureTeamDataDir(team.id, announcements, norms);
|
|
61819
61843
|
const members = manifest.team?.members ?? [];
|
|
61820
61844
|
const knownRoles = this.orgService.listAvailableRoles();
|
|
@@ -61839,7 +61863,7 @@ var init_api_server = __esm({
|
|
|
61839
61863
|
});
|
|
61840
61864
|
const agentRoleDir = join18(agentManager.getDataDir(), agent.id, "role");
|
|
61841
61865
|
mkdirSync15(agentRoleDir, { recursive: true });
|
|
61842
|
-
if (
|
|
61866
|
+
if (existsSync23(memberFilesDir)) {
|
|
61843
61867
|
for (const fname of readdirSync9(memberFilesDir)) {
|
|
61844
61868
|
const srcFile = join18(memberFilesDir, fname);
|
|
61845
61869
|
if (statSync4(srcFile).isFile()) {
|
|
@@ -61870,7 +61894,7 @@ var init_api_server = __esm({
|
|
|
61870
61894
|
try {
|
|
61871
61895
|
const skillFile = manifest.skill?.skillFile ?? "SKILL.md";
|
|
61872
61896
|
const instrPath = join18(skillDir, skillFile);
|
|
61873
|
-
const instructions =
|
|
61897
|
+
const instructions = existsSync23(instrPath) ? readFileSync19(instrPath, "utf-8").replace(/^---\s*\n[\s\S]*?\n---\s*\n?/, "").trim() : void 0;
|
|
61874
61898
|
this.skillRegistry.register({
|
|
61875
61899
|
manifest: {
|
|
61876
61900
|
name: manifest.name,
|
|
@@ -61913,7 +61937,7 @@ var init_api_server = __esm({
|
|
|
61913
61937
|
if (type === "agent") {
|
|
61914
61938
|
for (const agentInfo of agentManager.listAgents()) {
|
|
61915
61939
|
const originPath = join18(dataDir, agentInfo.id, "role", ".role-origin.json");
|
|
61916
|
-
if (
|
|
61940
|
+
if (existsSync23(originPath)) {
|
|
61917
61941
|
try {
|
|
61918
61942
|
const origin = JSON.parse(readFileSync19(originPath, "utf-8"));
|
|
61919
61943
|
if (origin.artifact === name && (!origin.artifactType || origin.artifactType === "agent")) {
|
|
@@ -61929,7 +61953,7 @@ var init_api_server = __esm({
|
|
|
61929
61953
|
let teamId;
|
|
61930
61954
|
for (const agentInfo of agentManager.listAgents()) {
|
|
61931
61955
|
const originPath = join18(dataDir, agentInfo.id, "role", ".role-origin.json");
|
|
61932
|
-
if (
|
|
61956
|
+
if (existsSync23(originPath)) {
|
|
61933
61957
|
try {
|
|
61934
61958
|
const origin = JSON.parse(readFileSync19(originPath, "utf-8"));
|
|
61935
61959
|
if (origin.artifact === name && origin.artifactType === "team") {
|
|
@@ -61966,7 +61990,7 @@ var init_api_server = __esm({
|
|
|
61966
61990
|
removedAgents.push(...teamAgentIds);
|
|
61967
61991
|
} else if (type === "skill") {
|
|
61968
61992
|
const skillDir = join18(homedir11(), ".markus", "skills", name);
|
|
61969
|
-
if (
|
|
61993
|
+
if (existsSync23(skillDir)) {
|
|
61970
61994
|
rmSync3(skillDir, { recursive: true, force: true });
|
|
61971
61995
|
if (this.skillRegistry) {
|
|
61972
61996
|
try {
|
|
@@ -61990,7 +62014,7 @@ var init_api_server = __esm({
|
|
|
61990
62014
|
const name = decodeURIComponent(delMatch[2]);
|
|
61991
62015
|
const typeDir = rawType.endsWith("s") ? rawType : rawType + "s";
|
|
61992
62016
|
const artDir = join18(homedir11(), ".markus", "builder-artifacts", typeDir, name);
|
|
61993
|
-
if (!
|
|
62017
|
+
if (!existsSync23(artDir)) {
|
|
61994
62018
|
this.json(res, 404, { error: "Artifact not found" });
|
|
61995
62019
|
return;
|
|
61996
62020
|
}
|
|
@@ -62622,7 +62646,7 @@ var init_api_server = __esm({
|
|
|
62622
62646
|
if (token) {
|
|
62623
62647
|
mkdirSync15(join18(homedir11(), ".markus"), { recursive: true });
|
|
62624
62648
|
writeFileSync13(tokenPath, token, "utf-8");
|
|
62625
|
-
} else if (
|
|
62649
|
+
} else if (existsSync23(tokenPath)) {
|
|
62626
62650
|
rmSync3(tokenPath);
|
|
62627
62651
|
}
|
|
62628
62652
|
log51.info(`Hub token ${token ? "saved to" : "cleared from"} ${tokenPath}`);
|
|
@@ -63439,7 +63463,7 @@ var init_api_server = __esm({
|
|
|
63439
63463
|
try {
|
|
63440
63464
|
const body = await this.readBody(req);
|
|
63441
63465
|
const dirPath = body["path"];
|
|
63442
|
-
if (!dirPath || !
|
|
63466
|
+
if (!dirPath || !existsSync23(dirPath)) {
|
|
63443
63467
|
this.json(res, 400, { error: "Invalid or non-existent path" });
|
|
63444
63468
|
return;
|
|
63445
63469
|
}
|
|
@@ -63580,14 +63604,14 @@ var init_api_server = __esm({
|
|
|
63580
63604
|
}
|
|
63581
63605
|
try {
|
|
63582
63606
|
const { resolve: resolve20, extname } = await import("node:path");
|
|
63583
|
-
const { readFileSync: readFileSync24, existsSync:
|
|
63607
|
+
const { readFileSync: readFileSync24, existsSync: existsSync29, statSync: statSync5 } = await import("node:fs");
|
|
63584
63608
|
const resolved = resolve20(filePath);
|
|
63585
63609
|
const markusBase = join18(homedir11(), ".markus");
|
|
63586
63610
|
if (!resolved.startsWith(markusBase)) {
|
|
63587
63611
|
this.json(res, 403, { error: "Access denied: file is outside the allowed directory" });
|
|
63588
63612
|
return;
|
|
63589
63613
|
}
|
|
63590
|
-
if (!
|
|
63614
|
+
if (!existsSync29(resolved)) {
|
|
63591
63615
|
this.json(res, 404, { error: "File not found" });
|
|
63592
63616
|
return;
|
|
63593
63617
|
}
|
|
@@ -63635,10 +63659,10 @@ var init_api_server = __esm({
|
|
|
63635
63659
|
}
|
|
63636
63660
|
try {
|
|
63637
63661
|
const { resolve: resolve20, dirname: dirname10 } = await import("node:path");
|
|
63638
|
-
const { existsSync:
|
|
63662
|
+
const { existsSync: existsSync29, statSync: statSync5 } = await import("node:fs");
|
|
63639
63663
|
const { exec } = await import("node:child_process");
|
|
63640
63664
|
const resolved = resolve20(filePath);
|
|
63641
|
-
if (!
|
|
63665
|
+
if (!existsSync29(resolved)) {
|
|
63642
63666
|
this.json(res, 404, { error: "Path not found" });
|
|
63643
63667
|
return;
|
|
63644
63668
|
}
|
|
@@ -64156,12 +64180,12 @@ var init_api_server = __esm({
|
|
|
64156
64180
|
if (this.webUiDir) {
|
|
64157
64181
|
const safePath = path.replace(/\.\./g, "").replace(/\/\//g, "/");
|
|
64158
64182
|
const filePath = join18(this.webUiDir, safePath === "/" ? "index.html" : safePath);
|
|
64159
|
-
if (
|
|
64183
|
+
if (existsSync23(filePath) && statSync4(filePath).isFile()) {
|
|
64160
64184
|
this.serveStaticFile(res, filePath);
|
|
64161
64185
|
return;
|
|
64162
64186
|
}
|
|
64163
64187
|
const indexPath = join18(this.webUiDir, "index.html");
|
|
64164
|
-
if (
|
|
64188
|
+
if (existsSync23(indexPath) && !path.startsWith("/api/")) {
|
|
64165
64189
|
this.serveStaticFile(res, indexPath);
|
|
64166
64190
|
return;
|
|
64167
64191
|
}
|
|
@@ -64308,14 +64332,14 @@ var init_api_server = __esm({
|
|
|
64308
64332
|
resolveAgentRoleDir(agent) {
|
|
64309
64333
|
const agentDataDir = join18(this.orgService.getAgentManager().getDataDir(), agent.config.id);
|
|
64310
64334
|
const agentRoleDir = join18(agentDataDir, "role");
|
|
64311
|
-
if (
|
|
64335
|
+
if (existsSync23(join18(agentRoleDir, "ROLE.md")))
|
|
64312
64336
|
return agentRoleDir;
|
|
64313
64337
|
const base = join18(process.cwd(), "templates", "roles");
|
|
64314
|
-
if (!
|
|
64338
|
+
if (!existsSync23(base))
|
|
64315
64339
|
return null;
|
|
64316
64340
|
const tryDir = (dirName) => {
|
|
64317
64341
|
const p = join18(base, dirName, "ROLE.md");
|
|
64318
|
-
return
|
|
64342
|
+
return existsSync23(p) ? join18(base, dirName) : null;
|
|
64319
64343
|
};
|
|
64320
64344
|
if (agent.config.roleId) {
|
|
64321
64345
|
const d2 = tryDir(agent.config.roleId);
|
|
@@ -64330,7 +64354,7 @@ var init_api_server = __esm({
|
|
|
64330
64354
|
if (!entry.isDirectory())
|
|
64331
64355
|
continue;
|
|
64332
64356
|
const rolePath = join18(base, entry.name, "ROLE.md");
|
|
64333
|
-
if (!
|
|
64357
|
+
if (!existsSync23(rolePath))
|
|
64334
64358
|
continue;
|
|
64335
64359
|
try {
|
|
64336
64360
|
const content = readFileSync19(rolePath, "utf-8");
|
|
@@ -64346,7 +64370,7 @@ var init_api_server = __esm({
|
|
|
64346
64370
|
}
|
|
64347
64371
|
collectStorageInfo(dataDir) {
|
|
64348
64372
|
const dirSize = (p, maxDepth = 3, depth = 0) => {
|
|
64349
|
-
if (!
|
|
64373
|
+
if (!existsSync23(p))
|
|
64350
64374
|
return 0;
|
|
64351
64375
|
try {
|
|
64352
64376
|
const st = statSync4(p);
|
|
@@ -64377,7 +64401,7 @@ var init_api_server = __esm({
|
|
|
64377
64401
|
if (item.name === "Database") {
|
|
64378
64402
|
for (const ext of ["", "-wal", "-shm"]) {
|
|
64379
64403
|
const f = item.path + ext;
|
|
64380
|
-
if (
|
|
64404
|
+
if (existsSync23(f)) {
|
|
64381
64405
|
try {
|
|
64382
64406
|
item.size += statSync4(f).size;
|
|
64383
64407
|
} catch {
|
|
@@ -64391,7 +64415,7 @@ var init_api_server = __esm({
|
|
|
64391
64415
|
const agentsDir = join18(dataDir, "agents");
|
|
64392
64416
|
const agentInfos = [];
|
|
64393
64417
|
const am = this.orgService.getAgentManager();
|
|
64394
|
-
if (
|
|
64418
|
+
if (existsSync23(agentsDir)) {
|
|
64395
64419
|
for (const entry of readdirSync9(agentsDir, { withFileTypes: true })) {
|
|
64396
64420
|
if (!entry.isDirectory() || entry.name === "vector-store")
|
|
64397
64421
|
continue;
|
|
@@ -64405,7 +64429,7 @@ var init_api_server = __esm({
|
|
|
64405
64429
|
})();
|
|
64406
64430
|
const subItems = [
|
|
64407
64431
|
{ name: "workspace", size: dirSize(join18(agentDir, "workspace")) },
|
|
64408
|
-
{ name: "memory", size: dirSize(join18(agentDir, "sessions")) + (
|
|
64432
|
+
{ name: "memory", size: dirSize(join18(agentDir, "sessions")) + (existsSync23(join18(agentDir, "memories.json")) ? statSync4(join18(agentDir, "memories.json")).size : 0) + (existsSync23(join18(agentDir, "MEMORY.md")) ? statSync4(join18(agentDir, "MEMORY.md")).size : 0) },
|
|
64409
64433
|
{ name: "role", size: dirSize(join18(agentDir, "role")) },
|
|
64410
64434
|
{ name: "tool-outputs", size: dirSize(join18(agentDir, "tool-outputs")) },
|
|
64411
64435
|
{ name: "daily-logs", size: dirSize(join18(agentDir, "daily-logs")) }
|
|
@@ -64438,7 +64462,7 @@ var init_api_server = __esm({
|
|
|
64438
64462
|
const orphanAgents = [];
|
|
64439
64463
|
const orphanTeams = [];
|
|
64440
64464
|
const dirSize = (p, maxDepth = 3, depth = 0) => {
|
|
64441
|
-
if (!
|
|
64465
|
+
if (!existsSync23(p))
|
|
64442
64466
|
return 0;
|
|
64443
64467
|
try {
|
|
64444
64468
|
const st = statSync4(p);
|
|
@@ -64456,7 +64480,7 @@ var init_api_server = __esm({
|
|
|
64456
64480
|
}
|
|
64457
64481
|
};
|
|
64458
64482
|
const agentsDir = join18(dataDir, "agents");
|
|
64459
|
-
if (
|
|
64483
|
+
if (existsSync23(agentsDir)) {
|
|
64460
64484
|
for (const entry of readdirSync9(agentsDir, { withFileTypes: true })) {
|
|
64461
64485
|
if (!entry.isDirectory() || entry.name === "vector-store")
|
|
64462
64486
|
continue;
|
|
@@ -64467,7 +64491,7 @@ var init_api_server = __esm({
|
|
|
64467
64491
|
}
|
|
64468
64492
|
}
|
|
64469
64493
|
const teamsDir = join18(dataDir, "teams");
|
|
64470
|
-
if (
|
|
64494
|
+
if (existsSync23(teamsDir)) {
|
|
64471
64495
|
for (const entry of readdirSync9(teamsDir, { withFileTypes: true })) {
|
|
64472
64496
|
if (!entry.isDirectory())
|
|
64473
64497
|
continue;
|
|
@@ -65718,7 +65742,7 @@ var init_knowledge_service = __esm({
|
|
|
65718
65742
|
});
|
|
65719
65743
|
|
|
65720
65744
|
// ../org-manager/dist/file-knowledge-store.js
|
|
65721
|
-
import { readFileSync as readFileSync20, writeFileSync as writeFileSync14, existsSync as
|
|
65745
|
+
import { readFileSync as readFileSync20, writeFileSync as writeFileSync14, existsSync as existsSync24, mkdirSync as mkdirSync16, readdirSync as readdirSync10, unlinkSync as unlinkSync3 } from "node:fs";
|
|
65722
65746
|
import { join as join19 } from "node:path";
|
|
65723
65747
|
function readdirSafe(dir) {
|
|
65724
65748
|
try {
|
|
@@ -65751,13 +65775,13 @@ var init_file_knowledge_store = __esm({
|
|
|
65751
65775
|
// ─── Load ────────────────────────────────────────────────────────────────
|
|
65752
65776
|
loadAll() {
|
|
65753
65777
|
const entries2 = [];
|
|
65754
|
-
if (!
|
|
65778
|
+
if (!existsSync24(this.baseDir))
|
|
65755
65779
|
return entries2;
|
|
65756
65780
|
for (const scope of readdirSafe(this.baseDir)) {
|
|
65757
65781
|
const scopePath = join19(this.baseDir, scope);
|
|
65758
65782
|
for (const scopeId of readdirSafe(scopePath)) {
|
|
65759
65783
|
const idxPath = join19(scopePath, scopeId, "_index.json");
|
|
65760
|
-
if (!
|
|
65784
|
+
if (!existsSync24(idxPath))
|
|
65761
65785
|
continue;
|
|
65762
65786
|
try {
|
|
65763
65787
|
const data = JSON.parse(readFileSync20(idxPath, "utf-8"));
|
|
@@ -78972,7 +78996,7 @@ __export(init_exports, {
|
|
|
78972
78996
|
registerInitCommand: () => registerInitCommand
|
|
78973
78997
|
});
|
|
78974
78998
|
import { resolve as resolve15 } from "node:path";
|
|
78975
|
-
import { readFileSync as readFileSync21, existsSync as
|
|
78999
|
+
import { readFileSync as readFileSync21, existsSync as existsSync25, cpSync as cpSync2 } from "node:fs";
|
|
78976
79000
|
import { homedir as homedir13 } from "node:os";
|
|
78977
79001
|
function registerInitCommand(program3) {
|
|
78978
79002
|
program3.command("init").description("Interactive setup wizard: configure LLM provider, API keys, and server settings").option("--force", "Overwrite existing configuration").action(async (opts) => {
|
|
@@ -78994,7 +79018,7 @@ async function quickInit(options) {
|
|
|
78994
79018
|
\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
78995
79019
|
`);
|
|
78996
79020
|
const configPath = getDefaultConfigPath();
|
|
78997
|
-
if (
|
|
79021
|
+
if (existsSync25(configPath) && !options?.force) {
|
|
78998
79022
|
console.log(` Existing configuration found: ${configPath}`);
|
|
78999
79023
|
const overwrite = await ask(" Overwrite? (y/n)", "n");
|
|
79000
79024
|
if (overwrite.toLowerCase() !== "y") {
|
|
@@ -79033,7 +79057,7 @@ async function quickInit(options) {
|
|
|
79033
79057
|
pathJoin(homedir13(), ".openclaw", "openclaw.json5")
|
|
79034
79058
|
];
|
|
79035
79059
|
for (const p of openclawCandidates) {
|
|
79036
|
-
if (
|
|
79060
|
+
if (existsSync25(p)) {
|
|
79037
79061
|
openclawPath = p;
|
|
79038
79062
|
break;
|
|
79039
79063
|
}
|
|
@@ -79160,14 +79184,14 @@ async function quickInit(options) {
|
|
|
79160
79184
|
}
|
|
79161
79185
|
const userTemplatesDir = pathJoin(homedir13(), ".markus", "templates");
|
|
79162
79186
|
const builtinTemplatesDir = resolveTemplatesDir("roles");
|
|
79163
|
-
if (builtinTemplatesDir &&
|
|
79187
|
+
if (builtinTemplatesDir && existsSync25(builtinTemplatesDir) && !existsSync25(userTemplatesDir)) {
|
|
79164
79188
|
const builtinRoot = resolve15(builtinTemplatesDir, "..");
|
|
79165
79189
|
mkdirSync19(userTemplatesDir, { recursive: true });
|
|
79166
79190
|
cpSync2(builtinRoot, userTemplatesDir, { recursive: true });
|
|
79167
79191
|
console.log(` Copied templates to ${userTemplatesDir}`);
|
|
79168
79192
|
}
|
|
79169
79193
|
const devRoleDir = pathJoin(userTemplatesDir || pathJoin(process.cwd(), "templates"), "roles", "developer");
|
|
79170
|
-
if (!
|
|
79194
|
+
if (!existsSync25(devRoleDir)) {
|
|
79171
79195
|
mkdirSync19(devRoleDir, { recursive: true });
|
|
79172
79196
|
writeFileSync16(
|
|
79173
79197
|
pathJoin(devRoleDir, "ROLE.md"),
|
|
@@ -79216,14 +79240,14 @@ __export(start_exports, {
|
|
|
79216
79240
|
registerStartCommand: () => registerStartCommand
|
|
79217
79241
|
});
|
|
79218
79242
|
import { resolve as resolve16, join as join21, dirname as dirname8 } from "node:path";
|
|
79219
|
-
import { existsSync as
|
|
79243
|
+
import { existsSync as existsSync26 } from "node:fs";
|
|
79220
79244
|
import { homedir as homedir14 } from "node:os";
|
|
79221
79245
|
function registerStartCommand(program3) {
|
|
79222
79246
|
program3.command("start").description("Start the Markus server (auto-initializes on first run)").option("--setup", "Force re-run the interactive setup wizard before starting").action(async (opts) => {
|
|
79223
79247
|
const globalOpts = program3.optsWithGlobals();
|
|
79224
79248
|
const configPath = globalOpts.config ?? getDefaultConfigPath();
|
|
79225
|
-
if (opts.setup || !
|
|
79226
|
-
if (!
|
|
79249
|
+
if (opts.setup || !existsSync26(configPath)) {
|
|
79250
|
+
if (!existsSync26(configPath)) {
|
|
79227
79251
|
console.log(" No configuration found \u2014 running first-time setup...\n");
|
|
79228
79252
|
}
|
|
79229
79253
|
const { quickInit: quickInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
@@ -79368,7 +79392,7 @@ async function startServer(config, values) {
|
|
|
79368
79392
|
const selfBinDir = dirname8(resolve16(process.argv[1] ?? ""));
|
|
79369
79393
|
if (selfBinDir && !currentPath.includes(selfBinDir)) extraPaths.push(selfBinDir);
|
|
79370
79394
|
const cwdBin = join21(process.cwd(), "node_modules", ".bin");
|
|
79371
|
-
if (
|
|
79395
|
+
if (existsSync26(cwdBin) && !currentPath.includes(cwdBin)) extraPaths.push(cwdBin);
|
|
79372
79396
|
if (extraPaths.length > 0) {
|
|
79373
79397
|
process.env["PATH"] = `${extraPaths.join(":")}:${currentPath}`;
|
|
79374
79398
|
}
|
|
@@ -81383,13 +81407,13 @@ __export(system_exports, {
|
|
|
81383
81407
|
registerSystemCommands: () => registerSystemCommands
|
|
81384
81408
|
});
|
|
81385
81409
|
import { execSync as execSync4 } from "node:child_process";
|
|
81386
|
-
import { existsSync as
|
|
81410
|
+
import { existsSync as existsSync27, readFileSync as readFileSync22 } from "node:fs";
|
|
81387
81411
|
import { resolve as resolve18, dirname as dirname9 } from "node:path";
|
|
81388
81412
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
81389
81413
|
function findMarkusRoot() {
|
|
81390
81414
|
let dir = dirname9(fileURLToPath4(import.meta.url));
|
|
81391
81415
|
for (let i = 0; i < 10; i++) {
|
|
81392
|
-
if (
|
|
81416
|
+
if (existsSync27(resolve18(dir, "package.json")) && existsSync27(resolve18(dir, "packages"))) return dir;
|
|
81393
81417
|
dir = dirname9(dir);
|
|
81394
81418
|
}
|
|
81395
81419
|
return null;
|
|
@@ -81527,7 +81551,7 @@ function registerSystemCommands(program3) {
|
|
|
81527
81551
|
} catch {
|
|
81528
81552
|
}
|
|
81529
81553
|
try {
|
|
81530
|
-
const isGit =
|
|
81554
|
+
const isGit = existsSync27(resolve18(markusRoot, ".git"));
|
|
81531
81555
|
if (isGit) {
|
|
81532
81556
|
info.gitBranch = execSync4("git rev-parse --abbrev-ref HEAD", { cwd: markusRoot, encoding: "utf-8" }).trim();
|
|
81533
81557
|
info.gitCommit = execSync4("git rev-parse --short HEAD", { cwd: markusRoot, encoding: "utf-8" }).trim();
|
|
@@ -81561,7 +81585,7 @@ function registerSystemCommands(program3) {
|
|
|
81561
81585
|
fail("Cannot locate Markus installation directory");
|
|
81562
81586
|
return;
|
|
81563
81587
|
}
|
|
81564
|
-
if (!
|
|
81588
|
+
if (!existsSync27(resolve18(markusRoot, ".git"))) {
|
|
81565
81589
|
fail("Markus installation is not a git repository. Update manually.");
|
|
81566
81590
|
return;
|
|
81567
81591
|
}
|
|
@@ -82256,7 +82280,7 @@ var init_settings = __esm({
|
|
|
82256
82280
|
|
|
82257
82281
|
// src/index.ts
|
|
82258
82282
|
import { resolve as resolve19 } from "node:path";
|
|
82259
|
-
import { readFileSync as readFileSync23, existsSync as
|
|
82283
|
+
import { readFileSync as readFileSync23, existsSync as existsSync28 } from "node:fs";
|
|
82260
82284
|
|
|
82261
82285
|
// ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/esm.mjs
|
|
82262
82286
|
var import_index = __toESM(require_commander(), 1);
|
|
@@ -82279,7 +82303,7 @@ var {
|
|
|
82279
82303
|
init_dist();
|
|
82280
82304
|
init_output();
|
|
82281
82305
|
var envPath = resolve19(process.cwd(), ".env");
|
|
82282
|
-
if (
|
|
82306
|
+
if (existsSync28(envPath)) {
|
|
82283
82307
|
for (const line2 of readFileSync23(envPath, "utf-8").split("\n")) {
|
|
82284
82308
|
const trimmed = line2.trim();
|
|
82285
82309
|
if (!trimmed || trimmed.startsWith("#")) continue;
|