@sentry/junior 0.244.0 → 0.246.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 (58) hide show
  1. package/dist/{admin-CF9lQg0M.js → admin-Bh-MYw-j.js} +1 -1
  2. package/dist/{agent-hooks-Cj_rSeWd.js → agent-hooks-DpklSWZg.js} +10 -10
  3. package/dist/{agent-runner-DtEtbaOb.js → agent-runner-DSKpHjHW.js} +568 -191
  4. package/dist/api/schema.d.ts +86 -3
  5. package/dist/api/schema.js +3 -3
  6. package/dist/api.js +372 -245
  7. package/dist/{app-DRLh-8zs.d.ts → app-BYB7szGb.d.ts} +2 -0
  8. package/dist/app.d.ts +1 -1
  9. package/dist/app.js +179 -146
  10. package/dist/{briefs-BMzTiGJO.js → briefs-cZ5vWqP_.js} +4 -4
  11. package/dist/{catalog-runtime-CpxhLwZG.js → catalog-runtime-CTaQXYqS.js} +1 -1
  12. package/dist/cli/chat.js +17 -13
  13. package/dist/cli/check.js +3 -3
  14. package/dist/cli/main.js +2 -2
  15. package/dist/cli/plugins.js +4 -4
  16. package/dist/cli/snapshot-create.js +3 -3
  17. package/dist/cli/upgrade.js +3 -3
  18. package/dist/{client-BVaGEb1-.js → client--xtsAxKP.js} +2 -2
  19. package/dist/{config-q9xXVN_5.js → config-BK53Ip5C.js} +11 -2
  20. package/dist/{conversation-BxvgH64Q.js → conversation-CvBG57Io.js} +11 -1
  21. package/dist/{conversation-privacy-Dyh_63Ee.js → conversation-privacy-BDBFw6Ws.js} +1 -1
  22. package/dist/{credential-sync-Bsn-6m16.js → credential-sync-BiuhC9Ds.js} +14 -14
  23. package/dist/{executor-DA7eHhmC.js → executor-bmmuRY-w.js} +2 -2
  24. package/dist/{images-CvMreau5.js → images-DZliDtSH.js} +3 -3
  25. package/dist/instrumentation.js +2 -2
  26. package/dist/{job-queue-mVyF9jgv.js → job-queue-Cz3M7gg4.js} +1 -1
  27. package/dist/{logging-z7_w-KN_.js → logging-DVtMYOdD.js} +1 -1
  28. package/dist/message-BSN-Ma5f.js +317 -0
  29. package/dist/nitro.d.ts +1 -1
  30. package/dist/nitro.js +3 -3
  31. package/dist/{oauth-authorization-Db1yGVvG.js → oauth-authorization-By_MVRDC.js} +1 -1
  32. package/dist/{oauth-callback-server-_MfOtSxS.js → oauth-callback-server-BrUo6w1e.js} +2 -2
  33. package/dist/{pending-auth-OndKPW4M.js → pending-auth-BuQLZ6dK.js} +2 -2
  34. package/dist/{profile-yeKVNECl.js → profile-BevMNSlr.js} +4 -4
  35. package/dist/{prompt-CX36ZlbV.js → prompt-C9Q9cjD3.js} +1 -1
  36. package/dist/{registry-DvzzL8-v.js → registry-C2rSEio1.js} +1 -1
  37. package/dist/{resolve-4u5gEU04.js → resolve-qPhrznTf.js} +2 -2
  38. package/dist/{runner-Y6A6pww4.js → runner-CNh5eMWx.js} +10 -10
  39. package/dist/{sandbox-egress-signals-D7AOkuoe.js → sandbox-egress-signals-BnDEKu8d.js} +1 -1
  40. package/dist/{schema-Dyyi9oRc.js → schema-BWMRg8JS.js} +28 -4
  41. package/dist/{skills-DFduSvuO.js → skills-C6zJbudq.js} +2 -2
  42. package/dist/{spawn-DYg7jhhR.js → spawn-C3efZSx3.js} +2 -2
  43. package/dist/{task-queue-BQ0vnumm.js → task-queue-BX4vG6uA.js} +3 -3
  44. package/dist/{task-runner-D4jvUpFV.js → task-runner-T51kll0U.js} +10 -10
  45. package/dist/{tasks-DBZAgTx7.js → tasks-B9OIjl2K.js} +82 -11
  46. package/dist/{thread-state-hj70P2Cp.js → thread-state-AGZtVyXp.js} +6 -6
  47. package/dist/{turn-failure-response-S2pwtR8b.js → turn-failure-response-DJ8KU2bo.js} +9 -9
  48. package/dist/{turn-lifecycle-CNFOMAJq.js → turn-lifecycle-DZJkJ95q.js} +1 -1
  49. package/dist/{turn-session-routing-1eTgv6ns.js → turn-session-routing-mRqLbMZW.js} +1 -1
  50. package/dist/{validation-DcsBjzdi.js → validation-Dg0Ihxzo.js} +1 -1
  51. package/dist/{version-DVCHJYcY.js → version-Deub4try.js} +1 -1
  52. package/dist/version.js +1 -1
  53. package/dist/{viewer-BBnCMR1g.js → viewer-D5hbx6TE.js} +3 -3
  54. package/dist/{web-authorization-CTltRLsB.js → web-authorization-DCxixz5S.js} +6 -6
  55. package/dist/{web-input-CIsRGF07.js → web-input-0sorYVLh.js} +74 -187
  56. package/dist/{work-fje9VXgQ.js → work-rm2X7jj4.js} +13 -6
  57. package/dist/{worker-Byd2Et9r.js → worker-bnGsAOP3.js} +5 -5
  58. package/package.json +4 -4
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { gn as toolInvocationDestination, hn as actorFromRun } from "./agent-runner-DtEtbaOb.js";
3
- import { n as createAndEnqueueAgentInvocation } from "./work-fje9VXgQ.js";
2
+ import { En as toolInvocationDestination, Tn as actorFromRun } from "./agent-runner-DSKpHjHW.js";
3
+ import { n as createAndEnqueueAgentInvocation } from "./work-rm2X7jj4.js";
4
4
  //#region src/chat/agent-invocations/spawn.ts
5
5
  var spawn_exports = /* @__PURE__ */ __exportAll({ bindSpawnAgent: () => bindSpawnAgent });
6
6
  /** Bind a Run's Actor and credentials to new Agent invocations. */
@@ -1,5 +1,5 @@
1
- import { p as logWarn } from "./logging-z7_w-KN_.js";
2
- import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as createVercelQueueClient, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-mVyF9jgv.js";
1
+ import { p as logWarn } from "./logging-DVtMYOdD.js";
2
+ import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as createVercelQueueClient, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-Cz3M7gg4.js";
3
3
  import { z } from "zod";
4
4
  import { createHash } from "node:crypto";
5
5
  import { handleCallback, registerDevConsumer } from "@vercel/queue";
@@ -115,7 +115,7 @@ function pluginTaskCallback() {
115
115
  maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
116
116
  onRejected: logPluginTaskQueueMessageRejected,
117
117
  run: async (message) => {
118
- const { processPluginTask } = await import("./task-runner-D4jvUpFV.js").then((n) => n.r);
118
+ const { processPluginTask } = await import("./task-runner-T51kll0U.js").then((n) => n.r);
119
119
  await processPluginTask(message);
120
120
  },
121
121
  topic: PLUGIN_TASK_QUEUE_TOPIC,
@@ -1,17 +1,17 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { h as runBestEffort, p as logWarn } from "./logging-z7_w-KN_.js";
2
+ import { h as runBestEffort, p as logWarn } from "./logging-DVtMYOdD.js";
3
3
  import { g as parseSlackMessageTs } from "./actor-BTtLaeWy.js";
4
- import { C as agentTurnTotalTokens, S as agentTurnCostUsd, d as getDb, r as readActorIdentity, u as getConversationStore } from "./viewer-BBnCMR1g.js";
4
+ import { C as agentTurnTotalTokens, S as agentTurnCostUsd, d as getDb, r as readActorIdentity, u as getConversationStore } from "./viewer-D5hbx6TE.js";
5
5
  import { s as juniorConversations } from "./agent-invocations-BO6ddZax.js";
6
- import { c as juniorAutomationExecutions } from "./executor-DA7eHhmC.js";
6
+ import { c as juniorAutomationExecutions } from "./executor-bmmuRY-w.js";
7
7
  import { p as sameActorIdentity } from "./history-Nte1oVed.js";
8
- import { p as credentialSubjectSchema } from "./registry-DvzzL8-v.js";
9
- import { A as formatSlackLink, Bt as hydrateConversationMessages, Kt as fallbackShortTitle, L as openSlackDirectMessage, X as getTurnRecord, a as readScheduledAutomation, at as getPiMessageRole, ft as isToolResultError, g as getEventAutomation, gt as stripRuntimeTurnContext, k as escapeSlackMrkdwnText, lt as instructionTextForProjection, mt as normalizeToolNameFromResult, pt as isToolResultMessage, u as blockEventAutomation, z as postSlackMessage } from "./tasks-DBZAgTx7.js";
10
- import { ct as createPluginModel, it as getDashboardTaskLink, lt as createPluginLogger, ot as createPluginState, p as coreTaskRegistrations, st as createPluginEmbedder, tt as JUNIOR_THREAD_STATE_TTL_MS, u as getPlugins, yt as createPluginConversationEvents } from "./agent-hooks-Cj_rSeWd.js";
11
- import { w as getStateAdapter } from "./profile-yeKVNECl.js";
12
- import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-hj70P2Cp.js";
13
- import { t as resolveConversationRouting } from "./turn-session-routing-1eTgv6ns.js";
14
- import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-BQ0vnumm.js";
8
+ import { p as credentialSubjectSchema } from "./registry-C2rSEio1.js";
9
+ import { Ht as hydrateConversationMessages, Jt as fallbackShortTitle, M as formatSlackLink, Q as getTurnRecord, V as postSlackMessage, a as readScheduledAutomation, dt as instructionTextForProjection, g as getEventAutomation, gt as normalizeToolNameFromResult, ht as isToolResultMessage, j as escapeSlackMrkdwnText, mt as isToolResultError, st as getPiMessageRole, u as blockEventAutomation, vt as stripRuntimeTurnContext, z as openSlackDirectMessage } from "./tasks-B9OIjl2K.js";
10
+ import { ct as createPluginModel, it as getDashboardTaskLink, lt as createPluginLogger, ot as createPluginState, p as coreTaskRegistrations, st as createPluginEmbedder, tt as JUNIOR_THREAD_STATE_TTL_MS, u as getPlugins, yt as createPluginConversationEvents } from "./agent-hooks-DpklSWZg.js";
11
+ import { w as getStateAdapter } from "./profile-BevMNSlr.js";
12
+ import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-AGZtVyXp.js";
13
+ import { t as resolveConversationRouting } from "./turn-session-routing-mRqLbMZW.js";
14
+ import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-BX4vG6uA.js";
15
15
  import { z } from "zod";
16
16
  import { createHash } from "node:crypto";
17
17
  import { and, asc, count, desc, eq, gte, inArray, lte, max, or, sql } from "drizzle-orm";
@@ -1,15 +1,15 @@
1
- import { d as unwrapCurrentInstruction, f as escapeXml, i as completeText, o as resolveGatewayModel } from "./client-BVaGEb1-.js";
2
- import { d as logException, o as getActiveTraceId, p as logWarn, s as getLogContextAttributes, t as buildTurnFailureResponse, v as setSpanAttributes } from "./logging-z7_w-KN_.js";
1
+ import { d as unwrapCurrentInstruction, f as escapeXml, i as completeText, o as resolveGatewayModel } from "./client--xtsAxKP.js";
2
+ import { d as logException, o as getActiveTraceId, p as logWarn, s as getLogContextAttributes, t as buildTurnFailureResponse, v as setSpanAttributes } from "./logging-DVtMYOdD.js";
3
3
  import { n as captureMessage } from "./sentry-CgWZM_kV.js";
4
- import { n as botConfig, v as normalizeSlackEmojiName } from "./config-q9xXVN_5.js";
4
+ import { n as botConfig, v as normalizeSlackEmojiName } from "./config-BK53Ip5C.js";
5
5
  import { c as toStoredSlackActor, f as parseSlackUserId, g as parseSlackMessageTs } from "./actor-BTtLaeWy.js";
6
- import { c as getConversationEventStore, f as getSqlExecutor, m as withConversationEventLock, p as createSqlConversationEventStore, u as getConversationStore, v as startLocationThread, x as addAgentTurnUsage, y as bindProviderConversation } from "./viewer-BBnCMR1g.js";
7
- import { a as juniorSchedulerRuns, o as juniorSchedulerTasks, s as juniorAutomationVersions, u as juniorEventAutomations } from "./executor-DA7eHhmC.js";
6
+ import { c as getConversationEventStore, f as getSqlExecutor, m as withConversationEventLock, p as createSqlConversationEventStore, u as getConversationStore, v as startLocationThread, x as addAgentTurnUsage, y as bindProviderConversation } from "./viewer-D5hbx6TE.js";
7
+ import { a as juniorSchedulerRuns, o as juniorSchedulerTasks, s as juniorAutomationVersions, u as juniorEventAutomations } from "./executor-bmmuRY-w.js";
8
8
  import { d as instructionActors, f as instructionProvenanceFor, n as agentHistoryItemSchema, u as contextProvenance } from "./history-Nte1oVed.js";
9
- import { p as credentialSubjectSchema } from "./registry-DvzzL8-v.js";
10
- import { Ft as SlackActionError, Ht as normalizeSlackConversationId, Jt as agentsInstructionsUpdatedEvent, Wt as withSlackRetries, Xt as authenticationUnlinkedEvent, Yt as authenticationLinkedEvent, n as applyPluginFormatMarkdown, qt as JUNIOR_NATIVE_EVENT_NAMESPACE, zt as getSlackClient } from "./agent-hooks-Cj_rSeWd.js";
11
- import { H as messageCardRef } from "./conversation-BxvgH64Q.js";
12
- import { D as fenceLock, O as withLock, T as MUTATION_LOCK_TTL_MS, k as sleep, w as getStateAdapter } from "./profile-yeKVNECl.js";
9
+ import { p as credentialSubjectSchema } from "./registry-C2rSEio1.js";
10
+ import { Ft as SlackActionError, Ht as normalizeSlackConversationId, Jt as agentsInstructionsUpdatedEvent, Wt as withSlackRetries, Xt as authenticationUnlinkedEvent, Yt as authenticationLinkedEvent, n as applyPluginFormatMarkdown, qt as JUNIOR_NATIVE_EVENT_NAMESPACE, zt as getSlackClient } from "./agent-hooks-DpklSWZg.js";
11
+ import { U as messageCardRef } from "./conversation-CvBG57Io.js";
12
+ import { D as fenceLock, O as withLock, T as MUTATION_LOCK_TTL_MS, k as sleep, w as getStateAdapter } from "./profile-BevMNSlr.js";
13
13
  import { A as eventAutomationSchema, D as scheduledRunSchema, E as scheduledAutomationSchema, S as automationVersionSchema } from "./automation-gznOMaQ2.js";
14
14
  import { isDeepStrictEqual } from "node:util";
15
15
  import { z } from "zod";
@@ -2832,6 +2832,75 @@ async function listAutomationVersions(db, kind, automationId, limit) {
2832
2832
  return (await db.select().from(juniorAutomationVersions).where(and(eq(juniorAutomationVersions.kind, kind), eq(juniorAutomationVersions.automationId, automationId))).orderBy(desc(juniorAutomationVersions.version)).limit(limit)).map((row) => parseVersionRow(kind, row));
2833
2833
  }
2834
2834
  //#endregion
2835
+ //#region src/chat/event-automations/run-limit.ts
2836
+ const RUN_LIST_PREFIX = "junior:event_automation_runs:v1";
2837
+ const RUN_LIST_BURST_ROOM = 100;
2838
+ /** Length of the rolling window for the run limit. */
2839
+ const EVENT_AUTOMATION_RUN_WINDOW_MS = 36e5;
2840
+ const runEntrySchema = z.union([z.object({
2841
+ atMs: z.number().finite(),
2842
+ id: z.string().min(1)
2843
+ }).strict(), z.object({ reset: z.literal(true) }).strict()]);
2844
+ function runListKey(automationId) {
2845
+ return `${RUN_LIST_PREFIX}:${automationId}`;
2846
+ }
2847
+ function runListMaxLength() {
2848
+ return botConfig.maxEventAutomationRunsPerHour + RUN_LIST_BURST_ROOM;
2849
+ }
2850
+ async function appendRunEntry(state, automationId, entry) {
2851
+ await state.connect();
2852
+ await state.appendToList(runListKey(automationId), entry, {
2853
+ maxLength: runListMaxLength(),
2854
+ ttlMs: EVENT_AUTOMATION_RUN_WINDOW_MS
2855
+ });
2856
+ }
2857
+ /** Reason stored on an Event automation that the run limit blocked. */
2858
+ function eventAutomationRunLimitReason() {
2859
+ return `This automation reached its limit of ${botConfig.maxEventAutomationRunsPerHour} runs per hour. Check that its trigger is not too broad, then resume it.`;
2860
+ }
2861
+ /**
2862
+ * Count one run of an Event automation, or refuse when its hour is full.
2863
+ *
2864
+ * `runKey` is the dispatch idempotency key, so a provider retry of the same
2865
+ * Event does not count again.
2866
+ */
2867
+ async function admitEventAutomationRun(args) {
2868
+ const state = args.state ?? getStateAdapter();
2869
+ await appendRunEntry(state, args.automationId, {
2870
+ atMs: args.nowMs,
2871
+ id: args.runKey
2872
+ });
2873
+ const windowStartMs = args.nowMs - EVENT_AUTOMATION_RUN_WINDOW_MS;
2874
+ const values = await state.getList(runListKey(args.automationId));
2875
+ const entries = values.flatMap((value) => {
2876
+ const entry = runEntrySchema.safeParse(value);
2877
+ return entry.success ? [entry.data] : [];
2878
+ });
2879
+ let lastReset = -1;
2880
+ entries.forEach((entry, index) => {
2881
+ if ("reset" in entry) lastReset = index;
2882
+ });
2883
+ const oldest = entries[0];
2884
+ const full = lastReset === -1 && values.length >= runListMaxLength() && oldest !== void 0 && "atMs" in oldest && oldest.atMs > windowStartMs;
2885
+ const runKeys = /* @__PURE__ */ new Set();
2886
+ for (const entry of entries.slice(lastReset + 1)) {
2887
+ if ("reset" in entry) continue;
2888
+ if (entry.atMs > windowStartMs) runKeys.add(entry.id);
2889
+ if (entry.id === args.runKey) return full || runKeys.size > botConfig.maxEventAutomationRunsPerHour ? "limited" : "allowed";
2890
+ }
2891
+ return "limited";
2892
+ }
2893
+ /**
2894
+ * Forget the runs counted for one Event automation.
2895
+ *
2896
+ * Resume and revive call this so the automation starts with a new window.
2897
+ * Call it before the automation becomes active, so an Event cannot see the
2898
+ * old full count and block it again.
2899
+ */
2900
+ async function clearEventAutomationRuns(automationId, state = getStateAdapter()) {
2901
+ await appendRunEntry(state, automationId, { reset: true });
2902
+ }
2903
+ //#endregion
2835
2904
  //#region src/chat/event-automations/store.ts
2836
2905
  const retainedEventAutomationSchema = eventAutomationSchema.extend({
2837
2906
  destination: slackDestinationSchema,
@@ -2886,6 +2955,7 @@ async function getEventAutomation(db, id) {
2886
2955
  async function createEventAutomation(db, task) {
2887
2956
  const parsed = eventAutomationSchema.parse(eventAutomationJsonPayload(task));
2888
2957
  const title = task.title?.trim() || null;
2958
+ if ((await getEventAutomation(db, parsed.id))?.status === "deleted") await clearEventAutomationRuns(parsed.id);
2889
2959
  return db.transaction(async (tx) => {
2890
2960
  const inserted = await tx.insert(juniorEventAutomations).values({
2891
2961
  id: parsed.id,
@@ -3001,9 +3071,10 @@ async function findMatchingEventAutomations(db, event, teamId) {
3001
3071
  * Change lifecycle under the same row lock as edits, without changing
3002
3072
  * credentials. A pause keeps an unresolved block reason, so resuming a paused
3003
3073
  * blocked automation returns it to blocked. Resume a blocked automation to
3004
- * clear the reason.
3074
+ * clear the reason. A resume also clears the run-limit count first.
3005
3075
  */
3006
3076
  async function setEventAutomationStatus(db, id, status, revision) {
3077
+ if (status === "active" && (await getEventAutomation(db, id))?.status !== "active") await clearEventAutomationRuns(id);
3007
3078
  return db.transaction(async (tx) => {
3008
3079
  const rows = await tx.select().from(juniorEventAutomations).where(eq(juniorEventAutomations.id, id)).for("update");
3009
3080
  const current = rows[0] ? parseEventAutomationRow(rows[0]) : void 0;
@@ -3233,4 +3304,4 @@ async function saveScheduledAutomationInLock(db, task, current) {
3233
3304
  await writeScheduledAutomation(db, requireStoredTask(task), current);
3234
3305
  }
3235
3306
  //#endregion
3236
- export { persistWithRetry as $, isHumanConversationMessage as $t, formatSlackLink as A, recordAttachmentsDelivered as At, removeReactionFromMessage as B, hydrateConversationMessages as Bt, listAutomationVersions as C, loadConversationProjection as Ct, automationRevision as D, loadTurnRoute as Dt, AutomationConflictError as E, loadTurnProjection as Et, addReactionToMessage as F, recordMcpProviderConnected as Ft, loadTurnCheckpoint as G, settleConversationTitleWork as Gt, slackEntitySchema as H, projectConversationMessages as Ht, getSlackMessagePermalink as I, recordSubscribedReplyRoute as It, completeTurnRecord as J, appendThreadContextMessages as Jt, saveTurnCheckpoint as K, fallbackShortTitle as Kt, openSlackDirectMessage as L, recordToolExecutionStarted as Lt, normalizeSlackStatusText as M, recordAuthorizationCompleted as Mt, slackMention as N, recordAuthorizationRequested as Nt, requireAutomationRevision as O, openConversationProjection as Ot, truncateStatusText as P, recordGuardianActionReviewed as Pt, recordTurnSummary as Q, getConversationMessageSlackTs as Qt, postSlackEphemeralMessage as R, recordTurnRoute as Rt, automationDefinition as S, loadConnectedMcpProviders as St, sameDefinitionValue as T, loadProjection as Tt, slackExternalRefIdSchema as U, persistConversationMessageSummaries as Ut, uploadFilesToConversation as V, persistConversationMessages as Vt, continuableMessages as W, resolveConversationTitle as Wt, getTurnRecord as X, createConversationMemoryService as Xt, failTurnRecord as Y, buildConversationContext as Yt, listTurnSummaries as Z, estimateConversationContextTokens as Zt, listDeletedEventAutomationsCreatedBy as _, trimTrailingAssistantMessages as _t, readScheduledAutomation as a, estimateTextTokens as an, getPiMessageRole as at, saveEventAutomation as b, commitAcceptedReply as bt, scheduledRunId as c, historyItemFromPiMessage as cn, hasRuntimeTurnContext as ct, collectEventAutomationMatchKeys as d, isContinuablePiBoundary as dt, markConversationMessage as en, TurnSliceLimitExceededError as et, createEventAutomation as f, isToolResultError as ft, getEventAutomation as g, stripRuntimeTurnContext as gt, findMatchingEventAutomations as h, retainRuntimeTurnContext as ht, parseScheduledAutomationRow as i, upsertConversationMessage as in, extractAssistantText as it, normalizeSlackReplyMarkdown as j, recordAuthenticationLinked as jt, escapeSlackMrkdwnText as k, recordAgentsInstructionsUpdated as kt, withScheduledAutomationLock as l, piMessageFromHistoryItem as ln, instructionTextForProjection as lt, eventAutomationBelongsToUser as m, normalizeToolNameFromResult as mt, listScheduledAutomations as n, recordDeliveredAssistantMessage as nn, buildTurnErrorResponse as nt, saveScheduledAutomation as o, getAgentContextCompactionTriggerTokens as on, getTerminalAssistantMessages as ot, deleteEventAutomation as p, isToolResultMessage as pt, abandonTurnRecord as q, resolveTaskTitle as qt, listScheduledAutomationsForTeam as r, turnHasReply as rn, isTurnExecutionLimitExceededError as rt, saveScheduledAutomationInLock as s, getAgentContextInputLimitTokens as sn, getUserMessageInstructionText as st, createScheduledAutomation as t, normalizeConversationText as tn, assertTurnToolCallLimit as tt, blockEventAutomation as u, isAssistantMessage as ut, listEventAutomationsForTeam as v, TURN_CONTEXT_TAG as vt, readAutomationVersion as w, loadLastModelProfile as wt, setEventAutomationStatus as x, commitMessages as xt, parseEventAutomationRow as y, ToolInputError as yt, postSlackMessage as z, appendConversationMessages as zt };
3307
+ export { listTurnSummaries as $, estimateConversationContextTokens as $t, requireAutomationRevision as A, openConversationProjection as At, postSlackEphemeralMessage as B, recordTurnRoute as Bt, eventAutomationRunLimitReason as C, commitMessages as Ct, sameDefinitionValue as D, loadProjection as Dt, readAutomationVersion as E, loadLastModelProfile as Et, slackMention as F, recordAuthorizationRequested as Ft, slackExternalRefIdSchema as G, persistConversationMessageSummaries as Gt, removeReactionFromMessage as H, hydrateConversationMessages as Ht, truncateStatusText as I, recordGuardianActionReviewed as It, saveTurnCheckpoint as J, fallbackShortTitle as Jt, continuableMessages as K, resolveConversationTitle as Kt, addReactionToMessage as L, recordMcpProviderConnected as Lt, formatSlackLink as M, recordAttachmentsDelivered as Mt, normalizeSlackReplyMarkdown as N, recordAuthenticationLinked as Nt, AutomationConflictError as O, loadTurnProjection as Ot, normalizeSlackStatusText as P, recordAuthorizationCompleted as Pt, getTurnRecord as Q, createConversationMemoryService as Qt, getSlackMessagePermalink as R, recordSubscribedReplyRoute as Rt, admitEventAutomationRun as S, commitAcceptedReply as St, listAutomationVersions as T, loadConversationProjection as Tt, uploadFilesToConversation as U, persistConversationMessages as Ut, postSlackMessage as V, appendConversationMessages as Vt, slackEntitySchema as W, projectConversationMessages as Wt, completeTurnRecord as X, appendThreadContextMessages as Xt, abandonTurnRecord as Y, resolveTaskTitle as Yt, failTurnRecord as Z, buildConversationContext as Zt, listDeletedEventAutomationsCreatedBy as _, retainRuntimeTurnContext as _t, readScheduledAutomation as a, turnHasReply as an, isTurnExecutionLimitExceededError as at, saveEventAutomation as b, TURN_CONTEXT_TAG as bt, scheduledRunId as c, getAgentContextCompactionTriggerTokens as cn, getTerminalAssistantMessages as ct, collectEventAutomationMatchKeys as d, piMessageFromHistoryItem as dn, instructionTextForProjection as dt, getConversationMessageSlackTs as en, recordTurnSummary as et, createEventAutomation as f, isAssistantMessage as ft, getEventAutomation as g, normalizeToolNameFromResult as gt, findMatchingEventAutomations as h, isToolResultMessage as ht, parseScheduledAutomationRow as i, recordDeliveredAssistantMessage as in, buildTurnErrorResponse as it, escapeSlackMrkdwnText as j, recordAgentsInstructionsUpdated as jt, automationRevision as k, loadTurnRoute as kt, withScheduledAutomationLock as l, getAgentContextInputLimitTokens as ln, getUserMessageInstructionText as lt, eventAutomationBelongsToUser as m, isToolResultError as mt, listScheduledAutomations as n, markConversationMessage as nn, TurnSliceLimitExceededError as nt, saveScheduledAutomation as o, upsertConversationMessage as on, extractAssistantText as ot, deleteEventAutomation as p, isContinuablePiBoundary as pt, loadTurnCheckpoint as q, settleConversationTitleWork as qt, listScheduledAutomationsForTeam as r, normalizeConversationText as rn, assertTurnToolCallLimit as rt, saveScheduledAutomationInLock as s, estimateTextTokens as sn, getPiMessageRole as st, createScheduledAutomation as t, isHumanConversationMessage as tn, persistWithRetry as tt, blockEventAutomation as u, historyItemFromPiMessage as un, hasRuntimeTurnContext as ut, listEventAutomationsForTeam as v, stripRuntimeTurnContext as vt, automationDefinition as w, loadConnectedMcpProviders as wt, setEventAutomationStatus as x, ToolInputError as xt, parseEventAutomationRow as y, trimTrailingAssistantMessages as yt, openSlackDirectMessage as z, recordToolExecutionStarted as zt };
@@ -1,10 +1,10 @@
1
- import { I as isRecord, L as toOptionalNumber, R as toOptionalString } from "./logging-z7_w-KN_.js";
2
- import { d as getDb } from "./viewer-BBnCMR1g.js";
1
+ import { I as isRecord, L as toOptionalNumber, R as toOptionalString } from "./logging-DVtMYOdD.js";
2
+ import { d as getDb } from "./viewer-D5hbx6TE.js";
3
3
  import { d as juniorDestinations } from "./agent-invocations-BO6ddZax.js";
4
- import { d as juniorLocationConfigurations } from "./executor-DA7eHhmC.js";
5
- import { Vt as persistConversationMessages } from "./tasks-DBZAgTx7.js";
6
- import { tt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-Cj_rSeWd.js";
7
- import { w as getStateAdapter } from "./profile-yeKVNECl.js";
4
+ import { d as juniorLocationConfigurations } from "./executor-bmmuRY-w.js";
5
+ import { Ut as persistConversationMessages } from "./tasks-B9OIjl2K.js";
6
+ import { tt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-DpklSWZg.js";
7
+ import { w as getStateAdapter } from "./profile-BevMNSlr.js";
8
8
  import { z } from "zod";
9
9
  import { randomUUID } from "node:crypto";
10
10
  import { and, eq, sql } from "drizzle-orm";
@@ -1,13 +1,13 @@
1
- import { _ as getProviderErrorUserMessage, g as getProviderErrorAttributes, h as findProviderError, p as ProviderError } from "./client-BVaGEb1-.js";
2
- import { I as isRecord, t as buildTurnFailureResponse } from "./logging-z7_w-KN_.js";
1
+ import { _ as getProviderErrorUserMessage, g as getProviderErrorAttributes, h as findProviderError, p as ProviderError } from "./client--xtsAxKP.js";
2
+ import { I as isRecord, t as buildTurnFailureResponse } from "./logging-DVtMYOdD.js";
3
3
  import { g as parseSlackMessageTs } from "./actor-BTtLaeWy.js";
4
- import { c as getConversationEventStore, d as getDb } from "./viewer-BBnCMR1g.js";
5
- import { Bt as hydrateConversationMessages, en as markConversationMessage } from "./tasks-DBZAgTx7.js";
6
- import { At as listConversationAnnotations } from "./agent-hooks-Cj_rSeWd.js";
7
- import { G as removedCardSchema, K as resolveMessageCards, W as readMessageCardRefs } from "./conversation-BxvgH64Q.js";
8
- import { r as clearPendingAuth, u as buildDeterministicTurnId } from "./pending-auth-OndKPW4M.js";
9
- import { g as markTurnCompleted, h as markTurnClosed } from "./oauth-authorization-Db1yGVvG.js";
10
- import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-hj70P2Cp.js";
4
+ import { c as getConversationEventStore, d as getDb } from "./viewer-D5hbx6TE.js";
5
+ import { Ht as hydrateConversationMessages, nn as markConversationMessage } from "./tasks-B9OIjl2K.js";
6
+ import { At as listConversationAnnotations } from "./agent-hooks-DpklSWZg.js";
7
+ import { G as readMessageCardRefs, K as removedCardSchema, q as resolveMessageCards } from "./conversation-CvBG57Io.js";
8
+ import { r as clearPendingAuth, u as buildDeterministicTurnId } from "./pending-auth-BuQLZ6dK.js";
9
+ import { g as markTurnCompleted, h as markTurnClosed } from "./oauth-authorization-By_MVRDC.js";
10
+ import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-AGZtVyXp.js";
11
11
  //#region src/chat/conversations/pending-cards.ts
12
12
  /** Select undelivered cards and load their latest saved facts. */
13
13
  async function loadPendingMessageCards(conversationId) {
@@ -1,4 +1,4 @@
1
- import { c as getConversationEventStore } from "./viewer-BBnCMR1g.js";
1
+ import { c as getConversationEventStore } from "./viewer-D5hbx6TE.js";
2
2
  //#region src/chat/conversations/turn-lifecycle.ts
3
3
  /** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
4
4
  var ConversationTurnLifecycleService = class {
@@ -34,7 +34,7 @@ function slackSourceForDestination(args) {
34
34
  * Reads parent Conversations when this Conversation has no Destination.
35
35
  */
36
36
  async function resolveConversationRouting(args) {
37
- const conversationStore = args.conversationStore ?? (await import("./viewer-BBnCMR1g.js").then((n) => n.s)).getConversationStore();
37
+ const conversationStore = args.conversationStore ?? (await import("./viewer-D5hbx6TE.js").then((n) => n.s)).getConversationStore();
38
38
  const chain = await loadConversationChain(args.conversationId, conversationStore);
39
39
  let destination;
40
40
  let source;
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { n as pluginCatalogRuntime } from "./catalog-runtime-CpxhLwZG.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-CTaQXYqS.js";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  //#region src/chat/plugins/validation.ts
5
5
  var validation_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.244.0";
2
+ var version = "0.246.0";
3
3
  //#endregion
4
4
  //#region src/version.ts
5
5
  /** Installed Junior package version, or `unknown` when package metadata is unavailable. */
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as JUNIOR_VERSION } from "./version-DVCHJYcY.js";
1
+ import { t as JUNIOR_VERSION } from "./version-Deub4try.js";
2
2
  export { JUNIOR_VERSION };
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { F as normalizeIdentityEmail } from "./logging-z7_w-KN_.js";
3
- import { i as getChatConfig } from "./config-q9xXVN_5.js";
2
+ import { F as normalizeIdentityEmail } from "./logging-DVtMYOdD.js";
3
+ import { i as getChatConfig } from "./config-BK53Ip5C.js";
4
4
  import { d as parseSlackTeamId, o as parseActorUserId, u as parseSlackChannelReferenceId } from "./actor-BTtLaeWy.js";
5
5
  import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-BO6ddZax.js";
6
- import { _ as juniorConversationEvents, f as juniorConversationParticipants, g as juniorConversationMetrics, h as CONVERSATION_METRICS, p as juniorConversationBindings, t as createJuniorSqlExecutor, y as juniorConversationAnnotations } from "./executor-DA7eHhmC.js";
6
+ import { _ as juniorConversationEvents, f as juniorConversationParticipants, g as juniorConversationMetrics, h as CONVERSATION_METRICS, p as juniorConversationBindings, t as createJuniorSqlExecutor, y as juniorConversationAnnotations } from "./executor-bmmuRY-w.js";
7
7
  import { c as newConversationEventSchema, l as encodeHistoryPayload, m as usageSchema, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-Nte1oVed.js";
8
8
  import { randomUUID } from "node:crypto";
9
9
  import { and, asc, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
@@ -1,9 +1,9 @@
1
- import { Vt as requestConversationWork, jt as ensureConversationWake } from "./agent-runner-DtEtbaOb.js";
2
- import { c as getConversationEventStore } from "./viewer-BBnCMR1g.js";
3
- import { G as loadTurnCheckpoint, X as getTurnRecord, Y as failTurnRecord } from "./tasks-DBZAgTx7.js";
4
- import { w as getStateAdapter } from "./profile-yeKVNECl.js";
5
- import { a as getVercelConversationWorkQueue } from "./job-queue-mVyF9jgv.js";
6
- import { n as resolveTurnSessionRouting } from "./turn-session-routing-1eTgv6ns.js";
1
+ import { Vt as ensureConversationWake, Zt as requestConversationWork } from "./agent-runner-DSKpHjHW.js";
2
+ import { c as getConversationEventStore } from "./viewer-D5hbx6TE.js";
3
+ import { Q as getTurnRecord, Z as failTurnRecord, q as loadTurnCheckpoint } from "./tasks-B9OIjl2K.js";
4
+ import { w as getStateAdapter } from "./profile-BevMNSlr.js";
5
+ import { a as getVercelConversationWorkQueue } from "./job-queue-Cz3M7gg4.js";
6
+ import { n as resolveTurnSessionRouting } from "./turn-session-routing-mRqLbMZW.js";
7
7
  import { z } from "zod";
8
8
  import { randomUUID } from "node:crypto";
9
9
  //#region src/chat/task-execution/authorized-turn.ts