@sentry/junior 0.297.0 → 0.299.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 (94) hide show
  1. package/dist/{actor-6jsm_v96.js → actor-D2iXzvlN.js} +2 -1
  2. package/dist/{state-DFnmLmfn.js → adapter-AgCNqqsG.js} +49 -133
  3. package/dist/{admin-tmGIw4KS.js → admin-1VwEXztm.js} +2 -2
  4. package/dist/{agent-runner-CneTquAE.js → agent-runner-Ciet8_nn.js} +1067 -1353
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +8 -7
  7. package/dist/api.d.ts +1 -1
  8. package/dist/api.js +125 -43
  9. package/dist/{app-BJojZ7HL.d.ts → app--ky-Eu33.d.ts} +6 -4
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +126 -299
  12. package/dist/{automation-BrP6ImrC.js → automation-M3RFJUBf.js} +1 -1
  13. package/dist/{background-compaction-queue-CwfJy3Cd.js → background-compaction-queue-CnimvRdk.js} +4 -4
  14. package/dist/{briefs-uFTuhMqA.js → briefs-CwzvgdCa.js} +4 -4
  15. package/dist/{catalog-runtime-0kuQqYL4.js → catalog-runtime-DaBaHY7u.js} +1 -1
  16. package/dist/cli/chat.js +17 -17
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +5 -5
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +4 -4
  23. package/dist/{config-Dj9M_nqB.js → config-CAXIpWQb.js} +80 -6
  24. package/dist/{connections-B96JUM5o.js → connections-Dy0hPdUq.js} +6 -6
  25. package/dist/continue-in-slack-DIOjFj76.js +176 -0
  26. package/dist/{conversation-CvcBU1z2.js → conversation-fCWD9Az3.js} +73 -13
  27. package/dist/{conversation-feed-BSMlGZnS.js → conversation-feed-BPK8vkkZ.js} +88 -3
  28. package/dist/{conversation-privacy-DI29jbZV.js → conversation-privacy-DUgtRkf8.js} +1 -1
  29. package/dist/{conversation-turn-CZWBr091.js → conversation-turn-DkJB6yMF.js} +85 -68
  30. package/dist/{credential-sync-Blhx4_xf.js → credential-sync-RX24Y8aY.js} +18 -18
  31. package/dist/{db-CrtyFRz7.d.ts → db-B07FtU9g.d.ts} +1 -1
  32. package/dist/{db-Br0tfAo7.js → db-COYOGzYS.js} +171 -12
  33. package/dist/{executor-BMPipFVA.js → executor-BWmAgSyi.js} +40 -11
  34. package/dist/{media-BepyEUNm.js → history-IjdmO_r6.js} +1 -85
  35. package/dist/instrumentation.js +2 -2
  36. package/dist/lineage-D-5jm_oj.js +37 -0
  37. package/dist/{logging-CQjlDQYX.js → logging-DPLEa8Bn.js} +1 -1
  38. package/dist/media-BAHvgkok.js +85 -0
  39. package/dist/{message-BOZEIuxy.js → message-BIHR1yRk.js} +9 -10
  40. package/dist/model-input-BPZYH8Nd.js +82 -0
  41. package/dist/nitro.d.ts +1 -1
  42. package/dist/nitro.js +17 -9
  43. package/dist/{oauth-callback-server-V_DuMuNX.js → oauth-callback-server-R7qvSzFG.js} +2 -2
  44. package/dist/{plugins-HYh_JOdw.js → plugins-CBW2Prb_.js} +1 -1
  45. package/dist/{projection-B08mfi0u.js → projection-DEdP1q6f.js} +261 -36
  46. package/dist/{prompt-BlutWLNt.js → prompt-4M98h_tC.js} +4 -4
  47. package/dist/{registry-BDWgCJDf.js → registry-BTKmKM-r.js} +3 -3
  48. package/dist/{resolve-2Z_o_SsI.js → resolve-B8hXNVZ3.js} +3 -3
  49. package/dist/{result-CAujiaci.js → result-g-XAaOj6.js} +158 -69
  50. package/dist/{runner-D2Chc02N.js → runner-BlPSA5A8.js} +9 -9
  51. package/dist/{sandbox-egress-signals-CFoJduFj.js → sandbox-egress-signals-Pai-MzEY.js} +1 -1
  52. package/dist/{schema-Bqa5NbcP.js → schema-BNnY_trV.js} +47 -7
  53. package/dist/{schema-Ce2XCS7O.d.ts → schema-DbuWR-DN.d.ts} +663 -346
  54. package/dist/{service-account-C9kRQEb_.js → service-account-9OLNQMyz.js} +4 -4
  55. package/dist/{service-account-CERfXEVU.js → service-account-BYGZ08DQ.js} +3 -3
  56. package/dist/session-stop-2XJrcNCy.js +3356 -0
  57. package/dist/{skills-B0m1nZ_j.js → skills-DpBQoeHV.js} +3 -3
  58. package/dist/slack-conversation-unfurl-BcDIWo67.js +370 -0
  59. package/dist/spawn-09GssFod.js +73 -0
  60. package/dist/state-Cufq0_rH.js +132 -0
  61. package/dist/{user-input-request-CXNIov9n.js → statuses-B8mUfghF.js} +30 -25
  62. package/dist/{stop-BCH9VNGf.js → stop-U7iUrR1g.js} +6011 -5773
  63. package/dist/{store-B59rOYbS.js → store-BHiaHCQu.js} +24 -4
  64. package/dist/{store-m5bmdmsP.js → store-CSgUTMdv.js} +10 -10
  65. package/dist/{task-queue-N0kuCknH.js → task-queue-bMNq0clp.js} +4 -4
  66. package/dist/{task-runner-COOwR8qm.js → task-runner-B__rxwxU.js} +10 -10
  67. package/dist/{thread-context-Cd44z_W5.js → thread-context-d0ceWbVT.js} +18 -18
  68. package/dist/{turn-session-routing-BlCtVFRN.js → turn-session-routing-BVZHBFCF.js} +5 -5
  69. package/dist/turn-user-message-BEw7acTP.js +355 -0
  70. package/dist/users-BK3dbxZL.js +424 -0
  71. package/dist/{validation-Ba2OcUse.js → validation-BDVJjO2E.js} +1 -1
  72. package/dist/{version-KNDzIAh6.js → version-DQgZoQ3D.js} +1 -1
  73. package/dist/version.js +1 -1
  74. package/dist/{viewer-BPpuN2f9.js → viewer-CAWfFo29.js} +25 -54
  75. package/dist/{warmup-Bskrwmk1.js → warmup-9ySPacF9.js} +1137 -143
  76. package/dist/{worker-B1skZlit.js → worker-D8jJO-WO.js} +8 -7
  77. package/migrations/0104_code_change_draft.sql +1 -0
  78. package/migrations/0105_attachment_uploads.sql +14 -0
  79. package/migrations/0106_conversation_agent_config.sql +1 -0
  80. package/migrations/meta/0104_snapshot.json +4516 -0
  81. package/migrations/meta/0105_snapshot.json +4611 -0
  82. package/migrations/meta/0106_snapshot.json +4617 -0
  83. package/migrations/meta/_journal.json +21 -0
  84. package/package.json +4 -4
  85. package/dist/attempt-selection-ClP3MMPr.js +0 -61
  86. package/dist/locks-D-0h111u.js +0 -48
  87. package/dist/notification-gusCgdQ6.js +0 -1284
  88. package/dist/prompt-input-Dxn8cDC0.js +0 -1424
  89. package/dist/session-stop-B-I1rAS1.js +0 -181
  90. package/dist/spawn-CwMjRRtn.js +0 -80
  91. package/dist/turn-cancel-DDu8TOwt.js +0 -201
  92. package/dist/turn-user-message-ygLG3ylQ.js +0 -641
  93. package/dist/turn-wake-DmQec4AG.js +0 -161
  94. package/dist/{oauth-relay-CsfIazeF.js → oauth-relay-DRzq73b6.js} +1 -1
package/dist/cli/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-CneTquAE.js";
1
+ import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-Ciet8_nn.js";
2
2
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
3
3
  import path from "node:path";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -98,11 +98,11 @@ async function loadLocalPluginSet() {
98
98
  /** Configure plugin hooks after local chat has selected its state adapter. */
99
99
  async function configureLocalChatPlugins(pluginSet) {
100
100
  const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
101
- import("../plugins-HYh_JOdw.js").then((n) => n.o),
102
- import("../projection-B08mfi0u.js").then((n) => n.qn),
103
- import("../catalog-runtime-0kuQqYL4.js").then((n) => n.t),
104
- import("../validation-Ba2OcUse.js").then((n) => n.r),
105
- import("../db-Br0tfAo7.js").then((n) => n.n)
101
+ import("../plugins-CBW2Prb_.js").then((n) => n.o),
102
+ import("../projection-DEdP1q6f.js").then((n) => n.nr),
103
+ import("../catalog-runtime-DaBaHY7u.js").then((n) => n.t),
104
+ import("../validation-BDVJjO2E.js").then((n) => n.r),
105
+ import("../db-COYOGzYS.js").then((n) => n.n)
106
106
  ]);
107
107
  const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
108
108
  const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
@@ -152,19 +152,19 @@ function localDevServerUrl() {
152
152
  async function prepareLocalChatRun(io, pluginSet) {
153
153
  defaultStateAdapterForLocalChat();
154
154
  await configureLocalChatPlugins(pluginSet);
155
- const { setBriefsConfig } = await import("../projection-B08mfi0u.js").then((n) => n.or);
155
+ const { setBriefsConfig } = await import("../projection-DEdP1q6f.js").then((n) => n.hr);
156
156
  setBriefsConfig({ enabled: true });
157
- const { runLocalAgentTurn } = await import("../runner-D2Chc02N.js");
158
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-V_DuMuNX.js");
159
- const { createLocalOAuthState } = await import("../oauth-relay-CsfIazeF.js").then((n) => n.t);
160
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-CFoJduFj.js");
161
- const { bindSpawnAgent } = await import("../spawn-CwMjRRtn.js").then((n) => n.n);
162
- const { bindMessageAgent } = await import("../message-BOZEIuxy.js").then((n) => n.n);
163
- const { createChildConversationWorker, createDeliverToParent } = await import("../result-CAujiaci.js").then((n) => n.o);
164
- const { createConversationTurnWorker } = await import("../conversation-turn-CZWBr091.js").then((n) => n.t);
165
- const { skipInputAfterConversationStop } = await import("../session-stop-B-I1rAS1.js").then((n) => n.a);
157
+ const { runLocalAgentTurn } = await import("../runner-BlPSA5A8.js");
158
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-R7qvSzFG.js");
159
+ const { createLocalOAuthState } = await import("../oauth-relay-DRzq73b6.js").then((n) => n.t);
160
+ const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-Pai-MzEY.js");
161
+ const { bindSpawnAgent } = await import("../spawn-09GssFod.js").then((n) => n.n);
162
+ const { bindMessageAgent } = await import("../message-BIHR1yRk.js").then((n) => n.n);
163
+ const { createChildConversationWorker, createDeliverToParent } = await import("../result-g-XAaOj6.js").then((n) => n.o);
164
+ const { createConversationTurnWorker } = await import("../conversation-turn-DkJB6yMF.js").then((n) => n.t);
165
+ const { skipInputAfterConversationStop } = await import("../session-stop-2XJrcNCy.js").then((n) => n.a);
166
166
  const { createLocalConversationWork } = await import("../conversation-work-BaT_T6EB.js");
167
- const { processConversationWork } = await import("../worker-B1skZlit.js").then((n) => n.n);
167
+ const { processConversationWork } = await import("../worker-D8jJO-WO.js").then((n) => n.n);
168
168
  let agentRunner;
169
169
  const localConversationWork = createLocalConversationWork(async (message) => {
170
170
  if (!agentRunner) throw new Error("Local agent runner is not ready");
package/dist/cli/check.js CHANGED
@@ -1,6 +1,6 @@
1
- import { N as JUNIOR_HEARTBEAT_ROUTE, R as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-CQjlDQYX.js";
2
- import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-BDWgCJDf.js";
3
- import { i as parseSkillFile } from "../skills-B0m1nZ_j.js";
1
+ import { N as JUNIOR_HEARTBEAT_ROUTE, R as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-DPLEa8Bn.js";
2
+ import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-BTKmKM-r.js";
3
+ import { i as parseSkillFile } from "../skills-DpBQoeHV.js";
4
4
  import path from "node:path";
5
5
  import fs from "node:fs/promises";
6
6
  import { pathToFileURL } from "node:url";
package/dist/cli/main.js CHANGED
@@ -45,13 +45,13 @@ async function runChat(argv, pluginSet) {
45
45
  return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
46
46
  }
47
47
  async function runAdmin(argv) {
48
- return await (await import("../admin-tmGIw4KS.js")).runAdmin(argv);
48
+ return await (await import("../admin-1VwEXztm.js")).runAdmin(argv);
49
49
  }
50
50
  async function runServiceAccount(argv) {
51
- return await (await import("../service-account-CERfXEVU.js")).runServiceAccount(argv);
51
+ return await (await import("../service-account-BYGZ08DQ.js")).runServiceAccount(argv);
52
52
  }
53
53
  async function runBriefs(argv) {
54
- return await (await import("../briefs-uFTuhMqA.js")).runBriefs(argv);
54
+ return await (await import("../briefs-CwzvgdCa.js")).runBriefs(argv);
55
55
  }
56
56
  function topLevelCommand(argv) {
57
57
  return (argv[0] === "--" ? argv.slice(1) : argv)[0];
@@ -1,8 +1,8 @@
1
- import { fo as createPluginLogger, ir as validatePlugins, rr as setPlugins } from "../projection-B08mfi0u.js";
2
- import { o as getDb } from "../db-Br0tfAo7.js";
3
- import { n as pluginCatalogRuntime } from "../catalog-runtime-0kuQqYL4.js";
4
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-Ba2OcUse.js";
5
- import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-HYh_JOdw.js";
1
+ import { Oo as createPluginLogger, fr as setPlugins, pr as validatePlugins } from "../projection-DEdP1q6f.js";
2
+ import { o as getDb } from "../db-COYOGzYS.js";
3
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-DaBaHY7u.js";
4
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-BDVJjO2E.js";
5
+ import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-CBW2Prb_.js";
6
6
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
7
7
  import { stderr, stdout } from "node:process";
8
8
  import { createJiti } from "jiti";
@@ -1,7 +1,7 @@
1
- import { Vi as create, qa as SANDBOX_RUNTIME } from "../projection-B08mfi0u.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-0kuQqYL4.js";
3
- import { r as disconnectStateAdapter } from "../state-DFnmLmfn.js";
4
- import { n as resolve } from "../resolve-2Z_o_SsI.js";
1
+ import { Qi as create, so as SANDBOX_RUNTIME } from "../projection-DEdP1q6f.js";
2
+ import { t as disconnectStateAdapter } from "../adapter-AgCNqqsG.js";
3
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-DaBaHY7u.js";
4
+ import { n as resolve } from "../resolve-B8hXNVZ3.js";
5
5
  // src/cli/snapshot-create.ts
6
6
  const DEFAULT_TIMEOUT_MS = 6e5;
7
7
  function progressMessage(phase) {
@@ -1,4 +1,4 @@
1
- import "../db-CrtyFRz7.js";
1
+ import "../db-B07FtU9g.js";
2
2
  import { n as JuniorPluginSet } from "../plugins-B_0Cr0MO.js";
3
3
  interface UpgradeIo {
4
4
  info: (line: string) => void;
@@ -1,7 +1,7 @@
1
- import { i as getChatConfig } from "../config-Dj9M_nqB.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-BMPipFVA.js";
3
- import { t as createPluginCatalogRuntime } from "../registry-BDWgCJDf.js";
4
- import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-HYh_JOdw.js";
1
+ import { i as getChatConfig } from "../config-CAXIpWQb.js";
2
+ import { t as createJuniorSqlExecutor } from "../executor-BWmAgSyi.js";
3
+ import { t as createPluginCatalogRuntime } from "../registry-BTKmKM-r.js";
4
+ import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-CBW2Prb_.js";
5
5
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
6
6
  import { basename, dirname, join, resolve } from "node:path";
7
7
  import { createHash } from "node:crypto";
@@ -1,15 +1,15 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-CQjlDQYX.js";
3
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-DI29jbZV.js";
2
+ import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-DPLEa8Bn.js";
3
+ import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-DUgtRkf8.js";
4
4
  import { AwsClient } from "aws4fetch";
5
- import { del, get, put } from "@vercel/blob";
5
+ import { del, get, issueSignedToken, presignUrl, put } from "@vercel/blob";
6
+ import * as z from "zod";
6
7
  import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
7
8
  import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
8
9
  import { createGatewayProvider } from "@ai-sdk/gateway";
9
10
  import { getVercelOidcToken } from "@vercel/oidc";
10
11
  import { Experimental_DecisionRefusalError, NoObjectGeneratedError, embedMany, experimental_decide, generateObject, rerank } from "ai";
11
12
  import { createHash } from "node:crypto";
12
- import * as z from "zod";
13
13
  // src/chat/optional-string.ts
14
14
  /**
15
15
  * Normalize optional env-style strings so blank values do not masquerade as
@@ -50,6 +50,16 @@ function createMemoryAttachmentStorage() {
50
50
  };
51
51
  }
52
52
  // src/chat/attachments/vercel.ts
53
+ const BLOB_API_VERSION = "12";
54
+ const delegationPayloadSchema = z.object({ storeId: z.string().min(1) });
55
+ /**
56
+ * Read the store id from a delegation token, as the SDK does for its own
57
+ * presigned requests. The token payload is base64url JSON before the dot.
58
+ */
59
+ function delegationStoreId(delegationToken) {
60
+ const { storeId } = delegationPayloadSchema.parse(JSON.parse(Buffer.from(delegationToken.split(".")[0] ?? "", "base64url").toString()));
61
+ return storeId.replace(/^store_/, "");
62
+ }
53
63
  /** Store private conversation attachments in Vercel Blob. */
54
64
  function createVercelAttachmentStorage() {
55
65
  return {
@@ -62,6 +72,36 @@ function createVercelAttachmentStorage() {
62
72
  contentType: input.contentType
63
73
  });
64
74
  },
75
+ async createUploadTarget(input) {
76
+ const limits = {
77
+ allowedContentTypes: [input.contentType],
78
+ maximumSizeInBytes: input.bytes,
79
+ validUntil: input.expiresAtMs
80
+ };
81
+ const token = await issueSignedToken({
82
+ ...limits,
83
+ operations: ["put"],
84
+ pathname: input.key
85
+ });
86
+ const { presignedUrl } = await presignUrl(token, {
87
+ ...limits,
88
+ access: "private",
89
+ addRandomSuffix: false,
90
+ allowOverwrite: false,
91
+ operation: "put",
92
+ pathname: input.key
93
+ });
94
+ return {
95
+ headers: {
96
+ "x-api-version": BLOB_API_VERSION,
97
+ "x-content-type": input.contentType,
98
+ "x-vercel-blob-access": "private",
99
+ "x-vercel-blob-store-id": delegationStoreId(token.delegationToken)
100
+ },
101
+ method: "PUT",
102
+ url: presignedUrl
103
+ };
104
+ },
65
105
  async get(key, range) {
66
106
  const result = await get(key, {
67
107
  access: "private",
@@ -168,6 +208,29 @@ function createS3AttachmentStorage(config) {
168
208
  method: "PUT"
169
209
  }), "put");
170
210
  },
211
+ async createUploadTarget(input) {
212
+ const url = new URL(objectUrl(config, input.key));
213
+ url.searchParams.set("X-Amz-Expires", String(Math.max(1, Math.ceil((input.expiresAtMs - Date.now()) / 1e3))));
214
+ const browserHeaders = {
215
+ "content-type": input.contentType,
216
+ "if-none-match": "*"
217
+ };
218
+ return {
219
+ headers: browserHeaders,
220
+ method: "PUT",
221
+ url: (await client.sign(url.toString(), {
222
+ aws: {
223
+ allHeaders: true,
224
+ signQuery: true
225
+ },
226
+ headers: {
227
+ ...browserHeaders,
228
+ "content-length": String(input.bytes)
229
+ },
230
+ method: "PUT"
231
+ })).url
232
+ };
233
+ },
171
234
  async get(key, range) {
172
235
  const response = await client.fetch(objectUrl(config, key), range ? { headers: { range: rangeHeader(range) } } : void 0);
173
236
  if (response.status === 404) {
@@ -1220,6 +1283,16 @@ function bestEffortObjectCompletionCost(modelId, usage) {
1220
1283
  return;
1221
1284
  }
1222
1285
  }
1286
+ /**
1287
+ * Keep only the fixed message and stack of a failed structured output. The SDK
1288
+ * error's `text` and its parse or validation cause hold the raw model output.
1289
+ */
1290
+ function structuredOutputErrorCause(error) {
1291
+ const cause = new Error(error.message);
1292
+ cause.name = error.name;
1293
+ cause.stack = error.stack;
1294
+ return cause;
1295
+ }
1223
1296
  /** Execute a schema-constrained completion using the AI SDK structured output path. */
1224
1297
  async function completeObject(params) {
1225
1298
  const credential = await resolveGatewayCredential();
@@ -1253,10 +1326,11 @@ async function completeObject(params) {
1253
1326
  ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : void 0
1254
1327
  });
1255
1328
  } catch (error) {
1256
- throw createProviderError(error, {
1257
- ...NoObjectGeneratedError.isInstance(error) ? { kind: "invalid_response" } : void 0,
1329
+ if (NoObjectGeneratedError.isInstance(error)) throw createProviderError(structuredOutputErrorCause(error), {
1330
+ kind: "invalid_response",
1258
1331
  modelId: params.modelId
1259
1332
  });
1333
+ throw createProviderError(error, { modelId: params.modelId });
1260
1334
  }
1261
1335
  const costUsd = bestEffortObjectCompletionCost(params.modelId, result.usage);
1262
1336
  return {
@@ -1,9 +1,9 @@
1
- import { Qi as startOAuthFlow } from "./projection-B08mfi0u.js";
2
- import { n as botConfig } from "./config-Dj9M_nqB.js";
3
- import { I as deleteProviderIdentityForSlackUser, L as deleteProviderIdentityForUser, s as getSqlExecutor } from "./db-Br0tfAo7.js";
4
- import { u as hasRequiredOAuthScope } from "./registry-BDWgCJDf.js";
5
- import { n as pluginCatalogRuntime } from "./catalog-runtime-0kuQqYL4.js";
6
- import { c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-CneTquAE.js";
1
+ import { la as startOAuthFlow } from "./projection-DEdP1q6f.js";
2
+ import { n as botConfig } from "./config-CAXIpWQb.js";
3
+ import { F as deleteProviderIdentityForSlackUser, I as deleteProviderIdentityForUser, s as getSqlExecutor } from "./db-COYOGzYS.js";
4
+ import { u as hasRequiredOAuthScope } from "./registry-BTKmKM-r.js";
5
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-DaBaHY7u.js";
6
+ import { c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-Ciet8_nn.js";
7
7
  import { randomBytes } from "node:crypto";
8
8
  // src/handlers/oauth-html.ts
9
9
  /** Build pre-escaped callback HTML with the shared response security policy. */
@@ -0,0 +1,176 @@
1
+ import { Lt as moveIdleConversationDestination, Oi as getDashboardConversationLink, Vo as readLatestConversationBrief, ba as getSlackMessagePermalink, da as escapeSlackMrkdwnText, fa as formatSlackLink, wa as postSlackMessage, ya as deleteSlackMessage } from "./projection-DEdP1q6f.js";
2
+ import { u as parseSlackChannelId, v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
3
+ import { G as claimProviderConversation, K as getConversationIdByProviderConversation, a as getConversationStore, k as setFirstConversationLocation, o as getDb, s as getSqlExecutor, x as withConversationMutationLock } from "./db-COYOGzYS.js";
4
+ import { P as juniorDestinations } from "./executor-BWmAgSyi.js";
5
+ import { r as getStateAdapter } from "./adapter-AgCNqqsG.js";
6
+ import "./store-BHiaHCQu.js";
7
+ import { c as joinPublicChannelForRead, s as checkSlackChannelReadAccess } from "./users-BK3dbxZL.js";
8
+ import { and, eq } from "drizzle-orm";
9
+ // src/chat/slack/continue-in-slack.ts
10
+ /** Refusal for a move that cannot wait for the active Run. */
11
+ const BUSY = "Wait for Junior to finish, then try again.";
12
+ const THREAD_TAKEN = "This thread already has a Junior conversation.";
13
+ const MOVED_ELSEWHERE = /* @__PURE__ */ new Error("Conversation already has a Location");
14
+ /**
15
+ * Return whether a Conversation can still move to a Slack thread.
16
+ *
17
+ * Only a dashboard root with no Location qualifies. The move is one-way, so
18
+ * a Conversation that has a Location never qualifies again.
19
+ */
20
+ function isMovableToSlack(conversation) {
21
+ return conversation.conversationId.startsWith("local:web:") && !conversation.location && !conversation.parentConversationId;
22
+ }
23
+ /** Return whether a viewer can move this public Conversation to Slack. */
24
+ function canContinueInSlack(conversation, access) {
25
+ return access?.isParticipant === true && access.visibility === "public" && isMovableToSlack(conversation);
26
+ }
27
+ /** Text for the first message of the Conversation in Slack. */
28
+ async function movedMessageText(conversation, actorName) {
29
+ const title = conversation.title ?? "Junior conversation";
30
+ const url = getDashboardConversationLink(conversation.conversationId);
31
+ const brief = await readLatestConversationBrief(getDb(), conversation.conversationId);
32
+ return [
33
+ `*${url ? formatSlackLink(url, title) : escapeSlackMrkdwnText(title)}*`,
34
+ ...brief ? [`> ${escapeSlackMrkdwnText(brief.content.summary)}`] : [],
35
+ `${escapeSlackMrkdwnText(actorName)} moved this conversation here from the dashboard. Mention me in this thread to continue.`
36
+ ].join("\n");
37
+ }
38
+ /** Make sure Junior can post in a public channel, then post there. */
39
+ async function postMovedMessage(channel, text, threadTs) {
40
+ const access = await checkSlackChannelReadAccess({
41
+ currentChannelIds: [],
42
+ targetChannelId: channel.channelId,
43
+ teamId: channel.teamId
44
+ });
45
+ if (!access.allowed) return { refused: access.reason === "private" ? "Only a public channel can be chosen." : access.error };
46
+ const channelName = access.channelName ?? channel.channelName;
47
+ if (access.isMember !== true) {
48
+ const joined = await joinPublicChannelForRead({
49
+ targetChannelId: channel.channelId,
50
+ ...channelName ? { channelName } : void 0
51
+ });
52
+ if (!joined.ok) return { refused: joined.error };
53
+ }
54
+ const posted = await postSlackMessage({
55
+ channelId: channel.channelId,
56
+ includePermalink: true,
57
+ text,
58
+ ...threadTs ? { threadTs } : void 0
59
+ });
60
+ return {
61
+ ...channelName ? { channelName } : void 0,
62
+ ...posted.permalink ? { permalink: posted.permalink } : void 0,
63
+ ts: posted.ts
64
+ };
65
+ }
66
+ async function readChannelLocationId(channel) {
67
+ const [row] = await getDb().select({ id: juniorDestinations.id }).from(juniorDestinations).where(and(eq(juniorDestinations.provider, "slack"), eq(juniorDestinations.providerTenantId, channel.teamId), eq(juniorDestinations.providerDestinationId, channel.channelId)));
68
+ if (!row) throw new Error("Slack channel Location was not stored");
69
+ return row.id;
70
+ }
71
+ /** Say which Slack thread a Conversation that already moved continues in. */
72
+ async function alreadyContinuesInSlackMessage(conversation) {
73
+ const { location } = conversation;
74
+ const channelId = location?.provider === "slack" ? parseSlackChannelId(location.channelId) : void 0;
75
+ const threadTs = parseSlackMessageTs(location?.provider === "slack" ? location.threadTs : void 0);
76
+ const url = channelId && threadTs ? await getSlackMessagePermalink({
77
+ channelId,
78
+ messageTs: threadTs
79
+ }) : void 0;
80
+ const place = conversation.channelName ? `#${conversation.channelName}` : "Slack";
81
+ return url ? `This conversation already continues in ${place}: ${url}` : `This conversation already continues in ${place}.`;
82
+ }
83
+ /**
84
+ * Move a qualifying dashboard Conversation to a public Slack channel thread.
85
+ *
86
+ * With `threadTs`, Junior replies in that existing thread. Without it, Junior
87
+ * starts a new thread. The thread then becomes the Conversation Location and
88
+ * its replies reach this Conversation. Dashboard Messages still get no Slack
89
+ * Delivery. The caller checks who may move it, and runs this inside the
90
+ * Slack installation of `channel.teamId`.
91
+ */
92
+ async function continueConversationInSlack(args) {
93
+ const { channel, conversation } = args;
94
+ const conversationId = conversation.conversationId;
95
+ if (conversation.execution.status === "running" || conversation.execution.status === "paused") return { status: "busy" };
96
+ const executor = getSqlExecutor();
97
+ const binding = (threadTs) => ({
98
+ provider: "slack",
99
+ providerDestinationId: channel.channelId,
100
+ providerTenantId: channel.teamId,
101
+ providerConversationId: threadTs
102
+ });
103
+ if (args.threadTs && await getConversationIdByProviderConversation(executor, binding(args.threadTs))) return {
104
+ message: THREAD_TAKEN,
105
+ status: "refused"
106
+ };
107
+ const posted = await postMovedMessage(channel, await movedMessageText(conversation, args.actorName), args.threadTs);
108
+ if ("refused" in posted) return {
109
+ message: posted.refused,
110
+ status: "refused"
111
+ };
112
+ const threadTs = args.threadTs ?? posted.ts;
113
+ const destination = {
114
+ platform: "slack",
115
+ teamId: channel.teamId,
116
+ channelId: channel.channelId
117
+ };
118
+ await getConversationStore().recordDestinationVisibility({
119
+ destination,
120
+ ...posted.channelName ? { channelName: posted.channelName } : void 0,
121
+ visibility: "public"
122
+ });
123
+ const locationId = await readChannelLocationId(channel);
124
+ let threadTaken = false;
125
+ const moved = await moveIdleConversationDestination({
126
+ conversationId,
127
+ destination,
128
+ move: async () => {
129
+ try {
130
+ return await withConversationMutationLock(executor, conversationId, async () => {
131
+ if (!await claimProviderConversation(executor, {
132
+ conversationId,
133
+ ...binding(threadTs)
134
+ })) {
135
+ threadTaken = true;
136
+ return false;
137
+ }
138
+ if (!await setFirstConversationLocation(executor, {
139
+ ...posted.channelName ? { channelName: posted.channelName } : void 0,
140
+ conversationId,
141
+ location: {
142
+ id: locationId,
143
+ provider: "slack",
144
+ teamId: channel.teamId,
145
+ channelId: channel.channelId,
146
+ threadTs
147
+ }
148
+ })) throw MOVED_ELSEWHERE;
149
+ return true;
150
+ });
151
+ } catch (error) {
152
+ if (error === MOVED_ELSEWHERE) return false;
153
+ throw error;
154
+ }
155
+ }
156
+ });
157
+ if (moved !== "moved") {
158
+ await deleteSlackMessage({
159
+ channelId: channel.channelId,
160
+ timestamp: posted.ts
161
+ });
162
+ if (moved === "busy") return { status: "busy" };
163
+ const current = await getConversationStore().get({ conversationId });
164
+ return {
165
+ message: threadTaken ? THREAD_TAKEN : await alreadyContinuesInSlackMessage(current ?? conversation),
166
+ status: "refused"
167
+ };
168
+ }
169
+ await getStateAdapter().subscribe(`slack:${channel.channelId}:${threadTs}`);
170
+ return {
171
+ ...posted.channelName ? { channelName: posted.channelName } : void 0,
172
+ ...posted.permalink ? { locationUrl: posted.permalink } : void 0,
173
+ status: "moved"
174
+ };
175
+ }
176
+ export { isMovableToSlack as a, continueConversationInSlack as i, alreadyContinuesInSlackMessage as n, canContinueInSlack as r, BUSY as t };
@@ -1,4 +1,4 @@
1
- import { c as conversationTurnFailureCodeSchema, l as conversationTurnFailureReasonSchema, n as INPUT_IMAGE_TYPES, y as usageSchema } from "./media-BepyEUNm.js";
1
+ import { a as conversationTurnFailureReasonSchema, h as usageSchema, i as conversationTurnFailureCodeSchema } from "./history-IjdmO_r6.js";
2
2
  import * as z from "zod";
3
3
  import { codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, objectFactFields, objectTypeSchema } from "@sentry/junior-plugin-api";
4
4
  // src/chat/briefs/schema.ts
@@ -132,14 +132,21 @@ function parseBriefInput(input) {
132
132
  };
133
133
  }
134
134
  // src/chat/attachments/input.ts
135
- /** Bound JSON image input below the hosting platform's request size limit. */
136
- const MAX_INPUT_IMAGE_BYTES = 3145728;
137
- const MAX_INPUT_IMAGES = 3;
138
- /** Image bytes accepted with a web message, never stored in its mailbox row. */
139
- const inputImageSchema = z.object({
135
+ /**
136
+ * Largest file that a web Message can carry.
137
+ *
138
+ * `loadAttachment` reads the whole file into memory before it writes the file
139
+ * to the sandbox, and the message request reads each upload once to check it.
140
+ * Keep this well below function memory.
141
+ */
142
+ const MAX_INPUT_ATTACHMENT_BYTES = 26214400;
143
+ /** Most files on one web Message, as in one Slack message. */
144
+ const MAX_INPUT_ATTACHMENTS = 10;
145
+ /** File facts that a browser declares before it uploads the bytes. */
146
+ const inputFileSchema = z.object({
140
147
  filename: z.string().trim().min(1).max(255),
141
- contentType: z.enum(INPUT_IMAGE_TYPES),
142
- data: z.string().min(4).max(MAX_INPUT_IMAGE_BYTES * 4 / 3).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine((data) => data.length % 4 === 0)
148
+ contentType: z.string().trim().toLowerCase().max(127).regex(/^[a-z0-9][\w.+-]*\/[a-z0-9][\w.+-]*$/),
149
+ bytes: z.number().int().min(1).max(MAX_INPUT_ATTACHMENT_BYTES)
143
150
  }).strict();
144
151
  /** Safe attachment facts shared by mailbox input and transcript messages. */
145
152
  const messageAttachmentSchema = z.object({
@@ -276,6 +283,44 @@ const conversationTitleSchema = z.string().trim().min(1).max(200);
276
283
  const renameConversationBodySchema = z.object({ title: conversationTitleSchema }).strict();
277
284
  /** The stored title after the rename. */
278
285
  const renameConversationResponseSchema = z.object({ title: z.string().min(1) }).strict();
286
+ // src/chat/agent-invocations/agent-types.ts
287
+ /**
288
+ * Child agent types. A type is plain data: when to pick it and what the child
289
+ * reads with its task. Runtime code reads only these fields, never a type
290
+ * name, so types can later come from configuration. Types do not limit tools:
291
+ * Guardian reviews each child action against the root user's messages, as for
292
+ * any child. A child keeps its type for later agent invocations. How a child
293
+ * starts, fresh or forked from its parent's history, is not a type: see
294
+ * `fork` on the agent invocation.
295
+ */
296
+ const AGENT_TYPES = ["explore", "reviewer"];
297
+ /**
298
+ * Stored name of a child agent type. A stored name stays readable after its
299
+ * type is removed; the runtime then treats the child as a
300
+ * child without a type.
301
+ */
302
+ const agentTypeSchema = z.string().regex(/^[a-z][a-z0-9_-]*$/);
303
+ const AGENT_TYPE_DEFINITIONS = {
304
+ explore: {
305
+ whenToUse: "Investigation across code, docs, logs, telemetry, or the web. Use it when an answer needs reading across many files or sources and you need the conclusion with evidence, not the raw output.",
306
+ instructions: "You are an explore agent. Your job is to investigate and report, so do not change anything outside your sandbox unless the task asks for it. Report what you found with exact evidence, such as paths, lines, links, and ids, and say what you could not verify."
307
+ },
308
+ reviewer: {
309
+ whenToUse: "An independent second opinion on a change, plan, or claim. Give it the evidence to judge, not your conclusion.",
310
+ instructions: "You are a reviewer agent. Give an independent assessment. Do not assume that the parent's framing is correct: verify each claim against the evidence. Do not change anything outside your own sandbox. Report concrete problems ranked by severity, each with its evidence, and say clearly when you found none."
311
+ }
312
+ };
313
+ function agentTypeDefinition(type) {
314
+ return type && Object.hasOwn(AGENT_TYPE_DEFINITIONS, type) ? AGENT_TYPE_DEFINITIONS[type] : void 0;
315
+ }
316
+ /** Model-facing list of child agent types. */
317
+ function formatAgentTypes() {
318
+ return AGENT_TYPES.map((type) => `- "${type}": ${AGENT_TYPE_DEFINITIONS[type].whenToUse}`).join("\n");
319
+ }
320
+ /** Return the instructions that a child of this type reads with its task. */
321
+ function agentTypeInstructions(type) {
322
+ return agentTypeDefinition(type)?.instructions;
323
+ }
279
324
  // src/api/schema/child-agent-totals.ts
280
325
  /**
281
326
  * The part of a Conversation total that its child agents spent, at any depth.
@@ -362,14 +407,19 @@ const conversationEventsQuerySchema = z.union([
362
407
  const conversationFeedQuerySchema = z.object({
363
408
  actorEmail: z.string().trim().email().transform((value) => value.toLowerCase()).optional(),
364
409
  codeRepositoryId: z.string().uuid().optional(),
410
+ /** `nextCursor` from the previous page of the same feed. */
411
+ cursor: z.string().min(1).max(500).optional(),
365
412
  q: z.string().trim().max(200).optional(),
366
413
  status: z.enum(["active", "archived"]).default("active")
367
414
  }).strict();
415
+ /** Client key that makes a retried send the same Message. */
416
+ const idempotencyKeySchema = z.string().trim().min(1).max(200);
368
417
  const createConversationMessageBodySchema = z.object({
369
- idempotencyKey: z.string().trim().min(1).max(200),
418
+ idempotencyKey: idempotencyKeySchema,
370
419
  message: z.string().trim().max(32e3),
371
- images: z.array(inputImageSchema).max(3).optional()
372
- }).strict().refine((body) => Boolean(body.message || body.images?.length), "Add a message or an image.").refine((body) => (body.images ?? []).reduce((sum, image) => sum + image.data.length, 0) <= MAX_INPUT_IMAGE_BYTES * 4 / 3, "Images must total 3 MB or less.");
420
+ /** Uploads from `POST /api/conversations/attachment-uploads`. */
421
+ uploadIds: z.array(z.string().min(1).max(64)).max(10).optional()
422
+ }).strict().refine((body) => Boolean(body.message || body.uploadIds?.length), "Add a message or a file.");
373
423
  const createConversationBodySchema = createConversationMessageBodySchema.safeExtend({
374
424
  /** Saved title. Title generation runs only when it is omitted. */
375
425
  title: conversationTitleSchema.optional(),
@@ -851,7 +901,17 @@ const forkConversationResponseSchema = z.object({ conversationId: z.string() }).
851
901
  const conversationAgentTreeNodeSchema = z.object({
852
902
  conversationId: z.string().min(1),
853
903
  kind: conversationKindSchema,
854
- label: z.string().min(1)
904
+ label: z.string().min(1),
905
+ /**
906
+ * Agent type of a child, such as `explore`. Absent for a root, a child
907
+ * without a type, or a viewer who cannot see private content.
908
+ */
909
+ agentType: agentTypeSchema.optional(),
910
+ /**
911
+ * The child started with its parent's history. Absent like `agentType`,
912
+ * or when the child started fresh.
913
+ */
914
+ fork: z.literal(true).optional()
855
915
  }).strict();
856
916
  const conversationEventPageSchema = z.object({
857
917
  events: z.array(conversationReportEventSchema),
@@ -943,4 +1003,4 @@ const conversationDetailReportSchema = conversationSummaryReportSchema.extend({
943
1003
  sentryConversationUrl: z.string().optional(),
944
1004
  sourceTask: conversationSourceTaskSchema.optional()
945
1005
  }).strict().superRefine(validateConversationEvents);
946
- export { renameConversationResponseSchema as A, MAX_INPUT_IMAGE_BYTES as B, createConversationMessageBodySchema as C, CONVERSATION_TITLE_MAX_LENGTH as D, conversationChildAgentTotalsSchema as E, messageCardText as F, briefOutcomeStatusSchema as G, readMessageAttachments as H, readMessageCardRefs as I, parseBriefInput as J, briefResourceLabel as K, removedCardSchema as L, reviewItemChangeRecordSchema as M, annotationCard as N, conversationTitleSchema as O, messageCardRef as P, resolveMessageCards as R, createConversationBodySchema as S, forkConversationResponseSchema as T, briefCodeChangeSchema as U, messageAttachmentSchema as V, briefLinkSchema as W, parseStoredBrief as Y, conversationReportMessageEventSchema as _, conversationActivityPreviewSchema as a, conversationSurfaceSchema as b, conversationDetailQuerySchema as c, conversationEventPageSchema as d, conversationEventsQuerySchema as f, conversationReportEventSchema as g, conversationReportEventDataSchema as h, actorIdentitySchema as i, conversationReadPositionSchema as j, renameConversationBodySchema as k, conversationDetailReportSchema as l, conversationParamsSchema as m, CONVERSATION_VERSION_HEADER as n, conversationAttachmentParamsSchema as o, conversationFeedQuerySchema as p, conversationBriefSchema as q, acceptedConversationMessageSchema as r, conversationAuxiliaryCostsSchema as s, CONVERSATION_DETAIL_VERSION_HEADER as t, conversationEventHistorySchema as u, conversationReportStatusSchema as v, forkConversationBodySchema as w, conversationUsageSchema as x, conversationSummaryReportSchema as y, MAX_INPUT_IMAGES as z };
1006
+ export { conversationBriefSchema as $, agentTypeSchema as A, messageCardText as B, createConversationMessageBodySchema as C, conversationChildAgentTotalsSchema as D, idempotencyKeySchema as E, renameConversationResponseSchema as F, MAX_INPUT_ATTACHMENT_BYTES as G, removedCardSchema as H, conversationReadPositionSchema as I, readMessageAttachments as J, inputFileSchema as K, reviewItemChangeRecordSchema as L, CONVERSATION_TITLE_MAX_LENGTH as M, conversationTitleSchema as N, AGENT_TYPES as O, renameConversationBodySchema as P, briefResourceLabel as Q, annotationCard as R, createConversationBodySchema as S, forkConversationResponseSchema as T, resolveMessageCards as U, readMessageCardRefs as V, MAX_INPUT_ATTACHMENTS as W, briefLinkSchema as X, briefCodeChangeSchema as Y, briefOutcomeStatusSchema as Z, conversationReportMessageEventSchema as _, conversationActivityPreviewSchema as a, conversationSurfaceSchema as b, conversationDetailQuerySchema as c, conversationEventPageSchema as d, parseBriefInput as et, conversationEventsQuerySchema as f, conversationReportEventSchema as g, conversationReportEventDataSchema as h, actorIdentitySchema as i, formatAgentTypes as j, agentTypeInstructions as k, conversationDetailReportSchema as l, conversationParamsSchema as m, CONVERSATION_VERSION_HEADER as n, conversationAttachmentParamsSchema as o, conversationFeedQuerySchema as p, messageAttachmentSchema as q, acceptedConversationMessageSchema as r, conversationAuxiliaryCostsSchema as s, CONVERSATION_DETAIL_VERSION_HEADER as t, parseStoredBrief as tt, conversationEventHistorySchema as u, conversationReportStatusSchema as v, forkConversationBodySchema as w, conversationUsageSchema as x, conversationSummaryReportSchema as y, messageCardRef as z };