@sentry/junior 0.74.1 → 0.76.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 +1 -1
- package/bin/junior.mjs +4 -66
- package/dist/agent-hooks-ZOE7RIED.js +37 -0
- package/dist/api-reference.d.ts +3 -1
- package/dist/app.js +5516 -5422
- package/dist/build/copy-build-content.d.ts +1 -1
- package/dist/build/virtual-config.d.ts +2 -2
- package/dist/chat/agent-dispatch/context.d.ts +2 -3
- package/dist/chat/agent-dispatch/runner.d.ts +2 -0
- package/dist/chat/agent-dispatch/types.d.ts +2 -1
- package/dist/chat/config.d.ts +3 -0
- package/dist/chat/credentials/state-adapter-token-store.d.ts +2 -0
- package/dist/chat/credentials/subject.d.ts +3 -3
- package/dist/chat/credentials/user-token-store.d.ts +17 -12
- package/dist/chat/db.d.ts +8 -0
- package/dist/chat/mcp/auth-store.d.ts +2 -1
- package/dist/chat/mcp/oauth.d.ts +2 -1
- package/dist/chat/oauth-flow.d.ts +3 -1
- package/dist/chat/pi/client.d.ts +15 -7
- package/dist/chat/plugins/agent-hooks.d.ts +20 -13
- package/dist/chat/plugins/auth/oauth-request.d.ts +11 -7
- package/dist/chat/plugins/credential-hooks.d.ts +6 -6
- package/dist/chat/plugins/logging.d.ts +2 -2
- package/dist/chat/plugins/model.d.ts +9 -0
- package/dist/chat/plugins/package-discovery.d.ts +2 -1
- package/dist/chat/plugins/prompt.d.ts +5 -0
- package/dist/chat/plugins/registry.d.ts +4 -0
- package/dist/chat/plugins/state.d.ts +3 -5
- package/dist/chat/plugins/task-callback.d.ts +5 -0
- package/dist/chat/plugins/task-message.d.ts +23 -0
- package/dist/chat/plugins/task-queue.d.ts +5 -0
- package/dist/chat/plugins/task-runner.d.ts +12 -0
- package/dist/chat/plugins/task-signing.d.ts +31 -0
- package/dist/chat/plugins/types.d.ts +1 -0
- package/dist/chat/plugins/validation.d.ts +5 -0
- package/dist/chat/prompt.d.ts +15 -1
- package/dist/chat/requester.d.ts +6 -5
- package/dist/chat/respond-helpers.d.ts +2 -0
- package/dist/chat/respond.d.ts +13 -2
- package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
- package/dist/chat/runtime/reply-executor.d.ts +5 -1
- package/dist/chat/runtime/slack-resume.d.ts +10 -2
- package/dist/chat/runtime/slack-runtime.d.ts +6 -1
- package/dist/chat/sandbox/egress-credentials.d.ts +8 -8
- package/dist/chat/sandbox/sandbox.d.ts +2 -2
- package/dist/chat/sentry.d.ts +1 -0
- package/dist/chat/services/mcp-auth-orchestration.d.ts +2 -1
- package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -1
- package/dist/chat/services/subscribed-decision.d.ts +2 -2
- package/dist/chat/services/turn-session-record.d.ts +11 -7
- package/dist/chat/sql/db.d.ts +3 -0
- package/dist/chat/sql/executor.d.ts +7 -0
- package/dist/chat/sql/neon.d.ts +2 -4
- package/dist/chat/sql/postgres.d.ts +6 -0
- package/dist/chat/state/turn-session.d.ts +8 -5
- package/dist/chat/task-execution/state.d.ts +7 -2
- package/dist/chat/task-execution/worker.d.ts +1 -1
- package/dist/chat/tools/agent-tools.d.ts +9 -2
- package/dist/chat/tools/slack/context.d.ts +2 -2
- package/dist/chat/tools/types.d.ts +7 -4
- package/dist/chat/vercel-queue-client.d.ts +3 -0
- package/dist/{chunk-YOHFWWBV.js → chunk-2ECJXSVQ.js} +5 -107
- package/dist/{chunk-OR6NQJ5E.js → chunk-4SCWV7TJ.js} +3 -3
- package/dist/chunk-4UO6FK4G.js +64 -0
- package/dist/chunk-56TBVRJG.js +115 -0
- package/dist/{chunk-3BYAPS6B.js → chunk-EJN6G5A2.js} +17 -11
- package/dist/{chunk-SQGMG7OD.js → chunk-HHDUKWVG.js} +508 -149
- package/dist/{chunk-6UP2Z2RZ.js → chunk-JBASI5VV.js} +7 -7
- package/dist/chunk-KNFROR7R.js +127 -0
- package/dist/{chunk-HYHKTFG2.js → chunk-KOIMO7S3.js} +186 -910
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-NFTMTIP3.js +964 -0
- package/dist/chunk-NYKJ3KON.js +1082 -0
- package/dist/{chunk-SJHUF3DP.js → chunk-OJ53FYVG.js} +2 -10
- package/dist/{chunk-KVZL5NZS.js → chunk-Q3XNY442.js} +17 -7
- package/dist/{chunk-YRDS7VKO.js → chunk-Q6XFTRV5.js} +2 -2
- package/dist/chunk-R6Z5XWY3.js +1076 -0
- package/dist/chunk-RV5RYIJW.js +56 -0
- package/dist/chunk-SG5WAA7H.js +132 -0
- package/dist/chunk-ST6YNAXG.js +54 -0
- package/dist/{chunk-GM7HTXYC.js → chunk-T77LUIX3.js} +148 -151
- package/dist/{chunk-CYUI7JU5.js → chunk-VALUBQ7R.js} +22 -30
- package/dist/chunk-XBBC6W45.js +71 -0
- package/dist/chunk-Y2CM7HXH.js +111 -0
- package/dist/{chunk-F6HWCPOC.js → chunk-Y5OFBCBZ.js} +1 -1
- package/dist/{chunk-M4FLLXXD.js → chunk-Z4CIQ3EB.js} +5 -1
- package/dist/{chunk-7Q5YOUUT.js → chunk-ZLMBNBUG.js} +146 -52
- package/dist/{chunk-2LUZA3LY.js → chunk-ZQB37HUX.js} +11 -11
- package/dist/cli/chat.js +87 -8
- package/dist/cli/check.js +8 -7
- package/dist/cli/env.js +4 -53
- package/dist/cli/init.js +6 -1
- package/dist/cli/main.js +84 -0
- package/dist/cli/plugins.js +244 -0
- package/dist/cli/run.js +5 -52
- package/dist/cli/snapshot-warmup.js +12 -11
- package/dist/cli/upgrade.js +385 -26
- package/dist/db-7A7PFRGL.js +17 -0
- package/dist/deployment.d.ts +1 -0
- package/dist/handlers/sandbox-egress-route.d.ts +4 -0
- package/dist/handlers/slack-webhook.d.ts +4 -0
- package/dist/handlers/webhooks.d.ts +6 -13
- package/dist/instrumentation.js +14 -18
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +67 -101
- package/dist/plugin-module.d.ts +21 -0
- package/dist/plugins-PZMDS7AT.js +15 -0
- package/dist/plugins.d.ts +9 -5
- package/dist/registry-OIPAJU2O.js +46 -0
- package/dist/reporting/conversations.d.ts +3 -3
- package/dist/reporting.d.ts +6 -5
- package/dist/reporting.js +42 -28
- package/dist/{runner-27NP2TEO.js → runner-KPLNHDCV.js} +77 -19
- package/dist/sentry-4CP5NNQ5.js +31 -0
- package/dist/validation-SLA6IGF7.js +15 -0
- package/dist/vercel.js +1 -1
- package/package.json +14 -11
- package/dist/chat/conversations/configured.d.ts +0 -5
- package/dist/chat/conversations/state.d.ts +0 -4
- package/dist/chunk-2KG3PWR4.js +0 -17
- package/dist/chunk-JL2SLRAT.js +0 -1970
package/dist/instrumentation.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDeploymentServiceVersion,
|
|
3
|
-
getDeploymentTelemetryAttributes
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
getDeploymentTelemetryAttributes
|
|
4
|
+
} from "./chunk-OJ53FYVG.js";
|
|
5
|
+
import {
|
|
6
|
+
getClient,
|
|
7
|
+
getGlobalScope,
|
|
8
|
+
init,
|
|
9
|
+
vercelAIIntegration
|
|
10
|
+
} from "./chunk-ST6YNAXG.js";
|
|
11
|
+
import "./chunk-MLKGABMK.js";
|
|
7
12
|
|
|
8
13
|
// src/instrumentation.ts
|
|
9
14
|
function getSampleRate(value, fallback) {
|
|
@@ -19,40 +24,31 @@ function getBoolean(value, fallback) {
|
|
|
19
24
|
return fallback;
|
|
20
25
|
}
|
|
21
26
|
function initSentry() {
|
|
22
|
-
if (
|
|
27
|
+
if (getClient()) {
|
|
23
28
|
return;
|
|
24
29
|
}
|
|
25
30
|
const dsn = process.env.SENTRY_DSN;
|
|
26
31
|
const enableLogs = getBoolean(process.env.SENTRY_ENABLE_LOGS, Boolean(dsn));
|
|
27
32
|
const serviceVersion = getDeploymentServiceVersion();
|
|
28
33
|
const deploymentSpanAttributes = getDeploymentTelemetryAttributes();
|
|
29
|
-
|
|
34
|
+
init({
|
|
30
35
|
dsn,
|
|
31
36
|
environment: process.env.SENTRY_ENVIRONMENT ?? process.env.VERCEL_ENV ?? process.env.NODE_ENV,
|
|
32
37
|
release: serviceVersion,
|
|
33
38
|
tracesSampleRate: getSampleRate(process.env.SENTRY_TRACES_SAMPLE_RATE, 1),
|
|
39
|
+
traceLifecycle: "stream",
|
|
34
40
|
sendDefaultPii: true,
|
|
35
41
|
enableLogs,
|
|
36
42
|
registerEsmLoaderHooks: false,
|
|
37
43
|
streamGenAiSpans: true,
|
|
38
|
-
// Keep deployment identity centralized so every emitted Sentry span carries it.
|
|
39
|
-
beforeSendSpan(span) {
|
|
40
|
-
if (Object.keys(deploymentSpanAttributes).length === 0) {
|
|
41
|
-
return span;
|
|
42
|
-
}
|
|
43
|
-
span.data = {
|
|
44
|
-
...span.data,
|
|
45
|
-
...deploymentSpanAttributes
|
|
46
|
-
};
|
|
47
|
-
return span;
|
|
48
|
-
},
|
|
49
44
|
integrations: [
|
|
50
|
-
|
|
45
|
+
vercelAIIntegration({
|
|
51
46
|
recordInputs: true,
|
|
52
47
|
recordOutputs: true
|
|
53
48
|
})
|
|
54
49
|
]
|
|
55
50
|
});
|
|
51
|
+
getGlobalScope().setAttributes(deploymentSpanAttributes);
|
|
56
52
|
}
|
|
57
53
|
export {
|
|
58
54
|
initSentry
|
package/dist/nitro.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface JuniorNitroOptions {
|
|
|
11
11
|
maxDuration?: number;
|
|
12
12
|
/** Vercel Queue topic for durable conversation work. Must match the runtime queue producer topic. */
|
|
13
13
|
conversationWorkQueueTopic?: string;
|
|
14
|
-
/** Plugin catalog set or runtime-safe plugin module. Direct sets must not include runtime
|
|
14
|
+
/** Plugin catalog set or runtime-safe plugin module. Direct sets must not include runtime code. */
|
|
15
15
|
plugins?: JuniorNitroPluginSource;
|
|
16
16
|
/**
|
|
17
17
|
* Extra file patterns to copy into the server output for files that the
|
package/dist/nitro.js
CHANGED
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
pluginCatalogConfigFromPluginSet,
|
|
3
|
-
pluginHookRegistrationsFromPluginSet,
|
|
4
2
|
resolveConversationWorkQueueTopic
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
3
|
+
} from "./chunk-2ECJXSVQ.js";
|
|
4
|
+
import {
|
|
5
|
+
PLUGIN_TASK_QUEUE_TOPIC
|
|
6
|
+
} from "./chunk-KNFROR7R.js";
|
|
7
|
+
import {
|
|
8
|
+
pluginCatalogConfigFromPluginSet,
|
|
9
|
+
pluginRuntimeRegistrationsFromPluginSet
|
|
10
|
+
} from "./chunk-SG5WAA7H.js";
|
|
11
|
+
import "./chunk-Q6XFTRV5.js";
|
|
12
|
+
import "./chunk-T77LUIX3.js";
|
|
13
|
+
import {
|
|
14
|
+
loadPluginSetFromModule,
|
|
15
|
+
resolvePluginModule
|
|
16
|
+
} from "./chunk-Y2CM7HXH.js";
|
|
7
17
|
import {
|
|
8
18
|
discoverInstalledPluginPackageContent,
|
|
9
19
|
isValidPackageName,
|
|
10
20
|
resolvePackageDir
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-3BYAPS6B.js";
|
|
21
|
+
} from "./chunk-Q3XNY442.js";
|
|
22
|
+
import "./chunk-EJN6G5A2.js";
|
|
14
23
|
import {
|
|
15
24
|
JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
|
|
16
25
|
JUNIOR_HEARTBEAT_CRON_SCHEDULE,
|
|
17
|
-
JUNIOR_HEARTBEAT_ROUTE
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
JUNIOR_HEARTBEAT_ROUTE,
|
|
27
|
+
JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE
|
|
28
|
+
} from "./chunk-OJ53FYVG.js";
|
|
29
|
+
import "./chunk-ST6YNAXG.js";
|
|
30
|
+
import "./chunk-MLKGABMK.js";
|
|
20
31
|
|
|
21
32
|
// src/nitro.ts
|
|
22
33
|
import path2 from "path";
|
|
23
|
-
import { statSync as statSync2 } from "fs";
|
|
24
|
-
import { createRequire } from "module";
|
|
25
|
-
import { pathToFileURL } from "url";
|
|
26
34
|
|
|
27
35
|
// src/build/rolldown-workarounds.ts
|
|
28
36
|
function applyRolldownTreeshakeWorkaround(nitro) {
|
|
@@ -65,6 +73,15 @@ function copyAppAndPluginContent(cwd, serverRoot, packageNames) {
|
|
|
65
73
|
for (const root of packagedContent.skillRoots) {
|
|
66
74
|
copyRootIntoServerOutput(cwd, serverRoot, root);
|
|
67
75
|
}
|
|
76
|
+
for (const pkg of packagedContent.packages) {
|
|
77
|
+
if (pkg.hasMigrationsDir) {
|
|
78
|
+
copyRootIntoServerOutput(
|
|
79
|
+
cwd,
|
|
80
|
+
serverRoot,
|
|
81
|
+
path.join(pkg.dir, "migrations")
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
68
85
|
}
|
|
69
86
|
function copyIncludedFiles(cwd, serverRoot, patterns) {
|
|
70
87
|
if (patterns === void 0) return;
|
|
@@ -195,7 +212,7 @@ function renderVirtualConfig(options) {
|
|
|
195
212
|
"export const pluginSet = juniorRuntimePluginSet;"
|
|
196
213
|
] : ["export const pluginSet = undefined;"],
|
|
197
214
|
`export const plugins = ${JSON.stringify(options.plugins ?? { packages: [] })};`,
|
|
198
|
-
`export const
|
|
215
|
+
`export const pluginRuntimeRegistrations = ${JSON.stringify(options.pluginRuntimeRegistrations ?? [])};`
|
|
199
216
|
];
|
|
200
217
|
return lines.join("\n");
|
|
201
218
|
}
|
|
@@ -208,9 +225,9 @@ function injectVirtualConfig(nitro, options = {}) {
|
|
|
208
225
|
return renderVirtualConfig({
|
|
209
226
|
pluginModule: options.pluginModule,
|
|
210
227
|
plugins: pluginCatalogConfigFromPluginSet(pluginSet),
|
|
211
|
-
|
|
228
|
+
pluginRuntimeRegistrations: pluginRuntimeRegistrationsFromPluginSet(
|
|
212
229
|
pluginSet
|
|
213
|
-
).map((plugin) => plugin.name)
|
|
230
|
+
).map((plugin) => plugin.manifest.name)
|
|
214
231
|
});
|
|
215
232
|
};
|
|
216
233
|
}
|
|
@@ -218,15 +235,6 @@ function injectVirtualConfig(nitro, options = {}) {
|
|
|
218
235
|
// src/nitro.ts
|
|
219
236
|
var DEFAULT_FUNCTION_MAX_DURATION_SECONDS = 300;
|
|
220
237
|
var VERCEL_QUEUE_TRIGGER_TYPE = "queue/v2beta";
|
|
221
|
-
var PLUGIN_MODULE_EXTENSIONS = [
|
|
222
|
-
"",
|
|
223
|
-
".ts",
|
|
224
|
-
".tsx",
|
|
225
|
-
".mts",
|
|
226
|
-
".mjs",
|
|
227
|
-
".js",
|
|
228
|
-
".cjs"
|
|
229
|
-
];
|
|
230
238
|
function isPluginModuleReference(value) {
|
|
231
239
|
return typeof value === "string" || Boolean(value && "module" in value);
|
|
232
240
|
}
|
|
@@ -236,83 +244,23 @@ function isPluginSet(value) {
|
|
|
236
244
|
}
|
|
237
245
|
return "packageNames" in value && "registrations" in value;
|
|
238
246
|
}
|
|
239
|
-
function resolveRelativePluginModule(cwd, specifier) {
|
|
240
|
-
const basePath = path2.resolve(cwd, specifier);
|
|
241
|
-
for (const extension of PLUGIN_MODULE_EXTENSIONS) {
|
|
242
|
-
const candidate = `${basePath}${extension}`;
|
|
243
|
-
try {
|
|
244
|
-
if (statSync2(candidate).isFile()) {
|
|
245
|
-
return candidate;
|
|
246
|
-
}
|
|
247
|
-
} catch {
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
for (const extension of PLUGIN_MODULE_EXTENSIONS) {
|
|
251
|
-
const candidate = path2.join(basePath, `index${extension}`);
|
|
252
|
-
try {
|
|
253
|
-
if (statSync2(candidate).isFile()) {
|
|
254
|
-
return candidate;
|
|
255
|
-
}
|
|
256
|
-
} catch {
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
throw new Error(`Plugin module "${specifier}" could not be resolved`);
|
|
260
|
-
}
|
|
261
|
-
function resolvePluginModule(cwd, input) {
|
|
262
|
-
const moduleSpecifier = typeof input === "string" ? input : input.module;
|
|
263
|
-
const exportName = typeof input === "string" ? "plugins" : input.exportName ?? "plugins";
|
|
264
|
-
if (!moduleSpecifier.trim()) {
|
|
265
|
-
throw new Error("Plugin module specifier must not be empty");
|
|
266
|
-
}
|
|
267
|
-
if (moduleSpecifier.startsWith(".") || path2.isAbsolute(moduleSpecifier)) {
|
|
268
|
-
const resolvedPath2 = resolveRelativePluginModule(cwd, moduleSpecifier);
|
|
269
|
-
return {
|
|
270
|
-
exportName,
|
|
271
|
-
importUrl: pathToFileURL(resolvedPath2).href,
|
|
272
|
-
runtimeModule: {
|
|
273
|
-
exportName,
|
|
274
|
-
specifier: resolvedPath2.split(path2.sep).join("/")
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
const requireFromApp = createRequire(path2.join(cwd, "package.json"));
|
|
279
|
-
const resolvedPath = requireFromApp.resolve(moduleSpecifier);
|
|
280
|
-
return {
|
|
281
|
-
exportName,
|
|
282
|
-
importUrl: pathToFileURL(resolvedPath).href,
|
|
283
|
-
runtimeModule: {
|
|
284
|
-
exportName,
|
|
285
|
-
specifier: moduleSpecifier
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
function assertPluginSet(value, source) {
|
|
290
|
-
if (!value || typeof value !== "object" || !Array.isArray(value.packageNames) || !Array.isArray(value.registrations)) {
|
|
291
|
-
throw new Error(
|
|
292
|
-
`Plugin module ${source} must export a defineJuniorPlugins(...) set`
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
return value;
|
|
296
|
-
}
|
|
297
|
-
async function loadPluginSetFromModule(moduleRef) {
|
|
298
|
-
const mod = await import(moduleRef.importUrl);
|
|
299
|
-
const value = moduleRef.exportName === "default" ? mod.default : mod[moduleRef.exportName];
|
|
300
|
-
return assertPluginSet(
|
|
301
|
-
value,
|
|
302
|
-
`${moduleRef.importUrl}#${moduleRef.exportName}`
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
247
|
function assertSerializableDirectPluginSet(pluginSet) {
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
);
|
|
309
|
-
if (
|
|
248
|
+
const pluginRuntimeNames = pluginRuntimeRegistrationsFromPluginSet(
|
|
249
|
+
pluginSet
|
|
250
|
+
).map((plugin) => plugin.manifest.name);
|
|
251
|
+
if (pluginRuntimeNames.length === 0) {
|
|
310
252
|
return;
|
|
311
253
|
}
|
|
312
254
|
throw new Error(
|
|
313
|
-
`juniorNitro({ plugins }) cannot receive a direct defineJuniorPlugins(...) set with runtime
|
|
255
|
+
`juniorNitro({ plugins }) cannot receive a direct defineJuniorPlugins(...) set with runtime plugin registration(s): ${pluginRuntimeNames.join(", ")}. Export the set from a runtime-safe plugin module and pass juniorNitro({ plugins: "./plugins" }) so createApp() can import the same registrations at runtime.`
|
|
314
256
|
);
|
|
315
257
|
}
|
|
258
|
+
function runtimeModuleForResolvedPluginModule(moduleRef) {
|
|
259
|
+
return {
|
|
260
|
+
exportName: moduleRef.exportName,
|
|
261
|
+
specifier: moduleRef.kind === "file" ? moduleRef.importPath.split(path2.sep).join("/") : moduleRef.sourceSpecifier
|
|
262
|
+
};
|
|
263
|
+
}
|
|
316
264
|
function bundleOpenTelemetryLoaderHooks(nitro) {
|
|
317
265
|
const existing = Array.isArray(nitro.options.noExternals) ? nitro.options.noExternals : [];
|
|
318
266
|
const additions = ["import-in-the-middle", "require-in-the-middle"].filter(
|
|
@@ -358,6 +306,24 @@ function configureVercelDeployment(nitro, options) {
|
|
|
358
306
|
}
|
|
359
307
|
]
|
|
360
308
|
};
|
|
309
|
+
const existingPluginTaskRule = nitro.options.vercel.functionRules[JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE] ?? {};
|
|
310
|
+
const existingPluginTaskTriggers = Array.isArray(
|
|
311
|
+
existingPluginTaskRule.experimentalTriggers
|
|
312
|
+
) ? existingPluginTaskRule.experimentalTriggers : [];
|
|
313
|
+
const otherPluginTaskTriggers = existingPluginTaskTriggers.filter(
|
|
314
|
+
(trigger) => trigger.type !== VERCEL_QUEUE_TRIGGER_TYPE
|
|
315
|
+
);
|
|
316
|
+
nitro.options.vercel.functionRules[JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE] = {
|
|
317
|
+
maxDuration: callbackMaxDuration,
|
|
318
|
+
...existingPluginTaskRule,
|
|
319
|
+
experimentalTriggers: [
|
|
320
|
+
...otherPluginTaskTriggers,
|
|
321
|
+
{
|
|
322
|
+
type: VERCEL_QUEUE_TRIGGER_TYPE,
|
|
323
|
+
topic: PLUGIN_TASK_QUEUE_TOPIC
|
|
324
|
+
}
|
|
325
|
+
]
|
|
326
|
+
};
|
|
361
327
|
}
|
|
362
328
|
function juniorNitro(options = {}) {
|
|
363
329
|
return {
|
|
@@ -381,16 +347,16 @@ function juniorNitro(options = {}) {
|
|
|
381
347
|
return pluginSetPromise;
|
|
382
348
|
};
|
|
383
349
|
const pluginCatalogConfig = pluginCatalogConfigFromPluginSet(directPluginSet);
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
)
|
|
350
|
+
const pluginRuntimeRegistrations = pluginRuntimeRegistrationsFromPluginSet(directPluginSet).map(
|
|
351
|
+
(plugin) => plugin.manifest.name
|
|
352
|
+
);
|
|
387
353
|
injectVirtualConfig(nitro, {
|
|
388
354
|
...pluginModule ? {
|
|
389
355
|
loadPluginSet: loadConfiguredPluginSet,
|
|
390
|
-
pluginModule: pluginModule
|
|
356
|
+
pluginModule: runtimeModuleForResolvedPluginModule(pluginModule)
|
|
391
357
|
} : {},
|
|
392
358
|
plugins: pluginCatalogConfig,
|
|
393
|
-
|
|
359
|
+
pluginRuntimeRegistrations
|
|
394
360
|
});
|
|
395
361
|
const copyBuildContent = async () => {
|
|
396
362
|
const pluginSet = await loadConfiguredPluginSet();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JuniorPluginSet } from "./plugins";
|
|
2
|
+
interface JuniorPluginModuleReference {
|
|
3
|
+
/** Runtime-safe module that exports a `defineJuniorPlugins(...)` set. */
|
|
4
|
+
module: string;
|
|
5
|
+
/** Named export to import from `module`. Defaults to `plugins`. */
|
|
6
|
+
exportName?: string;
|
|
7
|
+
}
|
|
8
|
+
interface ResolvedPluginModuleReference {
|
|
9
|
+
exportName: string;
|
|
10
|
+
importPath: string;
|
|
11
|
+
importUrl: string;
|
|
12
|
+
kind: "file" | "package";
|
|
13
|
+
sourceSpecifier: string;
|
|
14
|
+
}
|
|
15
|
+
/** Resolve the runtime-safe plugin module used by Junior app wiring. */
|
|
16
|
+
export declare function resolvePluginModule(cwd: string, input: JuniorPluginModuleReference | string): ResolvedPluginModuleReference;
|
|
17
|
+
/** Load a resolved plugin module and return its configured plugin set. */
|
|
18
|
+
export declare function loadPluginSetFromModule(moduleRef: ResolvedPluginModuleReference, importModule?: (moduleRef: ResolvedPluginModuleReference) => Promise<Record<string, unknown>>): Promise<JuniorPluginSet>;
|
|
19
|
+
/** Load an app-local `./plugins` module when one exists. */
|
|
20
|
+
export declare function loadAppPluginSet(cwd: string, importModule?: (moduleRef: ResolvedPluginModuleReference) => Promise<Record<string, unknown>>): Promise<JuniorPluginSet | undefined>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineJuniorPlugins,
|
|
3
|
+
pluginCatalogConfigFromEnv,
|
|
4
|
+
pluginCatalogConfigFromPluginSet,
|
|
5
|
+
pluginCliRegistrationsFromPluginSet,
|
|
6
|
+
pluginRuntimeRegistrationsFromPluginSet
|
|
7
|
+
} from "./chunk-SG5WAA7H.js";
|
|
8
|
+
import "./chunk-MLKGABMK.js";
|
|
9
|
+
export {
|
|
10
|
+
defineJuniorPlugins,
|
|
11
|
+
pluginCatalogConfigFromEnv,
|
|
12
|
+
pluginCatalogConfigFromPluginSet,
|
|
13
|
+
pluginCliRegistrationsFromPluginSet,
|
|
14
|
+
pluginRuntimeRegistrationsFromPluginSet
|
|
15
|
+
};
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginRegistration } from "@sentry/junior-plugin-api";
|
|
2
2
|
import type { PluginCatalogConfig, PluginManifestConfig } from "./chat/plugins/types";
|
|
3
|
-
export type JuniorPluginInput =
|
|
3
|
+
export type JuniorPluginInput = PluginRegistration | string;
|
|
4
4
|
export interface JuniorPluginSetOptions {
|
|
5
5
|
/** Install-level manifest overrides applied before validation. */
|
|
6
6
|
manifests?: Record<string, PluginManifestConfig>;
|
|
@@ -12,11 +12,15 @@ export interface JuniorPluginSet {
|
|
|
12
12
|
/** Manifest-only plugin packages included by package name. */
|
|
13
13
|
packageNames: string[];
|
|
14
14
|
/** JavaScript plugin definitions included by package factories. */
|
|
15
|
-
registrations:
|
|
15
|
+
registrations: PluginRegistration[];
|
|
16
16
|
}
|
|
17
17
|
/** Define package-name plugins and JS plugin definitions for one app. */
|
|
18
18
|
export declare function defineJuniorPlugins(inputs: JuniorPluginInput[], options?: JuniorPluginSetOptions): JuniorPluginSet;
|
|
19
19
|
/** Build the manifest catalog config implied by one plugin set. */
|
|
20
20
|
export declare function pluginCatalogConfigFromPluginSet(pluginSet: JuniorPluginSet | undefined): PluginCatalogConfig | undefined;
|
|
21
|
-
/**
|
|
22
|
-
export declare function
|
|
21
|
+
/** Build the manifest catalog config implied by plugin package env. */
|
|
22
|
+
export declare function pluginCatalogConfigFromEnv(env?: NodeJS.ProcessEnv): PluginCatalogConfig | undefined;
|
|
23
|
+
/** Return registrations that expose in-process runtime code. */
|
|
24
|
+
export declare function pluginRuntimeRegistrationsFromPluginSet(pluginSet: JuniorPluginSet | undefined): PluginRegistration[];
|
|
25
|
+
/** Return registrations that expose host CLI commands. */
|
|
26
|
+
export declare function pluginCliRegistrationsFromPluginSet(pluginSet: JuniorPluginSet | undefined): PluginRegistration[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPluginBroker,
|
|
3
|
+
getPluginCapabilityProviders,
|
|
4
|
+
getPluginCatalogSignature,
|
|
5
|
+
getPluginDefinition,
|
|
6
|
+
getPluginDisplayName,
|
|
7
|
+
getPluginForSkillPath,
|
|
8
|
+
getPluginMcpProviders,
|
|
9
|
+
getPluginMigrationRoots,
|
|
10
|
+
getPluginOAuthConfig,
|
|
11
|
+
getPluginPackageContent,
|
|
12
|
+
getPluginProviders,
|
|
13
|
+
getPluginRuntimeDependencies,
|
|
14
|
+
getPluginRuntimePostinstall,
|
|
15
|
+
getPluginSkillRoots,
|
|
16
|
+
isPluginCapability,
|
|
17
|
+
isPluginConfigKey,
|
|
18
|
+
isPluginProvider,
|
|
19
|
+
setPluginCatalogConfig
|
|
20
|
+
} from "./chunk-ZLMBNBUG.js";
|
|
21
|
+
import "./chunk-VALUBQ7R.js";
|
|
22
|
+
import "./chunk-Q3XNY442.js";
|
|
23
|
+
import "./chunk-EJN6G5A2.js";
|
|
24
|
+
import "./chunk-OJ53FYVG.js";
|
|
25
|
+
import "./chunk-ST6YNAXG.js";
|
|
26
|
+
import "./chunk-MLKGABMK.js";
|
|
27
|
+
export {
|
|
28
|
+
createPluginBroker,
|
|
29
|
+
getPluginCapabilityProviders,
|
|
30
|
+
getPluginCatalogSignature,
|
|
31
|
+
getPluginDefinition,
|
|
32
|
+
getPluginDisplayName,
|
|
33
|
+
getPluginForSkillPath,
|
|
34
|
+
getPluginMcpProviders,
|
|
35
|
+
getPluginMigrationRoots,
|
|
36
|
+
getPluginOAuthConfig,
|
|
37
|
+
getPluginPackageContent,
|
|
38
|
+
getPluginProviders,
|
|
39
|
+
getPluginRuntimeDependencies,
|
|
40
|
+
getPluginRuntimePostinstall,
|
|
41
|
+
getPluginSkillRoots,
|
|
42
|
+
isPluginCapability,
|
|
43
|
+
isPluginConfigKey,
|
|
44
|
+
isPluginProvider,
|
|
45
|
+
setPluginCatalogConfig
|
|
46
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginConversationStatus, PluginConversations, PluginConversationSummary } from "@sentry/junior-plugin-api";
|
|
2
2
|
import type { ConversationStore } from "@/chat/conversations/store";
|
|
3
|
-
export type {
|
|
3
|
+
export type { PluginConversationStatus, PluginConversations, PluginConversationSummary, };
|
|
4
4
|
interface ConversationReaderOptions {
|
|
5
5
|
conversationStore?: ConversationStore;
|
|
6
6
|
}
|
|
@@ -121,6 +121,6 @@ export declare function readConversationStatsReport(options?: ConversationReader
|
|
|
121
121
|
/** List recent conversation summaries for plugin operational reports. */
|
|
122
122
|
export declare function listRecentConversationSummaries(options?: {
|
|
123
123
|
limit?: number;
|
|
124
|
-
} & ConversationReaderOptions): Promise<
|
|
124
|
+
} & ConversationReaderOptions): Promise<PluginConversationSummary[]>;
|
|
125
125
|
/** Read one conversation transcript for reporting consumers. */
|
|
126
126
|
export declare function readConversationReport(conversationId: string, options?: ConversationReaderOptions): Promise<ConversationReport>;
|
package/dist/reporting.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginOperationalReport } from "@sentry/junior-plugin-api";
|
|
2
|
-
import { type ConversationFeed, type
|
|
3
|
-
export type {
|
|
2
|
+
import { type ConversationFeed, type PluginConversationSummary, type ConversationReport, type ConversationStatsReport } from "./reporting/conversations";
|
|
3
|
+
export type { PluginConversationStatus, PluginConversations, PluginConversationSummary, ConversationFeed, ConversationReport, ConversationReportStatus, ConversationRunReport, ConversationStatsItem, ConversationStatsReport, ConversationSummaryReport, ConversationSurface, ConversationUsage, RequesterIdentity, TranscriptMessage, TranscriptPart, TranscriptPartType, TranscriptRole, } from "./reporting/conversations";
|
|
4
4
|
export interface HealthReport {
|
|
5
5
|
status: "ok";
|
|
6
6
|
service: string;
|
|
@@ -23,8 +23,9 @@ export interface RuntimeInfoReport {
|
|
|
23
23
|
}
|
|
24
24
|
export interface PluginPackageContentItemReport {
|
|
25
25
|
dir: string;
|
|
26
|
+
hasMigrationsDir: boolean;
|
|
26
27
|
hasSkillsDir: boolean;
|
|
27
|
-
|
|
28
|
+
packageName: string;
|
|
28
29
|
}
|
|
29
30
|
export interface PluginPackageContentReport {
|
|
30
31
|
packageNames: string[];
|
|
@@ -55,7 +56,7 @@ export interface JuniorReporting {
|
|
|
55
56
|
/** Read recent conversation summaries without transcript payloads. */
|
|
56
57
|
listRecentConversations?(options?: {
|
|
57
58
|
limit?: number;
|
|
58
|
-
}): Promise<
|
|
59
|
+
}): Promise<PluginConversationSummary[]>;
|
|
59
60
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
60
61
|
getPluginOperationalReports?(): Promise<PluginOperationalReportFeed>;
|
|
61
62
|
/**
|
|
@@ -72,6 +73,6 @@ export declare function createJuniorReporting(): JuniorReporting & {
|
|
|
72
73
|
getConversationStats(): Promise<ConversationStatsReport>;
|
|
73
74
|
listRecentConversations(options?: {
|
|
74
75
|
limit?: number;
|
|
75
|
-
}): Promise<
|
|
76
|
+
}): Promise<PluginConversationSummary[]>;
|
|
76
77
|
getPluginOperationalReports(): Promise<PluginOperationalReportFeed>;
|
|
77
78
|
};
|
package/dist/reporting.js
CHANGED
|
@@ -6,39 +6,46 @@ import {
|
|
|
6
6
|
getConversationDetails,
|
|
7
7
|
getConversationDetailsForIds,
|
|
8
8
|
resolveSlackConversationContextFromThreadId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZQB37HUX.js";
|
|
10
10
|
import {
|
|
11
11
|
buildSystemPrompt,
|
|
12
|
-
getAgentPluginOperationalReports,
|
|
13
12
|
getAgentTurnSessionRecord,
|
|
14
|
-
getConfiguredConversationStore,
|
|
15
13
|
listAgentTurnSessionSummariesForConversation
|
|
16
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-KOIMO7S3.js";
|
|
17
15
|
import {
|
|
18
|
-
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import
|
|
16
|
+
getPluginOperationalReports
|
|
17
|
+
} from "./chunk-NFTMTIP3.js";
|
|
18
|
+
import "./chunk-56TBVRJG.js";
|
|
19
|
+
import {
|
|
20
|
+
getConversationStore
|
|
21
|
+
} from "./chunk-NYKJ3KON.js";
|
|
22
22
|
import "./chunk-G3E7SCME.js";
|
|
23
|
+
import "./chunk-Y5OFBCBZ.js";
|
|
24
|
+
import "./chunk-Q6XFTRV5.js";
|
|
25
|
+
import {
|
|
26
|
+
canExposeConversationPayload,
|
|
27
|
+
parseSlackThreadId,
|
|
28
|
+
resolveConversationPrivacy
|
|
29
|
+
} from "./chunk-T77LUIX3.js";
|
|
30
|
+
import {
|
|
31
|
+
discoverSkills
|
|
32
|
+
} from "./chunk-4SCWV7TJ.js";
|
|
23
33
|
import {
|
|
24
34
|
getPluginPackageContent,
|
|
25
35
|
getPluginProviders
|
|
26
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ZLMBNBUG.js";
|
|
27
37
|
import {
|
|
28
|
-
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-F6HWCPOC.js";
|
|
38
|
+
toStoredSlackRequester
|
|
39
|
+
} from "./chunk-VALUBQ7R.js";
|
|
31
40
|
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
resolveConversationPrivacy
|
|
35
|
-
} from "./chunk-GM7HTXYC.js";
|
|
36
|
-
import "./chunk-CYUI7JU5.js";
|
|
41
|
+
homeDir
|
|
42
|
+
} from "./chunk-Q3XNY442.js";
|
|
37
43
|
import {
|
|
38
44
|
isRecord
|
|
39
|
-
} from "./chunk-
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import "./chunk-
|
|
45
|
+
} from "./chunk-EJN6G5A2.js";
|
|
46
|
+
import "./chunk-OJ53FYVG.js";
|
|
47
|
+
import "./chunk-ST6YNAXG.js";
|
|
48
|
+
import "./chunk-MLKGABMK.js";
|
|
42
49
|
|
|
43
50
|
// src/reporting.ts
|
|
44
51
|
import { readFileSync } from "fs";
|
|
@@ -52,7 +59,7 @@ var CONVERSATION_FEED_LIMIT = 50;
|
|
|
52
59
|
var CONVERSATION_STATS_LIMIT = 5e3;
|
|
53
60
|
var RECENT_CONVERSATION_STATS_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
54
61
|
function conversationStore(options = {}) {
|
|
55
|
-
return options.conversationStore ??
|
|
62
|
+
return options.conversationStore ?? getConversationStore();
|
|
56
63
|
}
|
|
57
64
|
function statusFromCheckpoint(summary, nowMs = Date.now()) {
|
|
58
65
|
const state = summary.state;
|
|
@@ -92,6 +99,9 @@ function requesterIdentityReport(requester) {
|
|
|
92
99
|
};
|
|
93
100
|
return Object.keys(identity).length > 0 ? identity : void 0;
|
|
94
101
|
}
|
|
102
|
+
function sessionRequesterIdentityReport(requester) {
|
|
103
|
+
return requester?.platform === "slack" ? requesterIdentityReport(toStoredSlackRequester(requester)) : void 0;
|
|
104
|
+
}
|
|
95
105
|
function usageReport(usage) {
|
|
96
106
|
if (!usage) return void 0;
|
|
97
107
|
const report = {
|
|
@@ -120,12 +130,11 @@ function sessionReportFromSummary(summary, nowMs = Date.now(), details) {
|
|
|
120
130
|
channel: slackThread?.channelId,
|
|
121
131
|
channelName: effectiveChannelName
|
|
122
132
|
}) ?? surfaceFallbackLabel(effectiveSurface);
|
|
123
|
-
const
|
|
133
|
+
const requesterIdentity = requesterIdentityReport(details?.originRequester) ?? sessionRequesterIdentityReport(summary.requester);
|
|
124
134
|
const sentryConversationUrl = buildSentryConversationUrl(
|
|
125
135
|
summary.conversationId
|
|
126
136
|
);
|
|
127
137
|
const sentryTraceUrl = summary.traceId ? buildSentryTraceUrl(summary.traceId) : void 0;
|
|
128
|
-
const requesterIdentity = requesterIdentityReport(effectiveRequester);
|
|
129
138
|
const cumulativeUsage = usageReport(summary.cumulativeUsage);
|
|
130
139
|
return {
|
|
131
140
|
conversationId: summary.conversationId,
|
|
@@ -671,10 +680,15 @@ function isConversationMessage(message) {
|
|
|
671
680
|
function countConversationMessages(transcript) {
|
|
672
681
|
return transcript.filter(isConversationMessage).length;
|
|
673
682
|
}
|
|
674
|
-
function systemPromptMessage(
|
|
683
|
+
function systemPromptMessage(source) {
|
|
675
684
|
return {
|
|
676
685
|
role: "system",
|
|
677
|
-
parts: [
|
|
686
|
+
parts: [
|
|
687
|
+
{
|
|
688
|
+
type: "text",
|
|
689
|
+
text: buildSystemPrompt({ source })
|
|
690
|
+
}
|
|
691
|
+
]
|
|
678
692
|
};
|
|
679
693
|
}
|
|
680
694
|
function turnScopedMessages(messages, turnStartMessageIndex) {
|
|
@@ -875,7 +889,7 @@ async function readConversationReport(conversationId, options = {}) {
|
|
|
875
889
|
);
|
|
876
890
|
const transcriptMessageCount = countConversationMessages(normalizedTranscript);
|
|
877
891
|
const transcript = canExposeTranscript ? [
|
|
878
|
-
...scopedMessages.startsAtRunBoundary && normalizedTranscript.length > 0 && sessionRecord?.
|
|
892
|
+
...scopedMessages.startsAtRunBoundary && normalizedTranscript.length > 0 && sessionRecord?.source ? [systemPromptMessage(sessionRecord.source)] : [],
|
|
879
893
|
...normalizedTranscript
|
|
880
894
|
] : [];
|
|
881
895
|
const transcriptMetadata = canExposeTranscript ? void 0 : normalizedTranscript.map(redactTranscriptMessage);
|
|
@@ -951,7 +965,7 @@ async function readPlugins() {
|
|
|
951
965
|
}));
|
|
952
966
|
}
|
|
953
967
|
function createJuniorReporting() {
|
|
954
|
-
const conversationStore2 =
|
|
968
|
+
const conversationStore2 = getConversationStore();
|
|
955
969
|
const listRecent = (listOptions) => listRecentConversationSummaries({
|
|
956
970
|
...listOptions,
|
|
957
971
|
conversationStore: conversationStore2
|
|
@@ -982,7 +996,7 @@ function createJuniorReporting() {
|
|
|
982
996
|
return {
|
|
983
997
|
source: "plugins",
|
|
984
998
|
generatedAt: new Date(nowMs).toISOString(),
|
|
985
|
-
reports: await
|
|
999
|
+
reports: await getPluginOperationalReports(nowMs, {
|
|
986
1000
|
listRecent
|
|
987
1001
|
})
|
|
988
1002
|
};
|