@sentry/junior 0.119.0 → 0.120.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/dist/{agent-hooks-NZSV4QQR.js → agent-hooks-5DDPWRYO.js} +7 -7
- package/dist/api.js +58 -79
- package/dist/app.js +21 -21
- package/dist/build/copy-build-content.d.ts +2 -2
- package/dist/{catalog-runtime-TAOYIZIZ.js → catalog-runtime-5KR5XBMJ.js} +7 -7
- package/dist/chat/discovery.d.ts +2 -0
- package/dist/chat/mcp/tool-manager.d.ts +14 -1
- package/dist/chat/plugins/types.d.ts +3 -9
- package/dist/chat/plugins/user-pages.d.ts +2 -1
- package/dist/{chunk-BLQZACHV.js → chunk-24B5R6OU.js} +92 -6
- package/dist/{chunk-JXRAOOXQ.js → chunk-6WX5SPI3.js} +1 -1
- package/dist/{chunk-VJTWKJWQ.js → chunk-ALAKN7LR.js} +1 -1
- package/dist/{chunk-ZJ6IVZVO.js → chunk-ALYQOZG7.js} +1 -1
- package/dist/{chunk-ZFX4M743.js → chunk-BHXW734F.js} +6 -6
- package/dist/{chunk-GKFDU3ZI.js → chunk-DJDGDJDF.js} +4 -4
- package/dist/{chunk-JLJLZS2N.js → chunk-DMKHRBI6.js} +4 -3
- package/dist/{chunk-NUENIPQL.js → chunk-DWOH57FW.js} +1 -1
- package/dist/{chunk-QZ7XRJDB.js → chunk-EIVE6GL4.js} +3 -3
- package/dist/{chunk-TGIQN7QW.js → chunk-ERYVNWNE.js} +93 -18
- package/dist/{chunk-JSTGI7TX.js → chunk-GNNV3UTY.js} +1 -1
- package/dist/chunk-H4HBKISO.js +417 -0
- package/dist/{chunk-BNJEPYTC.js → chunk-JQWP6V22.js} +4 -4
- package/dist/{chunk-D3N4BPSL.js → chunk-M243JMZH.js} +2 -2
- package/dist/{chunk-B3IT5END.js → chunk-OOUNJNMR.js} +16 -152
- package/dist/{chunk-6ZR455DC.js → chunk-Q3RL6A4E.js} +1 -1
- package/dist/{chunk-YLYJIQRX.js → chunk-QOQPPRFS.js} +12 -12
- package/dist/{chunk-4UIUDOOV.js → chunk-TKUCRFNX.js} +7 -7
- package/dist/{chunk-VLTWQQKH.js → chunk-VURFJVFH.js} +1 -1
- package/dist/{chunk-R53UT2OI.js → chunk-XAI2HNAY.js} +9 -5
- package/dist/{chunk-TAGV4Z3J.js → chunk-YEAOUT5W.js} +1 -1
- package/dist/cli/chat.js +23 -23
- package/dist/cli/check.js +8 -8
- package/dist/cli/plugins.js +12 -12
- package/dist/cli/snapshot-create.js +10 -10
- package/dist/cli/upgrade.js +7 -7
- package/dist/{db-FWGP5CKY.js → db-T4ZY64PB.js} +5 -5
- package/dist/{discovery-RMHYSRL7.js → discovery-GUFTFBTL.js} +3 -1
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +24 -7
- package/dist/{oauth-callback-server-PM3QNXJQ.js → oauth-callback-server-LQ6DFI26.js} +16 -16
- package/dist/{runner-DV55N6ZB.js → runner-D3ZU6TJH.js} +9 -9
- package/dist/{skills-MANV5ZK6.js → skills-JMXY7LIY.js} +8 -8
- package/dist/{validation-QGB4INTI.js → validation-OEPJS7JX.js} +8 -8
- package/dist/version.js +1 -1
- package/package.json +8 -7
- package/skills/jr-rpc/SKILL.md +40 -0
- package/dist/chunk-3V7OFJZC.js +0 -264
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
// src/chat/discovery.ts
|
|
2
|
+
import fs, { statSync as statSync2 } from "fs";
|
|
3
|
+
import path2 from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
// src/package-resolution.ts
|
|
7
|
+
import { statSync } from "fs";
|
|
8
|
+
import { createRequire } from "module";
|
|
9
|
+
import path from "path";
|
|
10
|
+
function isDirectory(targetPath) {
|
|
11
|
+
try {
|
|
12
|
+
return statSync(targetPath).isDirectory();
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isFile(targetPath) {
|
|
18
|
+
try {
|
|
19
|
+
return statSync(targetPath).isFile();
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function uniqueResolvedPathsInOrder(values) {
|
|
25
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26
|
+
const resolved = [];
|
|
27
|
+
for (const value of values) {
|
|
28
|
+
const normalized = path.resolve(value);
|
|
29
|
+
if (seen.has(normalized)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
seen.add(normalized);
|
|
33
|
+
resolved.push(normalized);
|
|
34
|
+
}
|
|
35
|
+
return resolved;
|
|
36
|
+
}
|
|
37
|
+
function ancestorNodeModulesDirs(cwd) {
|
|
38
|
+
const dirs = [];
|
|
39
|
+
let current = path.resolve(cwd);
|
|
40
|
+
while (true) {
|
|
41
|
+
const nodeModulesDir = path.join(current, "node_modules");
|
|
42
|
+
if (isDirectory(nodeModulesDir)) {
|
|
43
|
+
dirs.push(nodeModulesDir);
|
|
44
|
+
}
|
|
45
|
+
const parent = path.dirname(current);
|
|
46
|
+
if (parent === current) {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
current = parent;
|
|
50
|
+
}
|
|
51
|
+
return dirs;
|
|
52
|
+
}
|
|
53
|
+
function packageDirInNodeModules(nodeModulesDir, packageName) {
|
|
54
|
+
const packageDir = path.join(nodeModulesDir, ...packageName.split("/"));
|
|
55
|
+
return isDirectory(packageDir) ? path.resolve(packageDir) : void 0;
|
|
56
|
+
}
|
|
57
|
+
function isValidPackageSegment(segment) {
|
|
58
|
+
return Boolean(segment) && segment !== "." && segment !== ".." && !segment.startsWith(".") && /^[A-Za-z0-9._~-]+$/.test(segment);
|
|
59
|
+
}
|
|
60
|
+
function isValidPackageName(packageName) {
|
|
61
|
+
if (!packageName || packageName.includes("\\") || path.isAbsolute(packageName)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const parts = packageName.split("/");
|
|
65
|
+
if (parts[0].startsWith("@")) {
|
|
66
|
+
return parts.length === 2 && parts[0].length > 1 && isValidPackageSegment(parts[0].slice(1)) && isValidPackageSegment(parts[1]);
|
|
67
|
+
}
|
|
68
|
+
return parts.length === 1 && isValidPackageSegment(parts[0]);
|
|
69
|
+
}
|
|
70
|
+
function findPackageRoot(entryPath) {
|
|
71
|
+
let dir = path.dirname(entryPath);
|
|
72
|
+
while (dir !== path.dirname(dir)) {
|
|
73
|
+
if (isFile(path.join(dir, "package.json"))) {
|
|
74
|
+
return path.resolve(dir);
|
|
75
|
+
}
|
|
76
|
+
dir = path.dirname(dir);
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
function findPackageNodeModulesDir(packageDir, packageName) {
|
|
81
|
+
const parts = path.resolve(packageDir).split(path.sep);
|
|
82
|
+
const packageParts = packageName.split("/");
|
|
83
|
+
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
84
|
+
if (parts[index] !== "node_modules") {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const candidatePackageParts = parts.slice(
|
|
88
|
+
index + 1,
|
|
89
|
+
index + 1 + packageParts.length
|
|
90
|
+
);
|
|
91
|
+
if (candidatePackageParts.join("/") !== packageParts.join("/")) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
return path.resolve(parts.slice(0, index + 1).join(path.sep) || path.sep);
|
|
95
|
+
}
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
function resolvePackageWithNode(cwd, packageName) {
|
|
99
|
+
let requireFromCwd;
|
|
100
|
+
try {
|
|
101
|
+
requireFromCwd = createRequire(path.join(cwd, "package.json"));
|
|
102
|
+
} catch {
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
for (const specifier of [`${packageName}/package.json`, packageName]) {
|
|
106
|
+
try {
|
|
107
|
+
const resolved = requireFromCwd.resolve(specifier);
|
|
108
|
+
const dir = specifier.endsWith("/package.json") ? path.dirname(resolved) : findPackageRoot(resolved);
|
|
109
|
+
if (!dir) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const nodeModulesDir = findPackageNodeModulesDir(dir, packageName);
|
|
113
|
+
return {
|
|
114
|
+
dir,
|
|
115
|
+
...nodeModulesDir ? { nodeModulesDir } : {}
|
|
116
|
+
};
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
function resolvePackageLocation(cwd, packageName, options) {
|
|
123
|
+
if (!isValidPackageName(packageName)) {
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
const nodeModulesDirs = uniqueResolvedPathsInOrder([
|
|
127
|
+
...options?.nodeModulesDirs ?? [],
|
|
128
|
+
...ancestorNodeModulesDirs(cwd)
|
|
129
|
+
]);
|
|
130
|
+
for (const nodeModulesDir of nodeModulesDirs) {
|
|
131
|
+
const dir = packageDirInNodeModules(nodeModulesDir, packageName);
|
|
132
|
+
if (dir) {
|
|
133
|
+
return { dir, nodeModulesDir };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return resolvePackageWithNode(cwd, packageName);
|
|
137
|
+
}
|
|
138
|
+
function resolvePackageDir(cwd, packageName) {
|
|
139
|
+
return resolvePackageLocation(cwd, packageName)?.dir;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/chat/discovery.ts
|
|
143
|
+
function isDirectory2(targetPath) {
|
|
144
|
+
try {
|
|
145
|
+
return statSync2(targetPath).isDirectory();
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function isFile2(targetPath) {
|
|
151
|
+
try {
|
|
152
|
+
return statSync2(targetPath).isFile();
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function normalizePath(targetPath) {
|
|
158
|
+
return path2.resolve(targetPath);
|
|
159
|
+
}
|
|
160
|
+
function uniqueResolvedPathsInOrder2(values) {
|
|
161
|
+
const seen = /* @__PURE__ */ new Set();
|
|
162
|
+
const resolved = [];
|
|
163
|
+
for (const value of values) {
|
|
164
|
+
const normalized = normalizePath(value);
|
|
165
|
+
if (seen.has(normalized)) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
seen.add(normalized);
|
|
169
|
+
resolved.push(normalized);
|
|
170
|
+
}
|
|
171
|
+
return resolved;
|
|
172
|
+
}
|
|
173
|
+
function isNodeModulesPath(candidatePath) {
|
|
174
|
+
return path2.basename(candidatePath) === "node_modules";
|
|
175
|
+
}
|
|
176
|
+
function isInsidePnpmStore(candidatePath) {
|
|
177
|
+
return candidatePath.split(path2.sep).includes(".pnpm");
|
|
178
|
+
}
|
|
179
|
+
function runningFromInstalledPackage() {
|
|
180
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
181
|
+
const marker = `${path2.sep}node_modules${path2.sep}@sentry${path2.sep}junior${path2.sep}`;
|
|
182
|
+
return currentFile.includes(marker);
|
|
183
|
+
}
|
|
184
|
+
function listInstalledPackageNodeModulesDirs() {
|
|
185
|
+
if (!runningFromInstalledPackage()) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
const dirs = [];
|
|
189
|
+
let current = path2.resolve(path2.dirname(fileURLToPath(import.meta.url)));
|
|
190
|
+
while (true) {
|
|
191
|
+
if (isNodeModulesPath(current) && !isInsidePnpmStore(current) && isDirectory2(current)) {
|
|
192
|
+
dirs.push(current);
|
|
193
|
+
}
|
|
194
|
+
const parent = path2.dirname(current);
|
|
195
|
+
if (parent === current) {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
current = parent;
|
|
199
|
+
}
|
|
200
|
+
return dirs;
|
|
201
|
+
}
|
|
202
|
+
function listCwdAncestorNodeModulesDirs(cwd) {
|
|
203
|
+
const resolvedCwd = normalizePath(cwd);
|
|
204
|
+
const dirs = [];
|
|
205
|
+
let current = resolvedCwd;
|
|
206
|
+
while (true) {
|
|
207
|
+
const nodeModulesDir = path2.join(current, "node_modules");
|
|
208
|
+
if (isDirectory2(nodeModulesDir)) {
|
|
209
|
+
dirs.push(nodeModulesDir);
|
|
210
|
+
}
|
|
211
|
+
if (isFile2(path2.join(current, "package.json"))) {
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
const parent = path2.dirname(current);
|
|
215
|
+
if (parent === current) {
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
current = parent;
|
|
219
|
+
}
|
|
220
|
+
return dirs;
|
|
221
|
+
}
|
|
222
|
+
function discoverNodeModulesDirs(cwd = process.cwd(), options) {
|
|
223
|
+
const explicit = options?.candidateDirs?.filter((dir) => isDirectory2(dir)) ?? [];
|
|
224
|
+
if (explicit.length > 0) {
|
|
225
|
+
return uniqueResolvedPathsInOrder2(explicit);
|
|
226
|
+
}
|
|
227
|
+
return uniqueResolvedPathsInOrder2([
|
|
228
|
+
...listInstalledPackageNodeModulesDirs(),
|
|
229
|
+
...listCwdAncestorNodeModulesDirs(cwd)
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
232
|
+
function discoverProjectRoots(cwd = process.cwd(), options) {
|
|
233
|
+
const roots = discoverNodeModulesDirs(
|
|
234
|
+
cwd,
|
|
235
|
+
options?.nodeModulesDirs ? { candidateDirs: options.nodeModulesDirs } : void 0
|
|
236
|
+
).map((nodeModulesDir) => path2.dirname(nodeModulesDir));
|
|
237
|
+
return uniqueResolvedPathsInOrder2([cwd, ...roots]);
|
|
238
|
+
}
|
|
239
|
+
function unique(values) {
|
|
240
|
+
return [...new Set(values)];
|
|
241
|
+
}
|
|
242
|
+
function pathExists(targetPath) {
|
|
243
|
+
try {
|
|
244
|
+
fs.accessSync(targetPath);
|
|
245
|
+
return true;
|
|
246
|
+
} catch {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function hasAnyDataMarkers(appDir) {
|
|
251
|
+
return pathExists(path2.join(appDir, "SOUL.md")) || pathExists(path2.join(appDir, "WORLD.md"));
|
|
252
|
+
}
|
|
253
|
+
function scoreAppCandidate(appDir) {
|
|
254
|
+
let score = 0;
|
|
255
|
+
if (pathExists(path2.join(appDir, "SOUL.md"))) {
|
|
256
|
+
score += 4;
|
|
257
|
+
}
|
|
258
|
+
if (pathExists(path2.join(appDir, "WORLD.md"))) {
|
|
259
|
+
score += 2;
|
|
260
|
+
}
|
|
261
|
+
if (pathExists(path2.join(appDir, "skills"))) {
|
|
262
|
+
score += 1;
|
|
263
|
+
}
|
|
264
|
+
if (pathExists(path2.join(appDir, "plugins"))) {
|
|
265
|
+
score += 1;
|
|
266
|
+
}
|
|
267
|
+
return score;
|
|
268
|
+
}
|
|
269
|
+
function resolveCandidateAppDirs(cwd, projectRoots) {
|
|
270
|
+
const roots = projectRoots ?? discoverProjectRoots(cwd);
|
|
271
|
+
const resolved = [];
|
|
272
|
+
const seen = /* @__PURE__ */ new Set();
|
|
273
|
+
for (const root of roots) {
|
|
274
|
+
const appDir = path2.resolve(root, "app");
|
|
275
|
+
if (!pathExists(appDir)) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (seen.has(appDir)) {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
seen.add(appDir);
|
|
282
|
+
resolved.push(appDir);
|
|
283
|
+
}
|
|
284
|
+
return resolved;
|
|
285
|
+
}
|
|
286
|
+
function homeDir() {
|
|
287
|
+
return resolveHomeDir();
|
|
288
|
+
}
|
|
289
|
+
function resolveHomeDir(cwd = process.cwd(), options) {
|
|
290
|
+
const resolvedCwd = path2.resolve(cwd);
|
|
291
|
+
const directApp = path2.resolve(resolvedCwd, "app");
|
|
292
|
+
if (pathExists(directApp) && hasAnyDataMarkers(directApp)) {
|
|
293
|
+
return directApp;
|
|
294
|
+
}
|
|
295
|
+
const candidates = resolveCandidateAppDirs(
|
|
296
|
+
resolvedCwd,
|
|
297
|
+
options?.projectRoots
|
|
298
|
+
);
|
|
299
|
+
if (candidates.length === 0) {
|
|
300
|
+
return directApp;
|
|
301
|
+
}
|
|
302
|
+
candidates.sort((left, right) => {
|
|
303
|
+
const leftScore = scoreAppCandidate(left);
|
|
304
|
+
const rightScore = scoreAppCandidate(right);
|
|
305
|
+
if (leftScore !== rightScore) {
|
|
306
|
+
return rightScore - leftScore;
|
|
307
|
+
}
|
|
308
|
+
const leftDistance = path2.relative(resolvedCwd, left).split(path2.sep).length;
|
|
309
|
+
const rightDistance = path2.relative(resolvedCwd, right).split(path2.sep).length;
|
|
310
|
+
if (leftDistance !== rightDistance) {
|
|
311
|
+
return leftDistance - rightDistance;
|
|
312
|
+
}
|
|
313
|
+
return left.localeCompare(right);
|
|
314
|
+
});
|
|
315
|
+
return candidates[0];
|
|
316
|
+
}
|
|
317
|
+
function resolveContentRoots(subdir) {
|
|
318
|
+
if (subdir === "data") {
|
|
319
|
+
return [homeDir()];
|
|
320
|
+
}
|
|
321
|
+
return [path2.join(homeDir(), subdir)];
|
|
322
|
+
}
|
|
323
|
+
function builtInSkillsDir() {
|
|
324
|
+
const moduleDir = path2.dirname(fileURLToPath(import.meta.url));
|
|
325
|
+
if (path2.basename(moduleDir) === "dist") {
|
|
326
|
+
return path2.join(path2.dirname(moduleDir), "skills");
|
|
327
|
+
}
|
|
328
|
+
if (path2.basename(moduleDir) === "chat" && path2.basename(path2.dirname(moduleDir)) === "src") {
|
|
329
|
+
return path2.resolve(moduleDir, "../../skills");
|
|
330
|
+
}
|
|
331
|
+
const packageDir = resolvePackageDir(process.cwd(), "@sentry/junior");
|
|
332
|
+
return path2.join(packageDir ?? moduleDir, "skills");
|
|
333
|
+
}
|
|
334
|
+
function dataDir() {
|
|
335
|
+
return resolveContentRoots("data")[0];
|
|
336
|
+
}
|
|
337
|
+
function soulPath() {
|
|
338
|
+
return path2.join(dataDir(), "SOUL.md");
|
|
339
|
+
}
|
|
340
|
+
function worldPath() {
|
|
341
|
+
return path2.join(dataDir(), "WORLD.md");
|
|
342
|
+
}
|
|
343
|
+
function descriptionPath() {
|
|
344
|
+
return path2.join(dataDir(), "DESCRIPTION.md");
|
|
345
|
+
}
|
|
346
|
+
function skillsDir() {
|
|
347
|
+
return resolveContentRoots("skills")[0];
|
|
348
|
+
}
|
|
349
|
+
function pluginsDir() {
|
|
350
|
+
return resolveContentRoots("plugins")[0];
|
|
351
|
+
}
|
|
352
|
+
function dataRoots() {
|
|
353
|
+
return unique(resolveContentRoots("data"));
|
|
354
|
+
}
|
|
355
|
+
function skillRoots() {
|
|
356
|
+
return unique([builtInSkillsDir(), ...resolveContentRoots("skills")]);
|
|
357
|
+
}
|
|
358
|
+
function pluginRoots() {
|
|
359
|
+
return unique(resolveContentRoots("plugins"));
|
|
360
|
+
}
|
|
361
|
+
function soulPathCandidates() {
|
|
362
|
+
const candidates = dataRoots().map((root) => path2.join(root, "SOUL.md"));
|
|
363
|
+
return unique(candidates);
|
|
364
|
+
}
|
|
365
|
+
function worldPathCandidates() {
|
|
366
|
+
const candidates = dataRoots().map((root) => path2.join(root, "WORLD.md"));
|
|
367
|
+
return unique(candidates);
|
|
368
|
+
}
|
|
369
|
+
function descriptionPathCandidates() {
|
|
370
|
+
const candidates = dataRoots().map(
|
|
371
|
+
(root) => path2.join(root, "DESCRIPTION.md")
|
|
372
|
+
);
|
|
373
|
+
return unique(candidates);
|
|
374
|
+
}
|
|
375
|
+
var RESERVED_APP_FILES = /* @__PURE__ */ new Set([
|
|
376
|
+
"SOUL.md",
|
|
377
|
+
"WORLD.md",
|
|
378
|
+
"DESCRIPTION.md",
|
|
379
|
+
"ABOUT.md"
|
|
380
|
+
]);
|
|
381
|
+
function listReferenceFiles() {
|
|
382
|
+
const appDir = homeDir();
|
|
383
|
+
try {
|
|
384
|
+
const entries = fs.readdirSync(appDir, { withFileTypes: true });
|
|
385
|
+
return entries.filter(
|
|
386
|
+
(entry) => entry.isFile() && entry.name.endsWith(".md") && !RESERVED_APP_FILES.has(entry.name)
|
|
387
|
+
).map((entry) => path2.join(appDir, entry.name)).sort();
|
|
388
|
+
} catch {
|
|
389
|
+
return [];
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export {
|
|
394
|
+
isValidPackageName,
|
|
395
|
+
resolvePackageLocation,
|
|
396
|
+
resolvePackageDir,
|
|
397
|
+
isDirectory2 as isDirectory,
|
|
398
|
+
isFile2 as isFile,
|
|
399
|
+
discoverNodeModulesDirs,
|
|
400
|
+
discoverProjectRoots,
|
|
401
|
+
homeDir,
|
|
402
|
+
resolveHomeDir,
|
|
403
|
+
builtInSkillsDir,
|
|
404
|
+
dataDir,
|
|
405
|
+
soulPath,
|
|
406
|
+
worldPath,
|
|
407
|
+
descriptionPath,
|
|
408
|
+
skillsDir,
|
|
409
|
+
pluginsDir,
|
|
410
|
+
dataRoots,
|
|
411
|
+
skillRoots,
|
|
412
|
+
pluginRoots,
|
|
413
|
+
soulPathCandidates,
|
|
414
|
+
worldPathCandidates,
|
|
415
|
+
descriptionPathCandidates,
|
|
416
|
+
listReferenceFiles
|
|
417
|
+
};
|
|
@@ -13,17 +13,17 @@ import {
|
|
|
13
13
|
instructionProvenanceFor,
|
|
14
14
|
sanitizePostgresJson,
|
|
15
15
|
withConversationEventLock
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-M243JMZH.js";
|
|
17
17
|
import {
|
|
18
18
|
getStateAdapter,
|
|
19
19
|
sleep
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ALAKN7LR.js";
|
|
21
21
|
import {
|
|
22
22
|
botConfig,
|
|
23
23
|
escapeXml,
|
|
24
24
|
resolveGatewayModel,
|
|
25
25
|
unwrapCurrentInstruction
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-VURFJVFH.js";
|
|
27
27
|
import {
|
|
28
28
|
toStoredSlackActor
|
|
29
29
|
} from "./chunk-HZF5P5UN.js";
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
logException,
|
|
33
33
|
logWarn,
|
|
34
34
|
setSpanAttributes
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-ALYQOZG7.js";
|
|
36
36
|
import {
|
|
37
37
|
isRecord,
|
|
38
38
|
toOptionalNumber,
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
TURN_REASONING_LEVELS,
|
|
10
10
|
getChatConfig,
|
|
11
11
|
modelProfileSchema
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VURFJVFH.js";
|
|
13
13
|
import {
|
|
14
14
|
juniorDestinations
|
|
15
15
|
} from "./chunk-VFUK3X5B.js";
|
|
16
16
|
import {
|
|
17
17
|
normalizeIdentityEmail
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ALYQOZG7.js";
|
|
19
19
|
import {
|
|
20
20
|
parseSlackChannelReferenceId,
|
|
21
21
|
parseSlackTeamId
|
|
@@ -1,149 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
discoverNodeModulesDirs,
|
|
3
3
|
isDirectory,
|
|
4
|
-
isFile
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { statSync } from "fs";
|
|
9
|
-
import { createRequire } from "module";
|
|
10
|
-
import path from "path";
|
|
11
|
-
function isDirectory2(targetPath) {
|
|
12
|
-
try {
|
|
13
|
-
return statSync(targetPath).isDirectory();
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function isFile2(targetPath) {
|
|
19
|
-
try {
|
|
20
|
-
return statSync(targetPath).isFile();
|
|
21
|
-
} catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function uniqueResolvedPathsInOrder(values) {
|
|
26
|
-
const seen = /* @__PURE__ */ new Set();
|
|
27
|
-
const resolved = [];
|
|
28
|
-
for (const value of values) {
|
|
29
|
-
const normalized = path.resolve(value);
|
|
30
|
-
if (seen.has(normalized)) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
seen.add(normalized);
|
|
34
|
-
resolved.push(normalized);
|
|
35
|
-
}
|
|
36
|
-
return resolved;
|
|
37
|
-
}
|
|
38
|
-
function ancestorNodeModulesDirs(cwd) {
|
|
39
|
-
const dirs = [];
|
|
40
|
-
let current = path.resolve(cwd);
|
|
41
|
-
while (true) {
|
|
42
|
-
const nodeModulesDir = path.join(current, "node_modules");
|
|
43
|
-
if (isDirectory2(nodeModulesDir)) {
|
|
44
|
-
dirs.push(nodeModulesDir);
|
|
45
|
-
}
|
|
46
|
-
const parent = path.dirname(current);
|
|
47
|
-
if (parent === current) {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
current = parent;
|
|
51
|
-
}
|
|
52
|
-
return dirs;
|
|
53
|
-
}
|
|
54
|
-
function packageDirInNodeModules(nodeModulesDir, packageName) {
|
|
55
|
-
const packageDir = path.join(nodeModulesDir, ...packageName.split("/"));
|
|
56
|
-
return isDirectory2(packageDir) ? path.resolve(packageDir) : void 0;
|
|
57
|
-
}
|
|
58
|
-
function isValidPackageSegment(segment) {
|
|
59
|
-
return Boolean(segment) && segment !== "." && segment !== ".." && !segment.startsWith(".") && /^[A-Za-z0-9._~-]+$/.test(segment);
|
|
60
|
-
}
|
|
61
|
-
function isValidPackageName(packageName) {
|
|
62
|
-
if (!packageName || packageName.includes("\\") || path.isAbsolute(packageName)) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
const parts = packageName.split("/");
|
|
66
|
-
if (parts[0].startsWith("@")) {
|
|
67
|
-
return parts.length === 2 && parts[0].length > 1 && isValidPackageSegment(parts[0].slice(1)) && isValidPackageSegment(parts[1]);
|
|
68
|
-
}
|
|
69
|
-
return parts.length === 1 && isValidPackageSegment(parts[0]);
|
|
70
|
-
}
|
|
71
|
-
function findPackageRoot(entryPath) {
|
|
72
|
-
let dir = path.dirname(entryPath);
|
|
73
|
-
while (dir !== path.dirname(dir)) {
|
|
74
|
-
if (isFile2(path.join(dir, "package.json"))) {
|
|
75
|
-
return path.resolve(dir);
|
|
76
|
-
}
|
|
77
|
-
dir = path.dirname(dir);
|
|
78
|
-
}
|
|
79
|
-
return void 0;
|
|
80
|
-
}
|
|
81
|
-
function findPackageNodeModulesDir(packageDir, packageName) {
|
|
82
|
-
const parts = path.resolve(packageDir).split(path.sep);
|
|
83
|
-
const packageParts = packageName.split("/");
|
|
84
|
-
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
85
|
-
if (parts[index] !== "node_modules") {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const candidatePackageParts = parts.slice(
|
|
89
|
-
index + 1,
|
|
90
|
-
index + 1 + packageParts.length
|
|
91
|
-
);
|
|
92
|
-
if (candidatePackageParts.join("/") !== packageParts.join("/")) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
return path.resolve(parts.slice(0, index + 1).join(path.sep) || path.sep);
|
|
96
|
-
}
|
|
97
|
-
return void 0;
|
|
98
|
-
}
|
|
99
|
-
function resolvePackageWithNode(cwd, packageName) {
|
|
100
|
-
let requireFromCwd;
|
|
101
|
-
try {
|
|
102
|
-
requireFromCwd = createRequire(path.join(cwd, "package.json"));
|
|
103
|
-
} catch {
|
|
104
|
-
return void 0;
|
|
105
|
-
}
|
|
106
|
-
for (const specifier of [`${packageName}/package.json`, packageName]) {
|
|
107
|
-
try {
|
|
108
|
-
const resolved = requireFromCwd.resolve(specifier);
|
|
109
|
-
const dir = specifier.endsWith("/package.json") ? path.dirname(resolved) : findPackageRoot(resolved);
|
|
110
|
-
if (!dir) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
const nodeModulesDir = findPackageNodeModulesDir(dir, packageName);
|
|
114
|
-
return {
|
|
115
|
-
dir,
|
|
116
|
-
...nodeModulesDir ? { nodeModulesDir } : {}
|
|
117
|
-
};
|
|
118
|
-
} catch {
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return void 0;
|
|
122
|
-
}
|
|
123
|
-
function resolvePackageLocation(cwd, packageName, options) {
|
|
124
|
-
if (!isValidPackageName(packageName)) {
|
|
125
|
-
return void 0;
|
|
126
|
-
}
|
|
127
|
-
const nodeModulesDirs = uniqueResolvedPathsInOrder([
|
|
128
|
-
...options?.nodeModulesDirs ?? [],
|
|
129
|
-
...ancestorNodeModulesDirs(cwd)
|
|
130
|
-
]);
|
|
131
|
-
for (const nodeModulesDir of nodeModulesDirs) {
|
|
132
|
-
const dir = packageDirInNodeModules(nodeModulesDir, packageName);
|
|
133
|
-
if (dir) {
|
|
134
|
-
return { dir, nodeModulesDir };
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return resolvePackageWithNode(cwd, packageName);
|
|
138
|
-
}
|
|
139
|
-
function resolvePackageDir(cwd, packageName) {
|
|
140
|
-
return resolvePackageLocation(cwd, packageName)?.dir;
|
|
141
|
-
}
|
|
4
|
+
isFile,
|
|
5
|
+
isValidPackageName,
|
|
6
|
+
resolvePackageLocation
|
|
7
|
+
} from "./chunk-H4HBKISO.js";
|
|
142
8
|
|
|
143
9
|
// src/chat/plugins/package-discovery.ts
|
|
144
|
-
import
|
|
10
|
+
import path from "path";
|
|
145
11
|
function normalizeForGlob(targetPath) {
|
|
146
|
-
return targetPath.split(
|
|
12
|
+
return targetPath.split(path.sep).join("/");
|
|
147
13
|
}
|
|
148
14
|
function uniqueStringsInOrder(values) {
|
|
149
15
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -158,8 +24,8 @@ function uniqueStringsInOrder(values) {
|
|
|
158
24
|
return resolved;
|
|
159
25
|
}
|
|
160
26
|
function pathForTracingInclude(cwd, targetPath) {
|
|
161
|
-
const relative =
|
|
162
|
-
if (!relative ||
|
|
27
|
+
const relative = path.relative(cwd, targetPath);
|
|
28
|
+
if (!relative || path.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path.sep}`)) {
|
|
163
29
|
return null;
|
|
164
30
|
}
|
|
165
31
|
const normalized = normalizeForGlob(relative);
|
|
@@ -196,10 +62,10 @@ function resolvePackageDirFromName(cwd, packageName, candidateNodeModulesDirs) {
|
|
|
196
62
|
}) ?? null;
|
|
197
63
|
}
|
|
198
64
|
function readPluginPackageFlags(dir) {
|
|
199
|
-
const hasRootPluginManifest = isFile(
|
|
200
|
-
const hasMigrationsDir = isDirectory(
|
|
201
|
-
const hasPluginsDir = isDirectory(
|
|
202
|
-
const hasSkillsDir = isDirectory(
|
|
65
|
+
const hasRootPluginManifest = isFile(path.join(dir, "plugin.yaml"));
|
|
66
|
+
const hasMigrationsDir = isDirectory(path.join(dir, "migrations"));
|
|
67
|
+
const hasPluginsDir = isDirectory(path.join(dir, "plugins"));
|
|
68
|
+
const hasSkillsDir = isDirectory(path.join(dir, "skills"));
|
|
203
69
|
if (!hasRootPluginManifest && !hasMigrationsDir && !hasPluginsDir && !hasSkillsDir) {
|
|
204
70
|
return null;
|
|
205
71
|
}
|
|
@@ -244,7 +110,7 @@ function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs, cwd) {
|
|
|
244
110
|
return discovered;
|
|
245
111
|
}
|
|
246
112
|
function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
247
|
-
const resolvedCwd =
|
|
113
|
+
const resolvedCwd = path.resolve(cwd);
|
|
248
114
|
const packageNames = normalizePluginPackageNames(options?.packageNames);
|
|
249
115
|
const nodeModulesDirs = options?.nodeModulesDirs ?? discoverNodeModulesDirs(resolvedCwd);
|
|
250
116
|
const discoveredPackages = discoverDeclaredPackages(
|
|
@@ -258,7 +124,7 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
|
258
124
|
for (const pkg of discoveredPackages) {
|
|
259
125
|
const tracingBasePath = pkg.nodeModulesDir ? pathForTracingInclude(
|
|
260
126
|
resolvedCwd,
|
|
261
|
-
|
|
127
|
+
path.join(pkg.nodeModulesDir, ...pkg.packageName.split("/"))
|
|
262
128
|
) : pathForTracingInclude(resolvedCwd, pkg.dir);
|
|
263
129
|
if (pkg.hasRootPluginManifest) {
|
|
264
130
|
manifestRoots.push(pkg.dir);
|
|
@@ -272,13 +138,13 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
|
272
138
|
}
|
|
273
139
|
}
|
|
274
140
|
if (pkg.hasPluginsDir) {
|
|
275
|
-
manifestRoots.push(
|
|
141
|
+
manifestRoots.push(path.join(pkg.dir, "plugins"));
|
|
276
142
|
if (tracingBasePath) {
|
|
277
143
|
tracingIncludes.push(`${tracingBasePath}/plugins/**/*`);
|
|
278
144
|
}
|
|
279
145
|
}
|
|
280
146
|
if (pkg.hasSkillsDir) {
|
|
281
|
-
skillRoots.push(
|
|
147
|
+
skillRoots.push(path.join(pkg.dir, "skills"));
|
|
282
148
|
if (tracingBasePath) {
|
|
283
149
|
tracingIncludes.push(`${tracingBasePath}/skills/**/*`);
|
|
284
150
|
}
|
|
@@ -301,8 +167,6 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
|
301
167
|
}
|
|
302
168
|
|
|
303
169
|
export {
|
|
304
|
-
isValidPackageName,
|
|
305
|
-
resolvePackageDir,
|
|
306
170
|
normalizePluginPackageNames,
|
|
307
171
|
discoverInstalledPluginPackageContent
|
|
308
172
|
};
|