@sentry/junior 0.272.0 → 0.273.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.
Files changed (70) hide show
  1. package/dist/{adapter-BDYDi1F9.js → adapter-umap1cth.js} +1 -1
  2. package/dist/{admin-Dj7EFycG.js → admin-0o6E_3lo.js} +1 -1
  3. package/dist/{agent-runner-Cl6Usx2Y.js → agent-runner-D7Qz-lGO.js} +517 -298
  4. package/dist/api/schema.d.ts +1 -1
  5. package/dist/api/schema.js +4 -4
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +56 -573
  8. package/dist/{app-DjZblE2J.d.ts → app-BcyhJq8x.d.ts} +4 -9
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +673 -127
  11. package/dist/{assistant-reply-DN2w6JL_.js → assistant-reply-wZ7i4OFa.js} +1 -1
  12. package/dist/{automation-CV7g5h3A.js → automation-yffXcZt9.js} +1 -1
  13. package/dist/{briefs-PysAqnjV.js → briefs-CgMnlpIp.js} +4 -4
  14. package/dist/{catalog-runtime-BNeCWIaF.js → catalog-runtime-TygDsPOU.js} +1 -1
  15. package/dist/cli/chat.js +15 -15
  16. package/dist/cli/check.js +3 -3
  17. package/dist/cli/init.js +1 -1
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/{client-FRphcDWW.js → client-DhqbV0Fe.js} +63 -5
  24. package/dist/{reporting-schema-CZREhYc-.js → common-Eu6sx09c.js} +4 -1
  25. package/dist/{config-BUP9wjiR.js → config-C6FTd7PX.js} +6 -14
  26. package/dist/{connections-CesHau9u.js → connections-Dq72KajR.js} +11 -11
  27. package/dist/{conversation-BtQzLoK8.js → conversation-T4oabbBi.js} +10 -0
  28. package/dist/{conversation-privacy-DiGvA9a3.js → conversation-privacy-BeRgrsph.js} +1 -1
  29. package/dist/{credential-sync-D2odJC30.js → credential-sync-BmCbHAp4.js} +15 -16
  30. package/dist/{db-BPLmOwXf.d.ts → db-DOzBGLn5.d.ts} +1 -1
  31. package/dist/{executor-DGDpyegI.js → executor-BafgvQcc.js} +2 -2
  32. package/dist/instrumentation.js +114 -3
  33. package/dist/{job-queue-CjB97sii.js → job-queue-C4lphW9Y.js} +3 -3
  34. package/dist/{logging-CjkDr-jP.js → logging-CNs1e04n.js} +6 -1
  35. package/dist/{message-D9y8PKA1.js → message-CETC5lsl.js} +9 -9
  36. package/dist/nitro.d.ts +1 -1
  37. package/dist/nitro.js +3 -3
  38. package/dist/{oauth-callback-server-02Pej6hj.js → oauth-callback-server-DcQZsKMm.js} +2 -2
  39. package/dist/{credentialed-CgTulRDH.js → projection-BOpi891B.js} +4576 -49
  40. package/dist/{prompt-vfceH0c-.js → prompt-B1ySjUyf.js} +1 -1
  41. package/dist/{registry-7XgwNgQe.js → registry-B-yUrv3h.js} +2 -2
  42. package/dist/{resolve-CuuxNfWG.js → resolve-DqVtd4Q9.js} +3 -3
  43. package/dist/{result-BRhb6iN1.js → result-DQwTiLTw.js} +9 -9
  44. package/dist/{runner-DaWCofuS.js → runner-Dco5qMq6.js} +11 -11
  45. package/dist/{sandbox-egress-signals-Bn6FA1UC.js → sandbox-egress-signals-DFc_9Mcv.js} +1 -1
  46. package/dist/{schema-D5VLF4NT.js → schema-5xHDGlBW.js} +9 -7
  47. package/dist/{schema-CNjAzYOw.d.ts → schema-9OGdsaxF.d.ts} +13 -0
  48. package/dist/{service-account-D9vrsi8d.js → service-account-CWfk9Cs-.js} +3 -3
  49. package/dist/{service-account-H45LIAG2.js → service-account-smdPFWNy.js} +3 -3
  50. package/dist/{session-stop-HKl0ECX0.js → session-stop-DaT_7tYa.js} +11 -11
  51. package/dist/{skills-CsiKu3-g.js → skills-BbtJSF2-.js} +2 -2
  52. package/dist/{spawn-DqjBxqWh.js → spawn-Ceikdjkp.js} +2 -2
  53. package/dist/{list-JZUP1yog.js → stop-dKUc-x2K.js} +996 -432
  54. package/dist/{store-DyVKH0QB.js → store-C1xuZcLd.js} +4 -4
  55. package/dist/{store-CPF2kzbu.js → store-DaxUuOmD.js} +3 -3
  56. package/dist/{task-queue-BbQXCcNX.js → task-queue-ymAh_-P1.js} +4 -4
  57. package/dist/{task-runner-ChzW5E7R.js → task-runner-vlH6pEm3.js} +6 -6
  58. package/dist/{thread-state-Ds8JTsX6.js → thread-state-BkUpE9Ae.js} +4 -5
  59. package/dist/{turn-failure-response-DCMvjsA0.js → turn-failure-response-DIsD7ip_.js} +7 -8
  60. package/dist/{turn-lifecycle-DM_77q33.js → turn-lifecycle-BdPKdPS8.js} +1 -1
  61. package/dist/turn-session-routing-BdCTDq9m.js +1625 -0
  62. package/dist/{validation-DcGelbBi.js → validation-BQjCfh84.js} +1 -1
  63. package/dist/{version-C48azPKq.js → version-BpiFGZZW.js} +1 -1
  64. package/dist/version.js +1 -1
  65. package/dist/{viewer-BCRuO8Wg.js → viewer-C6Y1aXjZ.js} +27 -15
  66. package/dist/{work-zxkmbJAp.js → work-ChPh_YEh.js} +10 -38
  67. package/dist/{worker-CNNxHF1V.js → worker-Be_sK_ou.js} +6 -6
  68. package/package.json +4 -4
  69. package/dist/turn-session-routing-BV_gX7n3.js +0 -6072
  70. package/dist/{oauth-relay-CTygMkNx.js → oauth-relay-C6ZAyJgf.js} +1 -1
@@ -1,7 +1,117 @@
1
- import { F as getDeploymentServiceVersion, I as getDeploymentTelemetryAttributes } from "./logging-CjkDr-jP.js";
2
- import { a as getClient, c as init, o as getGlobalScope } from "./sentry-MDkYAVPV.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-DiGvA9a3.js";
1
+ import { F as getDeploymentServiceVersion, I as getDeploymentTelemetryAttributes } from "./logging-CNs1e04n.js";
2
+ import { a as getClient, c as init, i as getActiveSpan, o as getGlobalScope, p as spanToJSON } from "./sentry-MDkYAVPV.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-BeRgrsph.js";
4
4
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-CE7_lEdq.js";
5
+ import { performance } from "node:perf_hooks";
6
+ import { subscribe, unsubscribe } from "node:diagnostics_channel";
7
+ // src/chat/pi/gateway-request-timing.ts
8
+ const PHASE_ATTRIBUTES = [
9
+ "app.ai.http.queue_ms",
10
+ "app.ai.http.connection_reused",
11
+ "app.ai.http.connect_ms",
12
+ "app.ai.http.body_send_ms",
13
+ "app.ai.http.response_wait_ms",
14
+ "http.request.body.size"
15
+ ];
16
+ function elapsedMs(fromMs, toMs) {
17
+ return Math.round(toMs - fromMs);
18
+ }
19
+ function connectKey(params) {
20
+ return `${String(params?.hostname)}:${String(params?.port)}`;
21
+ }
22
+ function gatewayChatSpan(request) {
23
+ const span = getActiveSpan();
24
+ if (!span || typeof request.origin !== "string") return;
25
+ const { attributes } = spanToJSON(span);
26
+ if (attributes["sentry.op"] !== "gen_ai.chat") return;
27
+ const host = URL.parse(request.origin)?.hostname;
28
+ return host && host === attributes["server.address"] ? span : void 0;
29
+ }
30
+ function createGatewayRequestTimingHandlers() {
31
+ const now = () => performance.now();
32
+ const requests = /* @__PURE__ */ new WeakMap();
33
+ const attempts = /* @__PURE__ */ new WeakMap();
34
+ const usedSockets = /* @__PURE__ */ new WeakSet();
35
+ const connectMsBySocket = /* @__PURE__ */ new WeakMap();
36
+ const pendingConnects = /* @__PURE__ */ new Map();
37
+ const takePendingConnect = (key) => {
38
+ const starts = pendingConnects.get(key);
39
+ pendingConnects.delete(key);
40
+ return starts?.length === 1 ? starts[0] : void 0;
41
+ };
42
+ return {
43
+ "undici:request:create": (message) => {
44
+ const { request } = message;
45
+ const span = gatewayChatSpan(request);
46
+ if (!span) return;
47
+ const attempt = (attempts.get(span) ?? 0) + 1;
48
+ attempts.set(span, attempt);
49
+ requests.set(request, {
50
+ span,
51
+ createdAtMs: now()
52
+ });
53
+ if (attempt > 1) for (const key of PHASE_ATTRIBUTES) span.setAttribute(key, void 0);
54
+ span.setAttribute("app.ai.http.attempt_count", attempt);
55
+ if (typeof request.contentLength === "number") span.setAttribute("http.request.body.size", request.contentLength);
56
+ },
57
+ "undici:client:beforeConnect": (message) => {
58
+ const { connectParams } = message;
59
+ const key = connectKey(connectParams);
60
+ pendingConnects.set(key, [...pendingConnects.get(key) ?? [], now()]);
61
+ },
62
+ "undici:client:connected": (message) => {
63
+ const { connectParams, socket } = message;
64
+ const startedAtMs = takePendingConnect(connectKey(connectParams));
65
+ if (startedAtMs !== void 0) connectMsBySocket.set(socket, elapsedMs(startedAtMs, now()));
66
+ },
67
+ "undici:client:connectError": (message) => {
68
+ const { connectParams } = message;
69
+ takePendingConnect(connectKey(connectParams));
70
+ },
71
+ "undici:client:sendHeaders": (message) => {
72
+ const { request, socket } = message;
73
+ const timing = requests.get(request);
74
+ if (!timing) return;
75
+ timing.sendHeadersAtMs = now();
76
+ const reused = usedSockets.has(socket);
77
+ usedSockets.add(socket);
78
+ timing.span.setAttribute("app.ai.http.queue_ms", elapsedMs(timing.createdAtMs, timing.sendHeadersAtMs));
79
+ timing.span.setAttribute("app.ai.http.connection_reused", reused);
80
+ const connectMs = reused ? void 0 : connectMsBySocket.get(socket);
81
+ if (connectMs !== void 0) timing.span.setAttribute("app.ai.http.connect_ms", connectMs);
82
+ },
83
+ "undici:request:bodySent": (message) => {
84
+ const { request } = message;
85
+ const timing = requests.get(request);
86
+ if (!timing || timing.sendHeadersAtMs === void 0) return;
87
+ timing.bodySentAtMs = now();
88
+ timing.span.setAttribute("app.ai.http.body_send_ms", elapsedMs(timing.sendHeadersAtMs, timing.bodySentAtMs));
89
+ },
90
+ "undici:request:headers": (message) => {
91
+ const { request } = message;
92
+ const timing = requests.get(request);
93
+ if (!timing || timing.bodySentAtMs === void 0) return;
94
+ timing.span.setAttribute("app.ai.http.response_wait_ms", elapsedMs(timing.bodySentAtMs, now()));
95
+ }
96
+ };
97
+ }
98
+ /**
99
+ * Subscribes to undici's diagnostics channels and writes the HTTP phases of
100
+ * AI Gateway model requests onto their `gen_ai.chat` span. Telemetry must not
101
+ * fail a request, so handler errors are dropped. Returns a function that
102
+ * removes the subscriptions.
103
+ */
104
+ function subscribeGatewayRequestTiming() {
105
+ const handlers = Object.entries(createGatewayRequestTimingHandlers()).map(([name, handler]) => [name, (message) => {
106
+ try {
107
+ handler(message);
108
+ } catch {}
109
+ }]);
110
+ for (const [name, handler] of handlers) subscribe(name, handler);
111
+ return () => {
112
+ for (const [name, handler] of handlers) unsubscribe(name, handler);
113
+ };
114
+ }
5
115
  // src/chat/sentry-payload-filter.ts
6
116
  const PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
7
117
  "app.message.input",
@@ -178,5 +288,6 @@ function initSentry() {
178
288
  integrations: (defaultIntegrations) => defaultIntegrations.filter((integration) => !MANUAL_GEN_AI_INTEGRATIONS.has(integration.name))
179
289
  });
180
290
  getGlobalScope().setAttributes(deploymentSpanAttributes);
291
+ subscribeGatewayRequestTiming();
181
292
  }
182
293
  export { initSentry };
@@ -1,8 +1,8 @@
1
- import { i as getChatConfig } from "./config-BUP9wjiR.js";
2
- import { E as withSpan, m as logInfo, p as logException } from "./logging-CjkDr-jP.js";
1
+ import { i as getChatConfig } from "./config-C6FTd7PX.js";
2
+ import { E as withSpan, m as logInfo, p as logException } from "./logging-CNs1e04n.js";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
- import { z } from "zod";
5
4
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
5
+ import { z } from "zod";
6
6
  import { QueueClient, handleCallback, registerDevConsumer } from "@vercel/queue";
7
7
  /** Validate the v2 conversation work hint sent through Vercel Queue. */
8
8
  const conversationQueueMessageSchema = z.object({
@@ -1,9 +1,10 @@
1
1
  import { _ as withScope, d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException } from "./sentry-MDkYAVPV.js";
2
- import { t as JUNIOR_VERSION } from "./version-C48azPKq.js";
2
+ import { t as JUNIOR_VERSION } from "./version-BpiFGZZW.js";
3
3
  import path from "node:path";
4
4
  import { styleText } from "node:util";
5
5
  import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
6
6
  import { AsyncLocalStorage } from "node:async_hooks";
7
+ import { randomUUID } from "node:crypto";
7
8
  // src/chat/coerce.ts
8
9
  /** Narrow an unknown value to a non-empty string, or undefined. */
9
10
  function toOptionalString(value) {
@@ -108,6 +109,7 @@ const JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE = "/api/internal/agent/continue";
108
109
  const JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE = "/api/internal/plugin/tasks";
109
110
  const JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE = "/api/internal/workspace/snapshots";
110
111
  const LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION = "api/internal/agent/continue.ts";
112
+ const SERVICE_INSTANCE_ID = randomUUID();
111
113
  function toOptionalTrimmed(value) {
112
114
  const trimmed = value?.trim();
113
115
  return trimmed ? trimmed : void 0;
@@ -124,7 +126,10 @@ function getDeploymentTelemetryAttributes() {
124
126
  const attributes = {};
125
127
  const serviceVersion = getDeploymentServiceVersion();
126
128
  const deploymentId = toOptionalTrimmed(process.env.VERCEL_DEPLOYMENT_ID);
129
+ const region = toOptionalTrimmed(process.env.VERCEL_REGION);
127
130
  attributes["app.junior.version"] = JUNIOR_VERSION;
131
+ attributes["service.instance.id"] = SERVICE_INSTANCE_ID;
132
+ if (region) attributes["cloud.region"] = region;
128
133
  if (serviceVersion) attributes["service.version"] = serviceVersion;
129
134
  if (deploymentId) attributes["deployment.id"] = deploymentId;
130
135
  return attributes;
@@ -1,13 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { n as botConfig } from "./config-BUP9wjiR.js";
3
- import { S as getDb, i as readActorIdentity, j as SYSTEM_IDENTITY_ID, x as getConversationStore } from "./viewer-BCRuO8Wg.js";
4
- import { Mt as actorFromRun, Nt as toolInvocationDestination } from "./agent-runner-Cl6Usx2Y.js";
5
- import { or as readConversationAccessFromSql } from "./credentialed-CgTulRDH.js";
6
- import { A as AgentMessagePausedError, I as PARENT_AGENT_TARGET, M as AgentMessageTargetError, P as findChildAgentConversationId, i as createAgentInvocationForMessage, o as getActiveAgentInvocationForConversation } from "./store-DyVKH0QB.js";
7
- import { T as postAutomatedTurnLimitNoticeForConversation, a as EVENT_WAIT_MS, k as admitAutomatedTurn } from "./session-stop-HKl0ECX0.js";
8
- import { r as appendAndEnqueueInboundMessage } from "./store-CPF2kzbu.js";
9
- import { r as enqueueAgentMessageToParent } from "./result-BRhb6iN1.js";
10
- import { r as enqueueAgentInvocation } from "./work-zxkmbJAp.js";
2
+ import { wa as readConversationAccessFromSql } from "./projection-BOpi891B.js";
3
+ import { n as botConfig } from "./config-C6FTd7PX.js";
4
+ import { M as SYSTEM_IDENTITY_ID, S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-C6Y1aXjZ.js";
5
+ import { Mt as actorFromRun, Nt as toolInvocationDestination } from "./agent-runner-D7Qz-lGO.js";
6
+ import { A as AgentMessagePausedError, I as PARENT_AGENT_TARGET, M as AgentMessageTargetError, P as findChildAgentConversationId, i as createAgentInvocationForMessage, o as getActiveAgentInvocationForConversation } from "./store-C1xuZcLd.js";
7
+ import { T as postAutomatedTurnLimitNoticeForConversation, a as EVENT_WAIT_MS, k as admitAutomatedTurn } from "./session-stop-DaT_7tYa.js";
8
+ import { r as appendAndEnqueueInboundMessage } from "./store-DaxUuOmD.js";
9
+ import { r as enqueueAgentMessageToParent } from "./result-DQwTiLTw.js";
10
+ import { r as enqueueAgentInvocation } from "./work-ChPh_YEh.js";
11
11
  // src/chat/agent-invocations/top-level-message.ts
12
12
  const AGENT_MESSAGE_EVENT_NAMESPACE = "junior";
13
13
  /** Event type of a message from another top-level agent. */
package/dist/nitro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as JuniorDashboardOptions } from "./app-DjZblE2J.js";
1
+ import { i as JuniorDashboardOptions } from "./app-BcyhJq8x.js";
2
2
  import { n as JuniorPluginSet } from "./plugins-B_0Cr0MO.js";
3
3
  import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
4
4
  type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
package/dist/nitro.js CHANGED
@@ -1,8 +1,8 @@
1
- import { A as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, D as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, F as getDeploymentServiceVersion, M as JUNIOR_RETENTION_ROUTE, N as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_HEARTBEAT_CRON_SCHEDULE, j as JUNIOR_RETENTION_CRON_SCHEDULE, k as JUNIOR_HEARTBEAT_ROUTE } from "./logging-CjkDr-jP.js";
1
+ import { A as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, D as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, F as getDeploymentServiceVersion, M as JUNIOR_RETENTION_ROUTE, N as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_HEARTBEAT_CRON_SCHEDULE, j as JUNIOR_RETENTION_CRON_SCHEDULE, k as JUNIOR_HEARTBEAT_ROUTE } from "./logging-CNs1e04n.js";
2
2
  import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-DJBompdd.js";
3
- import { o as resolveConversationWorkQueueTopic, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-CjB97sii.js";
3
+ import { o as resolveConversationWorkQueueTopic, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-C4lphW9Y.js";
4
4
  import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-DOm9Y6qI.js";
5
- import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-BbQXCcNX.js";
5
+ import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-ymAh_-P1.js";
6
6
  import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-Cf5gVPWP.js";
7
7
  import path from "node:path";
8
8
  import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
@@ -1,5 +1,5 @@
1
- import { n as createUserTokenStore } from "./credentialed-CgTulRDH.js";
2
- import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-D2odJC30.js";
1
+ import { Sn as createUserTokenStore } from "./projection-BOpi891B.js";
2
+ import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-BmCbHAp4.js";
3
3
  import { createServer } from "node:http";
4
4
  // src/chat/local/oauth-callback-server.ts
5
5
  const LOCAL_OAUTH_TIMEOUT_MS = 6e5;