@sentry/junior 0.71.3 → 0.73.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/bin/junior.mjs +22 -10
- package/dist/api-reference.d.ts +2 -0
- package/dist/app.d.ts +12 -3
- package/dist/app.js +2522 -15560
- package/dist/chat/agent-dispatch/heartbeat.d.ts +0 -6
- package/dist/chat/agent-dispatch/runner.d.ts +2 -0
- package/dist/chat/agent-dispatch/store.d.ts +2 -2
- package/dist/chat/agent-dispatch/types.d.ts +6 -3
- package/dist/chat/agent-dispatch/validation.d.ts +2 -3
- package/dist/chat/app/production.d.ts +8 -1
- package/dist/chat/app/services.d.ts +7 -0
- package/dist/chat/destination.d.ts +3 -1
- package/dist/chat/logging.d.ts +3 -0
- package/dist/chat/mcp/errors.d.ts +3 -0
- package/dist/chat/mcp/tool-manager.d.ts +5 -1
- package/dist/chat/oauth-flow.d.ts +1 -1
- package/dist/chat/plugins/agent-hooks.d.ts +3 -2
- package/dist/chat/plugins/registry.d.ts +2 -0
- package/dist/chat/plugins/types.d.ts +2 -0
- package/dist/chat/prompt.d.ts +4 -1
- package/dist/chat/requester.d.ts +67 -0
- package/dist/chat/respond.d.ts +8 -8
- package/dist/chat/runtime/agent-continue-runner.d.ts +25 -0
- package/dist/chat/runtime/reply-executor.d.ts +7 -5
- package/dist/chat/runtime/slack-resume.d.ts +3 -3
- package/dist/chat/runtime/slack-runtime.d.ts +13 -3
- package/dist/chat/runtime/turn.d.ts +17 -3
- package/dist/chat/sandbox/egress-credentials.d.ts +5 -2
- package/dist/chat/sandbox/egress-policy.d.ts +5 -1
- package/dist/chat/sandbox/egress-proxy.d.ts +2 -0
- package/dist/chat/sandbox/egress-schemas.d.ts +4 -0
- package/dist/chat/sandbox/egress-session.d.ts +3 -1
- package/dist/chat/sandbox/egress-tracing.d.ts +7 -0
- package/dist/chat/sandbox/sandbox.d.ts +2 -0
- package/dist/chat/sandbox/session.d.ts +3 -2
- package/dist/chat/services/agent-continue.d.ts +27 -0
- package/dist/chat/services/auth-pause-response.d.ts +1 -1
- package/dist/chat/services/auth-pause.d.ts +2 -1
- package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
- package/dist/chat/services/message-actor-identity.d.ts +12 -4
- package/dist/chat/services/plugin-auth-orchestration.d.ts +9 -8
- package/dist/chat/services/turn-result.d.ts +3 -0
- package/dist/chat/services/turn-session-record.d.ts +10 -7
- package/dist/chat/slack/user.d.ts +4 -4
- package/dist/chat/state/adapter.d.ts +2 -0
- package/dist/chat/state/conversation-details.d.ts +4 -3
- package/dist/chat/state/session-log.d.ts +43 -0
- package/dist/chat/state/turn-session.d.ts +7 -10
- package/dist/chat/task-execution/slack-work.d.ts +5 -5
- package/dist/chat/task-execution/store.d.ts +83 -48
- package/dist/chat/task-execution/worker.d.ts +3 -3
- package/dist/chat/tools/definition.d.ts +3 -0
- package/dist/chat/tools/execution/tool-error-handler.d.ts +2 -1
- package/dist/chat/tools/slack/canvas-tools.d.ts +3 -2
- package/dist/chat/tools/slack/channel-list-messages.d.ts +2 -2
- package/dist/chat/tools/slack/channel-post-message.d.ts +3 -2
- package/dist/chat/tools/slack/context.d.ts +15 -2
- package/dist/chat/tools/slack/message-add-reaction.d.ts +3 -2
- package/dist/chat/tools/slack/thread-read.d.ts +2 -2
- package/dist/chat/tools/types.d.ts +20 -23
- package/dist/{chunk-BBXYXOJW.js → chunk-3BYAPS6B.js} +48 -529
- package/dist/{chunk-UXG6TU2U.js → chunk-7Q5YOUUT.js} +16 -93
- package/dist/chunk-AL5T52ZD.js +1119 -0
- package/dist/chunk-CYUI7JU5.js +195 -0
- package/dist/{chunk-R62YWUNO.js → chunk-DIMX5F3T.js} +10 -28
- package/dist/chunk-G3E7SCME.js +28 -0
- package/dist/chunk-KVZL5NZS.js +519 -0
- package/dist/chunk-M4FLLXXD.js +212 -0
- package/dist/chunk-OQSYYOLM.js +12787 -0
- package/dist/{chunk-GT67ZWZQ.js → chunk-OR6NQJ5E.js} +5 -3
- package/dist/{chunk-B5HKWWQB.js → chunk-RY6AL5C7.js} +8 -6
- package/dist/chunk-SJHUF3DP.js +43 -0
- package/dist/{chunk-XE2VFQQN.js → chunk-UOTZ3EEQ.js} +1 -1
- package/dist/{chunk-HOGQL2H6.js → chunk-UZVHXZ7V.js} +1357 -1486
- package/dist/{chunk-76YMBKW7.js → chunk-V4VYUY4A.js} +27 -14
- package/dist/{chunk-JS4HURDT.js → chunk-WS2EG3GW.js} +224 -224
- package/dist/chunk-ZDA2HYX5.js +275 -0
- package/dist/cli/chat.js +205 -0
- package/dist/cli/check.js +6 -5
- package/dist/cli/run.js +18 -2
- package/dist/cli/snapshot-warmup.js +11 -8
- package/dist/cli/upgrade.js +599 -0
- package/dist/deployment.d.ts +4 -0
- package/dist/handlers/agent-dispatch.d.ts +6 -1
- package/dist/handlers/mcp-oauth-callback.d.ts +6 -1
- package/dist/handlers/oauth-callback.d.ts +6 -1
- package/dist/handlers/sandbox-egress-proxy.d.ts +2 -0
- package/dist/handlers/webhooks.d.ts +4 -2
- package/dist/instrumentation.js +17 -2
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +10 -10
- package/dist/plugins.d.ts +1 -1
- package/dist/reporting/conversations.d.ts +116 -0
- package/dist/reporting.d.ts +24 -129
- package/dist/reporting.js +320 -166
- package/dist/runner-LMAM4OGD.js +259 -0
- package/package.json +3 -3
- package/dist/chat/runtime/timeout-resume-runner.d.ts +0 -19
- package/dist/chat/services/requester-identity.d.ts +0 -19
- package/dist/chat/services/timeout-resume.d.ts +0 -23
- package/dist/chunk-6YY4Q3D4.js +0 -12
- package/dist/chunk-Z3YD6NHK.js +0 -12
- package/dist/handlers/turn-resume.d.ts +0 -4
|
@@ -1,225 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getDeploymentTelemetryAttributes,
|
|
2
3
|
sentry_exports
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SJHUF3DP.js";
|
|
4
5
|
|
|
5
|
-
// src/chat/
|
|
6
|
-
import
|
|
6
|
+
// src/chat/logging.ts
|
|
7
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
7
8
|
import path from "path";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
function isFile(targetPath) {
|
|
17
|
-
try {
|
|
18
|
-
return statSync(targetPath).isFile();
|
|
19
|
-
} catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function normalizePath(targetPath) {
|
|
24
|
-
return path.resolve(targetPath);
|
|
25
|
-
}
|
|
26
|
-
function uniqueResolvedPathsInOrder(values) {
|
|
27
|
-
const seen = /* @__PURE__ */ new Set();
|
|
28
|
-
const resolved = [];
|
|
29
|
-
for (const value of values) {
|
|
30
|
-
const normalized = normalizePath(value);
|
|
31
|
-
if (seen.has(normalized)) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
seen.add(normalized);
|
|
35
|
-
resolved.push(normalized);
|
|
36
|
-
}
|
|
37
|
-
return resolved;
|
|
38
|
-
}
|
|
39
|
-
function isNodeModulesPath(candidatePath) {
|
|
40
|
-
return path.basename(candidatePath) === "node_modules";
|
|
41
|
-
}
|
|
42
|
-
function isInsidePnpmStore(candidatePath) {
|
|
43
|
-
return candidatePath.split(path.sep).includes(".pnpm");
|
|
44
|
-
}
|
|
45
|
-
function runningFromInstalledPackage() {
|
|
46
|
-
const currentFile = fileURLToPath(import.meta.url);
|
|
47
|
-
const marker = `${path.sep}node_modules${path.sep}@sentry${path.sep}junior${path.sep}`;
|
|
48
|
-
return currentFile.includes(marker);
|
|
49
|
-
}
|
|
50
|
-
function listInstalledPackageNodeModulesDirs() {
|
|
51
|
-
if (!runningFromInstalledPackage()) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
const dirs = [];
|
|
55
|
-
let current = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
|
|
56
|
-
while (true) {
|
|
57
|
-
if (isNodeModulesPath(current) && !isInsidePnpmStore(current) && isDirectory(current)) {
|
|
58
|
-
dirs.push(current);
|
|
59
|
-
}
|
|
60
|
-
const parent = path.dirname(current);
|
|
61
|
-
if (parent === current) {
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
current = parent;
|
|
65
|
-
}
|
|
66
|
-
return dirs;
|
|
67
|
-
}
|
|
68
|
-
function listCwdAncestorNodeModulesDirs(cwd) {
|
|
69
|
-
const resolvedCwd = normalizePath(cwd);
|
|
70
|
-
const dirs = [];
|
|
71
|
-
let current = resolvedCwd;
|
|
72
|
-
while (true) {
|
|
73
|
-
const nodeModulesDir = path.join(current, "node_modules");
|
|
74
|
-
if (isDirectory(nodeModulesDir)) {
|
|
75
|
-
dirs.push(nodeModulesDir);
|
|
76
|
-
}
|
|
77
|
-
if (isFile(path.join(current, "package.json"))) {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
const parent = path.dirname(current);
|
|
81
|
-
if (parent === current) {
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
current = parent;
|
|
85
|
-
}
|
|
86
|
-
return dirs;
|
|
87
|
-
}
|
|
88
|
-
function discoverNodeModulesDirs(cwd = process.cwd(), options) {
|
|
89
|
-
const explicit = options?.candidateDirs?.filter((dir) => isDirectory(dir)) ?? [];
|
|
90
|
-
if (explicit.length > 0) {
|
|
91
|
-
return uniqueResolvedPathsInOrder(explicit);
|
|
92
|
-
}
|
|
93
|
-
return uniqueResolvedPathsInOrder([
|
|
94
|
-
...listInstalledPackageNodeModulesDirs(),
|
|
95
|
-
...listCwdAncestorNodeModulesDirs(cwd)
|
|
96
|
-
]);
|
|
97
|
-
}
|
|
98
|
-
function discoverProjectRoots(cwd = process.cwd(), options) {
|
|
99
|
-
const roots = discoverNodeModulesDirs(
|
|
100
|
-
cwd,
|
|
101
|
-
options?.nodeModulesDirs ? { candidateDirs: options.nodeModulesDirs } : void 0
|
|
102
|
-
).map((nodeModulesDir) => path.dirname(nodeModulesDir));
|
|
103
|
-
return uniqueResolvedPathsInOrder([cwd, ...roots]);
|
|
104
|
-
}
|
|
105
|
-
function unique(values) {
|
|
106
|
-
return [...new Set(values)];
|
|
107
|
-
}
|
|
108
|
-
function pathExists(targetPath) {
|
|
109
|
-
try {
|
|
110
|
-
fs.accessSync(targetPath);
|
|
111
|
-
return true;
|
|
112
|
-
} catch {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function hasAnyDataMarkers(appDir) {
|
|
117
|
-
return pathExists(path.join(appDir, "SOUL.md")) || pathExists(path.join(appDir, "WORLD.md"));
|
|
118
|
-
}
|
|
119
|
-
function scoreAppCandidate(appDir) {
|
|
120
|
-
let score = 0;
|
|
121
|
-
if (pathExists(path.join(appDir, "SOUL.md"))) {
|
|
122
|
-
score += 4;
|
|
123
|
-
}
|
|
124
|
-
if (pathExists(path.join(appDir, "WORLD.md"))) {
|
|
125
|
-
score += 2;
|
|
126
|
-
}
|
|
127
|
-
if (pathExists(path.join(appDir, "skills"))) {
|
|
128
|
-
score += 1;
|
|
129
|
-
}
|
|
130
|
-
if (pathExists(path.join(appDir, "plugins"))) {
|
|
131
|
-
score += 1;
|
|
132
|
-
}
|
|
133
|
-
return score;
|
|
134
|
-
}
|
|
135
|
-
function resolveCandidateAppDirs(cwd, projectRoots) {
|
|
136
|
-
const roots = projectRoots ?? discoverProjectRoots(cwd);
|
|
137
|
-
const resolved = [];
|
|
138
|
-
const seen = /* @__PURE__ */ new Set();
|
|
139
|
-
for (const root of roots) {
|
|
140
|
-
const appDir = path.resolve(root, "app");
|
|
141
|
-
if (!pathExists(appDir)) {
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (seen.has(appDir)) {
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
seen.add(appDir);
|
|
148
|
-
resolved.push(appDir);
|
|
149
|
-
}
|
|
150
|
-
return resolved;
|
|
151
|
-
}
|
|
152
|
-
function homeDir() {
|
|
153
|
-
return resolveHomeDir();
|
|
154
|
-
}
|
|
155
|
-
function resolveHomeDir(cwd = process.cwd(), options) {
|
|
156
|
-
const resolvedCwd = path.resolve(cwd);
|
|
157
|
-
const directApp = path.resolve(resolvedCwd, "app");
|
|
158
|
-
if (pathExists(directApp) && hasAnyDataMarkers(directApp)) {
|
|
159
|
-
return directApp;
|
|
160
|
-
}
|
|
161
|
-
const candidates = resolveCandidateAppDirs(
|
|
162
|
-
resolvedCwd,
|
|
163
|
-
options?.projectRoots
|
|
164
|
-
);
|
|
165
|
-
if (candidates.length === 0) {
|
|
166
|
-
return directApp;
|
|
167
|
-
}
|
|
168
|
-
candidates.sort((left, right) => {
|
|
169
|
-
const leftScore = scoreAppCandidate(left);
|
|
170
|
-
const rightScore = scoreAppCandidate(right);
|
|
171
|
-
if (leftScore !== rightScore) {
|
|
172
|
-
return rightScore - leftScore;
|
|
173
|
-
}
|
|
174
|
-
const leftDistance = path.relative(resolvedCwd, left).split(path.sep).length;
|
|
175
|
-
const rightDistance = path.relative(resolvedCwd, right).split(path.sep).length;
|
|
176
|
-
if (leftDistance !== rightDistance) {
|
|
177
|
-
return leftDistance - rightDistance;
|
|
178
|
-
}
|
|
179
|
-
return left.localeCompare(right);
|
|
180
|
-
});
|
|
181
|
-
return candidates[0];
|
|
182
|
-
}
|
|
183
|
-
function resolveContentRoots(subdir) {
|
|
184
|
-
if (subdir === "data") {
|
|
185
|
-
return [homeDir()];
|
|
186
|
-
}
|
|
187
|
-
return [path.join(homeDir(), subdir)];
|
|
188
|
-
}
|
|
189
|
-
function dataRoots() {
|
|
190
|
-
return unique(resolveContentRoots("data"));
|
|
191
|
-
}
|
|
192
|
-
function skillRoots() {
|
|
193
|
-
return unique(resolveContentRoots("skills"));
|
|
194
|
-
}
|
|
195
|
-
function pluginRoots() {
|
|
196
|
-
return unique(resolveContentRoots("plugins"));
|
|
197
|
-
}
|
|
198
|
-
function soulPathCandidates() {
|
|
199
|
-
const candidates = dataRoots().map((root) => path.join(root, "SOUL.md"));
|
|
200
|
-
return unique(candidates);
|
|
201
|
-
}
|
|
202
|
-
function worldPathCandidates() {
|
|
203
|
-
const candidates = dataRoots().map((root) => path.join(root, "WORLD.md"));
|
|
204
|
-
return unique(candidates);
|
|
205
|
-
}
|
|
206
|
-
var RESERVED_APP_FILES = /* @__PURE__ */ new Set([
|
|
207
|
-
"SOUL.md",
|
|
208
|
-
"WORLD.md",
|
|
209
|
-
"DESCRIPTION.md",
|
|
210
|
-
"ABOUT.md"
|
|
211
|
-
]);
|
|
212
|
-
function listReferenceFiles() {
|
|
213
|
-
const appDir = homeDir();
|
|
214
|
-
try {
|
|
215
|
-
const entries = fs.readdirSync(appDir, { withFileTypes: true });
|
|
216
|
-
return entries.filter(
|
|
217
|
-
(entry) => entry.isFile() && entry.name.endsWith(".md") && !RESERVED_APP_FILES.has(entry.name)
|
|
218
|
-
).map((entry) => path.join(appDir, entry.name)).sort();
|
|
219
|
-
} catch {
|
|
220
|
-
return [];
|
|
221
|
-
}
|
|
222
|
-
}
|
|
9
|
+
import { styleText } from "util";
|
|
10
|
+
import {
|
|
11
|
+
ConfigError,
|
|
12
|
+
configureSync,
|
|
13
|
+
getConfig,
|
|
14
|
+
getLogger
|
|
15
|
+
} from "@logtape/logtape";
|
|
223
16
|
|
|
224
17
|
// src/chat/coerce.ts
|
|
225
18
|
function toOptionalString(value) {
|
|
@@ -233,15 +26,6 @@ function isRecord(value) {
|
|
|
233
26
|
}
|
|
234
27
|
|
|
235
28
|
// src/chat/logging.ts
|
|
236
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
237
|
-
import path2 from "path";
|
|
238
|
-
import { styleText } from "util";
|
|
239
|
-
import {
|
|
240
|
-
ConfigError,
|
|
241
|
-
configureSync,
|
|
242
|
-
getConfig,
|
|
243
|
-
getLogger
|
|
244
|
-
} from "@logtape/logtape";
|
|
245
29
|
var MAX_STRING_VALUE = 1200;
|
|
246
30
|
var SECRETS_RE = [
|
|
247
31
|
/\b(sk-[A-Za-z0-9_-]{20,})\b/g,
|
|
@@ -293,6 +77,7 @@ function normalizeGenAiFinishReasons(value) {
|
|
|
293
77
|
}
|
|
294
78
|
var contextStorage = new AsyncLocalStorage();
|
|
295
79
|
var logRecordSinks = /* @__PURE__ */ new Set();
|
|
80
|
+
var deploymentLogAttributes = getDeploymentTelemetryAttributes();
|
|
296
81
|
var LOGTAPE_BODY_KEY = "__logtape_body";
|
|
297
82
|
var ROOT_LOGGER_CATEGORY = ["junior"];
|
|
298
83
|
var CONSOLE_PRIORITY_KEYS = [
|
|
@@ -813,8 +598,8 @@ function toRelativeConsolePath(value) {
|
|
|
813
598
|
return normalized;
|
|
814
599
|
}
|
|
815
600
|
try {
|
|
816
|
-
const relative =
|
|
817
|
-
if (relative.length > 0 && !relative.startsWith("..") && !
|
|
601
|
+
const relative = path.relative(process.cwd(), normalized);
|
|
602
|
+
if (relative.length > 0 && !relative.startsWith("..") && !path.isAbsolute(relative)) {
|
|
818
603
|
return relative;
|
|
819
604
|
}
|
|
820
605
|
} catch {
|
|
@@ -1037,11 +822,17 @@ function emitRecord(category, level, eventName, attrs = {}, body) {
|
|
|
1037
822
|
const message = body ? redactSecrets(body) : normalizedEventName;
|
|
1038
823
|
const source = getLogSource([...ROOT_LOGGER_CATEGORY, ...category]);
|
|
1039
824
|
const contextAttributes = ownsLogTapeBackend ? void 0 : contextStorage.getStore();
|
|
1040
|
-
const attributes = mergeAttributes(
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
825
|
+
const attributes = mergeAttributes(
|
|
826
|
+
contextAttributes,
|
|
827
|
+
traceAttributes,
|
|
828
|
+
{
|
|
829
|
+
"event.name": normalizedEventName,
|
|
830
|
+
...source ? { "app.log.source": source } : {},
|
|
831
|
+
...attrs
|
|
832
|
+
},
|
|
833
|
+
// Deployment identity is process-owned and must win over event-local attrs.
|
|
834
|
+
deploymentLogAttributes
|
|
835
|
+
);
|
|
1045
836
|
if (usesDirectEmissionFallback) {
|
|
1046
837
|
emitDirect(level, normalizedEventName, message, attributes);
|
|
1047
838
|
return;
|
|
@@ -1355,6 +1146,21 @@ async function withSpan(name, op, context, callback, attributes = {}) {
|
|
|
1355
1146
|
);
|
|
1356
1147
|
});
|
|
1357
1148
|
}
|
|
1149
|
+
function getTracePropagationHeaders() {
|
|
1150
|
+
const sentry = sentry_exports;
|
|
1151
|
+
const traceData = sentry.getTraceData?.({ propagateTraceparent: true });
|
|
1152
|
+
if (!traceData) {
|
|
1153
|
+
return {};
|
|
1154
|
+
}
|
|
1155
|
+
const headers = {};
|
|
1156
|
+
for (const key of ["sentry-trace", "baggage", "traceparent"]) {
|
|
1157
|
+
const value = traceData[key];
|
|
1158
|
+
if (typeof value === "string" && value.trim()) {
|
|
1159
|
+
headers[key] = value;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
return headers;
|
|
1163
|
+
}
|
|
1358
1164
|
function setSpanAttributes(attributes) {
|
|
1359
1165
|
const sentry = sentry_exports;
|
|
1360
1166
|
const span = sentry.getActiveSpan?.();
|
|
@@ -1534,301 +1340,15 @@ function extractGenAiUsageAttributes(...sources) {
|
|
|
1534
1340
|
};
|
|
1535
1341
|
}
|
|
1536
1342
|
|
|
1537
|
-
// src/
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
import path3 from "path";
|
|
1541
|
-
function isDirectory2(targetPath) {
|
|
1542
|
-
try {
|
|
1543
|
-
return statSync2(targetPath).isDirectory();
|
|
1544
|
-
} catch {
|
|
1545
|
-
return false;
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
function isFile2(targetPath) {
|
|
1549
|
-
try {
|
|
1550
|
-
return statSync2(targetPath).isFile();
|
|
1551
|
-
} catch {
|
|
1552
|
-
return false;
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
function uniqueResolvedPathsInOrder2(values) {
|
|
1556
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1557
|
-
const resolved = [];
|
|
1558
|
-
for (const value of values) {
|
|
1559
|
-
const normalized = path3.resolve(value);
|
|
1560
|
-
if (seen.has(normalized)) {
|
|
1561
|
-
continue;
|
|
1562
|
-
}
|
|
1563
|
-
seen.add(normalized);
|
|
1564
|
-
resolved.push(normalized);
|
|
1565
|
-
}
|
|
1566
|
-
return resolved;
|
|
1567
|
-
}
|
|
1568
|
-
function ancestorNodeModulesDirs(cwd) {
|
|
1569
|
-
const dirs = [];
|
|
1570
|
-
let current = path3.resolve(cwd);
|
|
1571
|
-
while (true) {
|
|
1572
|
-
const nodeModulesDir = path3.join(current, "node_modules");
|
|
1573
|
-
if (isDirectory2(nodeModulesDir)) {
|
|
1574
|
-
dirs.push(nodeModulesDir);
|
|
1575
|
-
}
|
|
1576
|
-
const parent = path3.dirname(current);
|
|
1577
|
-
if (parent === current) {
|
|
1578
|
-
break;
|
|
1579
|
-
}
|
|
1580
|
-
current = parent;
|
|
1581
|
-
}
|
|
1582
|
-
return dirs;
|
|
1583
|
-
}
|
|
1584
|
-
function packageDirInNodeModules(nodeModulesDir, packageName) {
|
|
1585
|
-
const packageDir = path3.join(nodeModulesDir, ...packageName.split("/"));
|
|
1586
|
-
return isDirectory2(packageDir) ? path3.resolve(packageDir) : void 0;
|
|
1587
|
-
}
|
|
1588
|
-
function isValidPackageSegment(segment) {
|
|
1589
|
-
return Boolean(segment) && segment !== "." && segment !== ".." && !segment.startsWith(".") && /^[A-Za-z0-9._~-]+$/.test(segment);
|
|
1590
|
-
}
|
|
1591
|
-
function isValidPackageName(packageName) {
|
|
1592
|
-
if (!packageName || packageName.includes("\\") || path3.isAbsolute(packageName)) {
|
|
1593
|
-
return false;
|
|
1594
|
-
}
|
|
1595
|
-
const parts = packageName.split("/");
|
|
1596
|
-
if (parts[0].startsWith("@")) {
|
|
1597
|
-
return parts.length === 2 && parts[0].length > 1 && isValidPackageSegment(parts[0].slice(1)) && isValidPackageSegment(parts[1]);
|
|
1598
|
-
}
|
|
1599
|
-
return parts.length === 1 && isValidPackageSegment(parts[0]);
|
|
1600
|
-
}
|
|
1601
|
-
function findPackageRoot(entryPath) {
|
|
1602
|
-
let dir = path3.dirname(entryPath);
|
|
1603
|
-
while (dir !== path3.dirname(dir)) {
|
|
1604
|
-
if (isFile2(path3.join(dir, "package.json"))) {
|
|
1605
|
-
return path3.resolve(dir);
|
|
1606
|
-
}
|
|
1607
|
-
dir = path3.dirname(dir);
|
|
1608
|
-
}
|
|
1609
|
-
return void 0;
|
|
1610
|
-
}
|
|
1611
|
-
function findPackageNodeModulesDir(packageDir, packageName) {
|
|
1612
|
-
const parts = path3.resolve(packageDir).split(path3.sep);
|
|
1613
|
-
const packageParts = packageName.split("/");
|
|
1614
|
-
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
1615
|
-
if (parts[index] !== "node_modules") {
|
|
1616
|
-
continue;
|
|
1617
|
-
}
|
|
1618
|
-
const candidatePackageParts = parts.slice(
|
|
1619
|
-
index + 1,
|
|
1620
|
-
index + 1 + packageParts.length
|
|
1621
|
-
);
|
|
1622
|
-
if (candidatePackageParts.join("/") !== packageParts.join("/")) {
|
|
1623
|
-
continue;
|
|
1624
|
-
}
|
|
1625
|
-
return path3.resolve(parts.slice(0, index + 1).join(path3.sep) || path3.sep);
|
|
1626
|
-
}
|
|
1627
|
-
return void 0;
|
|
1628
|
-
}
|
|
1629
|
-
function resolvePackageWithNode(cwd, packageName) {
|
|
1630
|
-
let requireFromCwd;
|
|
1631
|
-
try {
|
|
1632
|
-
requireFromCwd = createRequire(path3.join(cwd, "package.json"));
|
|
1633
|
-
} catch {
|
|
1634
|
-
return void 0;
|
|
1635
|
-
}
|
|
1636
|
-
for (const specifier of [`${packageName}/package.json`, packageName]) {
|
|
1637
|
-
try {
|
|
1638
|
-
const resolved = requireFromCwd.resolve(specifier);
|
|
1639
|
-
const dir = specifier.endsWith("/package.json") ? path3.dirname(resolved) : findPackageRoot(resolved);
|
|
1640
|
-
if (!dir) {
|
|
1641
|
-
continue;
|
|
1642
|
-
}
|
|
1643
|
-
const nodeModulesDir = findPackageNodeModulesDir(dir, packageName);
|
|
1644
|
-
return {
|
|
1645
|
-
dir,
|
|
1646
|
-
...nodeModulesDir ? { nodeModulesDir } : {}
|
|
1647
|
-
};
|
|
1648
|
-
} catch {
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
return void 0;
|
|
1652
|
-
}
|
|
1653
|
-
function resolvePackageLocation(cwd, packageName, options) {
|
|
1654
|
-
if (!isValidPackageName(packageName)) {
|
|
1655
|
-
return void 0;
|
|
1656
|
-
}
|
|
1657
|
-
const nodeModulesDirs = uniqueResolvedPathsInOrder2([
|
|
1658
|
-
...options?.nodeModulesDirs ?? [],
|
|
1659
|
-
...ancestorNodeModulesDirs(cwd)
|
|
1660
|
-
]);
|
|
1661
|
-
for (const nodeModulesDir of nodeModulesDirs) {
|
|
1662
|
-
const dir = packageDirInNodeModules(nodeModulesDir, packageName);
|
|
1663
|
-
if (dir) {
|
|
1664
|
-
return { dir, nodeModulesDir };
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
return resolvePackageWithNode(cwd, packageName);
|
|
1668
|
-
}
|
|
1669
|
-
function resolvePackageDir(cwd, packageName) {
|
|
1670
|
-
return resolvePackageLocation(cwd, packageName)?.dir;
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
// src/chat/plugins/package-discovery.ts
|
|
1674
|
-
import path4 from "path";
|
|
1675
|
-
function normalizeForGlob(targetPath) {
|
|
1676
|
-
return targetPath.split(path4.sep).join("/");
|
|
1677
|
-
}
|
|
1678
|
-
function uniqueStringsInOrder(values) {
|
|
1679
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1680
|
-
const resolved = [];
|
|
1681
|
-
for (const value of values) {
|
|
1682
|
-
if (seen.has(value)) {
|
|
1683
|
-
continue;
|
|
1684
|
-
}
|
|
1685
|
-
seen.add(value);
|
|
1686
|
-
resolved.push(value);
|
|
1687
|
-
}
|
|
1688
|
-
return resolved;
|
|
1689
|
-
}
|
|
1690
|
-
function pathForTracingInclude(cwd, targetPath) {
|
|
1691
|
-
const relative = path4.relative(cwd, targetPath);
|
|
1692
|
-
if (!relative || path4.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path4.sep}`)) {
|
|
1693
|
-
return null;
|
|
1694
|
-
}
|
|
1695
|
-
const normalized = normalizeForGlob(relative);
|
|
1696
|
-
return normalized.startsWith(".") ? normalized : `./${normalized}`;
|
|
1697
|
-
}
|
|
1698
|
-
function normalizePluginPackageNames(packageNames) {
|
|
1699
|
-
if (packageNames === void 0) {
|
|
1700
|
-
return [];
|
|
1701
|
-
}
|
|
1702
|
-
if (!Array.isArray(packageNames)) {
|
|
1703
|
-
throw new Error("Plugin package names must be an array");
|
|
1704
|
-
}
|
|
1705
|
-
const normalized = [];
|
|
1706
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1707
|
-
for (const packageName of packageNames) {
|
|
1708
|
-
const normalizedPackageName = typeof packageName === "string" ? packageName.trim() : "";
|
|
1709
|
-
if (!normalizedPackageName || !isValidPackageName(normalizedPackageName)) {
|
|
1710
|
-
throw new Error("Plugin package names must be valid npm package names");
|
|
1711
|
-
}
|
|
1712
|
-
if (seen.has(normalizedPackageName)) {
|
|
1713
|
-
continue;
|
|
1714
|
-
}
|
|
1715
|
-
seen.add(normalizedPackageName);
|
|
1716
|
-
normalized.push(normalizedPackageName);
|
|
1717
|
-
}
|
|
1718
|
-
return normalized;
|
|
1719
|
-
}
|
|
1720
|
-
function formatNodeModulesDirs(candidateNodeModulesDirs) {
|
|
1721
|
-
return candidateNodeModulesDirs.length > 0 ? candidateNodeModulesDirs.join(", ") : "none found";
|
|
1722
|
-
}
|
|
1723
|
-
function resolvePackageDirFromName(cwd, packageName, candidateNodeModulesDirs) {
|
|
1724
|
-
return resolvePackageLocation(cwd, packageName, {
|
|
1725
|
-
nodeModulesDirs: candidateNodeModulesDirs
|
|
1726
|
-
}) ?? null;
|
|
1727
|
-
}
|
|
1728
|
-
function readPluginPackageFlags(dir) {
|
|
1729
|
-
const hasRootPluginManifest = isFile(path4.join(dir, "plugin.yaml"));
|
|
1730
|
-
const hasPluginsDir = isDirectory(path4.join(dir, "plugins"));
|
|
1731
|
-
const hasSkillsDir = isDirectory(path4.join(dir, "skills"));
|
|
1732
|
-
if (!hasRootPluginManifest && !hasPluginsDir && !hasSkillsDir) {
|
|
1733
|
-
return null;
|
|
1734
|
-
}
|
|
1735
|
-
return {
|
|
1736
|
-
hasRootPluginManifest,
|
|
1737
|
-
hasPluginsDir,
|
|
1738
|
-
hasSkillsDir
|
|
1739
|
-
};
|
|
1740
|
-
}
|
|
1741
|
-
function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs, cwd) {
|
|
1742
|
-
const discovered = [];
|
|
1743
|
-
const seenPackageDirs = /* @__PURE__ */ new Set();
|
|
1744
|
-
for (const packageName of packageNames) {
|
|
1745
|
-
const resolved = resolvePackageDirFromName(
|
|
1746
|
-
cwd,
|
|
1747
|
-
packageName,
|
|
1748
|
-
candidateNodeModulesDirs
|
|
1749
|
-
);
|
|
1750
|
-
if (!resolved) {
|
|
1751
|
-
throw new Error(
|
|
1752
|
-
`Plugin package "${packageName}" was configured but could not be resolved from node_modules or package resolution (${formatNodeModulesDirs(candidateNodeModulesDirs)})`
|
|
1753
|
-
);
|
|
1754
|
-
}
|
|
1755
|
-
if (seenPackageDirs.has(resolved.dir)) {
|
|
1756
|
-
continue;
|
|
1757
|
-
}
|
|
1758
|
-
const pluginFlags = readPluginPackageFlags(resolved.dir);
|
|
1759
|
-
if (!pluginFlags) {
|
|
1760
|
-
throw new Error(
|
|
1761
|
-
`Plugin package "${packageName}" was configured but does not contain plugin content; expected plugin.yaml, plugins/, or skills/ in ${resolved.dir}`
|
|
1762
|
-
);
|
|
1763
|
-
}
|
|
1764
|
-
seenPackageDirs.add(resolved.dir);
|
|
1765
|
-
discovered.push({
|
|
1766
|
-
name: packageName,
|
|
1767
|
-
dir: resolved.dir,
|
|
1768
|
-
nodeModulesDir: resolved.nodeModulesDir,
|
|
1769
|
-
...pluginFlags
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
return discovered;
|
|
1343
|
+
// src/chat/slack/ids.ts
|
|
1344
|
+
function isSlackTeamId(value) {
|
|
1345
|
+
return /^T[A-Z0-9]+$/.test(value);
|
|
1773
1346
|
}
|
|
1774
|
-
function
|
|
1775
|
-
|
|
1776
|
-
const packageNames = normalizePluginPackageNames(options?.packageNames);
|
|
1777
|
-
const nodeModulesDirs = options?.nodeModulesDirs ?? discoverNodeModulesDirs(resolvedCwd);
|
|
1778
|
-
const discoveredPackages = discoverDeclaredPackages(
|
|
1779
|
-
packageNames,
|
|
1780
|
-
nodeModulesDirs,
|
|
1781
|
-
resolvedCwd
|
|
1782
|
-
);
|
|
1783
|
-
const manifestRoots = [];
|
|
1784
|
-
const skillRoots2 = [];
|
|
1785
|
-
const tracingIncludes = [];
|
|
1786
|
-
for (const pkg of discoveredPackages) {
|
|
1787
|
-
const tracingBasePath = pkg.nodeModulesDir ? pathForTracingInclude(
|
|
1788
|
-
resolvedCwd,
|
|
1789
|
-
path4.join(pkg.nodeModulesDir, ...pkg.name.split("/"))
|
|
1790
|
-
) : pathForTracingInclude(resolvedCwd, pkg.dir);
|
|
1791
|
-
if (pkg.hasRootPluginManifest) {
|
|
1792
|
-
manifestRoots.push(pkg.dir);
|
|
1793
|
-
if (tracingBasePath) {
|
|
1794
|
-
tracingIncludes.push(`${tracingBasePath}/plugin.yaml`);
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
if (pkg.hasPluginsDir) {
|
|
1798
|
-
manifestRoots.push(path4.join(pkg.dir, "plugins"));
|
|
1799
|
-
if (tracingBasePath) {
|
|
1800
|
-
tracingIncludes.push(`${tracingBasePath}/plugins/**/*`);
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
if (pkg.hasSkillsDir) {
|
|
1804
|
-
skillRoots2.push(path4.join(pkg.dir, "skills"));
|
|
1805
|
-
if (tracingBasePath) {
|
|
1806
|
-
tracingIncludes.push(`${tracingBasePath}/skills/**/*`);
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
return {
|
|
1811
|
-
packageNames: uniqueStringsInOrder(
|
|
1812
|
-
discoveredPackages.map((pkg) => pkg.name)
|
|
1813
|
-
),
|
|
1814
|
-
packages: discoveredPackages.map((pkg) => ({
|
|
1815
|
-
dir: pkg.dir,
|
|
1816
|
-
hasSkillsDir: pkg.hasSkillsDir,
|
|
1817
|
-
name: pkg.name
|
|
1818
|
-
})),
|
|
1819
|
-
manifestRoots: uniqueStringsInOrder(manifestRoots),
|
|
1820
|
-
skillRoots: uniqueStringsInOrder(skillRoots2),
|
|
1821
|
-
tracingIncludes: uniqueStringsInOrder(tracingIncludes)
|
|
1822
|
-
};
|
|
1347
|
+
function isSlackConversationId(value) {
|
|
1348
|
+
return /^(C|G|D)[A-Z0-9]+$/.test(value);
|
|
1823
1349
|
}
|
|
1824
1350
|
|
|
1825
1351
|
export {
|
|
1826
|
-
homeDir,
|
|
1827
|
-
skillRoots,
|
|
1828
|
-
pluginRoots,
|
|
1829
|
-
soulPathCandidates,
|
|
1830
|
-
worldPathCandidates,
|
|
1831
|
-
listReferenceFiles,
|
|
1832
1352
|
toOptionalString,
|
|
1833
1353
|
toOptionalNumber,
|
|
1834
1354
|
isRecord,
|
|
@@ -1844,6 +1364,7 @@ export {
|
|
|
1844
1364
|
createRequestContext,
|
|
1845
1365
|
withContext,
|
|
1846
1366
|
withSpan,
|
|
1367
|
+
getTracePropagationHeaders,
|
|
1847
1368
|
setSpanAttributes,
|
|
1848
1369
|
setSpanStatus,
|
|
1849
1370
|
getActiveTraceId,
|
|
@@ -1851,8 +1372,6 @@ export {
|
|
|
1851
1372
|
serializeGenAiAttribute,
|
|
1852
1373
|
extractGenAiUsageSummary,
|
|
1853
1374
|
extractGenAiUsageAttributes,
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
normalizePluginPackageNames,
|
|
1857
|
-
discoverInstalledPluginPackageContent
|
|
1375
|
+
isSlackTeamId,
|
|
1376
|
+
isSlackConversationId
|
|
1858
1377
|
};
|