@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
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPluginForSkillPath,
|
|
3
3
|
getPluginSkillRoots
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZLMBNBUG.js";
|
|
5
5
|
import {
|
|
6
6
|
skillRoots
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Q3XNY442.js";
|
|
8
8
|
import {
|
|
9
9
|
logWarn
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EJN6G5A2.js";
|
|
11
11
|
|
|
12
12
|
// src/chat/skills.ts
|
|
13
13
|
import fs from "fs/promises";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/cli/run.ts
|
|
2
|
+
var CLI_USAGE = "usage: junior init <dir>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>";
|
|
3
|
+
var DEFAULT_IO = {
|
|
4
|
+
error: console.error
|
|
5
|
+
};
|
|
6
|
+
function normalizeCliArgv(argv) {
|
|
7
|
+
return argv[0] === "--" ? argv.slice(1) : argv;
|
|
8
|
+
}
|
|
9
|
+
async function runCli(argv, handlers, io = DEFAULT_IO) {
|
|
10
|
+
const [command, subcommand, ...rest] = normalizeCliArgv(argv);
|
|
11
|
+
if (command === "chat") {
|
|
12
|
+
return await handlers.runChat(
|
|
13
|
+
subcommand === void 0 ? [] : [subcommand, ...rest]
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
if (command === "init") {
|
|
17
|
+
if (!subcommand || rest.length > 0) {
|
|
18
|
+
io.error(CLI_USAGE);
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
await handlers.runInit(subcommand);
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
if (command === "snapshot" && subcommand === "create") {
|
|
25
|
+
if (rest.length > 0) {
|
|
26
|
+
io.error(CLI_USAGE);
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
await handlers.runSnapshotCreate();
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
if (command === "check") {
|
|
33
|
+
if (rest.length > 0) {
|
|
34
|
+
io.error(CLI_USAGE);
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
await handlers.runCheck(subcommand);
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
if (command === "upgrade") {
|
|
41
|
+
if (subcommand || rest.length > 0) {
|
|
42
|
+
io.error(CLI_USAGE);
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
await handlers.runUpgrade();
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
if (command && handlers.runPluginCommand) {
|
|
49
|
+
const exitCode = await handlers.runPluginCommand(
|
|
50
|
+
command,
|
|
51
|
+
subcommand === void 0 ? [] : [subcommand, ...rest]
|
|
52
|
+
);
|
|
53
|
+
if (exitCode !== void 0) {
|
|
54
|
+
return exitCode;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
io.error(CLI_USAGE);
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
CLI_USAGE,
|
|
63
|
+
runCli
|
|
64
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getStateAdapter
|
|
3
|
+
} from "./chunk-Y5OFBCBZ.js";
|
|
4
|
+
import {
|
|
5
|
+
logException,
|
|
6
|
+
logInfo,
|
|
7
|
+
logWarn
|
|
8
|
+
} from "./chunk-EJN6G5A2.js";
|
|
9
|
+
|
|
10
|
+
// src/chat/plugins/logging.ts
|
|
11
|
+
function createPluginLogger(plugin) {
|
|
12
|
+
return {
|
|
13
|
+
info(message, metadata) {
|
|
14
|
+
logInfo(
|
|
15
|
+
"agent_plugin_log_info",
|
|
16
|
+
{},
|
|
17
|
+
{ "app.plugin.name": plugin, ...metadata },
|
|
18
|
+
message
|
|
19
|
+
);
|
|
20
|
+
},
|
|
21
|
+
warn(message, metadata) {
|
|
22
|
+
logWarn(
|
|
23
|
+
"agent_plugin_log_warn",
|
|
24
|
+
{},
|
|
25
|
+
{ "app.plugin.name": plugin, ...metadata },
|
|
26
|
+
message
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
error(message, metadata) {
|
|
30
|
+
logException(
|
|
31
|
+
new Error(message),
|
|
32
|
+
"agent_plugin_log_error",
|
|
33
|
+
{},
|
|
34
|
+
{ "app.plugin.name": plugin, ...metadata },
|
|
35
|
+
message
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/chat/plugins/state.ts
|
|
42
|
+
import { createHash } from "crypto";
|
|
43
|
+
var MAX_PLUGIN_STATE_KEY_LENGTH = 512;
|
|
44
|
+
function hashKeyPart(value) {
|
|
45
|
+
return createHash("sha256").update(value).digest("hex").slice(0, 32);
|
|
46
|
+
}
|
|
47
|
+
function pluginStateKey(plugin, key) {
|
|
48
|
+
const pluginPrefix = `junior:${plugin}`;
|
|
49
|
+
if (key === pluginPrefix || key.startsWith(`${pluginPrefix}:`)) {
|
|
50
|
+
return key;
|
|
51
|
+
}
|
|
52
|
+
return `junior:plugin_state:${hashKeyPart(plugin)}:${hashKeyPart(key)}`;
|
|
53
|
+
}
|
|
54
|
+
function validatePluginStateKey(key) {
|
|
55
|
+
if (!key.trim()) {
|
|
56
|
+
throw new Error("Plugin state key is required");
|
|
57
|
+
}
|
|
58
|
+
if (key.length > MAX_PLUGIN_STATE_KEY_LENGTH) {
|
|
59
|
+
throw new Error("Plugin state key exceeds the maximum length");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function createPluginState(plugin, adapter) {
|
|
63
|
+
const getAdapter = () => adapter ?? getStateAdapter();
|
|
64
|
+
return {
|
|
65
|
+
async delete(key) {
|
|
66
|
+
validatePluginStateKey(key);
|
|
67
|
+
const state = getAdapter();
|
|
68
|
+
await state.connect();
|
|
69
|
+
await state.delete(pluginStateKey(plugin, key));
|
|
70
|
+
},
|
|
71
|
+
async get(key) {
|
|
72
|
+
validatePluginStateKey(key);
|
|
73
|
+
const state = getAdapter();
|
|
74
|
+
await state.connect();
|
|
75
|
+
const value = await state.get(pluginStateKey(plugin, key));
|
|
76
|
+
return value ?? void 0;
|
|
77
|
+
},
|
|
78
|
+
async set(key, value, ttlMs) {
|
|
79
|
+
validatePluginStateKey(key);
|
|
80
|
+
const state = getAdapter();
|
|
81
|
+
await state.connect();
|
|
82
|
+
await state.set(pluginStateKey(plugin, key), value, ttlMs);
|
|
83
|
+
},
|
|
84
|
+
async setIfNotExists(key, value, ttlMs) {
|
|
85
|
+
validatePluginStateKey(key);
|
|
86
|
+
const state = getAdapter();
|
|
87
|
+
await state.connect();
|
|
88
|
+
return await state.setIfNotExists(
|
|
89
|
+
pluginStateKey(plugin, key),
|
|
90
|
+
value,
|
|
91
|
+
ttlMs
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
async withLock(key, ttlMs, callback) {
|
|
95
|
+
validatePluginStateKey(key);
|
|
96
|
+
const state = getAdapter();
|
|
97
|
+
await state.connect();
|
|
98
|
+
const lockKey = pluginStateKey(plugin, key);
|
|
99
|
+
const lock = await state.acquireLock(lockKey, ttlMs);
|
|
100
|
+
if (!lock) {
|
|
101
|
+
throw new Error(`Could not acquire plugin state lock for ${key}`);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
return await callback();
|
|
105
|
+
} finally {
|
|
106
|
+
await state.releaseLock(lock);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export {
|
|
113
|
+
createPluginLogger,
|
|
114
|
+
createPluginState
|
|
115
|
+
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getDeploymentTelemetryAttributes
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
getDeploymentTelemetryAttributes
|
|
3
|
+
} from "./chunk-OJ53FYVG.js";
|
|
4
|
+
import {
|
|
5
|
+
captureException,
|
|
6
|
+
sentry_exports,
|
|
7
|
+
setTag,
|
|
8
|
+
setUser,
|
|
9
|
+
startSpan,
|
|
10
|
+
withScope
|
|
11
|
+
} from "./chunk-ST6YNAXG.js";
|
|
5
12
|
|
|
6
13
|
// src/chat/logging.ts
|
|
7
14
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -887,8 +894,8 @@ var log = {
|
|
|
887
894
|
body ?? normalizedError.message
|
|
888
895
|
);
|
|
889
896
|
let eventId;
|
|
890
|
-
const sentryWithScope =
|
|
891
|
-
const sentryCaptureException =
|
|
897
|
+
const sentryWithScope = withScope;
|
|
898
|
+
const sentryCaptureException = captureException;
|
|
892
899
|
if (typeof sentryWithScope === "function" && typeof sentryCaptureException === "function") {
|
|
893
900
|
sentryWithScope((scope) => {
|
|
894
901
|
if (context) {
|
|
@@ -1032,7 +1039,7 @@ function setSentryTagsFromContext(context) {
|
|
|
1032
1039
|
continue;
|
|
1033
1040
|
}
|
|
1034
1041
|
if (typeof value === "string" && value.length > 0) {
|
|
1035
|
-
|
|
1042
|
+
setTag(key, value);
|
|
1036
1043
|
}
|
|
1037
1044
|
}
|
|
1038
1045
|
}
|
|
@@ -1056,7 +1063,7 @@ function sentryUserFromIdentity(identity) {
|
|
|
1056
1063
|
}
|
|
1057
1064
|
function setSentryUser(identity) {
|
|
1058
1065
|
if (!identity) return;
|
|
1059
|
-
|
|
1066
|
+
setUser(sentryUserFromIdentity(identity));
|
|
1060
1067
|
}
|
|
1061
1068
|
function setSentryScopeContext(scope, context) {
|
|
1062
1069
|
const attrs = contextToAttributes(context);
|
|
@@ -1133,7 +1140,7 @@ async function withSpan(name, op, context, callback, attributes = {}) {
|
|
|
1133
1140
|
const normalizedAttributes = normalizeSpanAttributes(attributes);
|
|
1134
1141
|
return withLogContext(context, () => {
|
|
1135
1142
|
const inheritedAttributes = getLogContextAttributes();
|
|
1136
|
-
return
|
|
1143
|
+
return startSpan(
|
|
1137
1144
|
{
|
|
1138
1145
|
name,
|
|
1139
1146
|
op,
|
|
@@ -1208,8 +1215,7 @@ var TURN_FAILURE_RESPONSE_TEMPLATE = "I ran into an internal error while process
|
|
|
1208
1215
|
function buildTurnFailureResponse(eventId) {
|
|
1209
1216
|
return TURN_FAILURE_RESPONSE_TEMPLATE.replace("{eventId}", eventId);
|
|
1210
1217
|
}
|
|
1211
|
-
var GEN_AI_DEFAULT_MAX_ATTRIBUTE_CHARS =
|
|
1212
|
-
var GEN_AI_MAX_STRING_CHARS = 2e3;
|
|
1218
|
+
var GEN_AI_DEFAULT_MAX_ATTRIBUTE_CHARS = 1e5;
|
|
1213
1219
|
var GEN_AI_MAX_ARRAY_ITEMS = 50;
|
|
1214
1220
|
var GEN_AI_MAX_OBJECT_KEYS = 50;
|
|
1215
1221
|
function truncateGenAiString(value, maxChars) {
|
|
@@ -1224,7 +1230,7 @@ function sanitizeGenAiValue(value, seen, depth, keyName) {
|
|
|
1224
1230
|
if (shouldTreatAsBlob) {
|
|
1225
1231
|
return `[omitted:${value.length}]`;
|
|
1226
1232
|
}
|
|
1227
|
-
return
|
|
1233
|
+
return redactSecrets(value);
|
|
1228
1234
|
}
|
|
1229
1235
|
if (typeof value === "number") {
|
|
1230
1236
|
return Number.isFinite(value) ? value : void 0;
|