@sentry/junior 0.63.0 → 0.65.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 +5 -1
- package/dist/api-reference.d.ts +2 -0
- package/dist/app.d.ts +5 -10
- package/dist/app.js +107 -54
- package/dist/build/virtual-config.d.ts +18 -2
- package/dist/chat/logging.d.ts +12 -2
- package/dist/chat/plugins/agent-hooks.d.ts +4 -4
- package/dist/chat/plugins/command-env.d.ts +1 -1
- package/dist/chat/plugins/inline-manifest-source.d.ts +5 -0
- package/dist/chat/plugins/manifest.d.ts +5 -3
- package/dist/chat/plugins/package-discovery.d.ts +5 -0
- package/dist/chat/plugins/registry.d.ts +2 -2
- package/dist/chat/plugins/types.d.ts +9 -3
- package/dist/chat/state/turn-session.d.ts +1 -1
- package/dist/chunk-5VDO6LSG.js +104 -0
- package/dist/{chunk-ITZ2F7UE.js → chunk-7KZXQNA6.js} +10 -22
- package/dist/{chunk-H652GMDH.js → chunk-EDHJIYHS.js} +323 -90
- package/dist/{chunk-LRVKJAR2.js → chunk-K3JNVV4Q.js} +2 -2
- package/dist/{chunk-5LUISFEY.js → chunk-KVZL5NZS.js} +6 -1
- package/dist/{chunk-PEF6UXTY.js → chunk-OMQ5X5QH.js} +1 -1
- package/dist/{chunk-ITOW4DED.js → chunk-PYU2YB35.js} +2 -2
- package/dist/cli/check.js +9 -4
- package/dist/cli/snapshot-warmup.js +4 -4
- package/dist/nitro.d.ts +10 -3
- package/dist/nitro.js +161 -6
- package/dist/plugins.d.ts +22 -0
- package/dist/reporting.d.ts +1 -1
- package/dist/reporting.js +20 -11
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -25,7 +25,11 @@ export default app;
|
|
|
25
25
|
|
|
26
26
|
Run `junior init my-bot` to scaffold a complete project including `vercel.json` for Vercel deployment.
|
|
27
27
|
|
|
28
|
-
Use `
|
|
28
|
+
Use `defineJuniorPlugins([...])` in a runtime-safe plugin module, then point
|
|
29
|
+
`juniorNitro({ plugins: "./plugins" })` at that module. `createApp()` reads the
|
|
30
|
+
same enabled set from Nitro's virtual module. Manifest-only packages use
|
|
31
|
+
package-name strings; trusted factories such as `githubPlugin()` register their
|
|
32
|
+
manifest and in-process hooks together.
|
|
29
33
|
|
|
30
34
|
## Full docs
|
|
31
35
|
|
package/dist/api-reference.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export type { JuniorAppOptions } from "./app";
|
|
|
3
3
|
export { initSentry } from "./instrumentation";
|
|
4
4
|
export { juniorNitro } from "./nitro";
|
|
5
5
|
export type { JuniorNitroOptions } from "./nitro";
|
|
6
|
+
export { defineJuniorPlugins } from "./plugins";
|
|
7
|
+
export type { JuniorPluginInput, JuniorPluginSet, JuniorPluginSetOptions, } from "./plugins";
|
|
6
8
|
export { juniorVercelConfig } from "./vercel";
|
|
7
9
|
export type { JuniorVercelConfigOptions } from "./vercel";
|
package/dist/app.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import type
|
|
3
|
-
import type { JuniorPlugin } from "@sentry/junior-plugin-api";
|
|
2
|
+
import { type JuniorPluginSet } from "@/plugins";
|
|
4
3
|
import type { WaitUntilFn } from "@/handlers/types";
|
|
4
|
+
export { defineJuniorPlugins } from "@/plugins";
|
|
5
|
+
export type { JuniorPluginInput, JuniorPluginSet, JuniorPluginSetOptions, } from "@/plugins";
|
|
5
6
|
export interface JuniorAppOptions {
|
|
6
7
|
/** Install-wide provider defaults (`provider.key` format). Channel overrides take precedence. */
|
|
7
8
|
configDefaults?: Record<string, unknown>;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
* Use `PluginConfig` for declarative package lists and manifest overrides.
|
|
12
|
-
* Use `JuniorPlugin[]` for trusted plugin factories such as `githubPlugin()`;
|
|
13
|
-
* their package config is merged with the catalog bundled by `juniorNitro()`.
|
|
14
|
-
*/
|
|
15
|
-
plugins?: PluginConfig | JuniorPlugin[];
|
|
9
|
+
/** Direct plugin set override. Usually omitted when `juniorNitro()` uses a plugin module. */
|
|
10
|
+
plugins?: JuniorPluginSet;
|
|
16
11
|
waitUntil?: WaitUntilFn;
|
|
17
12
|
}
|
|
18
13
|
/** Create a Hono app with all Junior routes. */
|
package/dist/app.js
CHANGED
|
@@ -22,13 +22,13 @@ import {
|
|
|
22
22
|
splitSlackReplyText,
|
|
23
23
|
truncateStatusText,
|
|
24
24
|
upsertAgentTurnSessionRecord
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-7KZXQNA6.js";
|
|
26
26
|
import {
|
|
27
27
|
discoverSkills,
|
|
28
28
|
findSkillByName,
|
|
29
29
|
loadSkillsByName,
|
|
30
30
|
parseSkillInvocation
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-PYU2YB35.js";
|
|
32
32
|
import {
|
|
33
33
|
buildNonInteractiveShellScript,
|
|
34
34
|
createSandboxInstance,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
isSnapshotMissingError,
|
|
38
38
|
resolveRuntimeDependencySnapshot,
|
|
39
39
|
runNonInteractiveCommand
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-K3JNVV4Q.js";
|
|
41
41
|
import {
|
|
42
42
|
ACTIVE_LOCK_TTL_MS,
|
|
43
43
|
GEN_AI_PROVIDER_NAME,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
toGenAiPayloadMetadata,
|
|
71
71
|
toGenAiPayloadTraceAttributes,
|
|
72
72
|
toGenAiTextMetadata
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-OMQ5X5QH.js";
|
|
74
74
|
import {
|
|
75
75
|
CredentialUnavailableError,
|
|
76
76
|
buildOAuthTokenRequest,
|
|
@@ -101,7 +101,8 @@ import {
|
|
|
101
101
|
resolveAuthTokenPlaceholder,
|
|
102
102
|
resolvePluginCommandEnv,
|
|
103
103
|
serializeGenAiAttribute,
|
|
104
|
-
|
|
104
|
+
setPluginCatalogConfig,
|
|
105
|
+
setSentryUser,
|
|
105
106
|
setSpanAttributes,
|
|
106
107
|
setSpanStatus,
|
|
107
108
|
setTags,
|
|
@@ -109,14 +110,19 @@ import {
|
|
|
109
110
|
toOptionalString,
|
|
110
111
|
withContext,
|
|
111
112
|
withSpan
|
|
112
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-EDHJIYHS.js";
|
|
113
114
|
import {
|
|
114
115
|
sentry_exports
|
|
115
116
|
} from "./chunk-Z3YD6NHK.js";
|
|
117
|
+
import {
|
|
118
|
+
defineJuniorPlugins,
|
|
119
|
+
pluginCatalogConfigFromPluginSet,
|
|
120
|
+
trustedPluginRegistrationsFromPluginSet
|
|
121
|
+
} from "./chunk-5VDO6LSG.js";
|
|
116
122
|
import {
|
|
117
123
|
homeDir,
|
|
118
124
|
listReferenceFiles
|
|
119
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-KVZL5NZS.js";
|
|
120
126
|
import "./chunk-2KG3PWR4.js";
|
|
121
127
|
|
|
122
128
|
// src/app.ts
|
|
@@ -298,7 +304,7 @@ var AGENT_PLUGIN_ROUTE_METHODS = /* @__PURE__ */ new Set([
|
|
|
298
304
|
"ALL"
|
|
299
305
|
]);
|
|
300
306
|
function validateLegacyStatePrefixes(plugin) {
|
|
301
|
-
const prefixes = plugin.
|
|
307
|
+
const prefixes = plugin.legacyStatePrefixes;
|
|
302
308
|
if (prefixes === void 0) {
|
|
303
309
|
return;
|
|
304
310
|
}
|
|
@@ -367,7 +373,7 @@ function getAgentPluginTools(context) {
|
|
|
367
373
|
threadTs: context.threadTs,
|
|
368
374
|
userText: context.userText,
|
|
369
375
|
state: createPluginState(plugin.name, {
|
|
370
|
-
legacyStatePrefixes: plugin.
|
|
376
|
+
legacyStatePrefixes: plugin.legacyStatePrefixes
|
|
371
377
|
})
|
|
372
378
|
});
|
|
373
379
|
for (const [name, tool2] of Object.entries(pluginTools)) {
|
|
@@ -10703,6 +10709,8 @@ Note: No file was attached in this turn. I need to attach the file before claimi
|
|
|
10703
10709
|
// src/chat/services/turn-result.ts
|
|
10704
10710
|
var POST_CANVAS_REPLY_MAX_CHARS = 700;
|
|
10705
10711
|
var POST_CANVAS_REPLY_MAX_LINES = 8;
|
|
10712
|
+
var THINKING_XML_BLOCK_PATTERN = /[ \t]*<thinking\b[^>]*>[\s\S]*?<\/thinking>[ \t]*(?:\r?\n)?/gi;
|
|
10713
|
+
var FENCED_CODE_BLOCK_PATTERN = /```[\s\S]*?```/g;
|
|
10706
10714
|
function isVerbosePostCanvasReply(text) {
|
|
10707
10715
|
const lines = text.split(/\r?\n/).filter((line) => line.trim().length > 0);
|
|
10708
10716
|
return text.length > POST_CANVAS_REPLY_MAX_CHARS || lines.length > POST_CANVAS_REPLY_MAX_LINES;
|
|
@@ -10717,6 +10725,21 @@ function buildBriefPostCanvasReply(artifactStatePatch) {
|
|
|
10717
10725
|
const canvasUrl = getCreatedCanvasUrl(artifactStatePatch);
|
|
10718
10726
|
return canvasUrl ? `I created a canvas with the full reference: ${canvasUrl}` : "I created a canvas with the full reference.";
|
|
10719
10727
|
}
|
|
10728
|
+
function stripThinkingXmlBlocks(text) {
|
|
10729
|
+
let result = "";
|
|
10730
|
+
let cursor = 0;
|
|
10731
|
+
for (const match of text.matchAll(FENCED_CODE_BLOCK_PATTERN)) {
|
|
10732
|
+
const start = match.index;
|
|
10733
|
+
if (start === void 0) {
|
|
10734
|
+
continue;
|
|
10735
|
+
}
|
|
10736
|
+
result += text.slice(cursor, start).replace(THINKING_XML_BLOCK_PATTERN, "");
|
|
10737
|
+
result += match[0];
|
|
10738
|
+
cursor = start + match[0].length;
|
|
10739
|
+
}
|
|
10740
|
+
result += text.slice(cursor).replace(THINKING_XML_BLOCK_PATTERN, "");
|
|
10741
|
+
return result;
|
|
10742
|
+
}
|
|
10720
10743
|
function buildTurnResult(input) {
|
|
10721
10744
|
const {
|
|
10722
10745
|
newMessages,
|
|
@@ -10737,7 +10760,9 @@ function buildTurnResult(input) {
|
|
|
10737
10760
|
const toolResults = newMessages.filter(isToolResultMessage);
|
|
10738
10761
|
const assistantMessages = newMessages.filter(isAssistantMessage);
|
|
10739
10762
|
const terminalAssistantMessages = getTerminalAssistantMessages(newMessages);
|
|
10740
|
-
const primaryText =
|
|
10763
|
+
const primaryText = stripThinkingXmlBlocks(
|
|
10764
|
+
terminalAssistantMessages.map((message) => extractAssistantText(message)).join("\n\n")
|
|
10765
|
+
).trim();
|
|
10741
10766
|
const toolErrorCount = toolResults.filter((result) => result.isError).length;
|
|
10742
10767
|
const explicitChannelPostIntent = isExplicitChannelPostIntent(userInput);
|
|
10743
10768
|
const successfulToolNames = new Set(
|
|
@@ -14449,7 +14474,7 @@ async function runTrustedPluginHeartbeats(args) {
|
|
|
14449
14474
|
Promise.resolve(
|
|
14450
14475
|
heartbeat(
|
|
14451
14476
|
createHeartbeatContext({
|
|
14452
|
-
legacyStatePrefixes: plugin.
|
|
14477
|
+
legacyStatePrefixes: plugin.legacyStatePrefixes,
|
|
14453
14478
|
plugin: plugin.name,
|
|
14454
14479
|
nowMs: args.nowMs
|
|
14455
14480
|
})
|
|
@@ -19559,6 +19584,13 @@ function createReplyToThread(deps) {
|
|
|
19559
19584
|
conversation: preparedState.conversation
|
|
19560
19585
|
});
|
|
19561
19586
|
const resolvedUserName = message.author.userName ?? fallbackIdentity?.userName;
|
|
19587
|
+
if (message.author.userId) {
|
|
19588
|
+
setSentryUser({
|
|
19589
|
+
id: message.author.userId,
|
|
19590
|
+
...resolvedUserName ? { username: resolvedUserName } : {},
|
|
19591
|
+
...fallbackIdentity?.email ? { email: fallbackIdentity.email } : {}
|
|
19592
|
+
});
|
|
19593
|
+
}
|
|
19562
19594
|
if (resolvedUserName) {
|
|
19563
19595
|
setTags({ slackUserName: resolvedUserName });
|
|
19564
19596
|
}
|
|
@@ -21135,10 +21167,14 @@ async function defaultWaitUntil() {
|
|
|
21135
21167
|
};
|
|
21136
21168
|
}
|
|
21137
21169
|
}
|
|
21138
|
-
async function
|
|
21170
|
+
async function resolveVirtualConfig() {
|
|
21139
21171
|
try {
|
|
21140
21172
|
const mod = await import("#junior/config");
|
|
21141
|
-
return
|
|
21173
|
+
return {
|
|
21174
|
+
pluginSet: mod.pluginSet,
|
|
21175
|
+
plugins: mod.plugins,
|
|
21176
|
+
trustedPluginRegistrations: mod.trustedPluginRegistrations ?? []
|
|
21177
|
+
};
|
|
21142
21178
|
} catch (error) {
|
|
21143
21179
|
if (!isMissingVirtualConfig(error)) {
|
|
21144
21180
|
throw error;
|
|
@@ -21146,11 +21182,7 @@ async function resolveVirtualPluginConfig() {
|
|
|
21146
21182
|
return void 0;
|
|
21147
21183
|
}
|
|
21148
21184
|
}
|
|
21149
|
-
|
|
21150
|
-
const virtualConfig = await resolveVirtualPluginConfig();
|
|
21151
|
-
if (virtualConfig) {
|
|
21152
|
-
return virtualConfig;
|
|
21153
|
-
}
|
|
21185
|
+
function resolveEnvPluginCatalogConfig() {
|
|
21154
21186
|
const packages = readEnvPluginPackages();
|
|
21155
21187
|
if (packages) {
|
|
21156
21188
|
return { packages };
|
|
@@ -21189,38 +21221,55 @@ function hasConfiguredPluginCatalog(config) {
|
|
|
21189
21221
|
return false;
|
|
21190
21222
|
}
|
|
21191
21223
|
return Boolean(
|
|
21192
|
-
config.packages?.length || Object.keys(config.manifests ?? {}).length
|
|
21224
|
+
config.inlineManifests?.length || config.packages?.length || Object.keys(config.manifests ?? {}).length
|
|
21193
21225
|
);
|
|
21194
21226
|
}
|
|
21195
|
-
function
|
|
21196
|
-
return
|
|
21227
|
+
function pluginPackageNames(config) {
|
|
21228
|
+
return config?.packages ?? [];
|
|
21197
21229
|
}
|
|
21198
|
-
function
|
|
21199
|
-
if (!
|
|
21200
|
-
|
|
21201
|
-
|
|
21202
|
-
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
|
|
21206
|
-
|
|
21207
|
-
|
|
21208
|
-
|
|
21209
|
-
|
|
21230
|
+
function validateBuildIncludesPluginPackages(pluginConfig, virtualConfig) {
|
|
21231
|
+
if (!virtualConfig?.plugins) {
|
|
21232
|
+
return;
|
|
21233
|
+
}
|
|
21234
|
+
const bundled = new Set(pluginPackageNames(virtualConfig.plugins));
|
|
21235
|
+
const missing = pluginPackageNames(pluginConfig).filter(
|
|
21236
|
+
(packageName) => !bundled.has(packageName)
|
|
21237
|
+
);
|
|
21238
|
+
if (missing.length === 0) {
|
|
21239
|
+
return;
|
|
21240
|
+
}
|
|
21241
|
+
throw new Error(
|
|
21242
|
+
`createApp() registered plugin package(s) not bundled by juniorNitro(): ${missing.join(", ")}. Point juniorNitro({ plugins: "./plugins" }) at the runtime plugin module or pass the same defineJuniorPlugins(...) set to juniorNitro({ plugins }) and createApp({ plugins }).`
|
|
21243
|
+
);
|
|
21210
21244
|
}
|
|
21211
|
-
function
|
|
21212
|
-
const
|
|
21213
|
-
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
21245
|
+
function validateBuildIncludesTrustedRegistrations(trustedRegistrations, virtualConfig) {
|
|
21246
|
+
const bundledTrustedRegistrations = virtualConfig?.trustedPluginRegistrations ?? [];
|
|
21247
|
+
if (bundledTrustedRegistrations.length === 0) {
|
|
21248
|
+
return;
|
|
21249
|
+
}
|
|
21250
|
+
const registered = new Set(trustedRegistrations.map((plugin) => plugin.name));
|
|
21251
|
+
const missing = bundledTrustedRegistrations.filter(
|
|
21252
|
+
(pluginName) => !registered.has(pluginName)
|
|
21253
|
+
);
|
|
21254
|
+
if (missing.length === 0) {
|
|
21255
|
+
return;
|
|
21256
|
+
}
|
|
21257
|
+
throw new Error(
|
|
21258
|
+
`createApp() is missing trusted plugin registration(s) bundled by juniorNitro(): ${missing.join(", ")}. Pass a runtime-safe plugin module to juniorNitro({ plugins: "./plugins" }) or pass the same defineJuniorPlugins(...) set to createApp({ plugins }).`
|
|
21259
|
+
);
|
|
21218
21260
|
}
|
|
21219
|
-
|
|
21220
|
-
|
|
21221
|
-
|
|
21261
|
+
function validatePluginRegistrations(registrations) {
|
|
21262
|
+
const loadedPlugins = getPluginProviders();
|
|
21263
|
+
const loadedNames = new Set(
|
|
21264
|
+
loadedPlugins.map((plugin) => plugin.manifest.name)
|
|
21265
|
+
);
|
|
21266
|
+
for (const registration of registrations) {
|
|
21267
|
+
if (!loadedNames.has(registration.name)) {
|
|
21268
|
+
throw new Error(
|
|
21269
|
+
`Plugin registration "${registration.name}" does not have a matching plugin manifest. Add an inline manifest, packageName, or app-local plugin.yaml with the same name.`
|
|
21270
|
+
);
|
|
21271
|
+
}
|
|
21222
21272
|
}
|
|
21223
|
-
return resolveBuildPluginConfig();
|
|
21224
21273
|
}
|
|
21225
21274
|
function mountAgentPluginRoutes(app, routes) {
|
|
21226
21275
|
for (const route of routes) {
|
|
@@ -21237,15 +21286,17 @@ function mountAgentPluginRoutes(app, routes) {
|
|
|
21237
21286
|
}
|
|
21238
21287
|
}
|
|
21239
21288
|
async function createApp(options) {
|
|
21240
|
-
const
|
|
21241
|
-
const
|
|
21242
|
-
const
|
|
21243
|
-
|
|
21244
|
-
|
|
21245
|
-
|
|
21289
|
+
const virtualConfig = await resolveVirtualConfig();
|
|
21290
|
+
const configuredPlugins = options?.plugins ?? virtualConfig?.pluginSet;
|
|
21291
|
+
const agentPlugins2 = trustedPluginRegistrationsFromPluginSet(configuredPlugins);
|
|
21292
|
+
const pluginConfig = configuredPlugins ? pluginCatalogConfigFromPluginSet(configuredPlugins) : virtualConfig?.plugins ?? resolveEnvPluginCatalogConfig();
|
|
21293
|
+
if (configuredPlugins) {
|
|
21294
|
+
validateBuildIncludesPluginPackages(pluginConfig, virtualConfig);
|
|
21295
|
+
}
|
|
21296
|
+
validateBuildIncludesTrustedRegistrations(agentPlugins2, virtualConfig);
|
|
21246
21297
|
validateAgentPlugins(agentPlugins2);
|
|
21247
|
-
const shouldValidatePluginCatalog = hasConfiguredPluginCatalog(pluginConfig) || Boolean(Object.keys(options?.configDefaults ?? {}).length);
|
|
21248
|
-
const
|
|
21298
|
+
const shouldValidatePluginCatalog = hasConfiguredPluginCatalog(pluginConfig) || Boolean(configuredPlugins?.registrations.length) || Boolean(Object.keys(options?.configDefaults ?? {}).length);
|
|
21299
|
+
const previousPluginCatalogConfig = setPluginCatalogConfig(pluginConfig);
|
|
21249
21300
|
const previousAgentPlugins = setAgentPlugins(agentPlugins2);
|
|
21250
21301
|
const previousConfigDefaults = getConfigDefaults();
|
|
21251
21302
|
let agentPluginRoutes = [];
|
|
@@ -21253,10 +21304,11 @@ async function createApp(options) {
|
|
|
21253
21304
|
setConfigDefaults(options?.configDefaults);
|
|
21254
21305
|
if (shouldValidatePluginCatalog) {
|
|
21255
21306
|
getPluginCatalogSignature();
|
|
21307
|
+
validatePluginRegistrations(configuredPlugins?.registrations ?? []);
|
|
21256
21308
|
}
|
|
21257
21309
|
agentPluginRoutes = getAgentPluginRoutes();
|
|
21258
21310
|
} catch (error) {
|
|
21259
|
-
|
|
21311
|
+
setPluginCatalogConfig(previousPluginCatalogConfig);
|
|
21260
21312
|
setAgentPlugins(previousAgentPlugins);
|
|
21261
21313
|
setConfigDefaults(previousConfigDefaults);
|
|
21262
21314
|
throw error;
|
|
@@ -21297,5 +21349,6 @@ async function createApp(options) {
|
|
|
21297
21349
|
return app;
|
|
21298
21350
|
}
|
|
21299
21351
|
export {
|
|
21300
|
-
createApp
|
|
21352
|
+
createApp,
|
|
21353
|
+
defineJuniorPlugins
|
|
21301
21354
|
};
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type { Nitro } from "nitro/types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PluginCatalogConfig } from "@/chat/plugins/types";
|
|
3
|
+
import { type JuniorPluginSet } from "@/plugins";
|
|
4
|
+
export interface RuntimePluginModule {
|
|
5
|
+
exportName: string;
|
|
6
|
+
specifier: string;
|
|
7
|
+
}
|
|
8
|
+
/** Render the virtual config module consumed by createApp(). */
|
|
9
|
+
export declare function renderVirtualConfig(options: {
|
|
10
|
+
plugins?: PluginCatalogConfig;
|
|
11
|
+
pluginModule?: RuntimePluginModule;
|
|
12
|
+
trustedPluginRegistrations?: string[];
|
|
13
|
+
}): string;
|
|
3
14
|
/** Inject a virtual module so createApp() can read the plugin list at runtime. */
|
|
4
|
-
export declare function injectVirtualConfig(nitro: Nitro,
|
|
15
|
+
export declare function injectVirtualConfig(nitro: Nitro, options?: {
|
|
16
|
+
loadPluginSet?: () => Promise<JuniorPluginSet | undefined>;
|
|
17
|
+
pluginModule?: RuntimePluginModule;
|
|
18
|
+
plugins?: PluginCatalogConfig;
|
|
19
|
+
trustedPluginRegistrations?: string[];
|
|
20
|
+
}): void;
|
package/dist/chat/logging.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface LogContext {
|
|
|
18
18
|
slackThreadId?: string;
|
|
19
19
|
slackUserId?: string;
|
|
20
20
|
slackUserName?: string;
|
|
21
|
+
slackUserEmail?: string;
|
|
21
22
|
slackChannelId?: string;
|
|
22
23
|
runId?: string;
|
|
23
24
|
actorType?: string;
|
|
@@ -30,6 +31,11 @@ export interface LogContext {
|
|
|
30
31
|
urlFull?: string;
|
|
31
32
|
userAgent?: string;
|
|
32
33
|
}
|
|
34
|
+
interface SentryUserIdentity {
|
|
35
|
+
id: string | number;
|
|
36
|
+
email?: string;
|
|
37
|
+
username?: string;
|
|
38
|
+
}
|
|
33
39
|
/** Normalize runtime finish reasons to the telemetry spelling we emit. */
|
|
34
40
|
export declare function normalizeGenAiFinishReason(reason: string): string;
|
|
35
41
|
export declare const log: {
|
|
@@ -37,7 +43,7 @@ export declare const log: {
|
|
|
37
43
|
info(eventName: string, attrs?: Record<string, unknown>, body?: string): void;
|
|
38
44
|
warn(eventName: string, attrs?: Record<string, unknown>, body?: string): void;
|
|
39
45
|
error(eventName: string, attrs?: Record<string, unknown>, body?: string): void;
|
|
40
|
-
exception(eventName: string, error: unknown, attrs?: Record<string, unknown>, body?: string): string | undefined;
|
|
46
|
+
exception(eventName: string, error: unknown, attrs?: Record<string, unknown>, body?: string, context?: LogContext): string | undefined;
|
|
41
47
|
};
|
|
42
48
|
/** Create a Chat SDK logger that routes records through Junior's logging backend. */
|
|
43
49
|
export declare function createChatSdkLogger(): ChatSdkLogger;
|
|
@@ -47,7 +53,11 @@ export declare function getLogContextAttributes(): LogAttributes;
|
|
|
47
53
|
export declare function registerLogRecordSink(sink: (record: EmittedLogRecord) => void): () => void;
|
|
48
54
|
export declare function createLogContextFromRequest(request: Request, context?: Partial<LogContext>): LogContext;
|
|
49
55
|
export declare function toSpanAttributes(context: LogContext): Record<string, string>;
|
|
56
|
+
/** Attach filterable non-user context tags to Sentry. */
|
|
50
57
|
export declare function setSentryTagsFromContext(context: LogContext): void;
|
|
58
|
+
/** Bind requester identity to Sentry's native user fields. */
|
|
59
|
+
export declare function setSentryUser(identity: SentryUserIdentity | undefined): void;
|
|
60
|
+
/** Attach scoped Sentry context for isolated exception capture. */
|
|
51
61
|
export declare function setSentryScopeContext(scope: Sentry.Scope, context: LogContext): void;
|
|
52
62
|
/** Capture an error to Sentry and emit an error log record. */
|
|
53
63
|
export declare function captureException(error: unknown, context?: LogContext): void;
|
|
@@ -59,7 +69,7 @@ export declare function logWarn(eventName: string, context?: LogContext, attribu
|
|
|
59
69
|
export declare function logError(eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string): void;
|
|
60
70
|
/** Log an error with exception capture; returns the Sentry event ID if available. */
|
|
61
71
|
export declare function logException(error: unknown, eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string): string | undefined;
|
|
62
|
-
/** Set log context and Sentry
|
|
72
|
+
/** Set log context and Sentry scope metadata for the current request. */
|
|
63
73
|
export declare function setTags(context?: LogContext): void;
|
|
64
74
|
/** Create a LogContext from an incoming HTTP request. */
|
|
65
75
|
export declare function createRequestContext(request: Request, context?: Partial<LogContext>): LogContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentPluginRequester, AgentPluginRoute, SlackConversationLink,
|
|
1
|
+
import type { AgentPluginRequester, AgentPluginRoute, SlackConversationLink, JuniorPluginRegistration } from "@sentry/junior-plugin-api";
|
|
2
2
|
import type { ToolDefinition } from "@/chat/tools/definition";
|
|
3
3
|
import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
4
4
|
import type { SandboxInstance } from "@/chat/sandbox/workspace";
|
|
@@ -22,11 +22,11 @@ export interface AgentPluginHookRunner {
|
|
|
22
22
|
prepareSandbox(sandbox: SandboxInstance): Promise<void>;
|
|
23
23
|
}
|
|
24
24
|
/** Validate trusted plugin identity before it can affect process-wide hooks. */
|
|
25
|
-
export declare function validateAgentPlugins(plugins:
|
|
25
|
+
export declare function validateAgentPlugins(plugins: JuniorPluginRegistration[]): void;
|
|
26
26
|
/** Replace trusted agent plugins and return the previous list for rollback. */
|
|
27
|
-
export declare function setAgentPlugins(plugins:
|
|
27
|
+
export declare function setAgentPlugins(plugins: JuniorPluginRegistration[]): JuniorPluginRegistration[];
|
|
28
28
|
/** Return the current trusted agent plugins without exposing mutable state. */
|
|
29
|
-
export declare function getAgentPlugins():
|
|
29
|
+
export declare function getAgentPlugins(): JuniorPluginRegistration[];
|
|
30
30
|
/** Collect turn-scoped tools exposed by trusted plugins. */
|
|
31
31
|
export declare function getAgentPluginTools(context: ToolRuntimeContext): Record<string, ToolDefinition<any>>;
|
|
32
32
|
/** Collect route handlers exposed by trusted plugins for app-level mounting. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PluginManifest } from "@/chat/plugins/types";
|
|
2
|
-
/** Resolve
|
|
2
|
+
/** Resolve sandbox command env declared by a plugin manifest. */
|
|
3
3
|
export declare function resolvePluginCommandEnv(manifest: PluginManifest): Record<string, string>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PluginManifest } from "./types";
|
|
2
|
+
type ManifestSource = Record<string, unknown>;
|
|
3
|
+
/** Convert inline JavaScript plugin manifests to the canonical source shape. */
|
|
4
|
+
export declare function inlineManifestSource(manifest: PluginManifest): ManifestSource;
|
|
5
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/** Parse one plugin manifest after applying install-level plugin config. */
|
|
3
|
-
export declare function parsePluginManifest(raw: string, dir: string, config?:
|
|
1
|
+
import type { PluginCatalogConfig, PluginManifest } from "./types";
|
|
2
|
+
/** Parse one plugin.yaml manifest after applying install-level plugin config. */
|
|
3
|
+
export declare function parsePluginManifest(raw: string, dir: string, config?: PluginCatalogConfig): PluginManifest;
|
|
4
|
+
/** Parse one inline JavaScript manifest through the same effective manifest pipeline as plugin.yaml. */
|
|
5
|
+
export declare function parseInlinePluginManifest(manifest: PluginManifest, dir: string, config?: PluginCatalogConfig): PluginManifest;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { CapabilityProviderDefinition } from "@/chat/capabilities/catalog";
|
|
2
2
|
import type { CredentialBroker } from "@/chat/credentials/broker";
|
|
3
3
|
import { type InstalledPluginPackageContent } from "./package-discovery";
|
|
4
|
-
import type { PluginBrokerDeps,
|
|
4
|
+
import type { PluginBrokerDeps, PluginCatalogConfig, PluginDefinition, OAuthProviderConfig, PluginRuntimeDependency, PluginRuntimePostinstallCommand } from "./types";
|
|
5
5
|
/** Set install-wide plugin configuration and return the previous value for rollback. */
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function setPluginCatalogConfig(config: PluginCatalogConfig | undefined): PluginCatalogConfig | undefined;
|
|
7
7
|
/** Return installed plugin package content from the active plugin configuration. */
|
|
8
8
|
export declare function getPluginPackageContent(): InstalledPluginPackageContent;
|
|
9
9
|
/** Return the current plugin catalog signature used for cache invalidation. */
|
|
@@ -59,6 +59,7 @@ export interface PluginMcpHttpConfig {
|
|
|
59
59
|
export type PluginMcpConfig = PluginMcpHttpConfig;
|
|
60
60
|
export interface PluginEnvVarDeclaration {
|
|
61
61
|
default?: string;
|
|
62
|
+
exposeToCommandEnv?: boolean;
|
|
62
63
|
}
|
|
63
64
|
export interface PluginManifest {
|
|
64
65
|
name: string;
|
|
@@ -130,8 +131,9 @@ export interface PluginManifestConfig {
|
|
|
130
131
|
commandFlags?: string[] | null;
|
|
131
132
|
} | null;
|
|
132
133
|
}
|
|
133
|
-
/** Install-level plugin package list and manifest
|
|
134
|
-
export interface
|
|
134
|
+
/** Install-level plugin package list and manifest override catalog. */
|
|
135
|
+
export interface PluginCatalogConfig {
|
|
136
|
+
inlineManifests?: InlinePluginManifestDefinition[];
|
|
135
137
|
packages?: string[];
|
|
136
138
|
manifests?: Record<string, PluginManifestConfig>;
|
|
137
139
|
}
|
|
@@ -141,6 +143,10 @@ export interface PluginBrokerDeps {
|
|
|
141
143
|
export interface PluginDefinition {
|
|
142
144
|
manifest: PluginManifest;
|
|
143
145
|
dir: string;
|
|
144
|
-
skillsDir
|
|
146
|
+
skillsDir?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface InlinePluginManifestDefinition {
|
|
149
|
+
manifest: PluginManifest;
|
|
150
|
+
packageName?: string;
|
|
145
151
|
}
|
|
146
152
|
export {};
|
|
@@ -13,7 +13,7 @@ export interface AgentTurnSessionRecord {
|
|
|
13
13
|
conversationTitle?: string;
|
|
14
14
|
version: number;
|
|
15
15
|
conversationId: string;
|
|
16
|
-
cumulativeDurationMs
|
|
16
|
+
cumulativeDurationMs: number;
|
|
17
17
|
cumulativeUsage?: AgentTurnUsage;
|
|
18
18
|
errorMessage?: string;
|
|
19
19
|
lastProgressAtMs: number;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// src/plugins.ts
|
|
2
|
+
function cloneManifests(manifests) {
|
|
3
|
+
return manifests ? structuredClone(manifests) : void 0;
|
|
4
|
+
}
|
|
5
|
+
function cloneInlineManifests(registrations) {
|
|
6
|
+
const inlineManifests = registrations.flatMap(
|
|
7
|
+
(plugin) => plugin.manifest ? [
|
|
8
|
+
{
|
|
9
|
+
manifest: {
|
|
10
|
+
...structuredClone(plugin.manifest),
|
|
11
|
+
capabilities: plugin.manifest.capabilities?.map(
|
|
12
|
+
(capability) => capability.includes(".") ? capability : `${plugin.manifest.name}.${capability}`
|
|
13
|
+
) ?? [],
|
|
14
|
+
configKeys: plugin.manifest.configKeys?.map(
|
|
15
|
+
(key) => key.includes(".") ? key : `${plugin.manifest.name}.${key}`
|
|
16
|
+
) ?? [],
|
|
17
|
+
...plugin.manifest.target ? {
|
|
18
|
+
target: {
|
|
19
|
+
...plugin.manifest.target,
|
|
20
|
+
configKey: plugin.manifest.target.configKey.includes(".") ? plugin.manifest.target.configKey : `${plugin.manifest.name}.${plugin.manifest.target.configKey}`
|
|
21
|
+
}
|
|
22
|
+
} : {}
|
|
23
|
+
},
|
|
24
|
+
...plugin.packageName ? { packageName: plugin.packageName } : {}
|
|
25
|
+
}
|
|
26
|
+
] : []
|
|
27
|
+
);
|
|
28
|
+
return inlineManifests.length > 0 ? inlineManifests : void 0;
|
|
29
|
+
}
|
|
30
|
+
function assertUniquePluginNames(registrations) {
|
|
31
|
+
const seen = /* @__PURE__ */ new Set();
|
|
32
|
+
for (const plugin of registrations) {
|
|
33
|
+
if (seen.has(plugin.name)) {
|
|
34
|
+
throw new Error(`Duplicate plugin registration name "${plugin.name}"`);
|
|
35
|
+
}
|
|
36
|
+
seen.add(plugin.name);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function assertUniquePackageNames(packageNames) {
|
|
40
|
+
const seen = /* @__PURE__ */ new Set();
|
|
41
|
+
for (const packageName of packageNames) {
|
|
42
|
+
if (seen.has(packageName)) {
|
|
43
|
+
throw new Error(`Duplicate plugin package name "${packageName}"`);
|
|
44
|
+
}
|
|
45
|
+
seen.add(packageName);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function normalizePluginInput(input) {
|
|
49
|
+
if (typeof input === "string") {
|
|
50
|
+
return { packageName: input };
|
|
51
|
+
}
|
|
52
|
+
return { registration: input };
|
|
53
|
+
}
|
|
54
|
+
function defineJuniorPlugins(inputs, options = {}) {
|
|
55
|
+
const normalized = inputs.map(normalizePluginInput);
|
|
56
|
+
const packageNames = normalized.flatMap(
|
|
57
|
+
(input) => input.packageName ? [input.packageName] : []
|
|
58
|
+
);
|
|
59
|
+
const registrations = normalized.flatMap(
|
|
60
|
+
(input) => input.registration ? [input.registration] : []
|
|
61
|
+
);
|
|
62
|
+
assertUniquePackageNames(packageNames);
|
|
63
|
+
assertUniquePluginNames(registrations);
|
|
64
|
+
const manifests = cloneManifests(options.manifests);
|
|
65
|
+
return {
|
|
66
|
+
packageNames,
|
|
67
|
+
registrations: registrations.map((plugin) => ({ ...plugin })),
|
|
68
|
+
...manifests ? { manifests } : {}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function pluginCatalogConfigFromPluginSet(pluginSet) {
|
|
72
|
+
if (!pluginSet) {
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
const packages = [
|
|
76
|
+
.../* @__PURE__ */ new Set([
|
|
77
|
+
...pluginSet.packageNames,
|
|
78
|
+
...pluginSet.registrations.flatMap(
|
|
79
|
+
(plugin) => plugin.packageName ? [plugin.packageName] : []
|
|
80
|
+
)
|
|
81
|
+
])
|
|
82
|
+
];
|
|
83
|
+
const manifests = cloneManifests(pluginSet.manifests);
|
|
84
|
+
const inlineManifests = cloneInlineManifests(pluginSet.registrations);
|
|
85
|
+
if (packages.length === 0 && !manifests && !inlineManifests) {
|
|
86
|
+
return void 0;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
...inlineManifests ? { inlineManifests } : {},
|
|
90
|
+
...packages.length > 0 ? { packages } : {},
|
|
91
|
+
...manifests ? { manifests } : {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function trustedPluginRegistrationsFromPluginSet(pluginSet) {
|
|
95
|
+
return pluginSet?.registrations.filter(
|
|
96
|
+
(plugin) => plugin.hooks || plugin.legacyStatePrefixes
|
|
97
|
+
) ?? [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
defineJuniorPlugins,
|
|
102
|
+
pluginCatalogConfigFromPluginSet,
|
|
103
|
+
trustedPluginRegistrationsFromPluginSet
|
|
104
|
+
};
|