@kanadego/dsh-heartbeat 2.2.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -311
- package/USAGE-GUIDE.md +357 -0
- package/client.js +186 -24
- package/dist/{bili-login-XQVEE4M6.js → bili-login-KDDU63Z2.js} +4 -4
- package/dist/{bindings-U2M3CO2D.js → bindings-LTSGGNIH.js} +3 -3
- package/dist/{chunk-LQKOYTRL.js → chunk-4OQXAHU5.js} +2 -2
- package/dist/{chunk-3QJJRXIR.js → chunk-5CVAW5AS.js} +11 -2
- package/dist/chunk-5CVAW5AS.js.map +1 -0
- package/dist/{chunk-IBBAISSW.js → chunk-66IUDHCY.js} +50 -1
- package/dist/chunk-66IUDHCY.js.map +1 -0
- package/dist/{chunk-3DNGY4DS.js → chunk-77UYDI2A.js} +2 -2
- package/dist/{chunk-AT32XCCI.js → chunk-AJ5JAQVB.js} +20 -3
- package/dist/chunk-AJ5JAQVB.js.map +1 -0
- package/dist/chunk-CRRN6UD3.js +389 -0
- package/dist/chunk-CRRN6UD3.js.map +1 -0
- package/dist/{chunk-ECXYNTEV.js → chunk-ERRPMYKB.js} +164 -152
- package/dist/chunk-ERRPMYKB.js.map +1 -0
- package/dist/{chunk-M72T5MZU.js → chunk-GOLMRQRW.js} +3 -2
- package/dist/{chunk-KZLVR4J7.js → chunk-IPTNSXOY.js} +2 -2
- package/dist/chunk-L54R23O2.js +262 -0
- package/dist/chunk-L54R23O2.js.map +1 -0
- package/dist/chunk-MHRAPKES.js +1081 -0
- package/dist/chunk-MHRAPKES.js.map +1 -0
- package/dist/{chunk-SIY3YHFY.js → chunk-MMI6OBEC.js} +2 -2
- package/dist/{chunk-CJK6RTMH.js → chunk-RPWQZYNW.js} +1485 -310
- package/dist/chunk-RPWQZYNW.js.map +1 -0
- package/dist/cli/index.js +244 -36
- package/dist/cli/index.js.map +1 -1
- package/dist/{focus-store-RNHBAFYS.js → focus-store-XGTPIVF6.js} +3 -3
- package/dist/{inbox-ZLX2MH7A.js → inbox-7GGEMBUD.js} +4 -4
- package/dist/index.d.ts +66 -1
- package/dist/index.js +556 -167
- package/dist/index.js.map +1 -1
- package/dist/{migrate-XFZU5EBE.js → migrate-25F53XIC.js} +6 -4
- package/dist/{orchestrator-5BHYQ77Y.js → orchestrator-4PJD7QYO.js} +25 -11
- package/dist/runtime-RGZKOFP3.js +15 -0
- package/dist/snapshot-J6LKNY57.js +27 -0
- package/dist/store-HM6ZMFKS.js +45 -0
- package/package.json +6 -3
- package/dist/chunk-3QJJRXIR.js.map +0 -1
- package/dist/chunk-AT32XCCI.js.map +0 -1
- package/dist/chunk-CJK6RTMH.js.map +0 -1
- package/dist/chunk-DLOYERAK.js +0 -87
- package/dist/chunk-DLOYERAK.js.map +0 -1
- package/dist/chunk-ECXYNTEV.js.map +0 -1
- package/dist/chunk-F2XVKX55.js +0 -413
- package/dist/chunk-F2XVKX55.js.map +0 -1
- package/dist/chunk-IBBAISSW.js.map +0 -1
- package/dist/chunk-N6SMIGYJ.js +0 -393
- package/dist/chunk-N6SMIGYJ.js.map +0 -1
- package/dist/chunk-XYBII5PR.js +0 -602
- package/dist/chunk-XYBII5PR.js.map +0 -1
- package/dist/pool-76VLAZER.js +0 -49
- package/dist/runtime-W2OWJIHY.js +0 -11
- package/dist/snapshot-SU2VGM4C.js +0 -16
- /package/dist/{bili-login-XQVEE4M6.js.map → bili-login-KDDU63Z2.js.map} +0 -0
- /package/dist/{bindings-U2M3CO2D.js.map → bindings-LTSGGNIH.js.map} +0 -0
- /package/dist/{chunk-LQKOYTRL.js.map → chunk-4OQXAHU5.js.map} +0 -0
- /package/dist/{chunk-3DNGY4DS.js.map → chunk-77UYDI2A.js.map} +0 -0
- /package/dist/{chunk-M72T5MZU.js.map → chunk-GOLMRQRW.js.map} +0 -0
- /package/dist/{chunk-KZLVR4J7.js.map → chunk-IPTNSXOY.js.map} +0 -0
- /package/dist/{chunk-SIY3YHFY.js.map → chunk-MMI6OBEC.js.map} +0 -0
- /package/dist/{focus-store-RNHBAFYS.js.map → focus-store-XGTPIVF6.js.map} +0 -0
- /package/dist/{inbox-ZLX2MH7A.js.map → inbox-7GGEMBUD.js.map} +0 -0
- /package/dist/{migrate-XFZU5EBE.js.map → migrate-25F53XIC.js.map} +0 -0
- /package/dist/{orchestrator-5BHYQ77Y.js.map → orchestrator-4PJD7QYO.js.map} +0 -0
- /package/dist/{pool-76VLAZER.js.map → runtime-RGZKOFP3.js.map} +0 -0
- /package/dist/{runtime-W2OWJIHY.js.map → snapshot-J6LKNY57.js.map} +0 -0
- /package/dist/{snapshot-SU2VGM4C.js.map → store-HM6ZMFKS.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
burnFileSync
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-66IUDHCY.js";
|
|
4
4
|
|
|
5
5
|
// src/core/paths.ts
|
|
6
6
|
import fs2 from "fs";
|
|
@@ -703,6 +703,7 @@ export {
|
|
|
703
703
|
dshHomeDir,
|
|
704
704
|
initWorkspace,
|
|
705
705
|
workspace,
|
|
706
|
+
FileLockTimeoutError,
|
|
706
707
|
withFileLock,
|
|
707
708
|
tryWithFileLock,
|
|
708
709
|
matchFilesRecursive,
|
|
@@ -720,4 +721,4 @@ export {
|
|
|
720
721
|
upgradeVaultTree,
|
|
721
722
|
upgradeOneLegacyVaultFile
|
|
722
723
|
};
|
|
723
|
-
//# sourceMappingURL=chunk-
|
|
724
|
+
//# sourceMappingURL=chunk-GOLMRQRW.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
loadEncryptedText,
|
|
3
3
|
saveEncryptedText,
|
|
4
4
|
tryWithFileLock
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GOLMRQRW.js";
|
|
6
6
|
|
|
7
7
|
// src/profile/inbox.ts
|
|
8
8
|
import fs from "fs";
|
|
@@ -140,4 +140,4 @@ export {
|
|
|
140
140
|
inboxHealthCheck,
|
|
141
141
|
inboxFileExists
|
|
142
142
|
};
|
|
143
|
-
//# sourceMappingURL=chunk-
|
|
143
|
+
//# sourceMappingURL=chunk-IPTNSXOY.js.map
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readText,
|
|
3
|
+
writeText
|
|
4
|
+
} from "./chunk-GOLMRQRW.js";
|
|
5
|
+
|
|
6
|
+
// src/core/path-guard.ts
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
var PathOutsideWorkspaceError = class extends Error {
|
|
10
|
+
constructor(target, workspace) {
|
|
11
|
+
super(`path outside workspace: "${target}" (workspace: "${workspace}")`);
|
|
12
|
+
this.name = "PathOutsideWorkspaceError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function canonicalize(target) {
|
|
16
|
+
const abs = path.resolve(target);
|
|
17
|
+
try {
|
|
18
|
+
return fs.realpathSync(abs);
|
|
19
|
+
} catch {
|
|
20
|
+
const tail = [];
|
|
21
|
+
let dir = abs;
|
|
22
|
+
for (; ; ) {
|
|
23
|
+
const base = path.basename(dir);
|
|
24
|
+
const parent = path.dirname(dir);
|
|
25
|
+
if (parent === dir) {
|
|
26
|
+
throw new Error(`cannot canonicalize "${target}": no existing ancestor`);
|
|
27
|
+
}
|
|
28
|
+
tail.push(base);
|
|
29
|
+
dir = parent;
|
|
30
|
+
try {
|
|
31
|
+
const realDir = fs.realpathSync(dir);
|
|
32
|
+
return path.join(realDir, ...tail.reverse());
|
|
33
|
+
} catch {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isInsideWorkspace(workspaceCanon, targetCanon) {
|
|
40
|
+
const norm = (p) => {
|
|
41
|
+
let n = path.normalize(p).toLowerCase();
|
|
42
|
+
if (!n.endsWith(path.sep)) n += path.sep;
|
|
43
|
+
return n;
|
|
44
|
+
};
|
|
45
|
+
const w = norm(workspaceCanon);
|
|
46
|
+
const t = norm(targetCanon);
|
|
47
|
+
return t === w || t.startsWith(w);
|
|
48
|
+
}
|
|
49
|
+
function createPathGuard(workspaceDir) {
|
|
50
|
+
const workspace = canonicalize(workspaceDir);
|
|
51
|
+
const guard = {
|
|
52
|
+
workspace,
|
|
53
|
+
check(target) {
|
|
54
|
+
const canon = canonicalize(target);
|
|
55
|
+
return isInsideWorkspace(workspace, canon) ? canon : null;
|
|
56
|
+
},
|
|
57
|
+
assert(target) {
|
|
58
|
+
const canon = guard.check(target);
|
|
59
|
+
if (canon === null) throw new PathOutsideWorkspaceError(target, workspace);
|
|
60
|
+
return canon;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return guard;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/excerpt/excerpt.ts
|
|
67
|
+
import path2 from "path";
|
|
68
|
+
import { randomUUID } from "crypto";
|
|
69
|
+
var EXCERPT_HEADER = "# \u6458\u6284\u672C\n\n> \u7559\u53E5\u5B50\u548C\u5C0F\u4E8B\u7684\u5730\u65B9\u3002\u53EF\u4EE5\u76F4\u63A5\u624B\u7F16\uFF0C\u6539\u4E71\u4E86\u4E5F\u4E0D\u5F71\u54CD\uFF1A\u8BA4\u4E0D\u51FA\u7684\u884C\u4F1A\u539F\u6837\u7559\u7740\u3002\n\n";
|
|
70
|
+
function excerptFilePath(dataDir) {
|
|
71
|
+
return path2.join(dataDir, "excerpts.md");
|
|
72
|
+
}
|
|
73
|
+
var LINE_RE = /^- \[(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2})\]\[#([0-9a-f]{6})\] (.*)$/;
|
|
74
|
+
function renderEntry(e) {
|
|
75
|
+
return `- [${e.date} ${e.time}][#${e.id}] ${e.text}`;
|
|
76
|
+
}
|
|
77
|
+
function readExcerpts(guard, file) {
|
|
78
|
+
const raw = readText(guard, file, EXCERPT_HEADER);
|
|
79
|
+
const rawLines = [];
|
|
80
|
+
const entries = [];
|
|
81
|
+
for (const line of raw.split("\n")) {
|
|
82
|
+
const m = LINE_RE.exec(line);
|
|
83
|
+
if (m) entries.push({ date: m[1], time: m[2], id: m[3], text: m[4] });
|
|
84
|
+
rawLines.push(line);
|
|
85
|
+
}
|
|
86
|
+
return { entries, rawLines };
|
|
87
|
+
}
|
|
88
|
+
function appendExcerpt(guard, file, text, now = Date.now()) {
|
|
89
|
+
const trimmed = text.trim();
|
|
90
|
+
if (!trimmed) throw new Error("excerpt must not be empty");
|
|
91
|
+
const d = new Date(now);
|
|
92
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
93
|
+
const entry = {
|
|
94
|
+
id: randomUUID().slice(0, 6),
|
|
95
|
+
date: `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`,
|
|
96
|
+
time: `${pad(d.getHours())}:${pad(d.getMinutes())}`,
|
|
97
|
+
text: trimmed.replace(/\r?\n/g, " ")
|
|
98
|
+
};
|
|
99
|
+
const { rawLines } = readExcerpts(guard, file);
|
|
100
|
+
rawLines.push(renderEntry(entry));
|
|
101
|
+
writeText(guard, file, rawLines.join("\n").replace(/\n*$/, "\n"));
|
|
102
|
+
return entry;
|
|
103
|
+
}
|
|
104
|
+
function removeExcerpt(guard, file, key) {
|
|
105
|
+
const { rawLines, entries } = readExcerpts(guard, file);
|
|
106
|
+
const target = entries.find((e) => e.id === key || e.text.includes(key));
|
|
107
|
+
if (!target) return null;
|
|
108
|
+
const out = rawLines.filter((line) => !line.startsWith(`- [${target.date} ${target.time}][#${target.id}] `));
|
|
109
|
+
writeText(guard, file, out.join("\n").replace(/\n*$/, "\n"));
|
|
110
|
+
return target;
|
|
111
|
+
}
|
|
112
|
+
function recentExcerpts(guard, file, limit) {
|
|
113
|
+
const { entries } = readExcerpts(guard, file);
|
|
114
|
+
return limit > 0 ? entries.slice(-limit) : [];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/core/preset-install.ts
|
|
118
|
+
import fs2 from "fs";
|
|
119
|
+
import os from "os";
|
|
120
|
+
import path3 from "path";
|
|
121
|
+
import { fileURLToPath } from "url";
|
|
122
|
+
var COMPOSITION_FILE = "agent.cordis.yml";
|
|
123
|
+
var METADATA_FILE = "preset.yml";
|
|
124
|
+
var BUNDLED_PRESET_ID = "heartbeat";
|
|
125
|
+
function bundledPresetDir(moduleUrl, id = BUNDLED_PRESET_ID) {
|
|
126
|
+
let dir;
|
|
127
|
+
try {
|
|
128
|
+
dir = path3.dirname(fileURLToPath(moduleUrl));
|
|
129
|
+
} catch {
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
for (let depth = 0; depth < 5; depth += 1) {
|
|
133
|
+
const candidate = path3.join(dir, "assets", "presets", id);
|
|
134
|
+
if (fs2.existsSync(path3.join(candidate, COMPOSITION_FILE))) return candidate;
|
|
135
|
+
const parent = path3.dirname(dir);
|
|
136
|
+
if (parent === dir) break;
|
|
137
|
+
dir = parent;
|
|
138
|
+
}
|
|
139
|
+
return void 0;
|
|
140
|
+
}
|
|
141
|
+
function userPresetRoot(roots) {
|
|
142
|
+
const found = roots?.find(
|
|
143
|
+
(root) => root?.trust === "user" && typeof root.path === "string" && root.path.length > 0
|
|
144
|
+
);
|
|
145
|
+
return found?.path === void 0 ? void 0 : path3.resolve(found.path);
|
|
146
|
+
}
|
|
147
|
+
function conventionalUserPresetRoot(env = process.env, home = os.homedir()) {
|
|
148
|
+
const override = env.DSH_HOME?.trim();
|
|
149
|
+
const root = override && override.length > 0 ? override : path3.join(home, ".dsh");
|
|
150
|
+
return path3.join(root, ".agent-presets");
|
|
151
|
+
}
|
|
152
|
+
function installBundledPreset(options) {
|
|
153
|
+
const id = options.id && options.id.length > 0 ? options.id : BUNDLED_PRESET_ID;
|
|
154
|
+
if (options.enabled === false) {
|
|
155
|
+
return { action: "skipped-disabled", id, detail: "installPreset=false" };
|
|
156
|
+
}
|
|
157
|
+
const bundledDir = bundledPresetDir(options.moduleUrl, BUNDLED_PRESET_ID);
|
|
158
|
+
if (id !== BUNDLED_PRESET_ID) {
|
|
159
|
+
return {
|
|
160
|
+
action: "skipped-custom-id",
|
|
161
|
+
id,
|
|
162
|
+
...bundledDir === void 0 ? {} : { bundledDir },
|
|
163
|
+
detail: `only "${BUNDLED_PRESET_ID}" ships with the plugin; "${id}" is yours to provide`
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (bundledDir === void 0) {
|
|
167
|
+
return {
|
|
168
|
+
action: "error",
|
|
169
|
+
id,
|
|
170
|
+
detail: "bundled template not found next to the plugin (assets/presets/heartbeat)"
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const root = options.root ?? (options.rosterKnown ? void 0 : conventionalUserPresetRoot());
|
|
174
|
+
if (root === void 0) {
|
|
175
|
+
return {
|
|
176
|
+
action: "skipped-no-root",
|
|
177
|
+
id,
|
|
178
|
+
bundledDir,
|
|
179
|
+
detail: "the roster mounts no user preset root (includeUserRoot=false)"
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const dir = path3.join(root, id);
|
|
183
|
+
const composition = path3.join(dir, COMPOSITION_FILE);
|
|
184
|
+
try {
|
|
185
|
+
if (fs2.existsSync(composition)) {
|
|
186
|
+
if (options.force !== true) {
|
|
187
|
+
const drifted = !sameBytes(composition, path3.join(bundledDir, COMPOSITION_FILE));
|
|
188
|
+
return {
|
|
189
|
+
action: "exists",
|
|
190
|
+
id,
|
|
191
|
+
dir,
|
|
192
|
+
bundledDir,
|
|
193
|
+
detail: drifted ? "kept as-is (differs from the bundled template)" : "kept as-is"
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
fs2.copyFileSync(path3.join(bundledDir, COMPOSITION_FILE), composition);
|
|
197
|
+
return {
|
|
198
|
+
action: "restored",
|
|
199
|
+
id,
|
|
200
|
+
dir,
|
|
201
|
+
bundledDir,
|
|
202
|
+
detail: "composition replaced from the bundled template"
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const existed = fs2.existsSync(dir);
|
|
206
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
207
|
+
fs2.copyFileSync(path3.join(bundledDir, COMPOSITION_FILE), composition);
|
|
208
|
+
const metadata = path3.join(dir, METADATA_FILE);
|
|
209
|
+
if (!fs2.existsSync(metadata)) fs2.copyFileSync(path3.join(bundledDir, METADATA_FILE), metadata);
|
|
210
|
+
return {
|
|
211
|
+
action: existed ? "repaired" : "created",
|
|
212
|
+
id,
|
|
213
|
+
dir,
|
|
214
|
+
bundledDir,
|
|
215
|
+
detail: existed ? "directory existed without a composition file (it occupied the id as a broken row)" : void 0
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
return { action: "error", id, dir, bundledDir, detail: String(error).slice(0, 200) };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function describeInstall(result) {
|
|
222
|
+
const where = result.dir === void 0 ? "" : ` (${result.dir})`;
|
|
223
|
+
const why = result.detail === void 0 ? "" : ` \u2014 ${result.detail}`;
|
|
224
|
+
return `preset ${result.id} ${result.action}${where}${why}`;
|
|
225
|
+
}
|
|
226
|
+
function presetStatus(moduleUrl, id = BUNDLED_PRESET_ID, root = conventionalUserPresetRoot()) {
|
|
227
|
+
const dir = path3.join(root, id);
|
|
228
|
+
const bundledDir = bundledPresetDir(moduleUrl, id);
|
|
229
|
+
const installed = fs2.existsSync(path3.join(dir, COMPOSITION_FILE));
|
|
230
|
+
return {
|
|
231
|
+
id,
|
|
232
|
+
dir,
|
|
233
|
+
...bundledDir === void 0 ? {} : { bundledDir },
|
|
234
|
+
installed,
|
|
235
|
+
compositionMatches: installed && bundledDir !== void 0 && sameBytes(path3.join(dir, COMPOSITION_FILE), path3.join(bundledDir, COMPOSITION_FILE)),
|
|
236
|
+
metadataMatches: bundledDir !== void 0 && fs2.existsSync(path3.join(dir, METADATA_FILE)) && sameBytes(path3.join(dir, METADATA_FILE), path3.join(bundledDir, METADATA_FILE))
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function sameBytes(left, right) {
|
|
240
|
+
try {
|
|
241
|
+
return fs2.readFileSync(left).equals(fs2.readFileSync(right));
|
|
242
|
+
} catch {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export {
|
|
248
|
+
createPathGuard,
|
|
249
|
+
EXCERPT_HEADER,
|
|
250
|
+
excerptFilePath,
|
|
251
|
+
readExcerpts,
|
|
252
|
+
appendExcerpt,
|
|
253
|
+
removeExcerpt,
|
|
254
|
+
recentExcerpts,
|
|
255
|
+
BUNDLED_PRESET_ID,
|
|
256
|
+
userPresetRoot,
|
|
257
|
+
conventionalUserPresetRoot,
|
|
258
|
+
installBundledPreset,
|
|
259
|
+
describeInstall,
|
|
260
|
+
presetStatus
|
|
261
|
+
};
|
|
262
|
+
//# sourceMappingURL=chunk-L54R23O2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/path-guard.ts","../src/excerpt/excerpt.ts","../src/core/preset-install.ts"],"sourcesContent":["// Path whitelist guard (requirement 8 / design doc §10.2).\n//\n// Every fs write/delete must have its target canonicalized first, then be\n// checked against the canonical workspace prefix with a separator boundary.\n// A raw startsWith check is bypassable via \"..\", symlinks/junctions, and\n// case variants; canonical realpath closes all of those on Windows.\n\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nexport class PathOutsideWorkspaceError extends Error {\n constructor(target: string, workspace: string) {\n super(`path outside workspace: \"${target}\" (workspace: \"${workspace}\")`);\n this.name = 'PathOutsideWorkspaceError';\n }\n}\n\n/**\n * Resolve to an absolute canonical path. For targets that do not exist yet,\n * realpath the deepest existing ancestor and re-append the virtual tail, so\n * planned files under the workspace validate while `..` escapes still resolve\n * through the real filesystem.\n */\nexport function canonicalize(target: string): string {\n const abs = path.resolve(target);\n try {\n return fs.realpathSync(abs);\n } catch {\n // Walk up from the missing leaf, recording each missing component, until\n // an existing ancestor is found; re-append the missing tail afterwards.\n const tail: string[] = [];\n let dir = abs;\n for (;;) {\n const base = path.basename(dir);\n const parent = path.dirname(dir);\n if (parent === dir) {\n throw new Error(`cannot canonicalize \"${target}\": no existing ancestor`);\n }\n tail.push(base);\n dir = parent;\n try {\n const realDir = fs.realpathSync(dir);\n return path.join(realDir, ...tail.reverse());\n } catch {\n continue;\n }\n }\n }\n}\n\n/**\n * True when `targetCanon` equals the workspace dir or lies under it.\n * Comparison is case-insensitive (Windows filesystems) and requires a\n * separator boundary so `D:\\ws-data-evil` does not match workspace `D:\\ws-data`.\n */\nexport function isInsideWorkspace(workspaceCanon: string, targetCanon: string): boolean {\n const norm = (p: string) => {\n let n = path.normalize(p).toLowerCase();\n if (!n.endsWith(path.sep)) n += path.sep;\n return n;\n };\n const w = norm(workspaceCanon);\n const t = norm(targetCanon);\n return t === w || t.startsWith(w);\n}\n\nexport interface PathGuard {\n /** Canonical workspace boundary. */\n readonly workspace: string;\n /** Canonicalize then validate; returns the canonical path or throws. */\n assert(target: string): string;\n /** Canonicalize then validate; returns null instead of throwing. */\n check(target: string): string | null;\n}\n\nexport function createPathGuard(workspaceDir: string): PathGuard {\n const workspace = canonicalize(workspaceDir);\n const guard: PathGuard = {\n workspace,\n check(target: string): string | null {\n const canon = canonicalize(target);\n return isInsideWorkspace(workspace, canon) ? canon : null;\n },\n assert(target: string): string {\n const canon = guard.check(target);\n if (canon === null) throw new PathOutsideWorkspaceError(target, workspace);\n return canon;\n },\n };\n return guard;\n}\n","// Excerpt book (\"摘抄本\") - the place for lines worth keeping.\n//\n// Deliberately plaintext Markdown, like the ledger: a notebook that cannot be\n// read is not a notebook. The two plaintext files in data/ are the ledger\n// (his todos) and this one (her clippings); everything private stays in KHBV2\n// containers. The user may edit it by hand, so the parser is tolerant:\n// unrecognised lines are preserved verbatim on rewrite.\n\nimport path from 'node:path';\nimport { randomUUID } from 'node:crypto';\nimport type { PathGuard } from '../core/path-guard.js';\nimport { readText, writeText } from '../vault/vault.js';\n\nexport interface ExcerptEntry {\n id: string;\n date: string; // \"YYYY-MM-DD\"\n time: string; // \"HH:MM\"\n text: string;\n}\n\n/** Used both as the read fallback and as the file the settings card opens, so\n * a fresh notebook already carries the two lines that explain it. */\nexport const EXCERPT_HEADER = '# 摘抄本\\n\\n> 留句子和小事的地方。可以直接手编,改乱了也不影响:认不出的行会原样留着。\\n\\n';\n\nexport function excerptFilePath(dataDir: string): string {\n return path.join(dataDir, 'excerpts.md');\n}\n\nconst LINE_RE = /^- \\[(\\d{4}-\\d{2}-\\d{2}) (\\d{2}:\\d{2})\\]\\[#([0-9a-f]{6})\\] (.*)$/;\n\nfunction renderEntry(e: ExcerptEntry): string {\n return `- [${e.date} ${e.time}][#${e.id}] ${e.text}`;\n}\n\nexport function readExcerpts(guard: PathGuard, file: string): { entries: ExcerptEntry[]; rawLines: string[] } {\n const raw = readText(guard, file, EXCERPT_HEADER);\n const rawLines: string[] = [];\n const entries: ExcerptEntry[] = [];\n for (const line of raw.split('\\n')) {\n const m = LINE_RE.exec(line);\n if (m) entries.push({ date: m[1]!, time: m[2]!, id: m[3]!, text: m[4]! });\n rawLines.push(line);\n }\n return { entries, rawLines };\n}\n\n/** Append one clipping, stamped with the local wall clock (like the ledger). */\nexport function appendExcerpt(guard: PathGuard, file: string, text: string, now = Date.now()): ExcerptEntry {\n const trimmed = text.trim();\n if (!trimmed) throw new Error('excerpt must not be empty');\n const d = new Date(now);\n const pad = (n: number) => String(n).padStart(2, '0');\n const entry: ExcerptEntry = {\n id: randomUUID().slice(0, 6),\n date: `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`,\n time: `${pad(d.getHours())}:${pad(d.getMinutes())}`,\n text: trimmed.replace(/\\r?\\n/g, ' '),\n };\n const { rawLines } = readExcerpts(guard, file);\n rawLines.push(renderEntry(entry));\n writeText(guard, file, rawLines.join('\\n').replace(/\\n*$/, '\\n'));\n return entry;\n}\n\n/** Tear one page out by id (preferred) or unique text substring. Unlike the\n * ledger there is no done-state: a clipping either stays or is gone. */\nexport function removeExcerpt(guard: PathGuard, file: string, key: string): ExcerptEntry | null {\n const { rawLines, entries } = readExcerpts(guard, file);\n const target = entries.find((e) => e.id === key || e.text.includes(key));\n if (!target) return null;\n const out = rawLines.filter((line) => !line.startsWith(`- [${target.date} ${target.time}][#${target.id}] `));\n writeText(guard, file, out.join('\\n').replace(/\\n*$/, '\\n'));\n return target;\n}\n\n/** The tail of the notebook, oldest-first among the newest `limit` entries. */\nexport function recentExcerpts(guard: PathGuard, file: string, limit: number): ExcerptEntry[] {\n const { entries } = readExcerpts(guard, file);\n return limit > 0 ? entries.slice(-limit) : [];\n}\n","// Bundled agent-preset installation (contract C13).\n//\n// Why this exists: the heartbeat agent is created by the host `agents` service,\n// which does NOT go through the session-start preset picker. A bare agent joins\n// no preset, and dsh-agent-presets states the consequence verbatim — \"its tools,\n// prompt sections, and skill catalog resolve against the empty global layer\" —\n// so it cannot even see `web_search`. The preset is therefore not optional, and\n// asking the operator to hand-copy two YAML files was the most error-prone step\n// of setup. The plugin now materialises its own bundled template in the roster's\n// USER root on first run.\n//\n// Two properties keep that safe:\n// 1. An existing preset is NEVER overwritten — the composition file belongs to\n// whoever edited it. Only a missing (or ghost) directory is filled in.\n// 2. The target comes from the roster's OWN roots (`agentPresets.roots`,\n// trust === \"user\") rather than a guessed `~/.dsh`, so `$DSH_HOME` and a\n// configured home are honoured without re-deriving them here.\n//\n// Timing: dsh-agent-presets re-scans the filesystem on every read\n// (`list()` -> `discoverPresets` -> `scanRoot`, no cache), so a directory\n// created here is visible to the very next `mount()` — no restart in between.\n\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport const COMPOSITION_FILE = 'agent.cordis.yml';\nexport const METADATA_FILE = 'preset.yml';\n/** The template this package ships, in `assets/presets/<id>/`. */\nexport const BUNDLED_PRESET_ID = 'heartbeat';\n\n/** One entry of the roster's root list (`AgentPresets.roots`). */\nexport interface PresetRootLike {\n path?: string;\n trust?: string;\n}\n\nexport type PresetInstallAction =\n | 'exists'\n | 'created'\n | 'repaired'\n | 'restored'\n | 'skipped-disabled'\n | 'skipped-custom-id'\n | 'skipped-no-root'\n | 'error';\n\nexport interface PresetInstallResult {\n action: PresetInstallAction;\n id: string;\n /** Where the preset lives (or would live). */\n dir?: string;\n /** Where the bundled template was read from. */\n bundledDir?: string;\n detail?: string;\n}\n\n/**\n * Locate the bundled template directory by walking up from a module URL.\n * Works from both entry points (`dist/index.js` and `dist/cli/index.js`) and\n * from the pnpm copy of an installed package.\n */\nexport function bundledPresetDir(\n moduleUrl: string,\n id: string = BUNDLED_PRESET_ID,\n): string | undefined {\n let dir: string;\n try {\n dir = path.dirname(fileURLToPath(moduleUrl));\n } catch {\n return undefined;\n }\n for (let depth = 0; depth < 5; depth += 1) {\n const candidate = path.join(dir, 'assets', 'presets', id);\n if (fs.existsSync(path.join(candidate, COMPOSITION_FILE))) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return undefined;\n}\n\n/** The roster's user-trust root, which is where locally authored presets live. */\nexport function userPresetRoot(roots?: readonly PresetRootLike[]): string | undefined {\n const found = roots?.find(\n (root) => root?.trust === 'user' && typeof root.path === 'string' && root.path.length > 0,\n );\n return found?.path === undefined ? undefined : path.resolve(found.path);\n}\n\n/**\n * `<dshHome>/.agent-presets` derived from the documented precedence\n * (`$DSH_HOME`, then `~/.dsh`). Only used where no roster is available — the\n * plugin itself prefers {@link userPresetRoot}.\n */\nexport function conventionalUserPresetRoot(\n env: NodeJS.ProcessEnv = process.env,\n home: string = os.homedir(),\n): string {\n const override = env.DSH_HOME?.trim();\n const root = override && override.length > 0 ? override : path.join(home, '.dsh');\n return path.join(root, '.agent-presets');\n}\n\nexport interface InstallPresetOptions {\n /** `import.meta.url` of the calling entry point. */\n moduleUrl: string;\n /** Preset id the heartbeat agent will join (config `agentPreset`). */\n id?: string;\n /** User-trust root reported by the roster. */\n root?: string;\n /** True when the roster answered — then an absent user root is a fact, not a guess. */\n rosterKnown?: boolean;\n /** `false` disables the install (config `installPreset`). */\n enabled?: boolean;\n /** Overwrite an existing composition file with the bundled one. */\n force?: boolean;\n}\n\n/**\n * Materialise the bundled preset in the roster's user root when it is absent.\n * Never destructive: an existing composition file is kept unless `force`.\n */\nexport function installBundledPreset(options: InstallPresetOptions): PresetInstallResult {\n const id = options.id && options.id.length > 0 ? options.id : BUNDLED_PRESET_ID;\n if (options.enabled === false) {\n return { action: 'skipped-disabled', id, detail: 'installPreset=false' };\n }\n const bundledDir = bundledPresetDir(options.moduleUrl, BUNDLED_PRESET_ID);\n if (id !== BUNDLED_PRESET_ID) {\n return {\n action: 'skipped-custom-id',\n id,\n ...(bundledDir === undefined ? {} : { bundledDir }),\n detail: `only \"${BUNDLED_PRESET_ID}\" ships with the plugin; \"${id}\" is yours to provide`,\n };\n }\n if (bundledDir === undefined) {\n return {\n action: 'error',\n id,\n detail: 'bundled template not found next to the plugin (assets/presets/heartbeat)',\n };\n }\n const root =\n options.root ?? (options.rosterKnown ? undefined : conventionalUserPresetRoot());\n if (root === undefined) {\n return {\n action: 'skipped-no-root',\n id,\n bundledDir,\n detail: 'the roster mounts no user preset root (includeUserRoot=false)',\n };\n }\n const dir = path.join(root, id);\n const composition = path.join(dir, COMPOSITION_FILE);\n try {\n if (fs.existsSync(composition)) {\n if (options.force !== true) {\n const drifted = !sameBytes(composition, path.join(bundledDir, COMPOSITION_FILE));\n return {\n action: 'exists',\n id,\n dir,\n bundledDir,\n detail: drifted ? 'kept as-is (differs from the bundled template)' : 'kept as-is',\n };\n }\n fs.copyFileSync(path.join(bundledDir, COMPOSITION_FILE), composition);\n return {\n action: 'restored',\n id,\n dir,\n bundledDir,\n detail: 'composition replaced from the bundled template',\n };\n }\n const existed = fs.existsSync(dir);\n fs.mkdirSync(dir, { recursive: true });\n fs.copyFileSync(path.join(bundledDir, COMPOSITION_FILE), composition);\n const metadata = path.join(dir, METADATA_FILE);\n // A directory with a composition but no metadata is legal; only fill a void.\n if (!fs.existsSync(metadata)) fs.copyFileSync(path.join(bundledDir, METADATA_FILE), metadata);\n return {\n action: existed ? 'repaired' : 'created',\n id,\n dir,\n bundledDir,\n detail: existed\n ? 'directory existed without a composition file (it occupied the id as a broken row)'\n : undefined,\n };\n } catch (error) {\n return { action: 'error', id, dir, bundledDir, detail: String(error).slice(0, 200) };\n }\n}\n\n/** One line suitable for the audit log and `ctx.logger`. */\nexport function describeInstall(result: PresetInstallResult): string {\n const where = result.dir === undefined ? '' : ` (${result.dir})`;\n const why = result.detail === undefined ? '' : ` — ${result.detail}`;\n return `preset ${result.id} ${result.action}${where}${why}`;\n}\n\nexport interface PresetStatus {\n id: string;\n dir: string;\n bundledDir?: string;\n installed: boolean;\n compositionMatches: boolean;\n metadataMatches: boolean;\n}\n\n/** Read-only inspection for the CLI (`preset status`). */\nexport function presetStatus(\n moduleUrl: string,\n id: string = BUNDLED_PRESET_ID,\n root: string = conventionalUserPresetRoot(),\n): PresetStatus {\n const dir = path.join(root, id);\n const bundledDir = bundledPresetDir(moduleUrl, id);\n const installed = fs.existsSync(path.join(dir, COMPOSITION_FILE));\n return {\n id,\n dir,\n ...(bundledDir === undefined ? {} : { bundledDir }),\n installed,\n compositionMatches:\n installed && bundledDir !== undefined && sameBytes(path.join(dir, COMPOSITION_FILE), path.join(bundledDir, COMPOSITION_FILE)),\n metadataMatches:\n bundledDir !== undefined &&\n fs.existsSync(path.join(dir, METADATA_FILE)) &&\n sameBytes(path.join(dir, METADATA_FILE), path.join(bundledDir, METADATA_FILE)),\n };\n}\n\nfunction sameBytes(left: string, right: string): boolean {\n try {\n return fs.readFileSync(left).equals(fs.readFileSync(right));\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;AAOA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,IAAM,4BAAN,cAAwC,MAAM;AAAA,EACnD,YAAY,QAAgB,WAAmB;AAC7C,UAAM,4BAA4B,MAAM,kBAAkB,SAAS,IAAI;AAC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