@sentry/junior 0.298.0 → 0.300.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 (95) hide show
  1. package/dist/{actor-6jsm_v96.js → actor-D2iXzvlN.js} +2 -1
  2. package/dist/{state-CSuA2J1V.js → adapter-S5UkjNK3.js} +53 -136
  3. package/dist/{admin-BF3DbYGf.js → admin-UrTniSPO.js} +2 -2
  4. package/dist/{agent-runner-Q9GkoerG.js → agent-runner-bY4_0UPm.js} +1444 -1478
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +7 -7
  7. package/dist/api.d.ts +1 -1
  8. package/dist/api.js +382 -68
  9. package/dist/{app-DOg_mCtV.d.ts → app-D-AcIcCV.d.ts} +17 -4
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +148 -483
  12. package/dist/{automation-Cn8qmbdr.js → automation-Dw82oQ-h.js} +2 -2
  13. package/dist/{background-compaction-queue-BZhGFOK6.js → background-compaction-queue-B6U3060-.js} +9 -5
  14. package/dist/{briefs-CQrCRF6-.js → briefs-DqiwWu-n.js} +4 -4
  15. package/dist/{catalog-runtime-DZeD2WbL.js → catalog-runtime-D1oYNv04.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-BOByVnxe.js → config-9nHoFiJP.js} +117 -12
  24. package/dist/{connections-BNN5cJam.js → connections-DZjTN3JC.js} +6 -6
  25. package/dist/continue-in-slack-Dtv7_U42.js +176 -0
  26. package/dist/{conversation-DCkzvxqB.js → conversation-Dyjq2CZ8.js} +36 -13
  27. package/dist/{conversation-feed-CMA12Rjs.js → conversation-feed-CcDxlrlQ.js} +109 -3
  28. package/dist/{conversation-privacy-C0eRxsgb.js → conversation-privacy-D-5HTXjS.js} +1 -1
  29. package/dist/{conversation-turn-D9qvcDX6.js → conversation-turn-Cxl8WZD7.js} +85 -68
  30. package/dist/{credential-sync-B_iUpxGL.js → credential-sync-C49ClwDX.js} +18 -18
  31. package/dist/{db-DoMcnYol.d.ts → db-2resqBh1.d.ts} +1 -1
  32. package/dist/{db-CoMNr2Zm.js → db-BJNo6fK5.js} +176 -12
  33. package/dist/{executor-C-m8VrzX.js → executor-DBIaOeJ_.js} +47 -13
  34. package/dist/{media-BepyEUNm.js → history-IjdmO_r6.js} +1 -85
  35. package/dist/instrumentation.js +14 -5
  36. package/dist/lineage-0dereG7H.js +37 -0
  37. package/dist/{logging-CJTi5niy.js → logging-BIclibct.js} +1 -1
  38. package/dist/{message-Q6_5DAWR.js → message-dkOl-Iii.js} +9 -10
  39. package/dist/model-input-CLo9TaUd.js +82 -0
  40. package/dist/nitro.d.ts +1 -1
  41. package/dist/nitro.js +17 -9
  42. package/dist/{oauth-callback-server-CH5XAyo-.js → oauth-callback-server-WmpjfJgQ.js} +2 -2
  43. package/dist/{plugins-HYh_JOdw.js → plugins-BBX07Jzt.js} +1 -1
  44. package/dist/{projection-BgwEE36_.js → projection-w_X-zi7v.js} +1035 -692
  45. package/dist/{prompt-DXc9DYT9.js → prompt-B1Xw46-S.js} +4 -4
  46. package/dist/{registry-9XwqSnM-.js → registry-BmP5vnlj.js} +4 -4
  47. package/dist/{resolve-DUIAbcRL.js → resolve-goo34bJK.js} +3 -3
  48. package/dist/{result-C2Vn8QGn.js → result-PVBeU0Wf.js} +158 -69
  49. package/dist/{runner-CXGtw-Mc.js → runner-DKrfvNV6.js} +9 -9
  50. package/dist/{sandbox-egress-signals-Di3S_dO7.js → sandbox-egress-signals-DsUcqrI0.js} +1 -1
  51. package/dist/{schema-Dyp7racy.js → schema-C9iNFz5n.js} +51 -7
  52. package/dist/{schema-BnbZ-rKv.d.ts → schema-Dns-sTas.d.ts} +1285 -761
  53. package/dist/{service-account-DM3KBBeG.js → service-account-CMAAloAL.js} +3 -3
  54. package/dist/{service-account-GzAMUQ8a.js → service-account-CmowamcB.js} +4 -4
  55. package/dist/session-stop-BcAXze8a.js +3330 -0
  56. package/dist/{skills-DCK9SD_l.js → skills-DfsazET6.js} +3 -3
  57. package/dist/slack-conversation-unfurl-CzQonuWz.js +370 -0
  58. package/dist/spawn-C7o0FDDp.js +73 -0
  59. package/dist/state-zSilNpbi.js +132 -0
  60. package/dist/{user-input-request-CXNIov9n.js → statuses-Hn-HsOph.js} +115 -26
  61. package/dist/{stop-Dh2DfwpK.js → stop-CFOujp8C.js} +9105 -6007
  62. package/dist/{store-DrA17Fbz.js → store-Dkeis_8o.js} +10 -10
  63. package/dist/{store-B1zepKG8.js → store-E3x2Fg_F.js} +24 -4
  64. package/dist/{task-queue-D1rXWfFN.js → task-queue-D-hCqdZW.js} +4 -4
  65. package/dist/{task-runner-CT4M8oDz.js → task-runner-vohUPLHe.js} +10 -10
  66. package/dist/{thread-context-DnqUkbzN.js → thread-context-BzvdkgI9.js} +18 -18
  67. package/dist/{turn-session-routing-VXDVXLRl.js → turn-session-routing-Bo_LxFum.js} +5 -5
  68. package/dist/turn-user-message-D5RnVmxQ.js +355 -0
  69. package/dist/users-2bggndVg.js +424 -0
  70. package/dist/{validation-zxAJBDDy.js → validation-BbWikeSa.js} +1 -1
  71. package/dist/{version-DcZ40a0g.js → version-GVBMW2jA.js} +1 -1
  72. package/dist/version.js +1 -1
  73. package/dist/{viewer-CgiGjW10.js → viewer-BpxRliyO.js} +36 -163
  74. package/dist/{warmup-CwKbxQLl.js → warmup-BW2qwnal.js} +1140 -145
  75. package/dist/{worker-CbDUzaBA.js → worker-Cbd-iuwZ.js} +25 -20
  76. package/migrations/0104_code_change_draft.sql +1 -0
  77. package/migrations/0105_attachment_uploads.sql +14 -0
  78. package/migrations/0106_conversation_agent_config.sql +1 -0
  79. package/migrations/0107_attachment_deferred_download.sql +2 -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/0107_snapshot.json +4617 -0
  84. package/migrations/meta/_journal.json +28 -0
  85. package/package.json +10 -8
  86. package/dist/attempt-selection-ClP3MMPr.js +0 -61
  87. package/dist/locks-D-0h111u.js +0 -48
  88. package/dist/notification-Bv25xbj0.js +0 -1284
  89. package/dist/prompt-input-BUr4J9RO.js +0 -1424
  90. package/dist/session-stop-D4i7e6iT.js +0 -181
  91. package/dist/spawn-6cX6xE9G.js +0 -80
  92. package/dist/turn-cancel-l460pfGW.js +0 -201
  93. package/dist/turn-user-message-BSPmkm7X.js +0 -608
  94. package/dist/turn-wake-DVFVXyhX.js +0 -161
  95. package/dist/{oauth-relay-CsfIazeF.js → oauth-relay-DRzq73b6.js} +1 -1
@@ -1,5 +1,5 @@
1
1
  import { c as resolveLocalScheduleAtMs, i as getFirstRunAtMs, o as getZonedDateTimeParts, s as isValidTimeZone } from "./schedule-cP0AACm1.js";
2
- import { i as actorIdentitySchema } from "./conversation-DCkzvxqB.js";
2
+ import { i as actorIdentitySchema } from "./conversation-Dyjq2CZ8.js";
3
3
  import * as z from "zod";
4
4
  import { actorUserIdSchema, destinationVisibilitySchema, eventMatchFieldsSchema, eventMatchSchema, eventReachSchema, eventTypeSchema, pluginEventTypeSchema, slackDestinationSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
5
5
  // src/chat/automations/task.ts
@@ -439,7 +439,7 @@ const automationTitleSchema = z.string().trim().min(1).max(60);
439
439
  */
440
440
  const automationInstructionToolSchema = automationTaskTextSchema.describe("Work to perform when the Automation runs. Say what to do, what to post, and when to post nothing. Do not say where to post: the outcomes set that, a run triggered by a Slack message replies in its thread, and each run ends with one message at most. The run does not see this conversation, so words like \"this channel\" or \"here\" will mean nothing then. Where the run reads or changes something, write the exact target, such as a channel mention, a repo, or a link. Call the person who created the Automation \"the Automation creator\", not \"me\"; each run knows who that is. Name every other person with their Slack mention, such as <@U123>, including a requester who did not create the Automation. Preserve the user's scope, targets, and constraints. Do not add permissions or side effects the user did not request.");
441
441
  /** Context input for agent tools. It follows the same rules as an instruction. */
442
- const automationContextToolSchema = automationTaskTextSchema.describe("What a skill run needs beyond the skill, such as a repo, a threshold, or who to tag. Leave out what the skill already says. Follow the same rules as an instruction: do not say where to post, write exact targets, call the creator \"the Automation creator\", and name other people with their Slack mention.");
442
+ const automationContextToolSchema = automationTaskTextSchema.describe("What a skill run needs beyond the skill, such as a repo, a threshold, or who to tag. Leave out what the skill says. Use instruction rules: do not say where to post, write exact targets, call the creator \"the Automation creator\", and tag others as <@U123>.");
443
443
  const automationEditFieldsSchema = z.object({
444
444
  title: automationTitleSchema.optional(),
445
445
  /** Replaces the whole task, so a mode switch drops the other mode's text. */
@@ -1,9 +1,9 @@
1
- import { i as getChatConfig } from "./config-BOByVnxe.js";
2
- import { E as withSpan, h as logWarn, m as logInfo, p as logException } from "./logging-CJTi5niy.js";
1
+ import { i as getChatConfig } from "./config-9nHoFiJP.js";
2
+ import { E as withSpan, h as logWarn, m as logInfo, p as logException } from "./logging-BIclibct.js";
3
3
  import { t as readJuniorSecret } from "./secrets-DebYU866.js";
4
+ import * as z from "zod";
4
5
  import { AsyncLocalStorage } from "node:async_hooks";
5
6
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
6
- import * as z from "zod";
7
7
  import { QueueClient, handleCallback, registerDevConsumer } from "@vercel/queue";
8
8
  // src/chat/queue/bullmq.ts
9
9
  const MAX_ATTEMPTS = 50;
@@ -369,7 +369,7 @@ function cacheWarmupCallback() {
369
369
  maxDeliveries: 1,
370
370
  onRejected: logCacheWarmupRejected,
371
371
  run: async (message) => {
372
- const { runCacheWarmup } = await import("./warmup-CwKbxQLl.js").then((n) => n.o);
372
+ const { runCacheWarmup } = await import("./warmup-BW2qwnal.js").then((n) => n.o);
373
373
  await runCacheWarmup(message);
374
374
  },
375
375
  skip: () => !getChatConfig().cacheWarmingEnabled,
@@ -408,6 +408,10 @@ var ConversationQueueMessageRejectedError = class extends Error {
408
408
  function isConversationQueueMessageRejectedError(error) {
409
409
  return error instanceof ConversationQueueMessageRejectedError;
410
410
  }
411
+ /** Build the idempotency key of a wake that one worker event sends. */
412
+ function nudgeIdempotencyKey(reason, conversationId, nowMs) {
413
+ return `${reason}:${conversationId}:${nowMs}`;
414
+ }
411
415
  // src/chat/task-execution/queue-signing.ts
412
416
  const conversationQueueSign = {
413
417
  context: "junior.conversation_work_queue.v2",
@@ -539,4 +543,4 @@ const vercelBackgroundCompactionQueue = { send: async (message) => {
539
543
  retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3
540
544
  });
541
545
  } };
542
- export { queueCallback as C, verifyQueueMessage as S, getQueueProvider as T, createVercelCacheWarmupCallback as _, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC as a, QUEUE_SIGNATURE_MAX_AGE_MS as b, verifyWorkspaceSnapshotJobMessage as c, verifyConversationQueueMessage as d, ConversationQueueMessageRejectedError as f, cacheWarmupQueueConsumer as g, CACHE_WARMUP_QUEUE_TOPIC as h, verifyBackgroundCompactionMessage as i, getVercelConversationWorkQueue as l, isConversationQueueMessageRejectedError as m, backgroundCompactionId as n, sendNextWorkspaceSnapshotJob as o, conversationQueueMessageSchema as p, vercelBackgroundCompactionQueue as r, sendWorkspaceSnapshotJob as s, BACKGROUND_COMPACTION_QUEUE_TOPIC as t, resolveConversationWorkQueueTopic as u, registerVercelCacheWarmupDevConsumer as v, getTurnRequestDeadline as w, signQueueMessage as x, sendCacheWarmup as y };
546
+ export { verifyQueueMessage as C, getQueueProvider as E, signQueueMessage as S, getTurnRequestDeadline as T, cacheWarmupQueueConsumer as _, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC as a, sendCacheWarmup as b, verifyWorkspaceSnapshotJobMessage as c, verifyConversationQueueMessage as d, ConversationQueueMessageRejectedError as f, CACHE_WARMUP_QUEUE_TOPIC as g, nudgeIdempotencyKey as h, verifyBackgroundCompactionMessage as i, getVercelConversationWorkQueue as l, isConversationQueueMessageRejectedError as m, backgroundCompactionId as n, sendNextWorkspaceSnapshotJob as o, conversationQueueMessageSchema as p, vercelBackgroundCompactionQueue as r, sendWorkspaceSnapshotJob as s, BACKGROUND_COMPACTION_QUEUE_TOPIC as t, resolveConversationWorkQueueTopic as u, createVercelCacheWarmupCallback as v, queueCallback as w, QUEUE_SIGNATURE_MAX_AGE_MS as x, registerVercelCacheWarmupDevConsumer as y };
@@ -1,8 +1,8 @@
1
- import { l as completeObject, n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-DXc9DYT9.js";
2
- import { Q as parseBriefInput, X as briefResourceLabel, d as conversationEventPageSchema, l as conversationDetailReportSchema, q as briefCodeChangeSchema } from "./conversation-DCkzvxqB.js";
1
+ import { l as completeObject, n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-B1Xw46-S.js";
2
+ import { $ as briefResourceLabel, X as briefCodeChangeSchema, f as conversationEventPageSchema, tt as parseBriefInput, u as conversationDetailReportSchema } from "./conversation-Dyjq2CZ8.js";
3
3
  import { CLI_USAGE } from "./cli/run.js";
4
- import path from "node:path";
5
4
  import * as z from "zod";
5
+ import path from "node:path";
6
6
  import { mkdir, readFile, writeFile } from "node:fs/promises";
7
7
  // src/chat/briefs/render.ts
8
8
  function list(items, empty) {
@@ -262,7 +262,7 @@ async function parseRunOptions(argv) {
262
262
  * token.
263
263
  */
264
264
  async function configuredBriefModelId() {
265
- const { botConfig } = await import("./config-BOByVnxe.js").then((n) => n.r);
265
+ const { botConfig } = await import("./config-9nHoFiJP.js").then((n) => n.r);
266
266
  return botConfig.fastModelId;
267
267
  }
268
268
  function apiUrl(baseUrl, pathname) {
@@ -1,5 +1,5 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { t as createPluginCatalogRuntime } from "./registry-9XwqSnM-.js";
2
+ import { t as createPluginCatalogRuntime } from "./registry-BmP5vnlj.js";
3
3
  // src/chat/plugins/catalog-runtime.ts
4
4
  var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
5
5
  const pluginCatalogRuntime = createPluginCatalogRuntime();
package/dist/cli/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-Q9GkoerG.js";
1
+ import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-bY4_0UPm.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-BgwEE36_.js").then((n) => n.qn),
103
- import("../catalog-runtime-DZeD2WbL.js").then((n) => n.t),
104
- import("../validation-zxAJBDDy.js").then((n) => n.r),
105
- import("../db-CoMNr2Zm.js").then((n) => n.n)
101
+ import("../plugins-BBX07Jzt.js").then((n) => n.o),
102
+ import("../projection-w_X-zi7v.js").then((n) => n.nr),
103
+ import("../catalog-runtime-D1oYNv04.js").then((n) => n.t),
104
+ import("../validation-BbWikeSa.js").then((n) => n.r),
105
+ import("../db-BJNo6fK5.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-BgwEE36_.js").then((n) => n.or);
155
+ const { setBriefsConfig } = await import("../projection-w_X-zi7v.js").then((n) => n.hr);
156
156
  setBriefsConfig({ enabled: true });
157
- const { runLocalAgentTurn } = await import("../runner-CXGtw-Mc.js");
158
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-CH5XAyo-.js");
159
- const { createLocalOAuthState } = await import("../oauth-relay-CsfIazeF.js").then((n) => n.t);
160
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-Di3S_dO7.js");
161
- const { bindSpawnAgent } = await import("../spawn-6cX6xE9G.js").then((n) => n.n);
162
- const { bindMessageAgent } = await import("../message-Q6_5DAWR.js").then((n) => n.n);
163
- const { createChildConversationWorker, createDeliverToParent } = await import("../result-C2Vn8QGn.js").then((n) => n.o);
164
- const { createConversationTurnWorker } = await import("../conversation-turn-D9qvcDX6.js").then((n) => n.t);
165
- const { skipInputAfterConversationStop } = await import("../session-stop-D4i7e6iT.js").then((n) => n.a);
157
+ const { runLocalAgentTurn } = await import("../runner-DKrfvNV6.js");
158
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-WmpjfJgQ.js");
159
+ const { createLocalOAuthState } = await import("../oauth-relay-DRzq73b6.js").then((n) => n.t);
160
+ const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-DsUcqrI0.js");
161
+ const { bindSpawnAgent } = await import("../spawn-C7o0FDDp.js").then((n) => n.n);
162
+ const { bindMessageAgent } = await import("../message-dkOl-Iii.js").then((n) => n.n);
163
+ const { createChildConversationWorker, createDeliverToParent } = await import("../result-PVBeU0Wf.js").then((n) => n.o);
164
+ const { createConversationTurnWorker } = await import("../conversation-turn-Cxl8WZD7.js").then((n) => n.t);
165
+ const { skipInputAfterConversationStop } = await import("../session-stop-BcAXze8a.js").then((n) => n.a);
166
166
  const { createLocalConversationWork } = await import("../conversation-work-BaT_T6EB.js");
167
- const { processConversationWork } = await import("../worker-CbDUzaBA.js").then((n) => n.n);
167
+ const { processConversationWork } = await import("../worker-Cbd-iuwZ.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-CJTi5niy.js";
2
- import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-9XwqSnM-.js";
3
- import { i as parseSkillFile } from "../skills-DCK9SD_l.js";
1
+ import { N as JUNIOR_HEARTBEAT_ROUTE, R as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-BIclibct.js";
2
+ import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-BmP5vnlj.js";
3
+ import { i as parseSkillFile } from "../skills-DfsazET6.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-BF3DbYGf.js")).runAdmin(argv);
48
+ return await (await import("../admin-UrTniSPO.js")).runAdmin(argv);
49
49
  }
50
50
  async function runServiceAccount(argv) {
51
- return await (await import("../service-account-DM3KBBeG.js")).runServiceAccount(argv);
51
+ return await (await import("../service-account-CMAAloAL.js")).runServiceAccount(argv);
52
52
  }
53
53
  async function runBriefs(argv) {
54
- return await (await import("../briefs-CQrCRF6-.js")).runBriefs(argv);
54
+ return await (await import("../briefs-DqiwWu-n.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-BgwEE36_.js";
2
- import { o as getDb } from "../db-CoMNr2Zm.js";
3
- import { n as pluginCatalogRuntime } from "../catalog-runtime-DZeD2WbL.js";
4
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-zxAJBDDy.js";
5
- import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-HYh_JOdw.js";
1
+ import { fr as setPlugins, ho as createPluginLogger, pr as validatePlugins } from "../projection-w_X-zi7v.js";
2
+ import { o as getDb } from "../db-BJNo6fK5.js";
3
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-D1oYNv04.js";
4
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-BbWikeSa.js";
5
+ import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-BBX07Jzt.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-BgwEE36_.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-DZeD2WbL.js";
3
- import { r as disconnectStateAdapter } from "../state-CSuA2J1V.js";
4
- import { n as resolve } from "../resolve-DUIAbcRL.js";
1
+ import { $i as create, Ya as SANDBOX_RUNTIME } from "../projection-w_X-zi7v.js";
2
+ import { t as disconnectStateAdapter } from "../adapter-S5UkjNK3.js";
3
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-D1oYNv04.js";
4
+ import { n as resolve } from "../resolve-goo34bJK.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-DoMcnYol.js";
1
+ import "../db-2resqBh1.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-BOByVnxe.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-C-m8VrzX.js";
3
- import { t as createPluginCatalogRuntime } from "../registry-9XwqSnM-.js";
4
- import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-HYh_JOdw.js";
1
+ import { i as getChatConfig } from "../config-9nHoFiJP.js";
2
+ import { t as createJuniorSqlExecutor } from "../executor-DBIaOeJ_.js";
3
+ import { t as createPluginCatalogRuntime } from "../registry-BmP5vnlj.js";
4
+ import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-BBX07Jzt.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-CJTi5niy.js";
3
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-C0eRxsgb.js";
2
+ import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-BIclibct.js";
3
+ import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-D-5HTXjS.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
@@ -33,7 +33,7 @@ function createMemoryAttachmentStorage() {
33
33
  objects,
34
34
  provider: "memory",
35
35
  async put(input) {
36
- objects.set(input.key, Buffer.from(input.body));
36
+ objects.set(input.key, Buffer.from(await new Response(input.body).arrayBuffer()));
37
37
  },
38
38
  async get(key, range) {
39
39
  const body = objects.get(key);
@@ -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",
@@ -82,6 +122,13 @@ function createVercelAttachmentStorage() {
82
122
  };
83
123
  }
84
124
  // src/chat/attachments/storage.ts
125
+ /** Stream bytes that are already in memory to `AttachmentStorage.put`. */
126
+ function bufferBody(data) {
127
+ return new ReadableStream({ start(controller) {
128
+ controller.enqueue(data);
129
+ controller.close();
130
+ } });
131
+ }
85
132
  /** Build the HTTP `Range` request header value for one byte range. */
86
133
  function rangeHeader(range) {
87
134
  return `bytes=${range.start}-${range.end}`;
@@ -159,15 +206,49 @@ function createS3AttachmentStorage(config) {
159
206
  secretAccessKey: config.secretAccessKey,
160
207
  service: "s3"
161
208
  });
209
+ const writeClient = new AwsClient({
210
+ accessKeyId: config.accessKeyId,
211
+ region: config.region,
212
+ retries: 0,
213
+ secretAccessKey: config.secretAccessKey,
214
+ service: "s3"
215
+ });
162
216
  return {
163
217
  provider: "s3",
164
218
  async put(input) {
165
- await expectOk(await client.fetch(objectUrl(config, input.key), {
166
- body: new Uint8Array(input.body),
167
- headers: { "content-type": input.contentType },
219
+ await expectOk(await writeClient.fetch(objectUrl(config, input.key), {
220
+ body: input.body,
221
+ headers: {
222
+ "content-length": String(input.bytes),
223
+ "content-type": input.contentType,
224
+ "x-amz-content-sha256": "UNSIGNED-PAYLOAD"
225
+ },
168
226
  method: "PUT"
169
227
  }), "put");
170
228
  },
229
+ async createUploadTarget(input) {
230
+ const url = new URL(objectUrl(config, input.key));
231
+ url.searchParams.set("X-Amz-Expires", String(Math.max(1, Math.ceil((input.expiresAtMs - Date.now()) / 1e3))));
232
+ const browserHeaders = {
233
+ "content-type": input.contentType,
234
+ "if-none-match": "*"
235
+ };
236
+ return {
237
+ headers: browserHeaders,
238
+ method: "PUT",
239
+ url: (await client.sign(url.toString(), {
240
+ aws: {
241
+ allHeaders: true,
242
+ signQuery: true
243
+ },
244
+ headers: {
245
+ ...browserHeaders,
246
+ "content-length": String(input.bytes)
247
+ },
248
+ method: "PUT"
249
+ })).url
250
+ };
251
+ },
171
252
  async get(key, range) {
172
253
  const response = await client.fetch(objectUrl(config, key), range ? { headers: { range: rangeHeader(range) } } : void 0);
173
254
  if (response.status === 404) {
@@ -1138,6 +1219,10 @@ async function completeText(params) {
1138
1219
  sessionId: params.sessionId,
1139
1220
  onPayload: (payload) => {
1140
1221
  setSpanAttributes(requestPrefixAttributes(payload));
1222
+ },
1223
+ onResponse: (response) => {
1224
+ const vercelId = response.headers["x-vercel-id"];
1225
+ if (vercelId) setSpanAttributes({ "app.ai.gateway.vercel_id": vercelId });
1141
1226
  }
1142
1227
  });
1143
1228
  } catch (error) {
@@ -1158,7 +1243,8 @@ async function completeText(params) {
1158
1243
  ...outputMessagesAttribute ? { "gen_ai.output.messages": outputMessagesAttribute } : void 0,
1159
1244
  ...usageAttributes,
1160
1245
  ...message.stopReason ? { "gen_ai.response.finish_reasons": [normalizeGenAiFinishReason(message.stopReason)] } : void 0,
1161
- ...message.model ? { "gen_ai.response.model": message.model } : void 0
1246
+ ...message.model ? { "gen_ai.response.model": message.model } : void 0,
1247
+ ...message.responseId ? { "gen_ai.response.id": message.responseId } : void 0
1162
1248
  });
1163
1249
  if (message.stopReason === "error") {
1164
1250
  const providerMessage = message.errorMessage?.trim() || "Unknown provider error";
@@ -1220,6 +1306,16 @@ function bestEffortObjectCompletionCost(modelId, usage) {
1220
1306
  return;
1221
1307
  }
1222
1308
  }
1309
+ /**
1310
+ * Keep only the fixed message and stack of a failed structured output. The SDK
1311
+ * error's `text` and its parse or validation cause hold the raw model output.
1312
+ */
1313
+ function structuredOutputErrorCause(error) {
1314
+ const cause = new Error(error.message);
1315
+ cause.name = error.name;
1316
+ cause.stack = error.stack;
1317
+ return cause;
1318
+ }
1223
1319
  /** Execute a schema-constrained completion using the AI SDK structured output path. */
1224
1320
  async function completeObject(params) {
1225
1321
  const credential = await resolveGatewayCredential();
@@ -1253,10 +1349,11 @@ async function completeObject(params) {
1253
1349
  ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : void 0
1254
1350
  });
1255
1351
  } catch (error) {
1256
- throw createProviderError(error, {
1257
- ...NoObjectGeneratedError.isInstance(error) ? { kind: "invalid_response" } : void 0,
1352
+ if (NoObjectGeneratedError.isInstance(error)) throw createProviderError(structuredOutputErrorCause(error), {
1353
+ kind: "invalid_response",
1258
1354
  modelId: params.modelId
1259
1355
  });
1356
+ throw createProviderError(error, { modelId: params.modelId });
1260
1357
  }
1261
1358
  const costUsd = bestEffortObjectCompletionCost(params.modelId, result.usage);
1262
1359
  return {
@@ -1466,6 +1563,7 @@ var config_exports = /* @__PURE__ */ __exportAll({
1466
1563
  resetRuntimeConfig: () => resetRuntimeConfig,
1467
1564
  restoreRuntimeConfig: () => restoreRuntimeConfig,
1468
1565
  setBotModelConfig: () => setBotModelConfig,
1566
+ setBotName: () => setBotName,
1469
1567
  setRuntimeLimits: () => setRuntimeLimits,
1470
1568
  setSlackReactionConfig: () => setSlackReactionConfig,
1471
1569
  snapshotRuntimeConfig: () => snapshotRuntimeConfig
@@ -1784,9 +1882,16 @@ function setBotModelConfig(config) {
1784
1882
  if (config.refusalFallbackModelId !== void 0) botConfig.refusalFallbackModelId = requireModelId("refusalFallbackModelId", config.refusalFallbackModelId, validateGatewayModelId);
1785
1883
  if (config.webSearchModelId !== void 0) botConfig.webSearchModelId = requireModelId("webSearchModelId", config.webSearchModelId, validateGatewayModelId);
1786
1884
  }
1885
+ /** Apply the bot name from createApp(). It overrides `JUNIOR_BOT_NAME`. */
1886
+ function setBotName(name) {
1887
+ if (name === void 0) return;
1888
+ const trimmed = toOptionalTrimmed(name);
1889
+ if (!trimmed) throw new Error("botName must not be empty");
1890
+ botConfig.userName = trimmed;
1891
+ }
1787
1892
  /** Apply Slack reaction emoji overrides from createApp() options, validating names. */
1788
1893
  function setSlackReactionConfig(overrides) {
1789
1894
  if (overrides.processingReactionEmoji !== void 0) chatConfig.slack.processingReactionEmoji = parseReactionEmoji("processingReactionEmoji", overrides.processingReactionEmoji, chatConfig.slack.processingReactionEmoji);
1790
1895
  if (overrides.completedReactionEmoji !== void 0) chatConfig.slack.completedReactionEmoji = parseReactionEmoji("completedReactionEmoji", overrides.completedReactionEmoji, chatConfig.slack.completedReactionEmoji);
1791
1896
  }
1792
- export { estimateTextTokens as A, createAssistantProviderError as B, completeText as C, requestPrefixAttributes as D, resolveGatewayModel as E, renderCurrentInstruction as F, isProviderRefusal as G, findProviderError as H, unwrapCurrentInstruction as I, resolveGatewayCredential as J, isProviderRetryError as K, escapeXml as L, COMPACTION_SUMMARY_PREFIX as M, hasCompactedConversationContext as N, estimateMessagesTokens as O, isCompactionSummaryText as P, escapeXmlText as R, completeObject as S, rerankTexts as T, getProviderErrorAttributes as U, createProviderError as V, getProviderErrorUserMessage as W, toOptionalTrimmed as X, getAttachmentStorage as Y, toPiReasoningLevel as _, getRuntimeMetadata as a, GEN_AI_SERVER_ADDRESS as b, getSlackClientSecret as c, restoreRuntimeConfig as d, setBotModelConfig as f, TURN_REASONING_LEVELS as g, snapshotRuntimeConfig as h, getChatConfig as i, textCharsForTokens as j, estimateRequestOverheadTokens as k, getSlackSigningSecret as l, setSlackReactionConfig as m, botConfig as n, getSlackBotToken as o, setRuntimeLimits as p, getGatewayApiKey as q, config_exports as r, getSlackClientId as s, DEFAULT_SQL_STATEMENT_TIMEOUT_MS as t, resetRuntimeConfig as u, normalizeSlackEmojiName as v, embedTexts as w, completeDecision as x, GEN_AI_PROVIDER_NAME as y, ProviderError as z };
1897
+ export { estimateRequestOverheadTokens as A, ProviderError as B, completeObject as C, resolveGatewayModel as D, rerankTexts as E, isCompactionSummaryText as F, getProviderErrorUserMessage as G, createProviderError as H, renderCurrentInstruction as I, getGatewayApiKey as J, isProviderRefusal as K, unwrapCurrentInstruction as L, textCharsForTokens as M, COMPACTION_SUMMARY_PREFIX as N, requestPrefixAttributes as O, hasCompactedConversationContext as P, toOptionalTrimmed as Q, escapeXml as R, completeDecision as S, embedTexts as T, findProviderError as U, createAssistantProviderError as V, getProviderErrorAttributes as W, bufferBody as X, resolveGatewayCredential as Y, getAttachmentStorage as Z, TURN_REASONING_LEVELS as _, getRuntimeMetadata as a, GEN_AI_PROVIDER_NAME as b, getSlackClientSecret as c, restoreRuntimeConfig as d, setBotModelConfig as f, snapshotRuntimeConfig as g, setSlackReactionConfig as h, getChatConfig as i, estimateTextTokens as j, estimateMessagesTokens as k, getSlackSigningSecret as l, setRuntimeLimits as m, botConfig as n, getSlackBotToken as o, setBotName as p, isProviderRetryError as q, config_exports as r, getSlackClientId as s, DEFAULT_SQL_STATEMENT_TIMEOUT_MS as t, resetRuntimeConfig as u, toPiReasoningLevel as v, completeText as w, GEN_AI_SERVER_ADDRESS as x, normalizeSlackEmojiName as y, escapeXmlText as z };
@@ -1,9 +1,9 @@
1
- import { Qi as startOAuthFlow } from "./projection-BgwEE36_.js";
2
- import { n as botConfig } from "./config-BOByVnxe.js";
3
- import { I as deleteProviderIdentityForSlackUser, L as deleteProviderIdentityForUser, s as getSqlExecutor } from "./db-CoMNr2Zm.js";
4
- import { u as hasRequiredOAuthScope } from "./registry-9XwqSnM-.js";
5
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DZeD2WbL.js";
6
- import { c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-Q9GkoerG.js";
1
+ import { ua as startOAuthFlow } from "./projection-w_X-zi7v.js";
2
+ import { n as botConfig } from "./config-9nHoFiJP.js";
3
+ import { F as deleteProviderIdentityForSlackUser, I as deleteProviderIdentityForUser, s as getSqlExecutor } from "./db-BJNo6fK5.js";
4
+ import { u as hasRequiredOAuthScope } from "./registry-BmP5vnlj.js";
5
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-D1oYNv04.js";
6
+ import { c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-bY4_0UPm.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. */