@sentry/junior 0.287.0 → 0.289.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 (79) hide show
  1. package/dist/{adapter-CL-HUKgd.js → adapter-tE1wnl0T.js} +1 -1
  2. package/dist/{admin-C9urXVfi.js → admin-BmsPbmO_.js} +2 -2
  3. package/dist/{agent-runner-Bfnw551N.js → agent-runner-bvl8U5uH.js} +489 -165
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +7 -7
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +628 -238
  8. package/dist/{app-DBY5TnfY.d.ts → app-Cu454FXq.d.ts} +2 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +550 -71
  11. package/dist/assistant-reply-1N9oxyyb.js +58 -0
  12. package/dist/{automation-DksGNDRO.js → automation-DWbjJltM.js} +2 -2
  13. package/dist/{background-compaction-queue-CYI909P5.js → background-compaction-queue-D36oCldp.js} +161 -90
  14. package/dist/{briefs-DaXiMWzT.js → briefs-CV-1qkXa.js} +3 -3
  15. package/dist/{catalog-runtime-BCIuBe4d.js → catalog-runtime-BNK4uJVZ.js} +1 -1
  16. package/dist/cli/chat.js +14 -14
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/{config-CkHcUMN7.js → config-DHAy7XlP.js} +363 -8
  24. package/dist/{connections-BnIj0wtx.js → connections-C3VmH3cf.js} +7 -129
  25. package/dist/{conversation-E7ZPJx2H.js → conversation-CwC8K3RZ.js} +22 -5
  26. package/dist/{conversation-pending-messages-DVch6YQw.js → conversation-pending-messages-B0cuLReP.js} +1 -1
  27. package/dist/{conversation-privacy-DF1hW0ja.js → conversation-privacy-Bky_veSp.js} +1 -1
  28. package/dist/{credential-sync-CzMar9hq.js → credential-sync-dY9o0YSj.js} +28 -20
  29. package/dist/{db-DJ11eZqq.js → db-BS2Kql3j.js} +81 -46
  30. package/dist/{db-YDKKDxlh.d.ts → db-BebRmhsH.d.ts} +10 -2
  31. package/dist/{executor-BY9TB31g.js → executor-cc4nH86C.js} +125 -18
  32. package/dist/instrumentation.js +2 -2
  33. package/dist/{logging-BO5zU6Mt.js → logging-CtCJmt9p.js} +3 -2
  34. package/dist/{media-Cz1ZiV1U.js → media-BepyEUNm.js} +5 -1
  35. package/dist/{message-CsUbuEc8.js → message-C5VuRcP9.js} +9 -9
  36. package/dist/nitro.d.ts +1 -1
  37. package/dist/nitro.js +19 -41
  38. package/dist/{oauth-callback-server-hiDKK0_n.js → oauth-callback-server-KRrYUZ35.js} +2 -2
  39. package/dist/{projection-CL_YWeGf.js → projection-BFJG58TG.js} +448 -721
  40. package/dist/{prompt-BHOEQSmf.js → prompt-D15oftoL.js} +5 -5
  41. package/dist/{registry-BriFLnaJ.js → registry-C_JrgqUz.js} +1 -1
  42. package/dist/{resolve-Bt6GgAiA.js → resolve-Cn_7JfP-.js} +3 -3
  43. package/dist/{result-Bo1TZu0Q.js → result-CIbQFLp6.js} +16 -10
  44. package/dist/{runner-D3YeCQgt.js → runner-BwmaMJVO.js} +8 -8
  45. package/dist/{sandbox-egress-signals-CcnSPP4S.js → sandbox-egress-signals-BOQ8gn7i.js} +1 -1
  46. package/dist/{schedule-BTp__wrw.js → schedule-cP0AACm1.js} +11 -2
  47. package/dist/{schema-BWE3RJEB.js → schema-Bptz19Ja.js} +72 -14
  48. package/dist/{schema-C6fsEwjo.d.ts → schema-DQaFSkZZ.d.ts} +122 -3
  49. package/dist/{service-account-DiQQuuw7.js → service-account-AGw_pANb.js} +3 -3
  50. package/dist/{service-account-r6fl0b-9.js → service-account-CLZfF8O1.js} +3 -3
  51. package/dist/{session-stop-B2Nut40V.js → session-stop-CbzKf7UI.js} +84 -31
  52. package/dist/{skills-CD5aJdzg.js → skills-CcAJBquq.js} +2 -2
  53. package/dist/{spawn-CalgZQiu.js → spawn-BvAk2vTI.js} +5 -5
  54. package/dist/{stop-kujZLbi0.js → stop-BQU4u7la.js} +893 -519
  55. package/dist/{store-DdIEUL1q.js → store-DE7NJOvQ.js} +4 -16
  56. package/dist/{task-runner-D_RDr2Hu.js → task-runner-Q_7duP_T.js} +31 -27
  57. package/dist/{turn-failure-response-B5nV1Er-.js → turn-failure-response-aWZLfUM8.js} +18 -9
  58. package/dist/{validation-K4pqwoVZ.js → validation-BOoPeIJR.js} +1 -1
  59. package/dist/{version-DBvhk1X9.js → version-Db0MFy61.js} +1 -1
  60. package/dist/version.js +1 -1
  61. package/dist/{viewer-DrMmFUul.js → viewer-FFEFu9In.js} +4 -4
  62. package/dist/warmup-DDzrA9Gv.js +967 -0
  63. package/dist/{work-ljRoODGu.js → work-BBJK458E.js} +16 -15
  64. package/dist/{worker-CYO1Q0Js.js → worker-2iU5RFyq.js} +7 -31
  65. package/migrations/0089_conversation_paused_status.sql +3 -0
  66. package/migrations/0090_guardian_review_time_index.sql +20 -0
  67. package/migrations/0091_conversation_participant_unsubscribed_index.sql +20 -0
  68. package/migrations/0092_turn_metric_actor.sql +12 -0
  69. package/migrations/0093_participant_root_actor_backfill.sql +18 -0
  70. package/migrations/0094_conversation_delivery_paused_at.sql +1 -0
  71. package/migrations/meta/0089_snapshot.json +4372 -0
  72. package/migrations/meta/0090_snapshot.json +4388 -0
  73. package/migrations/meta/0091_snapshot.json +4410 -0
  74. package/migrations/meta/0092_snapshot.json +4446 -0
  75. package/migrations/meta/0093_snapshot.json +4446 -0
  76. package/migrations/meta/0094_snapshot.json +4452 -0
  77. package/migrations/meta/_journal.json +42 -0
  78. package/package.json +6 -5
  79. package/dist/assistant-reply-u_PRYzuz.js +0 -65
@@ -1,19 +1,19 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { $i as postSlackMessage, Ga as SANDBOX_WORKSPACE_ROOT, Ha as SANDBOX_DATA_ROOT, Hi as formatSlackLink, In as isExperimentalFeatureEnabled, Ja as sandboxSkillPathResolution, Jn as getPluginSystemPromptContributions, Ka as sandboxSkillDir, N as normalizeConversationText, Ui as normalizeSlackReplyMarkdown, Vi as escapeSlackMrkdwnText, Wr as cancelSubscriptions, Xn as getPluginUserPromptContributions, Zn as getPlugins, at as listTurnSummaries, bn as renderUntrustedTag, ci as getDashboardConversationLink, cn as normalizeToolNameFromResult, en as hasRuntimeTurnContext, fn as REQUEST_CONTEXT_SECTION_TAG, gn as escapeTagText, gr as getReviewItem, hn as escapeClosingTags, it as getTurnRecord, li as getDashboardObjectIconLink, ln as retainRuntimeTurnContext, mi as ToolInputError, mn as TURN_CONTEXT_TAG, oi as verifyTimerWatchCredentialSubject, on as isToolResultError, pn as SESSION_CONTEXT_SECTION_TAG, qa as sandboxSkillFile, qn as getPluginSlackConversationLink, rn as isAssistantMessage, si as JUNIOR_THREAD_STATE_TTL_MS, sn as isToolResultMessage, un as stripRuntimeTurnContext, vn as renderChildTag, vo as buildSentryConversationUrl, x as toStoredConversationMessage, xi as listWorkspaces, xn as tagJson, yn as renderTag$1 } from "./projection-CL_YWeGf.js";
3
- import { A as renderCurrentInstruction, M as escapeXml, N as escapeXmlText, n as botConfig } from "./config-CkHcUMN7.js";
4
- import { h as logWarn, m as logInfo, p as logException, v as serializeGenAiAttribute } from "./logging-BO5zU6Mt.js";
2
+ import { Cn as renderUntrustedTag, Fn as getPluginSlackConversationLink, Ha as sandboxSkillDir, Ii as escapeSlackMrkdwnText, In as getPluginSystemPromptContributions, Ji as postSlackMessage, Li as formatSlackLink, M as normalizeConversationText, Ra as SANDBOX_DATA_ROOT, Ri as normalizeSlackReplyMarkdown, Rn as getPluginUserPromptContributions, Rr as cancelSubscriptions, Sn as renderTag$1, Ua as sandboxSkillFile, Va as SANDBOX_WORKSPACE_ROOT, Wa as sandboxSkillPathResolution, _n as TURN_CONTEXT_TAG, dn as normalizeToolNameFromResult, ei as verifyTimerWatchCredentialSubject, fn as retainRuntimeTurnContext, gi as listWorkspaces, gn as SESSION_CONTEXT_SECTION_TAG, hn as REQUEST_CONTEXT_SECTION_TAG, li as ToolInputError, ln as isToolResultError, mo as buildSentryConversationUrl, ni as getDashboardConversationLink, on as isAssistantMessage, or as getReviewItem, ot as getTurnRecord, pn as stripRuntimeTurnContext, ri as getDashboardObjectIconLink, rn as hasRuntimeTurnContext, st as listTurnSummaries, ti as JUNIOR_THREAD_STATE_TTL_MS, un as isToolResultMessage, vn as escapeClosingTags, wn as tagJson, x as toStoredConversationMessage, xn as renderChildTag, yn as escapeTagText, zn as getPlugins } from "./projection-BFJG58TG.js";
3
+ import { F as renderCurrentInstruction, L as escapeXml, R as escapeXmlText, n as botConfig } from "./config-DHAy7XlP.js";
4
+ import { h as logWarn, m as logInfo, p as logException, v as serializeGenAiAttribute } from "./logging-CtCJmt9p.js";
5
5
  import { o as isUserActor, t as createActor } from "./actor-6jsm_v96.js";
6
- import { T as SYSTEM_IDENTITY_ID, a as getConversationStore, o as getDb, r as getConversationEventStore, s as getSqlExecutor, z as nextDetailVersion } from "./db-DJ11eZqq.js";
7
- import { A as juniorConversations, M as juniorUsers } from "./executor-BY9TB31g.js";
8
- import { i as isVisionImageMediaType } from "./media-Cz1ZiV1U.js";
6
+ import { J as nextDetailVersion, T as SYSTEM_IDENTITY_ID, a as getConversationStore, o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-BS2Kql3j.js";
7
+ import { A as juniorConversations, M as juniorUsers } from "./executor-cc4nH86C.js";
8
+ import { i as isVisionImageMediaType } from "./media-BepyEUNm.js";
9
9
  import { a as listReferenceFiles, c as soulPathCandidates, l as worldPathCandidates } from "./package-discovery-DJhGdS4c.js";
10
- import { h as credentialSubjectSchema } from "./registry-BriFLnaJ.js";
11
- import { a as EVENT_SYSTEM_ACTOR, d as JUNIOR_NATIVE_EVENT_NAMESPACE, h as conversationNoteEvent, i as EVENT_MESSAGE_AUTHOR, o as isEventConversationMessage, r as EVENT_AUTHOR_ID } from "./prompt-BHOEQSmf.js";
12
- import { r as getStateAdapter } from "./adapter-CL-HUKgd.js";
13
- import { a as QUIET_MARKER, i as NO_REPLY_MARKER, r as sanitizeAssistantText } from "./assistant-reply-u_PRYzuz.js";
10
+ import { h as credentialSubjectSchema } from "./registry-C_JrgqUz.js";
11
+ import { a as EVENT_SYSTEM_ACTOR, d as JUNIOR_NATIVE_EVENT_NAMESPACE, h as conversationNoteEvent, i as EVENT_MESSAGE_AUTHOR, o as isEventConversationMessage, r as EVENT_AUTHOR_ID } from "./prompt-D15oftoL.js";
12
+ import { r as getStateAdapter } from "./adapter-tE1wnl0T.js";
13
+ import { i as NO_REPLY_TOOL_NAME, r as sanitizeAssistantText } from "./assistant-reply-1N9oxyyb.js";
14
14
  import { D as userCustomizationTextSchema, v as formatUserInputAnswer } from "./reporting-window-B3Ze-Qnt.js";
15
- import { r as appendAndEnqueueInboundMessage } from "./store-DdIEUL1q.js";
16
- import { Tt as eventGuidance, wt as eventCatalogEntry, xt as CORE_EVENT_NAMESPACE } from "./task-runner-D_RDr2Hu.js";
15
+ import { r as appendAndEnqueueInboundMessage } from "./store-DE7NJOvQ.js";
16
+ import { Ct as eventGuidance, St as eventCatalogEntry, yt as CORE_EVENT_NAMESPACE } from "./task-runner-Q_7duP_T.js";
17
17
  import path from "node:path";
18
18
  import { isDeepStrictEqual } from "node:util";
19
19
  import * as z from "zod";
@@ -25,7 +25,7 @@ import fs from "node:fs";
25
25
  * Automation run result.
26
26
  *
27
27
  * A Scheduled automation or Event automation run ends with one declared
28
- * result. The run does not deliver its final assistant text. The work owner
28
+ * result. The run does not deliver its final response. The work owner
29
29
  * reads the declared result and applies the stored outcomes.
30
30
  */
31
31
  /** Model-facing tool that ends an Automation run. */
@@ -46,7 +46,7 @@ const automationResultSchema = z.discriminatedUnion("result", [
46
46
  })
47
47
  ]);
48
48
  /**
49
- * Return whether the runtime delivers the final assistant text of a run. It
49
+ * Return whether the runtime delivers the final response of a run. It
50
50
  * does not for a dispatch with no outcomes. It does not for an Automation
51
51
  * run, which posts only its declared message, after the run.
52
52
  */
@@ -56,7 +56,7 @@ function deliversFinalText(dispatch) {
56
56
  /**
57
57
  * Return whether the runtime may post a failure reply or a status notice,
58
58
  * such as an auth prompt, for a run outside `finishedRunReply`. The rule is
59
- * the same as for final text. A chat Turn may post, also in a thread that an
59
+ * the same as for a final response. A chat Turn may post, also in a thread that an
60
60
  * Automation Conversation owns. A dispatch with no outcomes posts nothing. An
61
61
  * Automation run posts only a declared message; its failed execution shows on
62
62
  * the Automation.
@@ -283,13 +283,13 @@ const CONVERSATION_RULES = ["- In thread follow-ups, answer from prior thread co
283
283
  const SLACK_ACTION_RULES = [
284
284
  "- Assistant text, Slack posts, reactions, new canvases, new lists, and file sends go only to the current conversation or thread. Your reply is not a channel post, and you cannot create a new top-level channel post. When asked to post to a channel or anywhere else right now, explain that limitation; do not call a Slack send tool, and do not reply with only the requested text or present it as delivered. Scheduled automations can still post to the active channel later. Slack read tools can target other public channels with `channel_id`.",
285
285
  "- Ambient reaction requests target the current inbound message; do not ask for a message reference.",
286
- `- When no visible thread reply is requested or useful, keep tool-calling messages text-free and make the final message exactly ${NO_REPLY_MARKER}.`
286
+ `- When no visible thread reply is requested or useful, keep tool-calling messages text-free and end the Turn with \`${NO_REPLY_TOOL_NAME}\`.`
287
287
  ];
288
288
  /**
289
289
  * Block 6, `<failure-reporting>`: how to report a failure to a person. How to
290
290
  * find the cause goes in `<evidence>`.
291
291
  */
292
- const FAILURE_REPORTING_RULES = ["- Keep raw tool payloads and internal routing metadata out of the final answer."];
292
+ const FAILURE_REPORTING_RULES = ["- Keep raw tool payloads and internal routing metadata out of the final response."];
293
293
  /**
294
294
  * Block 6, `<failure-reporting>` for automation runs. No person reads the run,
295
295
  * so a failure that stops the job goes in the declared reason, never in the
@@ -650,7 +650,7 @@ function buildDispatchSection(params) {
650
650
  const metadataLines = Object.entries(params.metadata ?? {}).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `- dispatch.metadata.${escapeXml(key)}: ${escapeXml(value)}`);
651
651
  return renderTag("dispatch", [
652
652
  "- dispatch.execution: execute the dispatched input now",
653
- ...params.declaresResult ? [] : ["- dispatch.delivery: the runtime delivers the final answer to the destination", "- dispatch.delivery_rule: do not request or require a separate posting tool just to deliver the final answer"],
653
+ ...params.declaresResult ? [] : ["- dispatch.delivery: the runtime delivers the final response to the destination", "- dispatch.delivery_rule: do not request or require a separate posting tool just to deliver the final response"],
654
654
  ...params.actor ? [`- dispatch.actor.platform: ${escapeXml(params.actor.platform)}`, `- dispatch.actor.name: ${escapeXml(params.actor.name)}`] : [],
655
655
  ...params.plugin ? [`- dispatch.plugin: ${escapeXml(params.plugin)}`] : [],
656
656
  ...formatSourceLines(params.source),
@@ -865,6 +865,47 @@ async function loadTurnConversationNotes(input) {
865
865
  }
866
866
  return newestFirst.reverse();
867
867
  }
868
+ // src/chat/experimental.ts
869
+ /**
870
+ * Known unstable product features that must be opted into explicitly.
871
+ * Add new keys here as features graduate from private experiments; remove them
872
+ * once they become stable defaults.
873
+ */
874
+ const EXPERIMENTAL_FEATURES = [
875
+ "operator-tools",
876
+ "passive-routing",
877
+ "user-customization"
878
+ ];
879
+ const EXPERIMENTAL_FEATURE_SET = new Set(EXPERIMENTAL_FEATURES);
880
+ let configuredExperimental = {};
881
+ function isExperimentalFeature(value) {
882
+ return EXPERIMENTAL_FEATURE_SET.has(value);
883
+ }
884
+ /** Replace app-level experimental opt-ins and return the previous setting. */
885
+ function setExperimentalFeatures(config) {
886
+ const previous = { ...configuredExperimental };
887
+ if (config === void 0) {
888
+ configuredExperimental = {};
889
+ return previous;
890
+ }
891
+ const next = {};
892
+ for (const [rawName, enabled] of Object.entries(config)) {
893
+ if (enabled === void 0) continue;
894
+ if (typeof enabled !== "boolean") throw new Error(`experimental.${rawName} must be a boolean when provided`);
895
+ if (!isExperimentalFeature(rawName)) throw new Error(`experimental.${rawName} is not a known experimental feature. Known features: ${EXPERIMENTAL_FEATURES.join(", ")}`);
896
+ next[rawName] = enabled;
897
+ }
898
+ configuredExperimental = next;
899
+ return previous;
900
+ }
901
+ /** Return a copy of the app-level experimental opt-ins configured by createApp(). */
902
+ function getExperimentalFeatures() {
903
+ return { ...configuredExperimental };
904
+ }
905
+ /** Return whether one experimental feature is enabled via createApp({ experimental }). */
906
+ function isExperimentalFeatureEnabled(feature) {
907
+ return configuredExperimental[feature] === true;
908
+ }
868
909
  // src/chat/identities/customization.ts
869
910
  /** Read the saved customization for one user. */
870
911
  async function readUserCustomization(userId) {
@@ -1891,7 +1932,7 @@ function replyContractLines(outcomes) {
1891
1932
  if (!outcomes) return [
1892
1933
  "When an Event asks you a question, answer it where it was asked, with that provider's tool. Then reply with the answer and a link to it.",
1893
1934
  "When you reply, follow any reply format in the instructions.",
1894
- `When the outcome needs nobody's attention, such as a routine fix that worked or feedback that you handled, end the reply with exactly ${QUIET_MARKER}. The reply stays in the Conversation but notifies nobody. Do not use it when the instructions say to notify, mention, or report to a person, when the reply asks a question, when a person must decide or act, or when something failed.`
1935
+ `When the outcome needs nobody's attention, such as a routine fix that worked or feedback that you handled, end the Turn with \`${NO_REPLY_TOOL_NAME}\` and put the outcome in its \`note\`. The note stays in the Conversation but notifies nobody. Do not use it when the instructions say to notify, mention, or report to a person, when the reply asks a question, when a person must decide or act, or when something failed.`
1895
1936
  ];
1896
1937
  return [`End with \`${FINISH_AUTOMATION_RUN_TOOL_NAME}\`.`];
1897
1938
  }
@@ -2123,6 +2164,8 @@ const SLACK_CURRENT_CHANNEL_IDENTIFIER = "current_channel";
2123
2164
  const CHANNEL_RESOURCE_TYPE = "channel";
2124
2165
  const MESSAGE_POSTED_EVENT = "message.posted";
2125
2166
  const CHANNEL_ID_PATTERN = /^[CG][A-Z0-9]{2,}$/;
2167
+ const CHANNEL_LOCATION = "channel";
2168
+ const THREAD_LOCATION = "thread";
2126
2169
  const CHANNEL_MESSAGE_MATCH_FIELDS = eventMatchFieldsSchema.parse({
2127
2170
  channelId: {
2128
2171
  kind: "string",
@@ -2132,11 +2175,16 @@ const CHANNEL_MESSAGE_MATCH_FIELDS = eventMatchFieldsSchema.parse({
2132
2175
  userId: {
2133
2176
  kind: "string",
2134
2177
  description: "Slack user ID of the message author. Required to run on bot posts, such as alert bots."
2178
+ },
2179
+ location: {
2180
+ kind: "string",
2181
+ enum: [CHANNEL_LOCATION, THREAD_LOCATION],
2182
+ description: "channel for a top-level message, thread for a thread reply. Leave out for top-level only; thread replies run only when this names thread."
2135
2183
  }
2136
2184
  });
2137
2185
  /**
2138
- * Event registration for new top-level Slack channel messages. Only event
2139
- * automations can use it, so watchEvents rejects it.
2186
+ * Event registration for new Slack channel messages and thread replies. Only
2187
+ * event automations can use it, so watchEvents rejects it.
2140
2188
  */
2141
2189
  function slackChannelMessageEvents() {
2142
2190
  return {
@@ -2152,7 +2200,7 @@ function slackChannelMessageEvents() {
2152
2200
  }],
2153
2201
  events: { [MESSAGE_POSTED_EVENT]: {
2154
2202
  reach: { anyOf: ["channelId"] },
2155
- guidance: "A person or bot posted a new top-level message in this channel. A bot post runs the automation only when match names the bot in user_id. A reply goes in that message's thread. If the instructions do not apply to this message, end with no action."
2203
+ guidance: "A person or bot posted a new message in this channel. A bot post runs the automation only when match names the bot in user_id. A thread reply runs it only when match.location names thread. A reply goes in the message's Slack thread. If the instructions do not apply to this message, end with no action."
2156
2204
  } },
2157
2205
  limits: { [CHANNEL_RESOURCE_TYPE]: {
2158
2206
  watch: false,
@@ -2201,25 +2249,28 @@ function requireSlackChannelMessageScope(automation) {
2201
2249
  };
2202
2250
  }
2203
2251
  /**
2204
- * Build the Event for one new top-level channel message, or nothing.
2252
+ * Build the Event for one new channel message or thread reply, or nothing.
2205
2253
  *
2206
- * Thread replies and Slackbot posts do not count. Other bot posts are marked
2207
- * with `postedByBot`, so only automations that name the bot can run on them.
2254
+ * Slackbot posts do not count. Bot posts are marked with `postedByBot`, so
2255
+ * only automations that name the bot can run on them. Thread replies carry
2256
+ * the `thread` location, so only automations that name it can run on them.
2208
2257
  */
2209
2258
  function slackChannelMessageEvent(input) {
2210
2259
  if (input.userId === "USLACKBOT") return void 0;
2211
- if (input.threadTs && input.threadTs !== input.ts) return void 0;
2212
2260
  if (!CHANNEL_ID_PATTERN.test(input.channelId)) return void 0;
2213
2261
  const postedByBot = Boolean(input.botId || input.subtype === "bot_message");
2262
+ const threadTs = input.threadTs && input.threadTs !== input.ts ? input.threadTs : void 0;
2214
2263
  return {
2215
2264
  eventKey: `${input.channelId}:${input.ts}`,
2216
2265
  eventType: MESSAGE_POSTED_EVENT,
2217
2266
  identifier: input.channelId,
2218
2267
  occurredAtMs: Math.floor(Number(input.ts) * 1e3),
2219
- trustedSummary: `${postedByBot ? "The bot " : ""}<@${input.userId}> posted a new message in <#${input.channelId}>.`,
2268
+ trustedSummary: `${postedByBot ? "The bot " : ""}<@${input.userId}> posted a new ${threadTs ? `thread reply under message ${threadTs}` : "message"} in <#${input.channelId}>.`,
2220
2269
  data: {
2221
2270
  channelId: input.channelId,
2271
+ location: threadTs ? THREAD_LOCATION : CHANNEL_LOCATION,
2222
2272
  messageTs: input.ts,
2273
+ ...threadTs ? { threadTs } : void 0,
2223
2274
  userId: input.userId,
2224
2275
  ...postedByBot ? { postedByBot: true } : void 0
2225
2276
  },
@@ -2234,18 +2285,20 @@ function slackChannelMessageEvent(input) {
2234
2285
  * channel, and this check keeps the rule when it does not.
2235
2286
  * A bot post runs only automations whose match names its author in `userId`.
2236
2287
  * Bots can post often and would use up the run limit of every other
2237
- * automation in the channel.
2288
+ * automation in the channel. A thread reply runs only automations whose
2289
+ * match names the `thread` location, so existing automations stay top-level.
2238
2290
  */
2239
2291
  function slackChannelMessageRunsAutomation(event, automation) {
2240
2292
  if (event.namespace !== "slack") return true;
2241
2293
  if (event.data?.channelId !== automation.destination.channelId) return false;
2294
+ if (event.data?.location === THREAD_LOCATION && ![automation.trigger.match?.location].flat().includes(THREAD_LOCATION)) return false;
2242
2295
  if (event.data?.postedByBot !== true) return true;
2243
2296
  return automation.trigger.match?.userId !== void 0;
2244
2297
  }
2245
2298
  /** Return the source message thread for a channel-message run. */
2246
2299
  function slackChannelMessageReplyThreadTs(event) {
2247
2300
  if (event.namespace !== "slack") return void 0;
2248
- const messageTs = event.data?.messageTs;
2301
+ const messageTs = event.data?.threadTs ?? event.data?.messageTs;
2249
2302
  return typeof messageTs === "string" ? messageTs : void 0;
2250
2303
  }
2251
2304
  // src/chat/events/runtime-catalog.ts
@@ -2568,7 +2621,7 @@ function conversationSubtree(conversationIds) {
2568
2621
  from junior_conversations child
2569
2622
  join tree
2570
2623
  on child.parent_conversation_id = tree.conversation_id
2571
- and child.root_conversation_id = tree.root_conversation_id
2624
+ and (child.root_conversation_id || '') = tree.root_conversation_id
2572
2625
  )
2573
2626
  select scope_conversation_id, conversation_id from tree
2574
2627
  ) conversation_subtree`;
@@ -2923,4 +2976,4 @@ async function saveStoppedConversationEvents(conversationId, messages) {
2923
2976
  }
2924
2977
  }]);
2925
2978
  }
2926
- export { withoutSavedSteeringMessages as $, requireSlackChannelMessageScope as A, maybePostAutomatedTurnLimitNotice as B, enqueueEventNotification as C, timerWatchCredentialSubject as D, renderEventBatchInputs as E, WORKSPACE_SNAPSHOT_FAILED_EVENT as F, admitAutomatedTurn as G, resolveSlackReplyTarget as H, WORKSPACE_SNAPSHOT_READY_EVENT as I, assemblePrompt as J, recordFinishedTurnForAutomatedLimit as K, workspaceSnapshotFinishedEvent as L, slackChannelMessageReplyThreadTs as M, slackChannelMessageRunsAutomation as N, getEventCatalog as O, slackChannelMessageTrigger as P, loadPromptTurnContext as Q, workspaceSnapshotWatch as R, EVENT_WAIT_MS as S, isEventMailboxMetadata as T, sendSlackReply as U, postAutomatedTurnLimitNoticeForConversation as V, renderSlackObjectCard as W, buildSteeringPiMessage as X, buildPromptInput as Y, instructionForInputs as Z, sourceFromTurnInput as _, session_stop_exports as a, readBlockedReport as at, conversationSubtree as b, loadReviewItemInput as c, deliversFinalText as ct, getAuthPausedConversationTurnId as d, readAutomationResult as dt, readUserCustomization as et, getEventBatchDelayMs as f, remindMissingAutomationResult as ft, resolveMailboxTurnWork as g, parseWebMessages as h, resumeStoppedConversationTree as i, REPORT_BLOCKED_TOOL_NAME as it, slackChannelMessageEvent as j, SLACK_EVENT_NAMESPACE as k, savedInputInstruction as l, finishedRunReply as lt, parseEventMessages as m, isWatchEvent as n, addConversationNote as nt, skipInputAfterConversationStop as o, FINISH_AUTOMATION_RUN_TOOL_NAME as ot, listActiveMailboxTurns as p, runDispatchOutcome as pt, resetAutomatedTurnLimit as q, markConversationsStopped as r, JUNIOR_PERSONALITY as rt, eventReviewItemInputs as s, automationResultSchema as st, getConversationStoppedAtMs as t, saveUserCustomization as tt, getActiveConversationTurnId as u, postsRunNotices as ut, turnInputFactsFromConversationMessage as v, eventBatchMessageMeta as w, conversationSubtreeColumns as x, legacyWebMailboxMetadataSchema as y, renderTaskInput as z };
2979
+ export { withoutSavedSteeringMessages as $, requireSlackChannelMessageScope as A, maybePostAutomatedTurnLimitNotice as B, enqueueEventNotification as C, timerWatchCredentialSubject as D, renderEventBatchInputs as E, WORKSPACE_SNAPSHOT_FAILED_EVENT as F, admitAutomatedTurn as G, resolveSlackReplyTarget as H, WORKSPACE_SNAPSHOT_READY_EVENT as I, assemblePrompt as J, recordFinishedTurnForAutomatedLimit as K, workspaceSnapshotFinishedEvent as L, slackChannelMessageReplyThreadTs as M, slackChannelMessageRunsAutomation as N, getEventCatalog as O, slackChannelMessageTrigger as P, loadPromptTurnContext as Q, workspaceSnapshotWatch as R, EVENT_WAIT_MS as S, isEventMailboxMetadata as T, sendSlackReply as U, postAutomatedTurnLimitNoticeForConversation as V, renderSlackObjectCard as W, buildSteeringPiMessage as X, buildPromptInput as Y, instructionForInputs as Z, sourceFromTurnInput as _, session_stop_exports as a, addConversationNote as at, conversationSubtree as b, loadReviewItemInput as c, readBlockedReport as ct, getAuthPausedConversationTurnId as d, deliversFinalText as dt, readUserCustomization as et, getEventBatchDelayMs as f, finishedRunReply as ft, resolveMailboxTurnWork as g, runDispatchOutcome as gt, parseWebMessages as h, remindMissingAutomationResult as ht, resumeStoppedConversationTree as i, setExperimentalFeatures as it, slackChannelMessageEvent as j, SLACK_EVENT_NAMESPACE as k, savedInputInstruction as l, FINISH_AUTOMATION_RUN_TOOL_NAME as lt, parseEventMessages as m, readAutomationResult as mt, isWatchEvent as n, getExperimentalFeatures as nt, skipInputAfterConversationStop as o, JUNIOR_PERSONALITY as ot, listActiveMailboxTurns as p, postsRunNotices as pt, resetAutomatedTurnLimit as q, markConversationsStopped as r, isExperimentalFeatureEnabled as rt, eventReviewItemInputs as s, REPORT_BLOCKED_TOOL_NAME as st, getConversationStoppedAtMs as t, saveUserCustomization as tt, getActiveConversationTurnId as u, automationResultSchema as ut, turnInputFactsFromConversationMessage as v, eventBatchMessageMeta as w, conversationSubtreeColumns as x, legacyWebMailboxMetadataSchema as y, renderTaskInput as z };
@@ -1,7 +1,7 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { h as logWarn } from "./logging-BO5zU6Mt.js";
2
+ import { h as logWarn } from "./logging-CtCJmt9p.js";
3
3
  import { s as skillRoots } from "./package-discovery-DJhGdS4c.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-BCIuBe4d.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BNK4uJVZ.js";
5
5
  import path from "node:path";
6
6
  import * as z from "zod";
7
7
  import fs from "node:fs/promises";
@@ -1,9 +1,9 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { n as botConfig } from "./config-CkHcUMN7.js";
3
- import { o as getDb, x as conversationKindFromRow } from "./db-DJ11eZqq.js";
4
- import { A as juniorConversations } from "./executor-BY9TB31g.js";
5
- import { $t as toolInvocationDestination, Qt as actorFromRun, Vt as AgentDepthLimitError } from "./agent-runner-Bfnw551N.js";
6
- import { n as createAndEnqueueAgentInvocation } from "./work-ljRoODGu.js";
2
+ import { n as botConfig } from "./config-DHAy7XlP.js";
3
+ import { o as getDb, x as conversationKindFromRow } from "./db-BS2Kql3j.js";
4
+ import { A as juniorConversations } from "./executor-cc4nH86C.js";
5
+ import { dn as actorFromRun, en as AgentDepthLimitError, fn as toolInvocationDestination } from "./agent-runner-bvl8U5uH.js";
6
+ import { n as createAndEnqueueAgentInvocation } from "./work-BBJK458E.js";
7
7
  import { desc, eq, sql } from "drizzle-orm";
8
8
  // src/chat/conversations/lineage.ts
9
9
  /**