@sentry/junior 0.203.0 → 0.205.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-D4nu8MQV.js +17521 -0
- package/dist/agent-hooks-DXHpTJ4m.js +4042 -0
- package/dist/agent-runner-C04colea.js +678 -0
- package/dist/api/schema.d.ts +2736 -2639
- package/dist/api/schema.js +4 -169
- package/dist/api.d.ts +23 -17
- package/dist/api.js +3881 -5326
- package/dist/app-Cb776lL8.d.ts +247 -0
- package/dist/app.d.ts +4 -520
- package/dist/app.js +9524 -11875
- package/dist/auth-pause-state-C2P3guS1.js +168 -0
- package/dist/catalog-runtime-CXw3asJD.js +7 -0
- package/dist/checkpoint-CrViJ8Ps.js +2450 -0
- package/dist/cli/chat.d.ts +20 -0
- package/dist/cli/chat.js +229 -336
- package/dist/cli/check.d.ts +8 -0
- package/dist/cli/check.js +513 -806
- package/dist/cli/env.d.ts +13 -0
- package/dist/cli/env.js +63 -12
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.js +90 -159
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.js +43 -64
- package/dist/cli/plugins.d.ts +13 -0
- package/dist/cli/plugins.js +148 -227
- package/dist/cli/run.d.ts +16 -0
- package/dist/cli/run.js +52 -8
- package/dist/cli/snapshot-create.d.ts +4 -0
- package/dist/cli/snapshot-create.js +71 -125
- package/dist/cli/upgrade.d.ts +15 -0
- package/dist/cli/upgrade.js +232 -335
- package/dist/config-BOtJQ7Pc.js +941 -0
- package/dist/context-B45_WqVX.js +298 -0
- package/dist/conversation-privacy-BZRA6Pes.js +182 -0
- package/dist/conversation-work-C6y3T5Hx.js +51 -0
- package/dist/credential-sync-Bep34IB_.js +2661 -0
- package/dist/db-BeyXKJOI.d.ts +5 -0
- package/dist/destinations-BeBiJeEM.js +29 -0
- package/dist/execution-stats-B6lgWxCK.js +373 -0
- package/dist/executor-BlUhFL7_.js +721 -0
- package/dist/experimental-CIXf7Uye.js +46 -0
- package/dist/history-ClE4toxe.d.ts +32 -0
- package/dist/history-CqTuSAdI.js +441 -0
- package/dist/instrumentation.d.ts +3 -3
- package/dist/instrumentation.js +130 -176
- package/dist/job-queue-DLMqIK74.js +63 -0
- package/dist/logging-BMJzdDlP.js +1210 -0
- package/dist/model-profile-CZmVoGdX.js +49 -0
- package/dist/nitro.d.ts +31 -36
- package/dist/nitro.js +275 -456
- package/dist/oauth-callback-server-WwG5_Zgm.js +130 -0
- package/dist/oauth-relay-CdCnu80W.js +62 -0
- package/dist/package-discovery-7a9YqLhE.js +455 -0
- package/dist/pending-auth-CUbXq06G.js +185 -0
- package/dist/plugin-module-BKGOXca2.js +81 -0
- package/dist/plugins-BI9A1vKA.d.ts +95 -0
- package/dist/plugins-egKWjgue.js +99 -0
- package/dist/private-trace-result-BLvBjy_e.js +16 -0
- package/dist/profile-T0tXE4zu.js +861 -0
- package/dist/registry-BA0__8ai.js +1419 -0
- package/dist/reporting-schema-DosTN__Q.js +105 -0
- package/dist/resolve-bvD1ORdv.js +546 -0
- package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
- package/dist/runner-BXYxfIUL.js +392 -0
- package/dist/sandbox-egress-signals-ngEPjSEW.js +46 -0
- package/dist/schema-Rn8-XEaN.js +1140 -0
- package/dist/sentry-CD3SdJl-.js +26 -0
- package/dist/skills-DJOlYdBs.js +316 -0
- package/dist/spawn-h0R1bTEo.js +29 -0
- package/dist/stats-3YZn-Swi.js +2648 -0
- package/dist/store-C5qxF2ac.d.ts +208 -0
- package/dist/task-queue-CoXwd2eq.js +136 -0
- package/dist/task-runner-B2_mJZj0.js +639 -0
- package/dist/thread-state-CqZ1m-es.js +431 -0
- package/dist/turn-execution-fI6PZ0iI.js +47 -0
- package/dist/turn-lifecycle-CcnwrOcp.js +54 -0
- package/dist/usage-B5SfMb3H.js +296 -0
- package/dist/usage-schema-CKaDkH_j.js +20 -0
- package/dist/validation-DfWcvhuS.js +40 -0
- package/dist/vercel-queue-DIkVcfK4.js +167 -0
- package/dist/vercel.d.ts +6 -6
- package/dist/vercel.js +14 -6
- package/dist/version-CnXZ614E.d.ts +5 -0
- package/dist/version-oD-oPrbO.js +8 -0
- package/dist/version.d.ts +2 -4
- package/dist/version.js +2 -6
- package/dist/web-authorization-Crbzlmzo.js +76 -0
- package/dist/web-input-BOuq3oKK.js +494 -0
- package/dist/work-B91LQKHr.js +509 -0
- package/dist/worker-BcRRTe6k.js +625 -0
- package/package.json +9 -9
- package/dist/agent-hooks-GB2VPTNA.js +0 -51
- package/dist/catalog-runtime-UBLIWD3O.js +0 -14
- package/dist/chunk-2LYHWMR4.js +0 -46
- package/dist/chunk-352OWAZH.js +0 -320
- package/dist/chunk-3Y47VMHV.js +0 -6
- package/dist/chunk-3YJSKOWF.js +0 -164
- package/dist/chunk-4KSSKTQ5.js +0 -229
- package/dist/chunk-4UO6FK4G.js +0 -64
- package/dist/chunk-5AHX53NQ.js +0 -717
- package/dist/chunk-5J3E5FWA.js +0 -700
- package/dist/chunk-5PDAG6O3.js +0 -206
- package/dist/chunk-6Y5B5PEX.js +0 -80
- package/dist/chunk-7GWQ5S5R.js +0 -2086
- package/dist/chunk-7H2VZTWN.js +0 -103
- package/dist/chunk-7NL7T6VU.js +0 -406
- package/dist/chunk-A5L27LE4.js +0 -387
- package/dist/chunk-ADIAWL34.js +0 -81
- package/dist/chunk-ASTEMBKJ.js +0 -519
- package/dist/chunk-CEMMLV5L.js +0 -98
- package/dist/chunk-CM5HNV2W.js +0 -131
- package/dist/chunk-CRTRBBRI.js +0 -105
- package/dist/chunk-DA2KGZZI.js +0 -13
- package/dist/chunk-DIB4GX3G.js +0 -8
- package/dist/chunk-DKIJ2RP5.js +0 -68
- package/dist/chunk-DWPN6SCH.js +0 -172
- package/dist/chunk-EDKUFGPL.js +0 -64
- package/dist/chunk-ENY6SKIU.js +0 -1228
- package/dist/chunk-F4MGCZOX.js +0 -2943
- package/dist/chunk-FA6POGLH.js +0 -70
- package/dist/chunk-FSUR7GTG.js +0 -20475
- package/dist/chunk-GKEOHJL5.js +0 -1856
- package/dist/chunk-GMCB6W5Y.js +0 -333
- package/dist/chunk-IE2VPG7O.js +0 -1135
- package/dist/chunk-IZ5B5IHQ.js +0 -3656
- package/dist/chunk-JAL3CH4G.js +0 -27
- package/dist/chunk-KIIEUXD3.js +0 -1764
- package/dist/chunk-KXU4NIL7.js +0 -692
- package/dist/chunk-MTM5IFCY.js +0 -1190
- package/dist/chunk-N7TMSOZH.js +0 -235
- package/dist/chunk-NCEBK6PH.js +0 -36
- package/dist/chunk-NHJU2ZAL.js +0 -56
- package/dist/chunk-P6KTRNVC.js +0 -321
- package/dist/chunk-PDO5BLNM.js +0 -22
- package/dist/chunk-PDRNLLFT.js +0 -3295
- package/dist/chunk-PEQXYSSE.js +0 -45
- package/dist/chunk-PKEX2AQX.js +0 -198
- package/dist/chunk-PSJCGIGO.js +0 -1163
- package/dist/chunk-PZUSUL55.js +0 -506
- package/dist/chunk-R45M4TUS.js +0 -37
- package/dist/chunk-RC745GGZ.js +0 -122
- package/dist/chunk-SP3QKZXJ.js +0 -820
- package/dist/chunk-TXKUKMVO.js +0 -417
- package/dist/chunk-UE4GPWSD.js +0 -931
- package/dist/chunk-UIE3R5XU.js +0 -17
- package/dist/chunk-UXPG6ZIN.js +0 -84
- package/dist/chunk-VFUK3X5B.js +0 -50
- package/dist/chunk-VNMJWREK.js +0 -787
- package/dist/chunk-VZ7CSOX2.js +0 -706
- package/dist/chunk-WCNQJKFT.js +0 -10
- package/dist/chunk-WDZR3QQM.js +0 -135
- package/dist/chunk-WLYVJCHV.js +0 -1433
- package/dist/chunk-WS7NAFTM.js +0 -1520
- package/dist/chunk-X6GDDWQH.js +0 -60
- package/dist/chunk-XPDEYNQI.js +0 -102
- package/dist/chunk-XRW44VGM.js +0 -58
- package/dist/chunk-Y2CM7HXH.js +0 -111
- package/dist/chunk-Y7X25LFY.js +0 -15
- package/dist/conversation-work-VIOQ5ZF3.js +0 -54
- package/dist/db-NGDJV7YH.js +0 -26
- package/dist/discovery-DWVDM7UK.js +0 -44
- package/dist/experimental-P5FZM4CU.js +0 -12
- package/dist/oauth-callback-server-YFY7YEGK.js +0 -243
- package/dist/oauth-relay-5XPVRPYB.js +0 -8
- package/dist/plugins-YTYJMMJF.js +0 -14
- package/dist/runner-ORTNSB2Q.js +0 -522
- package/dist/sandbox-egress-signals-FIL7EGPR.js +0 -73
- package/dist/sentry-MB3NL3IR.js +0 -42
- package/dist/skills-H376WQOH.js +0 -27
- package/dist/spawn-T43WHLOS.js +0 -42
- package/dist/task-runner-LBZWF32V.js +0 -36
- package/dist/validation-REJLRKI6.js +0 -17
- package/dist/work-3KJ3RE76.js +0 -51
- package/dist/worker-QFEBU72E.js +0 -24
package/dist/instrumentation.js
CHANGED
|
@@ -1,208 +1,162 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "./
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
init,
|
|
15
|
-
vercelAIIntegration,
|
|
16
|
-
withStreamedSpan
|
|
17
|
-
} from "./chunk-PEQXYSSE.js";
|
|
18
|
-
import "./chunk-WDZR3QQM.js";
|
|
19
|
-
|
|
20
|
-
// src/chat/sentry-payload-filter.ts
|
|
21
|
-
var PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
|
|
22
|
-
"app.message.input",
|
|
23
|
-
"app.message.output",
|
|
24
|
-
"gen_ai.input.messages",
|
|
25
|
-
"gen_ai.output.messages",
|
|
26
|
-
"gen_ai.system_instructions",
|
|
27
|
-
"gen_ai.tool.call.arguments",
|
|
28
|
-
"gen_ai.tool.call.result"
|
|
1
|
+
import { M as getDeploymentServiceVersion, N as getDeploymentTelemetryAttributes } from "./logging-BMJzdDlP.js";
|
|
2
|
+
import { a as getClient, c as init, g as vercelAIIntegration, o as getGlobalScope, y as withStreamedSpan } from "./sentry-CD3SdJl-.js";
|
|
3
|
+
import { n as getCurrentConversationPrivacy } from "./conversation-privacy-BZRA6Pes.js";
|
|
4
|
+
import { t as consumePrivateTraceResultMarker } from "./private-trace-result-BLvBjy_e.js";
|
|
5
|
+
//#region src/chat/sentry-payload-filter.ts
|
|
6
|
+
const PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
|
|
7
|
+
"app.message.input",
|
|
8
|
+
"app.message.output",
|
|
9
|
+
"gen_ai.input.messages",
|
|
10
|
+
"gen_ai.output.messages",
|
|
11
|
+
"gen_ai.system_instructions",
|
|
12
|
+
"gen_ai.tool.call.arguments",
|
|
13
|
+
"gen_ai.tool.call.result"
|
|
29
14
|
]);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
]);
|
|
36
|
-
var OAUTH_CALLBACK_PATH = "/api/oauth/callback/";
|
|
37
|
-
var LOCAL_CREDENTIAL_PATH = "/api/internal/local-oauth-credentials";
|
|
38
|
-
var SECRET_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
39
|
-
"x-junior-local-credential-signature",
|
|
40
|
-
"x-junior-sandbox-egress-token"
|
|
15
|
+
const URL_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
|
|
16
|
+
"http.target",
|
|
17
|
+
"http.url",
|
|
18
|
+
"url.full",
|
|
19
|
+
"url.path"
|
|
41
20
|
]);
|
|
21
|
+
const OAUTH_CALLBACK_PATH = "/api/oauth/callback/";
|
|
22
|
+
const LOCAL_CREDENTIAL_PATH = "/api/internal/local-oauth-credentials";
|
|
23
|
+
const SECRET_HEADER_NAMES = /* @__PURE__ */ new Set(["x-junior-local-credential-signature", "x-junior-sandbox-egress-token"]);
|
|
42
24
|
function stripQuery(value) {
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
const queryIndex = value.indexOf("?");
|
|
26
|
+
return queryIndex >= 0 ? value.slice(0, queryIndex) : value;
|
|
45
27
|
}
|
|
46
28
|
function isSecretHeaderAttribute(key) {
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
30
|
+
return normalized.endsWith("xjuniorlocalcredentialsignature") || normalized.endsWith("xjuniorsandboxegresstoken");
|
|
49
31
|
}
|
|
50
32
|
function scrubSensitiveUrlAttributes(attributes) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
for (const key of URL_ATTRIBUTE_KEYS) {
|
|
65
|
-
const value = attributes[key];
|
|
66
|
-
if (typeof value !== "string" || !value.includes(OAUTH_CALLBACK_PATH)) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
attributes[key] = stripQuery(value);
|
|
70
|
-
}
|
|
33
|
+
if (!attributes) return;
|
|
34
|
+
delete attributes["url.query"];
|
|
35
|
+
const hasLocalCredentialUrl = [...URL_ATTRIBUTE_KEYS].some((key) => {
|
|
36
|
+
const value = attributes[key];
|
|
37
|
+
return typeof value === "string" && value.includes(LOCAL_CREDENTIAL_PATH);
|
|
38
|
+
});
|
|
39
|
+
for (const key of Object.keys(attributes)) if (isSecretHeaderAttribute(key) || hasLocalCredentialUrl && key === "http.request.body.data") delete attributes[key];
|
|
40
|
+
for (const key of URL_ATTRIBUTE_KEYS) {
|
|
41
|
+
const value = attributes[key];
|
|
42
|
+
if (typeof value !== "string" || !value.includes(OAUTH_CALLBACK_PATH)) continue;
|
|
43
|
+
attributes[key] = stripQuery(value);
|
|
44
|
+
}
|
|
71
45
|
}
|
|
72
46
|
function scrubSensitiveRequest(request) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
delete request.data;
|
|
83
|
-
}
|
|
84
|
-
if (!request.headers) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
for (const key of Object.keys(request.headers)) {
|
|
88
|
-
if (SECRET_HEADER_NAMES.has(key.toLowerCase())) {
|
|
89
|
-
delete request.headers[key];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
47
|
+
if (!request) return;
|
|
48
|
+
const url = request.url;
|
|
49
|
+
if (url?.includes(OAUTH_CALLBACK_PATH)) {
|
|
50
|
+
request.url = stripQuery(url);
|
|
51
|
+
delete request.query_string;
|
|
52
|
+
}
|
|
53
|
+
if (url?.includes(LOCAL_CREDENTIAL_PATH)) delete request.data;
|
|
54
|
+
if (!request.headers) return;
|
|
55
|
+
for (const key of Object.keys(request.headers)) if (SECRET_HEADER_NAMES.has(key.toLowerCase())) delete request.headers[key];
|
|
92
56
|
}
|
|
93
57
|
function hasPayloadAttributes(attributes) {
|
|
94
|
-
|
|
58
|
+
return Object.keys(attributes).some((key) => PAYLOAD_ATTRIBUTE_KEYS.has(key));
|
|
95
59
|
}
|
|
96
60
|
function shouldScrubPayloads(attributes) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
return getCurrentConversationPrivacy() !== "public";
|
|
61
|
+
if (!hasPayloadAttributes(attributes)) return false;
|
|
62
|
+
return getCurrentConversationPrivacy() !== "public";
|
|
101
63
|
}
|
|
102
64
|
function scrubPayloadAttributes(attributes) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
if (key in attributes) {
|
|
116
|
-
redacted = true;
|
|
117
|
-
}
|
|
118
|
-
delete attributes[key];
|
|
119
|
-
}
|
|
120
|
-
if (redacted) {
|
|
121
|
-
attributes["app.conversation.payload_redacted"] = true;
|
|
122
|
-
}
|
|
65
|
+
if (!attributes) return;
|
|
66
|
+
if (!shouldScrubPayloads(attributes)) return;
|
|
67
|
+
const preserveProjectedToolResult = consumePrivateTraceResultMarker(attributes);
|
|
68
|
+
let redacted = false;
|
|
69
|
+
for (const key of PAYLOAD_ATTRIBUTE_KEYS) {
|
|
70
|
+
if (key === "gen_ai.tool.call.result" && preserveProjectedToolResult) continue;
|
|
71
|
+
if (key in attributes) redacted = true;
|
|
72
|
+
delete attributes[key];
|
|
73
|
+
}
|
|
74
|
+
if (redacted) attributes["app.conversation.payload_redacted"] = true;
|
|
123
75
|
}
|
|
124
76
|
function scrubContainer(container) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
scrubSensitiveUrlAttributes(container.data);
|
|
131
|
-
scrubSensitiveUrlAttributes(container.attributes);
|
|
77
|
+
if (!container) return;
|
|
78
|
+
scrubPayloadAttributes(container.data);
|
|
79
|
+
scrubPayloadAttributes(container.attributes);
|
|
80
|
+
scrubSensitiveUrlAttributes(container.data);
|
|
81
|
+
scrubSensitiveUrlAttributes(container.attributes);
|
|
132
82
|
}
|
|
83
|
+
/** Remove private conversation payloads and boundary secrets from error events. */
|
|
133
84
|
function scrubPrivateSentryEvent(event) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
scrubContainer(breadcrumb);
|
|
140
|
-
}
|
|
141
|
-
return event;
|
|
85
|
+
scrubContainer(event);
|
|
86
|
+
scrubSensitiveRequest(event.request);
|
|
87
|
+
scrubContainer(event.contexts?.trace);
|
|
88
|
+
for (const breadcrumb of event.breadcrumbs ?? []) scrubContainer(breadcrumb);
|
|
89
|
+
return event;
|
|
142
90
|
}
|
|
91
|
+
/** Remove private conversation payloads and boundary secrets from transactions. */
|
|
143
92
|
function scrubPrivateSentryTransaction(event) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
scrubContainer(span);
|
|
150
|
-
}
|
|
151
|
-
return event;
|
|
93
|
+
scrubContainer(event);
|
|
94
|
+
scrubSensitiveRequest(event.request);
|
|
95
|
+
scrubContainer(event.contexts?.trace);
|
|
96
|
+
for (const span of event.spans ?? []) scrubContainer(span);
|
|
97
|
+
return event;
|
|
152
98
|
}
|
|
99
|
+
/** Remove private conversation payloads and boundary secrets from streamed spans. */
|
|
153
100
|
function scrubPrivateSentrySpan(span) {
|
|
154
|
-
|
|
155
|
-
|
|
101
|
+
scrubContainer(span);
|
|
102
|
+
return span;
|
|
156
103
|
}
|
|
104
|
+
/** Remove private conversation payloads and boundary secrets from structured logs. */
|
|
157
105
|
function scrubPrivateSentryLog(log) {
|
|
158
|
-
|
|
159
|
-
|
|
106
|
+
scrubContainer(log);
|
|
107
|
+
return log;
|
|
160
108
|
}
|
|
161
|
-
|
|
162
|
-
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/instrumentation.ts
|
|
163
111
|
function getSampleRate(value, fallback) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
112
|
+
if (!value) return fallback;
|
|
113
|
+
const parsed = Number(value);
|
|
114
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
167
115
|
}
|
|
168
116
|
function getBoolean(value, fallback) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
117
|
+
if (!value) return fallback;
|
|
118
|
+
const normalized = value.trim().toLowerCase();
|
|
119
|
+
if ([
|
|
120
|
+
"1",
|
|
121
|
+
"true",
|
|
122
|
+
"yes",
|
|
123
|
+
"on"
|
|
124
|
+
].includes(normalized)) return true;
|
|
125
|
+
if ([
|
|
126
|
+
"0",
|
|
127
|
+
"false",
|
|
128
|
+
"no",
|
|
129
|
+
"off"
|
|
130
|
+
].includes(normalized)) return false;
|
|
131
|
+
return fallback;
|
|
174
132
|
}
|
|
133
|
+
/** Initialize Sentry for the Junior runtime. Call at the top of your entry point. */
|
|
175
134
|
function initSentry() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
})
|
|
202
|
-
]
|
|
203
|
-
});
|
|
204
|
-
getGlobalScope().setAttributes(deploymentSpanAttributes);
|
|
135
|
+
if (getClient()) return;
|
|
136
|
+
const dsn = process.env.SENTRY_DSN;
|
|
137
|
+
const enableLogs = getBoolean(process.env.SENTRY_ENABLE_LOGS, Boolean(dsn));
|
|
138
|
+
const serviceVersion = getDeploymentServiceVersion();
|
|
139
|
+
const deploymentSpanAttributes = getDeploymentTelemetryAttributes();
|
|
140
|
+
init({
|
|
141
|
+
dsn,
|
|
142
|
+
environment: process.env.SENTRY_ENVIRONMENT ?? process.env.VERCEL_ENV ?? process.env.NODE_ENV,
|
|
143
|
+
release: serviceVersion,
|
|
144
|
+
tracesSampleRate: getSampleRate(process.env.SENTRY_TRACES_SAMPLE_RATE, 1),
|
|
145
|
+
traceLifecycle: "stream",
|
|
146
|
+
sendDefaultPii: true,
|
|
147
|
+
enableLogs,
|
|
148
|
+
registerEsmLoaderHooks: false,
|
|
149
|
+
streamGenAiSpans: true,
|
|
150
|
+
beforeSend: scrubPrivateSentryEvent,
|
|
151
|
+
beforeSendLog: scrubPrivateSentryLog,
|
|
152
|
+
beforeSendSpan: withStreamedSpan(scrubPrivateSentrySpan),
|
|
153
|
+
beforeSendTransaction: scrubPrivateSentryTransaction,
|
|
154
|
+
integrations: [vercelAIIntegration({
|
|
155
|
+
recordInputs: true,
|
|
156
|
+
recordOutputs: true
|
|
157
|
+
})]
|
|
158
|
+
});
|
|
159
|
+
getGlobalScope().setAttributes(deploymentSpanAttributes);
|
|
205
160
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
};
|
|
161
|
+
//#endregion
|
|
162
|
+
export { initSentry };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { i as getChatConfig } from "./config-BOtJQ7Pc.js";
|
|
2
|
+
import { a as signQueueMessage, i as QUEUE_SIGNATURE_MAX_AGE_MS, o as verifyQueueMessage, s as createVercelQueueClient } from "./vercel-queue-DIkVcfK4.js";
|
|
3
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
//#region src/chat/runtime/request-deadline.ts
|
|
7
|
+
const requestDeadlineStorage = new AsyncLocalStorage();
|
|
8
|
+
function createTurnRequestDeadline(startedAtMs) {
|
|
9
|
+
return {
|
|
10
|
+
startedAtMs,
|
|
11
|
+
deadlineAtMs: startedAtMs + Math.max(1, getChatConfig().functionMaxDurationSeconds * 1e3 - 2e4)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** Return the host request deadline inherited by the current async turn. */
|
|
15
|
+
function getTurnRequestDeadline() {
|
|
16
|
+
return requestDeadlineStorage.getStore();
|
|
17
|
+
}
|
|
18
|
+
/** Run work with one host request deadline shared by nested queued turns. */
|
|
19
|
+
function runWithTurnRequestDeadline(callback, startedAtMs = Date.now()) {
|
|
20
|
+
if (requestDeadlineStorage.getStore()) return callback();
|
|
21
|
+
return requestDeadlineStorage.run(createTurnRequestDeadline(startedAtMs), callback);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/chat/sandbox/snapshot/job-queue.ts
|
|
25
|
+
/** Send Workspace snapshot build messages. */
|
|
26
|
+
const SIGNATURE_CONTEXT = "junior.workspace_snapshot_queue.v1";
|
|
27
|
+
const SIGNATURE_VERSION = "v1";
|
|
28
|
+
const WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC = "junior_workspace_snapshots";
|
|
29
|
+
const workspaceSnapshotJobSign = {
|
|
30
|
+
context: SIGNATURE_CONTEXT,
|
|
31
|
+
schema: z.object({
|
|
32
|
+
workspaceId: z.string().uuid(),
|
|
33
|
+
profileHash: z.string().min(1)
|
|
34
|
+
}).strict(),
|
|
35
|
+
signatureVersion: SIGNATURE_VERSION,
|
|
36
|
+
parts: (message) => [message.workspaceId, message.profileHash]
|
|
37
|
+
};
|
|
38
|
+
function jobId(message) {
|
|
39
|
+
return `workspace-snapshot_${createHash("sha256").update(message.workspaceId).update("\0").update(message.profileHash).digest("hex").slice(0, 32)}`;
|
|
40
|
+
}
|
|
41
|
+
/** Sign a Workspace snapshot job for tests and local checks. */
|
|
42
|
+
function signWorkspaceSnapshotJobMessage(message, nowMs = Date.now()) {
|
|
43
|
+
return signQueueMessage(workspaceSnapshotJobSign, message, nowMs);
|
|
44
|
+
}
|
|
45
|
+
/** Check that a recent queue message came from Junior. */
|
|
46
|
+
function verifyWorkspaceSnapshotJobMessage(value, nowMs = Date.now()) {
|
|
47
|
+
return verifyQueueMessage(workspaceSnapshotJobSign, value, nowMs);
|
|
48
|
+
}
|
|
49
|
+
async function send(message, idempotencyKey) {
|
|
50
|
+
const options = { retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3 };
|
|
51
|
+
if (idempotencyKey) options.idempotencyKey = idempotencyKey;
|
|
52
|
+
await createVercelQueueClient().send(WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, signWorkspaceSnapshotJobMessage(message), options);
|
|
53
|
+
}
|
|
54
|
+
/** Send a job unless the same Workspace build already has one. */
|
|
55
|
+
async function sendWorkspaceSnapshotJob(message) {
|
|
56
|
+
await send(message, jobId(message));
|
|
57
|
+
}
|
|
58
|
+
/** Send the next job for a Workspace build that is still running. */
|
|
59
|
+
async function sendNextWorkspaceSnapshotJob(message) {
|
|
60
|
+
await send(message);
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { getTurnRequestDeadline as a, verifyWorkspaceSnapshotJobMessage as i, sendNextWorkspaceSnapshotJob as n, runWithTurnRequestDeadline as o, sendWorkspaceSnapshotJob as r, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC as t };
|