@sentry/junior 0.264.0 → 0.266.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 (69) hide show
  1. package/README.md +1 -1
  2. package/dist/{adapter-BIbMSKlG.js → adapter-eRFA_naf.js} +1 -1
  3. package/dist/{admin-D4d0HXax.js → admin-tILpP51p.js} +1 -1
  4. package/dist/{agent-runner-CvRxb09K.js → agent-runner-BtYK7bht.js} +263 -198
  5. package/dist/api/schema.d.ts +216 -15
  6. package/dist/api/schema.js +5 -5
  7. package/dist/api.js +109 -42
  8. package/dist/{app-Buc5gIWz.d.ts → app-Csbi9dW7.d.ts} +0 -4
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +79 -390
  11. package/dist/{assistant-reply-BcJj_ORj.js → assistant-reply-UyzAfZQo.js} +1 -1
  12. package/dist/{automation-CWX0qL8U.js → automation-BKpY9LPa.js} +31 -10
  13. package/dist/{briefs-BFfIE5N6.js → briefs-DgfWMU7e.js} +5 -5
  14. package/dist/{catalog-runtime-R53MWcMi.js → catalog-runtime-DAJjAbSx.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 +4 -18
  18. package/dist/cli/main.js +4 -4
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.js +3 -3
  22. package/dist/{client-DpOwh_zX.js → client-B0YZfxNy.js} +3 -8
  23. package/dist/{config-BxPrFVJP.js → config-C0UwYqDK.js} +100 -3
  24. package/dist/{connections-BnTM1nRf.js → connections-Bwu3VORi.js} +11 -10
  25. package/dist/{conversation-B0baEwoA.js → conversation-DF4rUcjb.js} +6 -2
  26. package/dist/{conversation-privacy-ueJ6i-t9.js → conversation-privacy-CY7JVjxn.js} +1 -1
  27. package/dist/{credential-sync-DeDkof_D.js → credential-sync-VGAMUTGp.js} +20 -20
  28. package/dist/{agent-hooks-D_PbluRX.js → credentialed-enF5Bf3y.js} +3316 -179
  29. package/dist/{executor-D3WIS4vl.js → executor-TnWbvL09.js} +10 -300
  30. package/dist/{history-AY8rs-FR.js → history-C84mlAwO.js} +2 -1
  31. package/dist/{images-5VNK_yYC.js → images-BKQqSi5W.js} +3 -3
  32. package/dist/instrumentation.js +41 -25
  33. package/dist/{job-queue-BYHonCAH.js → job-queue-DBpHmKnd.js} +53 -14
  34. package/dist/{logging-DNQqsQ57.js → logging-Ce0mXZ8J.js} +19 -32
  35. package/dist/{message-CDTJISxL.js → message-VZ3DFpGb.js} +4 -4
  36. package/dist/nitro.d.ts +17 -2
  37. package/dist/nitro.js +26 -27
  38. package/dist/{oauth-callback-server-Bk4rbLOs.js → oauth-callback-server-CpqWLjVY.js} +2 -2
  39. package/dist/{prompt-CxatQVaj.js → prompt-BcCGlmg2.js} +2 -2
  40. package/dist/{registry-CfdUEk4N.js → registry-1BEIPdbT.js} +1 -1
  41. package/dist/{resolve-BXShI336.js → resolve-BSHHkEGE.js} +7 -106
  42. package/dist/{result-R35jcahx.js → result-CwOpzqdh.js} +8 -8
  43. package/dist/{runner-IC4Drh3Y.js → runner-CEaX04kz.js} +11 -11
  44. package/dist/{sandbox-egress-signals-C4RIfjb8.js → sandbox-egress-signals-BwtGHwqa.js} +1 -1
  45. package/dist/{schema-QidbykYl.js → schema-RsaBHxRH.js} +45 -4
  46. package/dist/{sentry-BBUlHih9.js → sentry-MDkYAVPV.js} +3 -6
  47. package/dist/{service-account-DJSRo2cL.js → service-account-6wC76eBZ.js} +5 -5
  48. package/dist/{service-account-DifohWyX.js → service-account-Dg4lIbHm.js} +3 -3
  49. package/dist/{session-stop-B9RRGC-P.js → session-stop-tZOw9AJD.js} +120 -80
  50. package/dist/{skills-DVJmS_ZP.js → skills-DzyGN7wd.js} +2 -2
  51. package/dist/{spawn-DkVYGfSY.js → spawn-6rokq7l_.js} +2 -2
  52. package/dist/{store-BvolNnx4.js → store-DcKkzrdt.js} +3 -3
  53. package/dist/{store-C_mHwAnR.js → store-FALy-JQb.js} +6 -6
  54. package/dist/{task-queue-BcEyPhtX.js → task-queue-Bg4RS2Gy.js} +14 -19
  55. package/dist/{task-runner-CiQj5M_9.js → task-runner-8N5LIkSg.js} +47 -29
  56. package/dist/{tasks-OgXmReUv.js → tasks-DDT-J3Rf.js} +17 -2078
  57. package/dist/{thread-state-XFvpWXE9.js → thread-state-cprEaxgl.js} +5 -5
  58. package/dist/{turn-failure-response-BjBAtnVt.js → turn-failure-response-C8sMdsdX.js} +8 -8
  59. package/dist/{turn-lifecycle-nvKL2rul.js → turn-lifecycle-DaBVoz7h.js} +2 -2
  60. package/dist/{turn-session-routing-DEMxHySb.js → turn-session-routing-a9CHX-w6.js} +1 -1
  61. package/dist/{validation-XOFldwvE.js → validation-C2lllinq.js} +1 -1
  62. package/dist/{version-C9f5hdHD.js → version-oaLfxxnf.js} +1 -1
  63. package/dist/version.js +1 -1
  64. package/dist/{viewer-BuPwzOC9.js → viewer-BpE6Z3qf.js} +22 -6
  65. package/dist/{web-input-4t7TYLsY.js → web-input-B-bMjD1V.js} +147 -48
  66. package/dist/{work-C_aF6JN5.js → work-VX1SHWha.js} +52 -51
  67. package/dist/{worker-DR633sA-.js → worker-hook-y_Y.js} +5 -5
  68. package/package.json +10 -9
  69. package/dist/profile-ieODOp4u.js +0 -582
@@ -1,5 +1,5 @@
1
- import { 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, y as withScope } from "./sentry-BBUlHih9.js";
2
- import { t as JUNIOR_VERSION } from "./version-C9f5hdHD.js";
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-oaLfxxnf.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";
@@ -870,17 +870,8 @@ function getLogContextAttributes() {
870
870
  /** Return inherited log context filtered to attributes valid for the span operation. */
871
871
  function getLogContextAttributesForSpan(op) {
872
872
  const attributes = { ...getLogContextAttributes() };
873
- if (op === "gen_ai.invoke_agent" || op === "gen_ai.execute_tool") {
874
- delete attributes["gen_ai.request.model"];
875
- return attributes;
876
- }
877
- if (op === "gen_ai.chat" || op === "gen_ai.embeddings") {
878
- delete attributes["gen_ai.agent.name"];
879
- delete attributes["gen_ai.request.model"];
880
- return attributes;
881
- }
882
- delete attributes["gen_ai.agent.name"];
883
873
  delete attributes["gen_ai.request.model"];
874
+ if (op !== "gen_ai.invoke_agent" && op !== "gen_ai.execute_tool") delete attributes["gen_ai.agent.name"];
884
875
  return attributes;
885
876
  }
886
877
  function createLogContextFromRequest(request, context = {}) {
@@ -952,7 +943,7 @@ function normalizeSpanAttributes(attributes) {
952
943
  return normalized;
953
944
  }
954
945
  function setAttributesOnSpan(span, attributes) {
955
- for (const [key, value] of Object.entries(normalizeSpanAttributes(attributes))) span.setAttribute(key, value);
946
+ span.setAttributes(normalizeSpanAttributes(attributes));
956
947
  }
957
948
  /**
958
949
  * Emit an informational event with occurrence-specific attributes.
@@ -1028,25 +1019,21 @@ async function withContext(context, callback) {
1028
1019
  }
1029
1020
  /** Run a callback within a Sentry span and scoped log context. */
1030
1021
  async function withSpan(name, op, context, callback, attributes = {}) {
1031
- const normalizedAttributes = normalizeSpanAttributes(attributes);
1032
- return withLogContext(context, () => {
1033
- const inheritedAttributes = getLogContextAttributesForSpan(op);
1034
- return startSpan({
1035
- name,
1036
- op,
1037
- attributes: {
1038
- ...inheritedAttributes,
1039
- ...normalizedAttributes
1040
- }
1041
- }, async (span) => {
1042
- try {
1043
- return await callback((attributes) => setAttributesOnSpan(span, attributes));
1044
- } catch (error) {
1045
- setAttributesOnSpan(span, { "error.type": error instanceof Error ? error.name : typeof error });
1046
- throw error;
1047
- }
1048
- });
1049
- });
1022
+ return withLogContext(context, () => startSpan({
1023
+ name,
1024
+ op,
1025
+ attributes: {
1026
+ ...getLogContextAttributesForSpan(op),
1027
+ ...normalizeSpanAttributes(attributes)
1028
+ }
1029
+ }, async (span) => {
1030
+ try {
1031
+ return await callback((attributes) => setAttributesOnSpan(span, attributes));
1032
+ } catch (error) {
1033
+ if (spanToJSON(span).attributes?.["error.type"] === void 0) span.setAttribute("error.type", error instanceof Error ? error.name : typeof error);
1034
+ throw error;
1035
+ }
1036
+ }));
1050
1037
  }
1051
1038
  /** Return Sentry-standard trace propagation headers for the active span. */
1052
1039
  function getTracePropagationHeaders() {
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { $ as toolInvocationDestination, Q as actorFromRun } from "./agent-runner-CvRxb09K.js";
3
- import { P as PARENT_AGENT_TARGET, i as createAgentInvocationForMessage, j as AgentMessageTargetError, o as findChildAgentConversationId, s as getActiveAgentInvocationForConversation } from "./store-BvolNnx4.js";
4
- import { n as enqueueAgentMessageToParent } from "./result-R35jcahx.js";
5
- import { r as enqueueAgentInvocation } from "./work-C_aF6JN5.js";
2
+ import { $ as actorFromRun, et as toolInvocationDestination } from "./agent-runner-BtYK7bht.js";
3
+ import { P as PARENT_AGENT_TARGET, i as createAgentInvocationForMessage, j as AgentMessageTargetError, o as findChildAgentConversationId, s as getActiveAgentInvocationForConversation } from "./store-DcKkzrdt.js";
4
+ import { n as enqueueAgentMessageToParent } from "./result-CwOpzqdh.js";
5
+ import { r as enqueueAgentInvocation } from "./work-VX1SHWha.js";
6
6
  // src/chat/agent-invocations/message.ts
7
7
  var message_exports = /* @__PURE__ */ __exportAll({ bindMessageAgent: () => bindMessageAgent });
8
8
  /**
package/dist/nitro.d.ts CHANGED
@@ -1,5 +1,19 @@
1
- import { r as JuniorDashboardOptions } from "./app-Buc5gIWz.js";
1
+ import { r as JuniorDashboardOptions } from "./app-Csbi9dW7.js";
2
2
  import { n as JuniorPluginSet } from "./plugins-B_0Cr0MO.js";
3
+ import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
4
+ type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
5
+ type SentryNitroOptions = NonNullable<Parameters<typeof withSentryConfig$1>[1]>;
6
+ /**
7
+ * Sentry's Nitro config wrapper: source map upload and Nitro request hooks.
8
+ * Junior pins `@sentry/nitro` to the same version as its `@sentry/node`. The
9
+ * SDK keeps one client for each version, so this lets the Nitro hooks use the
10
+ * client that `initSentry()` creates. Apps import it from here, not from
11
+ * `@sentry/nitro`.
12
+ *
13
+ * The build release defaults to the release that `initSentry()` reports, so
14
+ * the uploaded source maps and the runtime events use the same release.
15
+ */
16
+ export declare function withSentryConfig(config: SentryNitroConfig, options?: SentryNitroOptions): SentryNitroConfig;
3
17
  export type JuniorNitroDashboardOptions = JuniorDashboardOptions;
4
18
  export interface JuniorPluginModuleReference {
5
19
  /** Runtime-safe module that exports a `defineJuniorPlugins(...)` set. */
@@ -30,4 +44,5 @@ export declare function juniorNitro(options?: JuniorNitroOptions): {
30
44
  nitro: {
31
45
  setup(nitro: unknown): void;
32
46
  };
33
- };
47
+ };
48
+ export {};
package/dist/nitro.js CHANGED
@@ -1,11 +1,13 @@
1
- import { A as JUNIOR_RETENTION_CRON_SCHEDULE, D as JUNIOR_HEARTBEAT_CRON_SCHEDULE, E as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, M as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_HEARTBEAT_ROUTE, j as JUNIOR_RETENTION_ROUTE, k as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE } from "./logging-DNQqsQ57.js";
1
+ import { A as JUNIOR_RETENTION_CRON_SCHEDULE, D as JUNIOR_HEARTBEAT_CRON_SCHEDULE, E as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, M as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_HEARTBEAT_ROUTE, P as getDeploymentServiceVersion, j as JUNIOR_RETENTION_ROUTE, k as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE } from "./logging-Ce0mXZ8J.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-BYHonCAH.js";
3
+ import { o as resolveConversationWorkQueueTopic, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-DBpHmKnd.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-BcEyPhtX.js";
5
+ import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-Bg4RS2Gy.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";
9
+ import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
10
+ import { sentryOrchestrionPlugin } from "@sentry/server-utils/orchestrion/rollup";
9
11
  // src/build/rolldown-workarounds.ts
10
12
  /**
11
13
  * Override rolldown's treeshake config so that module side effects survive
@@ -175,6 +177,25 @@ function injectVirtualConfig(nitro, options = {}) {
175
177
  };
176
178
  }
177
179
  // src/nitro.ts
180
+ /**
181
+ * Sentry's Nitro config wrapper: source map upload and Nitro request hooks.
182
+ * Junior pins `@sentry/nitro` to the same version as its `@sentry/node`. The
183
+ * SDK keeps one client for each version, so this lets the Nitro hooks use the
184
+ * client that `initSentry()` creates. Apps import it from here, not from
185
+ * `@sentry/nitro`.
186
+ *
187
+ * The build release defaults to the release that `initSentry()` reports, so
188
+ * the uploaded source maps and the runtime events use the same release.
189
+ */
190
+ function withSentryConfig(config, options = {}) {
191
+ return withSentryConfig$1(config, {
192
+ ...options,
193
+ release: {
194
+ name: getDeploymentServiceVersion(),
195
+ ...options.release
196
+ }
197
+ });
198
+ }
178
199
  const DEFAULT_FUNCTION_MAX_DURATION_SECONDS = 300;
179
200
  const VERCEL_QUEUE_TRIGGER_TYPE = "queue/v2beta";
180
201
  function isPluginModuleReference(value) {
@@ -198,28 +219,6 @@ function runtimeModuleForResolvedPluginModule(moduleRef) {
198
219
  specifier: moduleRef.kind === "file" ? moduleRef.importPath.split(path.sep).join("/") : moduleRef.sourceSpecifier
199
220
  };
200
221
  }
201
- /**
202
- * Prevent import-in-the-middle and require-in-the-middle from being
203
- * externalized so Rolldown bundles them inline.
204
- *
205
- * @sentry/node (via @opentelemetry/instrumentation) statically imports these
206
- * packages. Nitro already lists them in nf3's NonBundleablePackages, which
207
- * means it externalizes them and relies on traceNodeModules to copy the
208
- * package directories into the Vercel function output. In practice that trace
209
- * step fails to materialize the packages at runtime, causing an
210
- * ERR_MODULE_NOT_FOUND startup crash.
211
- *
212
- * Adding them to noExternals overrides the NonBundleablePackages default and
213
- * forces Rolldown to bundle their CJS code inline. The trade-off is that
214
- * Node.js ESM loader hooks (hook.mjs) are not active, which limits OTEL
215
- * auto-instrumentation of modules loaded after initialization. That is an
216
- * acceptable cost compared to a fatal startup failure.
217
- */
218
- function bundleOpenTelemetryLoaderHooks(nitro) {
219
- const existing = Array.isArray(nitro.options.noExternals) ? nitro.options.noExternals : [];
220
- const additions = ["import-in-the-middle", "require-in-the-middle"].filter((pkg) => !existing.includes(pkg));
221
- if (additions.length > 0) nitro.options.noExternals = [...existing, ...additions];
222
- }
223
222
  function configureVercelDeployment(nitro, options) {
224
223
  const defaultMaxDuration = options.maxDuration ?? DEFAULT_FUNCTION_MAX_DURATION_SECONDS;
225
224
  const queueTopic = resolveConversationWorkQueueTopic({ topic: options.conversationWorkQueueTopic });
@@ -274,7 +273,6 @@ function juniorNitro(options = {}) {
274
273
  return { nitro: { setup(nitro) {
275
274
  const cwd = path.resolve(options.cwd ?? nitro.options.rootDir ?? process.cwd());
276
275
  const functionMaxDurationSeconds = configureVercelDeployment(nitro, options);
277
- bundleOpenTelemetryLoaderHooks(nitro);
278
276
  applyRolldownTreeshakeWorkaround(nitro);
279
277
  const pluginSource = options.plugins;
280
278
  const pluginModule = isPluginModuleReference(pluginSource) ? resolvePluginModule(cwd, pluginSource) : void 0;
@@ -307,6 +305,7 @@ function juniorNitro(options = {}) {
307
305
  nitro.hooks.hook("rollup:before", (_nitro, config) => {
308
306
  const buildConfig = config;
309
307
  buildConfig.plugins ??= [];
308
+ buildConfig.plugins.push(sentryOrchestrionPlugin());
310
309
  buildConfig.plugins.push({
311
310
  name: "junior:copy-build-content",
312
311
  async writeBundle() {
@@ -316,4 +315,4 @@ function juniorNitro(options = {}) {
316
315
  });
317
316
  } } };
318
317
  }
319
- export { juniorNitro };
318
+ export { juniorNitro, withSentryConfig };
@@ -1,5 +1,5 @@
1
- import { bn as createUserTokenStore } from "./tasks-OgXmReUv.js";
2
- import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-DeDkof_D.js";
1
+ import { n as createUserTokenStore } from "./credentialed-enF5Bf3y.js";
2
+ import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-VGAMUTGp.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;
@@ -1,4 +1,4 @@
1
- import { J as parseBriefInput, K as briefOutcomeStatusSchema, q as conversationBriefSchema } from "./conversation-B0baEwoA.js";
1
+ import { J as parseBriefInput, K as briefOutcomeStatusSchema, q as conversationBriefSchema } from "./conversation-DF4rUcjb.js";
2
2
  import { z } from "zod";
3
3
  // src/chat/briefs/generate.ts
4
4
  const MAX_INPUT_CHARS = 6e4;
@@ -419,7 +419,7 @@ async function generateBrief(args) {
419
419
  const EVENT_AUTHOR_ID = "UJRNEVENT";
420
420
  /** System Message author for event input. */
421
421
  const EVENT_MESSAGE_AUTHOR = {
422
- fullName: "Junior event",
422
+ fullName: "System event",
423
423
  isBot: true,
424
424
  userId: EVENT_AUTHOR_ID,
425
425
  userName: "junior-event"
@@ -1,4 +1,4 @@
1
- import { m as logWarn, p as logInfo, y as setSpanAttributes } from "./logging-DNQqsQ57.js";
1
+ import { m as logWarn, p as logInfo, y as setSpanAttributes } from "./logging-Ce0mXZ8J.js";
2
2
  import { a as isUserActor, o as parseActorUserId } from "./actor-tlxzqaRe.js";
3
3
  import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-DJBompdd.js";
4
4
  import path from "node:path";
@@ -1,8 +1,7 @@
1
- import { T as withSpan, y as setSpanAttributes } from "./logging-DNQqsQ57.js";
2
- import { r as getStateAdapter } from "./adapter-BIbMSKlG.js";
3
- import { C as SANDBOX_COMMAND_PATH, D as SANDBOX_WORKSPACE_ROOT, S as runNonInteractiveCommand, r as isStale, t as create, u as isSandboxUnavailableError, v as getVercelSandboxCredentials, y as sleep } from "./profile-ieODOp4u.js";
1
+ import { T as withSpan, y as setSpanAttributes } from "./logging-Ce0mXZ8J.js";
2
+ import { Cn as SANDBOX_WORKSPACE_ROOT, I as getSandboxProvider, M as create, P as isStale, on as sleep, vn as runNonInteractiveCommand, yn as SANDBOX_COMMAND_PATH } from "./credentialed-enF5Bf3y.js";
3
+ import { r as getStateAdapter } from "./adapter-eRFA_naf.js";
4
4
  import { z } from "zod";
5
- import { FileSystem, Sandbox } from "@vercel/sandbox";
6
5
  // src/chat/sandbox/resources.ts
7
6
  let configuredResources;
8
7
  function resourcesFromEnv() {
@@ -228,97 +227,6 @@ async function postinstall(sandbox, commands, signal, timeoutMs) {
228
227
  }
229
228
  });
230
229
  }
231
- // src/chat/sandbox/workspace.ts
232
- /** Bind one tool call's cancellation to every sandbox filesystem operation. */
233
- function bindSandboxFileSystem(fs, signal) {
234
- if (!signal) return fs;
235
- return {
236
- readFile(filePath, options) {
237
- signal.throwIfAborted();
238
- return fs.readFile(filePath, {
239
- ...options,
240
- signal
241
- });
242
- },
243
- writeFile(filePath, content, options) {
244
- signal.throwIfAborted();
245
- return fs.writeFile(filePath, content, {
246
- ...options,
247
- signal
248
- });
249
- },
250
- readdir(filePath) {
251
- signal.throwIfAborted();
252
- return fs.readdir(filePath, { signal });
253
- },
254
- stat(filePath) {
255
- signal.throwIfAborted();
256
- return fs.stat(filePath, { signal });
257
- }
258
- };
259
- }
260
- /** Pin Junior's sandbox contract to one Vercel session without SDK replay. */
261
- function createSandboxSession(sandbox, options) {
262
- const session = sandbox.currentSession();
263
- const fileSystem = new FileSystem(session);
264
- const run = async (operation) => {
265
- try {
266
- return await operation();
267
- } catch (error) {
268
- if (isSandboxUnavailableError(error)) options?.onUnavailable?.(session.sessionId);
269
- throw error;
270
- }
271
- };
272
- return {
273
- sandboxId: sandbox.name,
274
- sessionId: session.sessionId,
275
- fs: {
276
- readFile: async (filePath, readOptions) => await run(async () => await fileSystem.readFile(filePath, readOptions)),
277
- writeFile: async (filePath, content, writeOptions) => await run(async () => await fileSystem.writeFile(filePath, content, writeOptions)),
278
- readdir: async (filePath, readOptions) => await run(async () => await fileSystem.readdir(filePath, readOptions)),
279
- stat: async (filePath, statOptions) => await run(async () => await fileSystem.stat(filePath, statOptions))
280
- },
281
- extendTimeout(duration) {
282
- return run(async () => await session.extendTimeout(duration));
283
- },
284
- mkDir(path) {
285
- return run(async () => await session.mkDir(path));
286
- },
287
- readFileToBuffer(input) {
288
- return run(async () => await session.readFileToBuffer(input));
289
- },
290
- async runCommand(input) {
291
- const result = await run(async () => await session.runCommand(input));
292
- const [stdout, stderr] = await Promise.all([run(async () => await result.stdout()), run(async () => await result.stderr())]);
293
- return {
294
- exitCode: result.exitCode,
295
- stdout,
296
- stderr
297
- };
298
- },
299
- snapshot(options) {
300
- return run(async () => {
301
- return { snapshotId: (await session.snapshot(options)).snapshotId };
302
- });
303
- },
304
- stop() {
305
- return run(async () => await session.stop());
306
- },
307
- update(params) {
308
- return run(async () => await session.update(params));
309
- },
310
- writeFiles(files) {
311
- return run(async () => await session.writeFiles(files));
312
- }
313
- };
314
- }
315
- /** Best-effort stop; ignore secondary stop failures during cleanup. */
316
- async function stopSession(session) {
317
- if (!session) return;
318
- try {
319
- await session.stop();
320
- } catch {}
321
- }
322
230
  // src/chat/sandbox/snapshot/resolve.ts
323
231
  const SNAPSHOT_CACHE_PREFIX = "junior:sandbox_snapshot_profile:v2";
324
232
  const SNAPSHOT_LOCK_PREFIX = "junior:sandbox_snapshot_lock";
@@ -367,15 +275,13 @@ async function build(value, runtime, timeoutMs, signal, prepare) {
367
275
  "app.sandbox.snapshot.dependency_count": value.dependencyCount
368
276
  }, async () => {
369
277
  const startedAtMs = Date.now();
370
- const sandboxCredentials = getVercelSandboxCredentials();
371
278
  const resources = getSandboxResources();
372
- const sandbox = createSandboxSession(await Sandbox.create({
373
- timeout: timeoutMs,
279
+ const sandbox = await getSandboxProvider().createSession({
280
+ timeoutMs,
374
281
  runtime,
375
282
  signal,
376
- ...sandboxCredentials ?? {},
377
283
  ...resources ? { resources } : void 0
378
- }));
284
+ });
379
285
  try {
380
286
  await dependencies(sandbox, value.dependencies, signal);
381
287
  await postinstall(sandbox, value.postinstall, signal);
@@ -538,9 +444,4 @@ async function resolve(params) {
538
444
  };
539
445
  });
540
446
  }
541
- /** Identify provider errors that mean a referenced snapshot no longer exists. */
542
- function isMissingError(error) {
543
- const searchable = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
544
- return searchable.includes("snapshot") && (searchable.includes("not found") || searchable.includes("unknown") || searchable.includes("404"));
545
- }
546
- export { createSandboxSession as a, postinstall as c, getSandboxResources as d, setSandboxResourceConfig as f, bindSandboxFileSystem as i, setSnapshotSpanAttributes as l, isMissingError as n, stopSession as o, resolve as r, dependencies as s, getCachedSnapshot as t, getSandboxResourceConfig as u };
447
+ export { setSnapshotSpanAttributes as a, setSandboxResourceConfig as c, postinstall as i, resolve as n, getSandboxResourceConfig as o, dependencies as r, getSandboxResources as s, getCachedSnapshot as t };
@@ -1,13 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { Nt as getTurnRecord, Pt as listTurnSummaries } from "./tasks-OgXmReUv.js";
2
+ import { Nt as getTurnRecord, Pt as listTurnSummaries } from "./tasks-DDT-J3Rf.js";
3
3
  import { t as createActor } from "./actor-tlxzqaRe.js";
4
- import { f as credentialContextForActor } from "./registry-CfdUEk4N.js";
5
- import { W as listUnreportedSiblingAgents } from "./agent-runner-CvRxb09K.js";
6
- import { a as EVENT_SYSTEM_ACTOR, i as EVENT_MESSAGE_AUTHOR, o as isEventConversationMessage } from "./prompt-CxatQVaj.js";
7
- import { C as markAgentInvocationParentMailboxAppended, _ as getLatestAgentInvocationForConversation, a as createAgentInvocationFromLatest, c as getAgentInvocation, d as getAgentInvocationIdForResult, l as getAgentInvocationIdForEvents, p as getAgentInvocationResultMessageId, u as getAgentInvocationIdForMessage, y as isTerminalAgentInvocation } from "./store-BvolNnx4.js";
8
- import { a as EVENT_WAIT_MS, c as isEventMailboxMetadata, l as renderEventBatchText, u as timerWatchCredentialSubject } from "./session-stop-B9RRGC-P.js";
9
- import { r as appendAndEnqueueInboundMessage } from "./store-C_mHwAnR.js";
10
- import { r as enqueueAgentInvocation } from "./work-C_aF6JN5.js";
4
+ import { f as credentialContextForActor } from "./registry-1BEIPdbT.js";
5
+ import { G as listUnreportedSiblingAgents } from "./agent-runner-BtYK7bht.js";
6
+ import { a as EVENT_SYSTEM_ACTOR, i as EVENT_MESSAGE_AUTHOR, o as isEventConversationMessage } from "./prompt-BcCGlmg2.js";
7
+ import { C as markAgentInvocationParentMailboxAppended, _ as getLatestAgentInvocationForConversation, a as createAgentInvocationFromLatest, c as getAgentInvocation, d as getAgentInvocationIdForResult, l as getAgentInvocationIdForEvents, p as getAgentInvocationResultMessageId, u as getAgentInvocationIdForMessage, y as isTerminalAgentInvocation } from "./store-DcKkzrdt.js";
8
+ import { a as EVENT_WAIT_MS, c as isEventMailboxMetadata, l as renderEventBatchText, u as timerWatchCredentialSubject } from "./session-stop-tZOw9AJD.js";
9
+ import { r as appendAndEnqueueInboundMessage } from "./store-FALy-JQb.js";
10
+ import { r as enqueueAgentInvocation } from "./work-VX1SHWha.js";
11
11
  import { z } from "zod";
12
12
  import { createEventSource, createLocalSource, createWebSource } from "@sentry/junior-plugin-api";
13
13
  // src/chat/conversations/web-mailbox.ts
@@ -1,14 +1,14 @@
1
- import { A as commitAcceptedReply, F as loadProjection, H as recordAuthorizationCompleted, Ut as persistWithRetry, X as hydrateConversationMessages, Z as persistConversationMessages, at as buildConversationContext, dt as normalizeConversationText, ft as recordDeliveredAssistantMessage, kt as saveTurnCheckpoint, mt as upsertConversationMessage, ut as markConversationMessage, vt as authorizationId } from "./tasks-OgXmReUv.js";
2
- import { f as logException, w as withLogContext, x as setTags } from "./logging-DNQqsQ57.js";
3
- import { c as getConversationEventStore, u as getConversationStore } from "./viewer-BuPwzOC9.js";
4
- import { f as credentialContextForActor } from "./registry-CfdUEk4N.js";
5
- import { P as messageCardText } from "./conversation-B0baEwoA.js";
6
- import { X as markTurnFailed, Z as startActiveTurn } from "./store-BvolNnx4.js";
7
- import { n as getAssistantReplyText } from "./assistant-reply-BcJj_ORj.js";
8
- import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-CiQj5M_9.js";
9
- import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-nvKL2rul.js";
10
- import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-XFvpWXE9.js";
11
- import { d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, t as finalizeFailedTurnReplyWithEvent } from "./turn-failure-response-BjBAtnVt.js";
1
+ import { A as commitAcceptedReply, F as loadProjection, H as recordAuthorizationCompleted, Ut as persistWithRetry, X as hydrateConversationMessages, Z as persistConversationMessages, at as buildConversationContext, dt as normalizeConversationText, ft as recordDeliveredAssistantMessage, kt as saveTurnCheckpoint, mt as upsertConversationMessage, ut as markConversationMessage, vt as authorizationId } from "./tasks-DDT-J3Rf.js";
2
+ import { f as logException, w as withLogContext, x as setTags } from "./logging-Ce0mXZ8J.js";
3
+ import { d as getConversationStore, l as getConversationEventStore } from "./viewer-BpE6Z3qf.js";
4
+ import { f as credentialContextForActor } from "./registry-1BEIPdbT.js";
5
+ import { P as messageCardText } from "./conversation-DF4rUcjb.js";
6
+ import { X as markTurnFailed, Z as startActiveTurn } from "./store-DcKkzrdt.js";
7
+ import { n as getAssistantReplyText } from "./assistant-reply-UyzAfZQo.js";
8
+ import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-8N5LIkSg.js";
9
+ import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DaBVoz7h.js";
10
+ import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-cprEaxgl.js";
11
+ import { d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, t as finalizeFailedTurnReplyWithEvent } from "./turn-failure-response-C8sMdsdX.js";
12
12
  import { randomUUID } from "node:crypto";
13
13
  import { createLocalSource, localDestinationSchema } from "@sentry/junior-plugin-api";
14
14
  // src/chat/local/runner.ts
@@ -1,4 +1,4 @@
1
- import { Mn as sandboxEgressSignalsResponseSchema } from "./tasks-OgXmReUv.js";
1
+ import { $ as sandboxEgressSignalsResponseSchema } from "./credentialed-enF5Bf3y.js";
2
2
  // src/chat/local/sandbox-egress-signals.ts
3
3
  const SANDBOX_EGRESS_SIGNALS_PATH = "/api/internal/sandbox-egress/signals";
4
4
  const LOCAL_DEV_SERVER_TIMEOUT_MS = 1e3;
@@ -1,9 +1,9 @@
1
1
  import { r as AGENT_INVOCATION_STATUSES, u as juniorDestinationKindSchema } from "./agent-invocations-CxKldAeB.js";
2
- import { E as conversationUsageSchema, T as conversationSummaryReportSchema, j as conversationChildAgentTotalsSchema, l as conversationAuxiliaryCostsSchema, n as actorIdentitySchema } from "./conversation-B0baEwoA.js";
3
- import "./automation-CWX0qL8U.js";
2
+ import { E as conversationUsageSchema, T as conversationSummaryReportSchema, j as conversationChildAgentTotalsSchema, l as conversationAuxiliaryCostsSchema, n as actorIdentitySchema } from "./conversation-DF4rUcjb.js";
3
+ import "./automation-BKpY9LPa.js";
4
4
  import { a as fillUtcHours, c as sumUtcHoursIntoSixHours, i as fillUtcDays } from "./web-message-id-CJSUiksE.js";
5
5
  import { z } from "zod";
6
- import { codeChangeStateSchema } from "@sentry/junior-plugin-api";
6
+ import { codeChangeStateSchema, eventMatchSchema } from "@sentry/junior-plugin-api";
7
7
  // src/api/schema/common.ts
8
8
  /** Stable error body returned by Junior-owned REST endpoints. */
9
9
  const apiErrorSchema = z.object({ error: z.string().min(1) }).strict();
@@ -123,6 +123,47 @@ const conversationChildAgentsReportSchema = z.object({
123
123
  agents: z.array(conversationChildAgentSchema),
124
124
  conversationId: z.string().min(1)
125
125
  }).strict();
126
+ // src/api/schema/watch.ts
127
+ /**
128
+ * One active Watch that a Conversation owns: its own, or one that a child agent
129
+ * below it created.
130
+ *
131
+ * Viewers who cannot see private content get the resource type, event types,
132
+ * and times, but not the label, intent, or match filter.
133
+ */
134
+ const conversationWatchSchema = z.object({
135
+ /** Absent when the Conversation itself created the Watch. */
136
+ childAgent: z.object({
137
+ conversationId: z.string().min(1),
138
+ name: z.string().min(1).optional()
139
+ }).strict().optional(),
140
+ createdAt: z.string().datetime(),
141
+ events: z.array(z.string().min(1)).min(1),
142
+ expiresAt: z.string().datetime(),
143
+ /** Set only for a timer Watch. */
144
+ firesAt: z.string().datetime().optional(),
145
+ id: z.string().min(1),
146
+ intent: z.string().min(1).optional(),
147
+ label: z.string().min(1).optional(),
148
+ match: eventMatchSchema.optional(),
149
+ namespace: z.string().min(1),
150
+ redacted: z.literal(true).optional(),
151
+ resourceType: z.string().min(1)
152
+ }).strict().superRefine((data, context) => {
153
+ if (data.label === void 0 === (data.redacted !== true)) context.addIssue({
154
+ code: "custom",
155
+ message: "watch label must be text or explicitly redacted"
156
+ });
157
+ if (data.redacted && (data.intent || data.match)) context.addIssue({
158
+ code: "custom",
159
+ message: "redacted watches must not expose an intent or match"
160
+ });
161
+ });
162
+ /** Active Watches that one Conversation owns, oldest first. */
163
+ const conversationWatchesReportSchema = z.object({
164
+ conversationId: z.string().min(1),
165
+ watches: z.array(conversationWatchSchema)
166
+ }).strict();
126
167
  // src/api/schema/code.ts
127
168
  const codeChangeSummarySchema = z.object({
128
169
  closed: z.number().int().nonnegative(),
@@ -485,4 +526,4 @@ const statsReportSchema = z.object({
485
526
  windowEnd: z.string(),
486
527
  windowStart: z.string()
487
528
  }).strict();
488
- export { activityHours as A, codeChangeSummarySchema as B, personParamsSchema as C, locationDirectoryReportSchema as D, locationDetailReportSchema as E, connectionSchema as F, codeRepositorySummarySchema as G, codePersonReportSchema as H, disconnectConnectionResponseSchema as I, stopConversationTurnResponseSchema as J, conversationChildAgentSchema as K, startConnectionResponseSchema as L, dailyConversationActivitySchema as M, connectionListSchema as N, locationParamsSchema as O, connectionParamsSchema as P, codeActivityDaySchema as R, actorProfileReportSchema as S, locationActivityDayReportSchema as T, codeRepositoryParamsSchema as U, codeOverviewReportSchema as V, codeRepositoryReportSchema as W, apiErrorSchema as X, conversationStatsReportSchema as Y, personalTokenListSchema as _, workspaceBodySchema as a, revokePersonalTokenResponseSchema as b, workspaceRepoSchema as c, serviceAccountListSchema as d, serviceAccountParamsSchema as f, createdPersonalTokenSchema as g, createPersonalTokenBodySchema as h, deleteWorkspaceResponseSchema as i, activitySixHours as j, activityDays as k, workspaceSchema as l, startServiceAccountSignInResponseSchema as m, statsReportSchema as n, workspaceListSchema as o, serviceAccountSchema as p, conversationChildAgentsReportSchema as q, baselineSnapshotSchema as r, workspaceParamsSchema as s, statSchema as t, disconnectServiceAccountResponseSchema as u, personalTokenMetadataSchema as v, personalSpendReportSchema as w, actorDirectoryReportSchema as x, personalTokenParamsSchema as y, codeChangeSummaryReportSchema as z };
529
+ export { activityHours as A, codeChangeSummarySchema as B, personParamsSchema as C, locationDirectoryReportSchema as D, locationDetailReportSchema as E, connectionSchema as F, codeRepositorySummarySchema as G, codePersonReportSchema as H, disconnectConnectionResponseSchema as I, conversationChildAgentSchema as J, conversationWatchSchema as K, startConnectionResponseSchema as L, dailyConversationActivitySchema as M, connectionListSchema as N, locationParamsSchema as O, connectionParamsSchema as P, apiErrorSchema as Q, codeActivityDaySchema as R, actorProfileReportSchema as S, locationActivityDayReportSchema as T, codeRepositoryParamsSchema as U, codeOverviewReportSchema as V, codeRepositoryReportSchema as W, stopConversationTurnResponseSchema as X, conversationChildAgentsReportSchema as Y, conversationStatsReportSchema as Z, personalTokenListSchema as _, workspaceBodySchema as a, revokePersonalTokenResponseSchema as b, workspaceRepoSchema as c, serviceAccountListSchema as d, serviceAccountParamsSchema as f, createdPersonalTokenSchema as g, createPersonalTokenBodySchema as h, deleteWorkspaceResponseSchema as i, activitySixHours as j, activityDays as k, workspaceSchema as l, startServiceAccountSignInResponseSchema as m, statsReportSchema as n, workspaceListSchema as o, serviceAccountSchema as p, conversationWatchesReportSchema as q, baselineSnapshotSchema as r, workspaceParamsSchema as s, statSchema as t, disconnectServiceAccountResponseSchema as u, personalTokenMetadataSchema as v, personalSpendReportSchema as w, actorDirectoryReportSchema as x, personalTokenParamsSchema as y, codeChangeSummaryReportSchema as z };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { captureException, captureMessage, continueTrace, flush, getActiveSpan, getClient, getGlobalScope, getTraceData, init, logger, setTag, setUser, spanToJSON, startInactiveSpan, startSpan, startSpanManual, vercelAIIntegration, withActiveSpan, withScope, withStreamedSpan } from "@sentry/node";
2
+ import { captureException, captureMessage, continueTrace, flush, getActiveSpan, getClient, getGlobalScope, getTraceData, init, logger, setTag, setUser, spanToJSON, startInactiveSpan, startSpan, withActiveSpan, withScope } from "@sentry/node";
3
3
  // src/chat/sentry.ts
4
4
  var sentry_exports = /* @__PURE__ */ __exportAll({
5
5
  captureException: () => captureException,
@@ -17,10 +17,7 @@ var sentry_exports = /* @__PURE__ */ __exportAll({
17
17
  spanToJSON: () => spanToJSON,
18
18
  startInactiveSpan: () => startInactiveSpan,
19
19
  startSpan: () => startSpan,
20
- startSpanManual: () => startSpanManual,
21
- vercelAIIntegration: () => vercelAIIntegration,
22
20
  withActiveSpan: () => withActiveSpan,
23
- withScope: () => withScope,
24
- withStreamedSpan: () => withStreamedSpan
21
+ withScope: () => withScope
25
22
  });
26
- export { vercelAIIntegration as _, getClient as a, withStreamedSpan as b, init as c, setTag as d, setUser as f, startSpanManual as g, startSpan as h, getActiveSpan as i, logger as l, startInactiveSpan as m, captureMessage as n, getGlobalScope as o, spanToJSON as p, continueTrace as r, getTraceData as s, captureException as t, sentry_exports as u, withActiveSpan as v, withScope as y };
23
+ export { withScope as _, getClient as a, init as c, setTag as d, setUser as f, withActiveSpan as g, startSpan as h, getActiveSpan as i, logger as l, startInactiveSpan as m, captureMessage as n, getGlobalScope as o, spanToJSON as p, continueTrace as r, getTraceData as s, captureException as t, sentry_exports as u };
@@ -1,6 +1,6 @@
1
- import { m as logWarn, y as setSpanAttributes, z as isRecord } from "./logging-DNQqsQ57.js";
2
- import { c as fetchWithBoundedOAuthErrorBodies, i as resolvePluginHeaderEnvRefs } from "./registry-CfdUEk4N.js";
3
- import { i as MUTATION_LOCK_TTL_MS, o as fenceLock, r as getStateAdapter, s as withLock } from "./adapter-BIbMSKlG.js";
1
+ import { m as logWarn, y as setSpanAttributes, z as isRecord } from "./logging-Ce0mXZ8J.js";
2
+ import { c as fetchWithBoundedOAuthErrorBodies, i as resolvePluginHeaderEnvRefs } from "./registry-1BEIPdbT.js";
3
+ import { i as MUTATION_LOCK_TTL_MS, o as fenceLock, r as getStateAdapter, s as withLock } from "./adapter-eRFA_naf.js";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { randomUUID } from "node:crypto";
6
6
  import { UnauthorizedError, auth } from "@modelcontextprotocol/sdk/client/auth.js";
@@ -62,7 +62,7 @@ var McpToolError = class extends Error {
62
62
  var McpServiceAccountRequiredError = class extends McpToolError {
63
63
  provider;
64
64
  constructor(provider, displayName) {
65
- super(`${displayName} is not available yet. Junior uses a shared ${displayName} account for everyone, and a Junior admin must connect it on the dashboard Admin page.`);
65
+ super(`${displayName} is not available yet. This app uses a shared ${displayName} account for everyone, and an admin must connect it on the dashboard Admin page.`);
66
66
  this.name = "McpServiceAccountRequiredError";
67
67
  this.provider = provider;
68
68
  }
@@ -348,7 +348,7 @@ function clientMetadata(redirectUrl) {
348
348
  };
349
349
  }
350
350
  function reconnectMessage(provider) {
351
- return `The ${provider} service account is not authorized anymore. A Junior admin must run \`junior service-account connect ${provider}\`.`;
351
+ return `The ${provider} service account is not authorized anymore. An admin must run \`junior service-account connect ${provider}\`.`;
352
352
  }
353
353
  /**
354
354
  * Build the OAuth client provider for a connected service account.
@@ -1,6 +1,6 @@
1
- import { n as pluginCatalogRuntime } from "./catalog-runtime-R53MWcMi.js";
2
- import { t as disconnectStateAdapter } from "./adapter-BIbMSKlG.js";
3
- import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-DJSRo2cL.js";
1
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-DAJjAbSx.js";
2
+ import { t as disconnectStateAdapter } from "./adapter-eRFA_naf.js";
3
+ import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-6wC76eBZ.js";
4
4
  import { CLI_USAGE } from "./cli/run.js";
5
5
  import { createServer } from "node:http";
6
6
  // src/cli/service-account.ts