@sentry/junior 0.256.0 → 0.258.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 (106) hide show
  1. package/dist/{actor-BTtLaeWy.js → actor-tlxzqaRe.js} +3 -6
  2. package/dist/{admin-BhucwVfy.js → admin-My1SLGVO.js} +2 -3
  3. package/dist/{agent-hooks-DlSK8PQQ.js → agent-hooks-BJ_5mlRH.js} +71 -111
  4. package/dist/{agent-invocations-BY60iNw-.js → agent-invocations-Qfz7dWgU.js} +8 -13
  5. package/dist/{agent-runner-C6_cd61V.js → agent-runner-DGsFQw72.js} +278 -467
  6. package/dist/api/schema.d.ts +454 -448
  7. package/dist/api/schema.js +5 -5
  8. package/dist/api.d.ts +2 -12
  9. package/dist/api.js +189 -165
  10. package/dist/{app-B0gT1Slp.d.ts → app-PX2H1PxU.d.ts} +20 -37
  11. package/dist/app.d.ts +3 -3
  12. package/dist/app.js +565 -305
  13. package/dist/{assistant-reply-yn5G-YEG.js → assistant-reply-H1M-91oF.js} +3 -5
  14. package/dist/{automation-CHdlHVZP.js → automation-DWBFBenG.js} +6 -11
  15. package/dist/{briefs-U6Bi3IYw.js → briefs-vYoK85rJ.js} +8 -11
  16. package/dist/{cadence-D00SCzT1.js → cadence-R7Em4RjE.js} +1 -2
  17. package/dist/{catalog-runtime-DF5OWqCc.js → catalog-runtime-BN4DVxco.js} +3 -4
  18. package/dist/cli/chat.d.ts +2 -4
  19. package/dist/cli/chat.js +22 -24
  20. package/dist/cli/check.d.ts +1 -3
  21. package/dist/cli/check.js +4 -5
  22. package/dist/cli/env.d.ts +1 -3
  23. package/dist/cli/env.js +1 -2
  24. package/dist/cli/init.d.ts +1 -3
  25. package/dist/cli/init.js +3 -3
  26. package/dist/cli/main.d.ts +1 -3
  27. package/dist/cli/main.js +4 -5
  28. package/dist/cli/plugins.d.ts +2 -4
  29. package/dist/cli/plugins.js +7 -8
  30. package/dist/cli/run.d.ts +1 -2
  31. package/dist/cli/run.js +1 -2
  32. package/dist/cli/snapshot-create.d.ts +1 -3
  33. package/dist/cli/snapshot-create.js +4 -5
  34. package/dist/cli/upgrade.d.ts +3 -6
  35. package/dist/cli/upgrade.js +11 -17
  36. package/dist/{client-BVrAp-pq.js → client-DbyHuMFU.js} +9 -16
  37. package/dist/{config-DdBiDanf.js → config-_WO_AjCB.js} +18 -15
  38. package/dist/{connections-CG04HdpC.js → connections-ag_1JOhB.js} +21 -21
  39. package/dist/{conversation-T18Xlkx9.js → conversation-DjN3mlog.js} +11 -17
  40. package/dist/{conversation-privacy-CpSYOWnP.js → conversation-privacy-DHP_xnVj.js} +2 -3
  41. package/dist/{conversation-work-C6y3T5Hx.js → conversation-work-BaT_T6EB.js} +1 -2
  42. package/dist/{credential-sync-DKWNdcgm.js → credential-sync-B-CPX_ag.js} +89 -52
  43. package/dist/{db-Ca9Nt5ci.d.ts → db-BnRqQ7G5.d.ts} +1 -1
  44. package/dist/{executor-BroK9oKy.js → executor-RvG6kVe1.js} +58 -70
  45. package/dist/{experimental-Qn9rKLgx.js → experimental-BNK1l1jv.js} +2 -3
  46. package/dist/{history-9pO1Zd4Y.js → history-AY8rs-FR.js} +5 -9
  47. package/dist/{history-DvqWZlYX.d.ts → history-BgI33Kie.d.ts} +12 -20
  48. package/dist/{images-D0VZ5nv0.js → images-C2J_bj2g.js} +5 -6
  49. package/dist/instrumentation.d.ts +1 -3
  50. package/dist/instrumentation.js +6 -8
  51. package/dist/{job-queue-BbGg3gvu.js → job-queue-DVe37it2.js} +6 -12
  52. package/dist/{logging-tPQeUe2i.js → logging-DsHONhVm.js} +54 -24
  53. package/dist/{message-DdPGRYQP.js → message-DyitL8no.js} +5 -6
  54. package/dist/{model-profile-BwU8mqwD.js → model-profile-Bg8EoCKD.js} +2 -4
  55. package/dist/nitro.d.ts +3 -5
  56. package/dist/nitro.js +12 -17
  57. package/dist/{oauth-authorization-BA4Dt6a7.js → oauth-authorization-djQn5Nhy.js} +2 -4
  58. package/dist/{oauth-callback-server-B-2errCX.js → oauth-callback-server-CDby-pCn.js} +3 -4
  59. package/dist/{oauth-relay-CdCnu80W.js → oauth-relay-CTygMkNx.js} +2 -3
  60. package/dist/{package-discovery-BVvSnQBB.js → package-discovery-DJBompdd.js} +17 -21
  61. package/dist/{pending-auth-DT3MRVW8.js → pending-auth-D8J1uJUS.js} +37 -28
  62. package/dist/{plugin-module-CVvEUSMH.js → plugin-module-Cf5gVPWP.js} +1 -2
  63. package/dist/{plugins-CjfUP5gJ.d.ts → plugins-B11Mfkmv.d.ts} +0 -4
  64. package/dist/{plugins-egKWjgue.js → plugins-DOm9Y6qI.js} +2 -3
  65. package/dist/{private-trace-result-BLvBjy_e.js → private-trace-result-CE7_lEdq.js} +1 -2
  66. package/dist/{profile-Bb1zCVGP.js → profile-DpYjfKke.js} +16 -28
  67. package/dist/{prompt-C04mP1hu.js → prompt-xgpyMtg7.js} +5 -9
  68. package/dist/{queue-B5SnqRln.d.ts → queue-C37RbDVc.d.ts} +0 -2
  69. package/dist/{registry-CsNavQ_Z.js → registry-Du566MtJ.js} +57 -30
  70. package/dist/{resolve-B6ZZ9duG.js → resolve-ClCIgh8E.js} +7 -12
  71. package/dist/{result-j9nS0se-.js → result-BBbKA61B.js} +13 -17
  72. package/dist/{rolldown-runtime-B4FMCO8f.js → rolldown-runtime-nwUcYXjP.js} +1 -2
  73. package/dist/{runner-Y331DoZ5.js → runner-CCuqFSqx.js} +12 -13
  74. package/dist/{sandbox-egress-signals-BUfjEdHY.js → sandbox-egress-signals-DY1mbKF4.js} +2 -3
  75. package/dist/{schema-BBgv0MNf.js → schema-DrMh3NtR.js} +17 -27
  76. package/dist/{sentry-CgWZM_kV.js → sentry-BBUlHih9.js} +2 -3
  77. package/dist/{session-stop-q-6GNHx6.js → session-stop-CIoFiwwe.js} +57 -41
  78. package/dist/{skills-CyvTsR9M.js → skills-DyQBLIrK.js} +9 -9
  79. package/dist/{spawn-Do5mX3d_.js → spawn-Dqfeo7XP.js} +4 -5
  80. package/dist/{store-DoewL5mG.d.ts → store-CG0VJyye.d.ts} +0 -14
  81. package/dist/{store-D2It0ozF.js → store-DJLwq4x8.js} +13 -15
  82. package/dist/{task-queue-ZMk9bLRT.js → task-queue-BzW4MaWU.js} +5 -7
  83. package/dist/{task-runner-cIGU5VwJ.js → task-runner-D3qJh4fK.js} +22 -26
  84. package/dist/{tasks-CODtRzvX.js → tasks-CEXKTASS.js} +78 -79
  85. package/dist/{thread-state-BPkwVmvK.js → thread-state-W3f6kAtz.js} +13 -19
  86. package/dist/{turn-failure-response-ChmMeKar.js → turn-failure-response-CWx7aNIh.js} +16 -22
  87. package/dist/{turn-lifecycle-BUP7ZOVa.js → turn-lifecycle-C9JFst7-.js} +2 -3
  88. package/dist/{turn-session-routing-BcWM3PLm.js → turn-session-routing-CUxtfpr7.js} +2 -3
  89. package/dist/{validation-DCd69-cP.js → validation-BHRxa5G4.js} +3 -4
  90. package/dist/vercel.d.ts +1 -3
  91. package/dist/vercel.js +1 -2
  92. package/dist/{version-DBc4Qt_P.js → version-C0U6rHg0.js} +3 -5
  93. package/dist/{version-CnXZ614E.d.ts → version-Cc2OFd9G.d.ts} +0 -2
  94. package/dist/version.d.ts +1 -1
  95. package/dist/version.js +1 -2
  96. package/dist/{viewer-C-9nFKYr.js → viewer-CGvvRqKp.js} +61 -44
  97. package/dist/{web-input-Cv42P3ni.js → web-input-Keb5GRWj.js} +139 -198
  98. package/dist/{web-message-id-xPI_EFSC.js → web-message-id-CJSUiksE.js} +3 -6
  99. package/dist/{work-6UmVQq1V.js → work-DRcsJ3hV.js} +14 -16
  100. package/dist/{worker-DAoBZuZn.js → worker-Cjo-QqPq.js} +7 -8
  101. package/migrations/0059_automation_run_version.sql +2 -0
  102. package/migrations/0060_identity_signed_in_at.sql +1 -0
  103. package/migrations/meta/0059_snapshot.json +3619 -0
  104. package/migrations/meta/0060_snapshot.json +3465 -0
  105. package/migrations/meta/_journal.json +15 -1
  106. package/package.json +8 -6
@@ -1,22 +1,22 @@
1
- import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { h as runBestEffort, p as logWarn } from "./logging-tPQeUe2i.js";
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-C-9nFKYr.js";
5
- import { s as juniorConversations } from "./agent-invocations-BY60iNw-.js";
6
- import { o as juniorAutomationRuns, s as juniorAutomations } from "./executor-BroK9oKy.js";
7
- import { m as sameActorIdentity } from "./history-9pO1Zd4Y.js";
8
- import { p as credentialSubjectSchema } from "./registry-CsNavQ_Z.js";
9
- import { A as formatSlackLink, L as openSlackDirectMessage, Ut as hydrateConversationMessages, X as getTurnRecord, Yt as fallbackShortTitle, _t as normalizeToolNameFromResult, ct as getPiMessageRole, ft as instructionTextForProjection, gt as isToolResultMessage, ht as isToolResultError, i as readScheduledAutomation, k as escapeSlackMrkdwnText, l as blockEventAutomation, m as getEventAutomation, yt as stripRuntimeTurnContext, z as postSlackMessage } from "./tasks-CODtRzvX.js";
10
- import { St as createPluginConversationEvents, dt as createPluginModel, ft as createPluginLogger, it as JUNIOR_THREAD_STATE_TTL_MS, lt as createPluginState, p as coreTaskRegistrations, st as getDashboardTaskLink, u as getPlugins, ut as createPluginEmbedder } from "./agent-hooks-DlSK8PQQ.js";
11
- import { w as getStateAdapter } from "./profile-Bb1zCVGP.js";
12
- import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-BPkwVmvK.js";
13
- import { t as resolveConversationRouting } from "./turn-session-routing-BcWM3PLm.js";
14
- import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-ZMk9bLRT.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
+ import { g as runBestEffort, m as logWarn } from "./logging-DsHONhVm.js";
3
+ import { g as parseSlackMessageTs } from "./actor-tlxzqaRe.js";
4
+ import { T as agentTurnTotalTokens, d as getDb, r as readActorIdentity, u as getConversationStore, w as agentTurnCostUsd } from "./viewer-CGvvRqKp.js";
5
+ import { s as juniorConversations } from "./agent-invocations-Qfz7dWgU.js";
6
+ import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-RvG6kVe1.js";
7
+ import { m as sameActorIdentity } from "./history-AY8rs-FR.js";
8
+ import { h as credentialSubjectSchema } from "./registry-Du566MtJ.js";
9
+ import { A as escapeSlackMrkdwnText, B as postSlackMessage, R as openSlackDirectMessage, Wt as hydrateConversationMessages, Xt as fallbackShortTitle, Z as getTurnRecord, _t as isToolResultMessage, bt as stripRuntimeTurnContext, gt as isToolResultError, i as readScheduledAutomation, j as formatSlackLink, l as blockEventAutomation, lt as getPiMessageRole, m as getEventAutomation, pt as instructionTextForProjection, vt as normalizeToolNameFromResult } from "./tasks-CEXKTASS.js";
10
+ import { St as createPluginConversationEvents, dt as createPluginModel, ft as createPluginLogger, it as JUNIOR_THREAD_STATE_TTL_MS, lt as createPluginState, p as coreTaskRegistrations, st as getDashboardTaskLink, u as getPlugins, ut as createPluginEmbedder } from "./agent-hooks-BJ_5mlRH.js";
11
+ import { w as getStateAdapter } from "./profile-DpYjfKke.js";
12
+ import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-W3f6kAtz.js";
13
+ import { t as resolveConversationRouting } from "./turn-session-routing-CUxtfpr7.js";
14
+ import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-BzW4MaWU.js";
15
15
  import { z } from "zod";
16
16
  import { createHash } from "node:crypto";
17
17
  import { and, asc, count, desc, eq, gte, inArray, isNotNull, lte, max, sql } from "drizzle-orm";
18
18
  import { destinationSchema, destinationVisibilitySchema, isSlackDestination, pluginRunContextSchema, replyAttributionSchema, sourceSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
19
- //#region src/api/conversations/aggregate.ts
19
+ // src/api/conversations/aggregate.ts
20
20
  function usageTokenValue(source, field) {
21
21
  return sql`CASE
22
22
  WHEN ${source.usage}->>${field} IS NOT NULL
@@ -98,8 +98,7 @@ function conversationRangeColumns() {
98
98
  function conversationActiveDaysColumn() {
99
99
  return sql`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
100
100
  }
101
- //#endregion
102
- //#region src/chat/automations/execution-stats.ts
101
+ // src/chat/automations/execution-stats.ts
103
102
  const AUTOMATION_EXECUTION_STATUSES = [
104
103
  "blocked",
105
104
  "completed",
@@ -428,8 +427,7 @@ async function readExecutionStatusBuckets(args) {
428
427
  status: juniorAutomationRuns.status
429
428
  }).from(juniorAutomationRuns).where(and(isExecution(), eq(juniorAutomationRuns.automationId, args.automationId), gte(juniorAutomationRuns.completedAtMs, args.startMs), lte(juniorAutomationRuns.completedAtMs, args.endMs))).groupBy(args.bucket, juniorAutomationRuns.status).orderBy(asc(args.bucket), asc(juniorAutomationRuns.status));
430
429
  }
431
- //#endregion
432
- //#region src/chat/automations/blocked-notice.ts
430
+ // src/chat/automations/blocked-notice.ts
433
431
  function buildBlockedNoticeText(automationId, title, reason) {
434
432
  const url = getDashboardTaskLink(automationId);
435
433
  return [
@@ -458,8 +456,7 @@ async function notifyAutomationBlocked(ref) {
458
456
  ...ref.dispatchId ? { "app.dispatch.id": ref.dispatchId } : void 0
459
457
  });
460
458
  }
461
- //#endregion
462
- //#region src/chat/agent-dispatch/store.ts
459
+ // src/chat/agent-dispatch/store.ts
463
460
  const DISPATCH_PREFIX = "junior:agent_dispatch";
464
461
  const DISPATCH_LOCK_TTL_MS = 6e5;
465
462
  const DISPATCH_MAILBOX_APPEND_INDEX_LOCK_TTL_MS = 1e4;
@@ -555,6 +552,7 @@ function normalizeMetadata(metadata) {
555
552
  return entries.length > 0 ? Object.fromEntries(entries) : void 0;
556
553
  }
557
554
  const DISPATCH_ID_PREFIX = "agent-dispatch:";
555
+ /** Return the stable dispatch id for one plugin idempotency key. */
558
556
  function buildDispatchId(plugin, idempotencyKey) {
559
557
  return `dispatch_${createHash("sha256").update(plugin).update("\0").update(idempotencyKey).digest("hex").slice(0, 32)}`;
560
558
  }
@@ -785,8 +783,7 @@ async function getPluginDispatchProjection(args) {
785
783
  if (!record || record.plugin !== args.plugin) return;
786
784
  return toDispatchProjection(record);
787
785
  }
788
- //#endregion
789
- //#region src/chat/plugins/task-runner.ts
786
+ // src/chat/plugins/task-runner.ts
790
787
  var task_runner_exports = /* @__PURE__ */ __exportAll({
791
788
  processPluginTask: () => processPluginTask,
792
789
  scheduleSessionCompletedPluginTasks: () => scheduleSessionCompletedPluginTasks
@@ -1032,9 +1029,8 @@ async function scheduleSessionCompletedPluginTasks(params, options = {}) {
1032
1029
  async function processPluginTask(message, options = {}) {
1033
1030
  await withPluginTaskLock(pluginTaskId(message), async () => {
1034
1031
  const resolved = findPluginTask(message);
1035
- if (!resolved) throw new Error(`Plugin task "${message.plugin}.${message.name}" is not registered`);
1032
+ if (!resolved?.task) throw new Error(`Plugin task "${message.plugin}.${message.name}" is not registered`);
1036
1033
  await resolved.task.run(taskPluginContext(resolved.plugin, message, options));
1037
1034
  });
1038
1035
  }
1039
- //#endregion
1040
- export { readAutomationRuns as A, readAutomationExecutionByConversationId as C, readAutomationExecutionStatusHours as D, readAutomationExecutionStatusDays as E, conversationRangeColumns as F, recordAutomationExecution as M, conversationActiveDaysColumn as N, readAutomationExecutionSummaries as O, conversationAggregateColumns as P, existingConversationId as S, readAutomationExecutionHours as T, markDispatchCompleted as _, confirmDispatchMailboxAppend as a, notifyAutomationBlocked as b, getDispatchIdForConversation as c, getDispatchTurnId as d, getPluginDispatchProjection as f, markDispatchBlocked as g, markDispatchAwaitingResume as h, claimDispatchMailboxAppend as i, readAutomationTitlesByConversationId as j, readAutomationExecutions as k, getDispatchInputMessageId as l, listPendingDispatchMailboxAppends as m, scheduleSessionCompletedPluginTasks as n, createOrGetDispatch as o, isTerminalDispatchStatus as p, task_runner_exports as r, getDispatchConversationId as s, processPluginTask as t, getDispatchRecord as u, markDispatchFailed as v, readAutomationExecutionDays as w, emptyAutomationRunWindows as x, markDispatchRunning as y };
1036
+ export { readAutomationExecutions as A, existingConversationId as C, readAutomationExecutionStatusDays as D, readAutomationExecutionHours as E, conversationAggregateColumns as F, conversationRangeColumns as I, readAutomationTitlesByConversationId as M, recordAutomationExecution as N, readAutomationExecutionStatusHours as O, conversationActiveDaysColumn as P, emptyAutomationRunWindows as S, readAutomationExecutionDays as T, markDispatchBlocked as _, claimDispatchMailboxAppend as a, markDispatchRunning as b, getDispatchConversationId as c, getDispatchRecord as d, getDispatchTurnId as f, markDispatchAwaitingResume as g, listPendingDispatchMailboxAppends as h, buildDispatchId as i, readAutomationRuns as j, readAutomationExecutionSummaries as k, getDispatchIdForConversation as l, isTerminalDispatchStatus as m, scheduleSessionCompletedPluginTasks as n, confirmDispatchMailboxAppend as o, getPluginDispatchProjection as p, task_runner_exports as r, createOrGetDispatch as s, processPluginTask as t, getDispatchInputMessageId as u, markDispatchCompleted as v, readAutomationExecutionByConversationId as w, notifyAutomationBlocked as x, markDispatchFailed as y };
@@ -1,30 +1,29 @@
1
- import { d as unwrapCurrentInstruction, f as escapeXml, i as completeText, o as resolveGatewayModel } from "./client-BVrAp-pq.js";
2
- import { d as logException, o as getActiveTraceId, p as logWarn, s as getLogContextAttributes, t as buildTurnFailureResponse, v as setSpanAttributes } from "./logging-tPQeUe2i.js";
3
- import { n as captureMessage } from "./sentry-CgWZM_kV.js";
4
- import { n as botConfig, v as normalizeSlackEmojiName } from "./config-DdBiDanf.js";
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-C-9nFKYr.js";
7
- import { a as juniorAutomationVersions, o as juniorAutomationRuns, s as juniorAutomations } from "./executor-BroK9oKy.js";
8
- import { d as contextProvenance, f as instructionActors, n as agentHistoryItemSchema, p as instructionProvenanceFor } from "./history-9pO1Zd4Y.js";
9
- import { p as credentialSubjectSchema } from "./registry-CsNavQ_Z.js";
10
- import { $t as authenticationUnlinkedEvent, Gt as normalizeSlackConversationId, Ht as getSlackClient, Qt as authenticationLinkedEvent, Rt as SlackActionError, Xt as JUNIOR_NATIVE_EVENT_NAMESPACE, Zt as agentsInstructionsUpdatedEvent, n as applyPluginFormatMarkdown, qt as withSlackRetries } from "./agent-hooks-DlSK8PQQ.js";
11
- import { G as messageCardRef } from "./conversation-T18Xlkx9.js";
12
- import { D as fenceLock, O as withLock, T as MUTATION_LOCK_TTL_MS, k as sleep, w as getStateAdapter } from "./profile-Bb1zCVGP.js";
13
- import { A as eventAutomationSchema, E as scheduledAutomationSchema, S as automationVersionSchema } from "./automation-CHdlHVZP.js";
1
+ import { d as unwrapCurrentInstruction, f as escapeXml, i as completeText, o as resolveGatewayModel } from "./client-DbyHuMFU.js";
2
+ import { f as logException, m as logWarn, o as getActiveTraceId, s as getLogContextAttributes, t as buildTurnFailureResponse, y as setSpanAttributes } from "./logging-DsHONhVm.js";
3
+ import { n as captureMessage } from "./sentry-BBUlHih9.js";
4
+ import { n as botConfig, v as normalizeSlackEmojiName } from "./config-_WO_AjCB.js";
5
+ import { c as toStoredSlackActor, f as parseSlackUserId, g as parseSlackMessageTs } from "./actor-tlxzqaRe.js";
6
+ import { C as addAgentTurnUsage, c as getConversationEventStore, f as getSqlExecutor, m as withConversationEventLock, p as createSqlConversationEventStore, u as getConversationStore, x as bindProviderConversation, y as startLocationThread } from "./viewer-CGvvRqKp.js";
7
+ import { a as juniorAutomationRuns, o as juniorAutomationVersions, s as juniorAutomations } from "./executor-RvG6kVe1.js";
8
+ import { d as contextProvenance, f as instructionActors, n as agentHistoryItemSchema, p as instructionProvenanceFor } from "./history-AY8rs-FR.js";
9
+ import { h as credentialSubjectSchema } from "./registry-Du566MtJ.js";
10
+ import { $t as authenticationUnlinkedEvent, Gt as normalizeSlackConversationId, Ht as getSlackClient, Qt as authenticationLinkedEvent, Rt as SlackActionError, Xt as JUNIOR_NATIVE_EVENT_NAMESPACE, Zt as agentsInstructionsUpdatedEvent, n as applyPluginFormatMarkdown, qt as withSlackRetries } from "./agent-hooks-BJ_5mlRH.js";
11
+ import { G as messageCardRef } from "./conversation-DjN3mlog.js";
12
+ import { D as fenceLock, O as withLock, T as MUTATION_LOCK_TTL_MS, k as sleep, w as getStateAdapter } from "./profile-DpYjfKke.js";
13
+ import { A as eventAutomationSchema, E as scheduledAutomationSchema, S as automationVersionSchema } from "./automation-DWBFBenG.js";
14
14
  import { isDeepStrictEqual } from "node:util";
15
15
  import { z } from "zod";
16
16
  import { createHash } from "node:crypto";
17
17
  import { and, asc, desc, eq, inArray, ne, or, sql } from "drizzle-orm";
18
18
  import { actorSchema, eventMatches, sourceSchema } from "@sentry/junior-plugin-api";
19
- //#region src/chat/pi/messages.ts
19
+ // src/chat/pi/messages.ts
20
20
  /** Permissive schema for durable Pi SDK messages whose content shape may evolve. */
21
21
  const piMessageSchema = z.object({ role: z.string() }).passthrough().transform((value) => value);
22
22
  z.object({
23
23
  content: z.array(z.unknown()),
24
24
  role: z.string().min(1)
25
25
  }).passthrough().transform((value) => value);
26
- //#endregion
27
- //#region src/chat/pi/conversation-events.ts
26
+ // src/chat/pi/conversation-events.ts
28
27
  function authorizationObservationMessage(data, createdAtMs) {
29
28
  const label = data.kind === "mcp" ? "MCP authorization" : "Authorization";
30
29
  return piMessageSchema.parse({
@@ -129,8 +128,7 @@ function projectConversationEvents(events, options) {
129
128
  replacementSeq
130
129
  };
131
130
  }
132
- //#endregion
133
- //#region src/chat/services/context-budget.ts
131
+ // src/chat/services/context-budget.ts
134
132
  const COMPACTION_TRIGGER_RATIO = .9;
135
133
  const CONTEXT_INPUT_LIMIT_RATIO = .95;
136
134
  const COMPACTION_TARGET_RATIO = .8;
@@ -173,8 +171,7 @@ function getAgentContextInputLimitTokens(modelId) {
173
171
  function getConversationContextCompactionTriggerTokens() {
174
172
  return calculateContextCompactionTriggerTokens(getModelContextBudget(botConfig.fastModelId));
175
173
  }
176
- //#endregion
177
- //#region src/chat/services/conversation-memory.ts
174
+ // src/chat/services/conversation-memory.ts
178
175
  const CONTEXT_MIN_LIVE_MESSAGES = 12;
179
176
  const CONTEXT_COMPACTION_BATCH_SIZE = 24;
180
177
  const CONTEXT_MAX_COMPACTIONS = 16;
@@ -271,6 +268,7 @@ function markConversationMessage(conversation, messageId, patch) {
271
268
  const messageIndex = conversation.messages.findIndex((entry) => entry.id === messageId);
272
269
  if (messageIndex < 0) return;
273
270
  const current = conversation.messages[messageIndex];
271
+ if (!current) return;
274
272
  conversation.messages[messageIndex] = {
275
273
  ...current,
276
274
  meta: {
@@ -526,8 +524,7 @@ async function resolveTaskTitle(args) {
526
524
  signal: args.signal
527
525
  });
528
526
  }
529
- //#endregion
530
- //#region src/chat/services/conversation-title.ts
527
+ // src/chat/services/conversation-title.ts
531
528
  const inFlightTitles = /* @__PURE__ */ new Map();
532
529
  /**
533
530
  * Set-once conversation title from the earliest human message.
@@ -630,8 +627,7 @@ async function resolveConversationTitle(args) {
630
627
  }
631
628
  return (await (args.conversationStore ?? getConversationStore()).get({ conversationId: args.conversationId }))?.title?.trim() || void 0;
632
629
  }
633
- //#endregion
634
- //#region src/chat/conversations/message-summaries.ts
630
+ // src/chat/conversations/message-summaries.ts
635
631
  /** Project the latest source-message summary snapshot from event history. */
636
632
  function projectConversationMessageSummaries(events) {
637
633
  for (let index = events.length - 1; index >= 0; index -= 1) {
@@ -657,8 +653,7 @@ async function persistConversationMessageSummaries(args) {
657
653
  createdAtMs: args.conversation.compactions.at(-1)?.createdAtMs ?? Date.now()
658
654
  }]);
659
655
  }
660
- //#endregion
661
- //#region src/chat/conversations/message-projection.ts
656
+ // src/chat/conversations/message-projection.ts
662
657
  function isMessageEvent(event) {
663
658
  return event.data.type === "message" || event.data.type === "message_updated" || event.data.type === "message_handled";
664
659
  }
@@ -720,8 +715,7 @@ function projectConversationMessages(history) {
720
715
  };
721
716
  });
722
717
  }
723
- //#endregion
724
- //#region src/chat/conversations/messages.ts
718
+ // src/chat/conversations/messages.ts
725
719
  /**
726
720
  * Conversation-message persistence and hydration.
727
721
  */
@@ -813,8 +807,7 @@ async function appendConversationMessages(eventStore, args) {
813
807
  });
814
808
  await eventStore.append(args.conversationId, events);
815
809
  }
816
- //#endregion
817
- //#region src/chat/conversations/projection.ts
810
+ // src/chat/conversations/projection.ts
818
811
  /**
819
812
  * Conversation projection orchestration.
820
813
  *
@@ -1281,8 +1274,7 @@ async function recordGuardianActionReviewed(args) {
1281
1274
  createdAtMs: Date.now()
1282
1275
  }]);
1283
1276
  }
1284
- //#endregion
1285
- //#region src/chat/tools/execution/tool-input-error.ts
1277
+ // src/chat/tools/execution/tool-input-error.ts
1286
1278
  /** Thrown when a tool fails due to invalid model/user input, not a system error. */
1287
1279
  var ToolInputError = class extends Error {
1288
1280
  constructor(message, options) {
@@ -1290,16 +1282,14 @@ var ToolInputError = class extends Error {
1290
1282
  this.name = "ToolInputError";
1291
1283
  }
1292
1284
  };
1293
- //#endregion
1294
- //#region src/chat/turn-context-tag.ts
1285
+ // src/chat/turn-context-tag.ts
1295
1286
  /**
1296
1287
  * Canonical tag name for the runtime turn context block injected into Pi
1297
1288
  * messages. Shared between prompt assembly and turn context stripping to keep
1298
1289
  * both in sync without requiring the full prompt module.
1299
1290
  */
1300
1291
  const TURN_CONTEXT_TAG = "runtime-turn-context";
1301
- //#endregion
1302
- //#region src/chat/pi/transcript.ts
1292
+ // src/chat/pi/transcript.ts
1303
1293
  const RUNTIME_TURN_CONTEXT_START = `<${TURN_CONTEXT_TAG}>`;
1304
1294
  const AGENTS_INSTRUCTIONS_START = "# AGENTS.md instructions";
1305
1295
  function userMessageContent(message) {
@@ -1431,8 +1421,7 @@ function stripRuntimeTurnContext(messages) {
1431
1421
  }];
1432
1422
  });
1433
1423
  }
1434
- //#endregion
1435
- //#region src/chat/services/turn-limit.ts
1424
+ // src/chat/services/turn-limit.ts
1436
1425
  /** Terminal failure when one turn uses too many execution slices. */
1437
1426
  var TurnSliceLimitExceededError = class extends Error {
1438
1427
  constructor(maxSlices) {
@@ -1495,8 +1484,7 @@ function buildTurnLimitResponse(eventId) {
1495
1484
  function buildTurnErrorResponse(error, eventId) {
1496
1485
  return isTurnExecutionLimitExceededError(error) ? buildTurnLimitResponse(eventId) : buildTurnFailureResponse(eventId);
1497
1486
  }
1498
- //#endregion
1499
- //#region src/chat/services/persist-retry.ts
1487
+ // src/chat/services/persist-retry.ts
1500
1488
  /**
1501
1489
  * Shared post-delivery persist retry.
1502
1490
  *
@@ -1517,8 +1505,7 @@ async function persistWithRetry(persist) {
1517
1505
  }
1518
1506
  throw lastError;
1519
1507
  }
1520
- //#endregion
1521
- //#region src/chat/task-execution/turn-cursor-keys.ts
1508
+ // src/chat/task-execution/turn-cursor-keys.ts
1522
1509
  /** Redis namespace for the current turn cursor format. */
1523
1510
  const TURN_CURSOR_PREFIX = "junior:turn_cursor:v2";
1524
1511
  /** Return the Redis key for one turn cursor. */
@@ -1533,8 +1520,7 @@ function turnCursorIndexKey(conversationId) {
1533
1520
  function turnCursorMutationKey(conversationId, turnId) {
1534
1521
  return `${TURN_CURSOR_PREFIX}:mutation:${conversationId}:${turnId}`;
1535
1522
  }
1536
- //#endregion
1537
- //#region src/chat/task-execution/turn-cursor.ts
1523
+ // src/chat/task-execution/turn-cursor.ts
1538
1524
  /**
1539
1525
  * Internal turn cursor storage for `checkpoint.ts`.
1540
1526
  *
@@ -2089,8 +2075,7 @@ async function failTurnRecord(args) {
2089
2075
  });
2090
2076
  });
2091
2077
  }
2092
- //#endregion
2093
- //#region src/chat/task-execution/checkpoint.ts
2078
+ // src/chat/task-execution/checkpoint.ts
2094
2079
  function definedProps(values) {
2095
2080
  return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== void 0));
2096
2081
  }
@@ -2241,8 +2226,7 @@ async function saveDone(args) {
2241
2226
  });
2242
2227
  });
2243
2228
  }
2244
- //#endregion
2245
- //#region src/chat/slack/post-warning.ts
2229
+ // src/chat/slack/post-warning.ts
2246
2230
  const codes = /* @__PURE__ */ new Set([
2247
2231
  "invalid_metadata_format",
2248
2232
  "invalid_metadata_schema",
@@ -2338,8 +2322,7 @@ function captureSlackPostWarning(response, attributes) {
2338
2322
  }
2339
2323
  });
2340
2324
  }
2341
- //#endregion
2342
- //#region src/chat/slack/work-object.ts
2325
+ // src/chat/slack/work-object.ts
2343
2326
  const url = z.url({ protocol: /^https?$/ });
2344
2327
  const textField = z.strictObject({
2345
2328
  type: z.literal("string"),
@@ -2388,8 +2371,7 @@ const slackEntitySchema = z.discriminatedUnion("entity_type", [entity.extend({
2388
2371
  entity_type: z.literal("slack#/entities/task"),
2389
2372
  entity_payload: payload.extend({ fields: z.strictObject({ status: z.strictObject({ value: z.string() }).optional() }).optional() })
2390
2373
  })]);
2391
- //#endregion
2392
- //#region src/chat/slack/outbound.ts
2374
+ // src/chat/slack/outbound.ts
2393
2375
  const MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
2394
2376
  function requireSlackConversationId(channelId, action) {
2395
2377
  const normalized = normalizeSlackConversationId(channelId);
@@ -2579,8 +2561,7 @@ async function removeReactionFromMessage(input) {
2579
2561
  }
2580
2562
  return { ok: true };
2581
2563
  }
2582
- //#endregion
2583
- //#region src/chat/slack/status-format.ts
2564
+ // src/chat/slack/status-format.ts
2584
2565
  const SLACK_STATUS_MAX_LENGTH = 50;
2585
2566
  /** Truncate a status string to fit Slack's 50-char assistant status limit. */
2586
2567
  function truncateStatusText(text) {
@@ -2589,8 +2570,7 @@ function truncateStatusText(text) {
2589
2570
  if (trimmed.length <= SLACK_STATUS_MAX_LENGTH) return trimmed;
2590
2571
  return `${trimmed.slice(0, 47).trimEnd()}...`;
2591
2572
  }
2592
- //#endregion
2593
- //#region src/chat/slack/mrkdwn.ts
2573
+ // src/chat/slack/mrkdwn.ts
2594
2574
  /** Escape dynamic text for Slack mrkdwn without changing intended formatting. */
2595
2575
  function escapeSlackMrkdwnText(text) {
2596
2576
  return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
@@ -2652,7 +2632,7 @@ function hasUnmatchedClosingParen(text) {
2652
2632
  function readBareUrl(line, start) {
2653
2633
  let end = start;
2654
2634
  while (end < line.length) {
2655
- const ch = line[end];
2635
+ const ch = line.charAt(end);
2656
2636
  if (/\s/.test(ch) || ch === "<" || ch === ">" || ch === "\"" || ch === "`" || ch === "|" || ch === "*") break;
2657
2637
  end++;
2658
2638
  }
@@ -2757,8 +2737,7 @@ function ensureBlockSpacing(text) {
2757
2737
  const lines = text.split("\n");
2758
2738
  const result = [];
2759
2739
  let inCodeBlock = false;
2760
- for (let i = 0; i < lines.length; i++) {
2761
- const line = lines[i];
2740
+ for (const line of lines) {
2762
2741
  if (codeBlockPattern.test(line.trimStart())) {
2763
2742
  if (!inCodeBlock) {
2764
2743
  const prev = result.length > 0 ? result[result.length - 1] : void 0;
@@ -2802,8 +2781,7 @@ function normalizeSlackStatusText(text) {
2802
2781
  function slackMention(userId) {
2803
2782
  return `<@${userId}>`;
2804
2783
  }
2805
- //#endregion
2806
- //#region src/chat/automations/revision.ts
2784
+ // src/chat/automations/revision.ts
2807
2785
  /** Storage revisions prevent stale edits from replacing newer values. */
2808
2786
  var AutomationConflictError = class extends ToolInputError {
2809
2787
  constructor() {
@@ -2825,8 +2803,7 @@ function automationRevision(task) {
2825
2803
  function requireAutomationRevision(task, revision) {
2826
2804
  if (!task || automationRevision(task) !== revision) throw new AutomationConflictError();
2827
2805
  }
2828
- //#endregion
2829
- //#region src/chat/automations/versions.ts
2806
+ // src/chat/automations/versions.ts
2830
2807
  /** Automation versions keep each saved definition so people can see how it changed. */
2831
2808
  /** Return the versioned part of an Automation. Lifecycle and run state are excluded. */
2832
2809
  function automationDefinition(task) {
@@ -2869,6 +2846,21 @@ async function recordAutomationVersion(db, task, current, editedBy) {
2869
2846
  definition
2870
2847
  });
2871
2848
  }
2849
+ /**
2850
+ * Select the newest saved version with the same definition as `task`.
2851
+ *
2852
+ * An Automation run stores this version so that a reader can see the
2853
+ * instruction that ran after the definition changes. The value is null when
2854
+ * no saved version has this definition.
2855
+ */
2856
+ function automationVersionOf(task) {
2857
+ return sql`(
2858
+ SELECT max(${juniorAutomationVersions.version})
2859
+ FROM ${juniorAutomationVersions}
2860
+ WHERE ${juniorAutomationVersions.automationId} = ${task.id}
2861
+ AND ${juniorAutomationVersions.definition} = ${JSON.stringify(automationDefinition(task))}::jsonb
2862
+ )`;
2863
+ }
2872
2864
  const versionColumns = {
2873
2865
  createdAtMs: juniorAutomationVersions.createdAtMs,
2874
2866
  definition: juniorAutomationVersions.definition,
@@ -2894,12 +2886,9 @@ async function readAutomationVersion(db, automationId, version) {
2894
2886
  async function listAutomationVersions(db, automationId, limit) {
2895
2887
  return (await db.select(versionColumns).from(juniorAutomationVersions).innerJoin(juniorAutomations, eq(juniorAutomations.id, juniorAutomationVersions.automationId)).where(eq(juniorAutomationVersions.automationId, automationId)).orderBy(desc(juniorAutomationVersions.version)).limit(limit)).map(parseVersionRow);
2896
2888
  }
2897
- //#endregion
2898
- //#region src/chat/event-automations/run-limit.ts
2889
+ // src/chat/event-automations/run-limit.ts
2899
2890
  const RUN_LIST_PREFIX = "junior:event_automation_runs:v1";
2900
2891
  const RUN_LIST_BURST_ROOM = 100;
2901
- /** Length of the rolling window for the run limit. */
2902
- const EVENT_AUTOMATION_RUN_WINDOW_MS = 36e5;
2903
2892
  const runEntrySchema = z.union([z.object({
2904
2893
  atMs: z.number().finite(),
2905
2894
  id: z.string().min(1)
@@ -2908,21 +2897,34 @@ function runListKey(automationId) {
2908
2897
  return `${RUN_LIST_PREFIX}:${automationId}`;
2909
2898
  }
2910
2899
  function runListMaxLength() {
2911
- return botConfig.maxEventAutomationRunsPerHour + RUN_LIST_BURST_ROOM;
2900
+ return botConfig.maxEventAutomationRuns + RUN_LIST_BURST_ROOM;
2912
2901
  }
2913
2902
  async function appendRunEntry(state, automationId, entry) {
2914
2903
  await state.connect();
2915
2904
  await state.appendToList(runListKey(automationId), entry, {
2916
2905
  maxLength: runListMaxLength(),
2917
- ttlMs: EVENT_AUTOMATION_RUN_WINDOW_MS
2906
+ ttlMs: botConfig.eventAutomationRunWindowMs
2918
2907
  });
2919
2908
  }
2909
+ function describeRunWindow(windowMs) {
2910
+ for (const [unit, unitMs] of [
2911
+ ["day", 864e5],
2912
+ ["hour", 36e5],
2913
+ ["minute", 6e4],
2914
+ ["second", 1e3]
2915
+ ]) if (windowMs % unitMs === 0) {
2916
+ const count = windowMs / unitMs;
2917
+ return count === 1 ? unit : `${count} ${unit}s`;
2918
+ }
2919
+ return `${windowMs} ms`;
2920
+ }
2920
2921
  /** Reason stored on an Event automation that the run limit blocked. */
2921
2922
  function eventAutomationRunLimitReason() {
2922
- return `This automation reached its limit of ${botConfig.maxEventAutomationRunsPerHour} runs per hour. Check that its trigger is not too broad, then resume it.`;
2923
+ const window = describeRunWindow(botConfig.eventAutomationRunWindowMs);
2924
+ return `This automation reached its limit of ${botConfig.maxEventAutomationRuns} runs per ${window}. Check that its trigger is not too broad, then resume it.`;
2923
2925
  }
2924
2926
  /**
2925
- * Count one run of an Event automation, or refuse when its hour is full.
2927
+ * Count one run of an Event automation, or refuse when its window is full.
2926
2928
  *
2927
2929
  * `runKey` is the dispatch idempotency key, so a provider retry of the same
2928
2930
  * Event does not count again.
@@ -2933,7 +2935,7 @@ async function admitEventAutomationRun(args) {
2933
2935
  atMs: args.nowMs,
2934
2936
  id: args.runKey
2935
2937
  });
2936
- const windowStartMs = args.nowMs - EVENT_AUTOMATION_RUN_WINDOW_MS;
2938
+ const windowStartMs = args.nowMs - botConfig.eventAutomationRunWindowMs;
2937
2939
  const values = await state.getList(runListKey(args.automationId));
2938
2940
  const entries = values.flatMap((value) => {
2939
2941
  const entry = runEntrySchema.safeParse(value);
@@ -2949,7 +2951,7 @@ async function admitEventAutomationRun(args) {
2949
2951
  for (const entry of entries.slice(lastReset + 1)) {
2950
2952
  if ("reset" in entry) continue;
2951
2953
  if (entry.atMs > windowStartMs) runKeys.add(entry.id);
2952
- if (entry.id === args.runKey) return full || runKeys.size > botConfig.maxEventAutomationRunsPerHour ? "limited" : "allowed";
2954
+ if (entry.id === args.runKey) return full || runKeys.size > botConfig.maxEventAutomationRuns ? "limited" : "allowed";
2953
2955
  }
2954
2956
  return "limited";
2955
2957
  }
@@ -2963,8 +2965,7 @@ async function admitEventAutomationRun(args) {
2963
2965
  async function clearEventAutomationRuns(automationId, state = getStateAdapter()) {
2964
2966
  await appendRunEntry(state, automationId, { reset: true });
2965
2967
  }
2966
- //#endregion
2967
- //#region src/chat/event-automations/store.ts
2968
+ // src/chat/event-automations/store.ts
2968
2969
  /**
2969
2970
  * Validate an event automation and split it into its SQL columns. Lifecycle
2970
2971
  * columns are written separately.
@@ -3146,8 +3147,7 @@ async function blockEventAutomation(db, id, reason) {
3146
3147
  statusReason: reason
3147
3148
  }).where(and(eventAutomationWhere(id), or(eq(juniorAutomations.status, "active"), and(eq(juniorAutomations.status, "paused"), sql`${juniorAutomations.statusReason} is distinct from ${reason}`)))).returning({ status: juniorAutomations.status }))[0]?.status === "blocked";
3148
3149
  }
3149
- //#endregion
3150
- //#region src/chat/scheduled-automations/tasks.ts
3150
+ // src/chat/scheduled-automations/tasks.ts
3151
3151
  const SCHEDULER_KEY_PREFIX = "junior:scheduler";
3152
3152
  /** Decode a Scheduled automation row. Returns undefined for an invalid row. */
3153
3153
  function parseScheduledAutomationRow(row) {
@@ -3269,5 +3269,4 @@ async function saveScheduledAutomation(db, task, expectedRevision, editedBy) {
3269
3269
  async function saveScheduledAutomationInLock(db, task, current) {
3270
3270
  await writeScheduledAutomation(db, requireStoredTask(task), current);
3271
3271
  }
3272
- //#endregion
3273
- export { persistWithRetry as $, createConversationMemoryService as $t, formatSlackLink as A, loadTurnRoute as At, removeReactionFromMessage as B, recordToolExecutionStarted as Bt, listAutomationVersions as C, commitAcceptedReply as Ct, automationRevision as D, loadLastModelProfile as Dt, AutomationConflictError as E, loadConversationProjection as Et, addReactionToMessage as F, recordAuthorizationCompleted as Ft, loadTurnCheckpoint as G, projectConversationMessages as Gt, slackEntitySchema as H, appendConversationMessages as Ht, getSlackMessagePermalink as I, recordAuthorizationRequested as It, completeTurnRecord as J, settleConversationTitleWork as Jt, saveTurnCheckpoint as K, persistConversationMessageSummaries as Kt, openSlackDirectMessage as L, recordGuardianActionReviewed as Lt, normalizeSlackStatusText as M, recordAgentsInstructionsUpdated as Mt, slackMention as N, recordAttachmentsDelivered as Nt, requireAutomationRevision as O, loadProjection as Ot, truncateStatusText as P, recordAuthenticationLinked as Pt, recordTurnSummary as Q, buildConversationContext as Qt, postSlackEphemeralMessage as R, recordMcpProviderConnected as Rt, automationDefinition as S, ToolInputError as St, sameDefinitionValue as T, loadConnectedMcpProviders as Tt, slackExternalRefIdSchema as U, hydrateConversationMessages as Ut, uploadFilesToConversation as V, recordTurnRoute as Vt, continuableMessages as W, persistConversationMessages as Wt, getTurnRecord as X, resolveTaskTitle as Xt, failTurnRecord as Y, fallbackShortTitle as Yt, listTurnSummaries as Z, appendThreadContextMessages as Zt, parseEventAutomationRow as _, normalizeToolNameFromResult as _t, saveScheduledAutomation as a, recordDeliveredAssistantMessage as an, createTurnLimitGate as at, admitEventAutomationRun as b, trimTrailingAssistantMessages as bt, withScheduledAutomationLock as c, estimateTextTokens as cn, getPiMessageRole as ct, createEventAutomation as d, historyItemFromPiMessage as dn, hasRuntimeTurnContext as dt, estimateConversationContextTokens as en, TURN_LIMIT_DISABLED_REASON as et, deleteEventAutomation as f, piMessageFromHistoryItem as fn, instructionTextForProjection as ft, listEventAutomationsForTeam as g, isToolResultMessage as gt, listDeletedEventAutomationsCreatedBy as h, isToolResultError as ht, readScheduledAutomation as i, normalizeConversationText as in, buildTurnErrorResponse as it, normalizeSlackReplyMarkdown as j, openConversationProjection as jt, escapeSlackMrkdwnText as k, loadTurnProjection as kt, blockEventAutomation as l, getAgentContextCompactionTriggerTokens as ln, getTerminalAssistantMessages as lt, getEventAutomation as m, isContinuablePiBoundary as mt, listScheduledAutomationsForTeam as n, isHumanConversationMessage as nn, TurnSliceLimitExceededError as nt, saveScheduledAutomationInLock as o, turnHasReply as on, isTurnExecutionLimitExceededError as ot, findMatchingEventAutomations as p, isAssistantMessage as pt, abandonTurnRecord as q, resolveConversationTitle as qt, parseScheduledAutomationRow as r, markConversationMessage as rn, TurnToolCallLimitExceededError as rt, scheduledRunId as s, upsertConversationMessage as sn, extractAssistantText as st, createScheduledAutomation as t, getConversationMessageSlackTs as tn, TurnBudgetExceededError as tt, collectEventAutomationMatchKeys as u, getAgentContextInputLimitTokens as un, getUserMessageInstructionText as ut, saveEventAutomation as v, retainRuntimeTurnContext as vt, readAutomationVersion as w, commitMessages as wt, eventAutomationRunLimitReason as x, TURN_CONTEXT_TAG as xt, setEventAutomationStatus as y, stripRuntimeTurnContext as yt, postSlackMessage as z, recordSubscribedReplyRoute as zt };
3272
+ export { recordTurnSummary as $, buildConversationContext as $t, escapeSlackMrkdwnText as A, loadTurnProjection as At, postSlackMessage as B, recordSubscribedReplyRoute as Bt, automationVersionOf as C, ToolInputError as Ct, AutomationConflictError as D, loadConversationProjection as Dt, sameDefinitionValue as E, loadConnectedMcpProviders as Et, truncateStatusText as F, recordAuthenticationLinked as Ft, continuableMessages as G, persistConversationMessages as Gt, uploadFilesToConversation as H, recordTurnRoute as Ht, addReactionToMessage as I, recordAuthorizationCompleted as It, abandonTurnRecord as J, resolveConversationTitle as Jt, loadTurnCheckpoint as K, projectConversationMessages as Kt, getSlackMessagePermalink as L, recordAuthorizationRequested as Lt, normalizeSlackReplyMarkdown as M, openConversationProjection as Mt, normalizeSlackStatusText as N, recordAgentsInstructionsUpdated as Nt, automationRevision as O, loadLastModelProfile as Ot, slackMention as P, recordAttachmentsDelivered as Pt, listTurnSummaries as Q, appendThreadContextMessages as Qt, openSlackDirectMessage as R, recordGuardianActionReviewed as Rt, automationDefinition as S, TURN_CONTEXT_TAG as St, readAutomationVersion as T, commitMessages as Tt, slackEntitySchema as U, appendConversationMessages as Ut, removeReactionFromMessage as V, recordToolExecutionStarted as Vt, slackExternalRefIdSchema as W, hydrateConversationMessages as Wt, failTurnRecord as X, fallbackShortTitle as Xt, completeTurnRecord as Y, settleConversationTitleWork as Yt, getTurnRecord as Z, resolveTaskTitle as Zt, parseEventAutomationRow as _, isToolResultMessage as _t, saveScheduledAutomation as a, normalizeConversationText as an, buildTurnErrorResponse as at, admitEventAutomationRun as b, stripRuntimeTurnContext as bt, withScheduledAutomationLock as c, upsertConversationMessage as cn, extractAssistantText as ct, createEventAutomation as d, getAgentContextInputLimitTokens as dn, getUserMessageInstructionText as dt, createConversationMemoryService as en, persistWithRetry as et, deleteEventAutomation as f, historyItemFromPiMessage as fn, hasRuntimeTurnContext as ft, listEventAutomationsForTeam as g, isToolResultError as gt, listDeletedEventAutomationsCreatedBy as h, isContinuablePiBoundary as ht, readScheduledAutomation as i, markConversationMessage as in, TurnToolCallLimitExceededError as it, formatSlackLink as j, loadTurnRoute as jt, requireAutomationRevision as k, loadProjection as kt, blockEventAutomation as l, estimateTextTokens as ln, getPiMessageRole as lt, getEventAutomation as m, isAssistantMessage as mt, listScheduledAutomationsForTeam as n, getConversationMessageSlackTs as nn, TurnBudgetExceededError as nt, saveScheduledAutomationInLock as o, recordDeliveredAssistantMessage as on, createTurnLimitGate as ot, findMatchingEventAutomations as p, piMessageFromHistoryItem as pn, instructionTextForProjection as pt, saveTurnCheckpoint as q, persistConversationMessageSummaries as qt, parseScheduledAutomationRow as r, isHumanConversationMessage as rn, TurnSliceLimitExceededError as rt, scheduledRunId as s, turnHasReply as sn, isTurnExecutionLimitExceededError as st, createScheduledAutomation as t, estimateConversationContextTokens as tn, TURN_LIMIT_DISABLED_REASON as tt, collectEventAutomationMatchKeys as u, getAgentContextCompactionTriggerTokens as un, getTerminalAssistantMessages as ut, saveEventAutomation as v, normalizeToolNameFromResult as vt, listAutomationVersions as w, commitAcceptedReply as wt, eventAutomationRunLimitReason as x, trimTrailingAssistantMessages as xt, setEventAutomationStatus as y, retainRuntimeTurnContext as yt, postSlackEphemeralMessage as z, recordMcpProviderConnected as zt };
@@ -1,18 +1,17 @@
1
- import { I as isRecord, L as toOptionalNumber, R as toOptionalString } from "./logging-tPQeUe2i.js";
2
- import { d as getDb } from "./viewer-C-9nFKYr.js";
3
- import { d as juniorDestinations } from "./agent-invocations-BY60iNw-.js";
4
- import { l as juniorLocationConfigurations } from "./executor-BroK9oKy.js";
5
- import { Wt as persistConversationMessages } from "./tasks-CODtRzvX.js";
6
- import { it as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-DlSK8PQQ.js";
7
- import { w as getStateAdapter } from "./profile-Bb1zCVGP.js";
1
+ import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-DsHONhVm.js";
2
+ import { d as getDb } from "./viewer-CGvvRqKp.js";
3
+ import { d as juniorDestinations } from "./agent-invocations-Qfz7dWgU.js";
4
+ import { l as juniorLocationConfigurations } from "./executor-RvG6kVe1.js";
5
+ import { Gt as persistConversationMessages } from "./tasks-CEXKTASS.js";
6
+ import { it as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-BJ_5mlRH.js";
7
+ import { w as getStateAdapter } from "./profile-DpYjfKke.js";
8
8
  import { z } from "zod";
9
9
  import { randomUUID } from "node:crypto";
10
10
  import { and, eq, sql } from "drizzle-orm";
11
- //#region src/chat/configuration/types.ts
11
+ // src/chat/configuration/types.ts
12
12
  /** JSON value accepted by Location configuration. */
13
13
  const configValueSchema = z.json();
14
- //#endregion
15
- //#region src/chat/configuration/validation.ts
14
+ // src/chat/configuration/validation.ts
16
15
  const CONFIG_KEY_RE = /^[a-z0-9]+(?:\.[a-z0-9-]+)+$/;
17
16
  const SECRET_KEY_RE = /(?:^|[_.-])(token|secret|password|passphrase|api[-_]?key|private[-_]?key|credential|auth)(?:$|[_.-])/i;
18
17
  const SECRET_VALUE_PATTERNS = [
@@ -51,8 +50,7 @@ function validateConfigValue(value) {
51
50
  collectStringValues(value, stringValues);
52
51
  for (const text of stringValues) for (const pattern of SECRET_VALUE_PATTERNS) if (pattern.test(text)) return "Configuration value appears to contain secret material and is not allowed";
53
52
  }
54
- //#endregion
55
- //#region src/chat/configuration/service.ts
53
+ // src/chat/configuration/service.ts
56
54
  function sanitizeEntry(value) {
57
55
  if (!isRecord(value)) return;
58
56
  const key = toOptionalString(value.key);
@@ -123,8 +121,7 @@ function createLocationConfigurationService(storage) {
123
121
  resolveValues
124
122
  };
125
123
  }
126
- //#endregion
127
- //#region src/chat/configuration/sql.ts
124
+ // src/chat/configuration/sql.ts
128
125
  /** Resolve or create the canonical Location for a Slack Destination. */
129
126
  async function resolveLocationId(db, destination) {
130
127
  const channelId = destination.channelId;
@@ -248,8 +245,7 @@ function createDurableLocationConfigurationService(args) {
248
245
  }
249
246
  });
250
247
  }
251
- //#endregion
252
- //#region src/chat/state/conversation.ts
248
+ // src/chat/state/conversation.ts
253
249
  function defaultConversationState() {
254
250
  return {
255
251
  schemaVersion: 1,
@@ -335,8 +331,7 @@ function buildConversationStatePatch(conversation) {
335
331
  processing: { ...conversation.processing }
336
332
  } };
337
333
  }
338
- //#endregion
339
- //#region src/chat/runtime/thread-state.ts
334
+ // src/chat/runtime/thread-state.ts
340
335
  function threadStateKey(threadId) {
341
336
  return `thread-state:${threadId}`;
342
337
  }
@@ -428,5 +423,4 @@ function getLocationConfigurationService(destination) {
428
423
  loadLegacy: async () => await getLegacyChannelState(destination.channelId)
429
424
  });
430
425
  }
431
- //#endregion
432
426
  export { persistThreadState as a, configValueSchema as c, persistThreadRuntimeState as i, getPersistedSandboxState as n, persistThreadStateById as o, getPersistedThreadState as r, coerceThreadConversationState as s, getLocationConfigurationService as t };