@sentry/junior 0.147.0 → 0.149.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 (162) hide show
  1. package/dist/{agent-hooks-HS6VGUPM.js → agent-hooks-CWMCXAMT.js} +10 -10
  2. package/dist/api/conversations/access.d.ts +2 -1
  3. package/dist/api/conversations/aggregate.d.ts +2 -0
  4. package/dist/api/conversations/archive.d.ts +3 -5
  5. package/dist/api/conversations/create.d.ts +6 -0
  6. package/dist/api/conversations/detail.d.ts +2 -296
  7. package/dist/api/conversations/event-list.d.ts +2 -193
  8. package/dist/api/conversations/list.d.ts +4 -66
  9. package/dist/api/conversations/pending-messages.d.ts +15 -0
  10. package/dist/api/conversations/routes.d.ts +1 -1
  11. package/dist/api/conversations/stats.d.ts +0 -54
  12. package/dist/api/http.d.ts +2 -6
  13. package/dist/api/locations/detail.d.ts +3 -111
  14. package/dist/api/locations/list.d.ts +0 -45
  15. package/dist/api/locations/query.d.ts +2 -1
  16. package/dist/api/locations/routes.d.ts +1 -1
  17. package/dist/api/people/list.d.ts +0 -29
  18. package/dist/api/people/profile.d.ts +2 -106
  19. package/dist/api/people/profile.query.d.ts +2 -1
  20. package/dist/api/people/routes.d.ts +1 -1
  21. package/dist/api/people/shared.d.ts +3 -1
  22. package/dist/api/people/spend.d.ts +3 -4
  23. package/dist/api/personal-tokens/routes.d.ts +2 -2
  24. package/dist/api/route.d.ts +8 -14
  25. package/dist/api/schema/conversation.d.ts +130 -25
  26. package/dist/api/schema/location.d.ts +4 -0
  27. package/dist/api/schema/person.d.ts +7 -3
  28. package/dist/api/schema.d.ts +2 -2
  29. package/dist/api/schema.js +13 -1
  30. package/dist/api/stats.d.ts +0 -13
  31. package/dist/api/validation.d.ts +7 -0
  32. package/dist/api/viewer.d.ts +3 -0
  33. package/dist/api.d.ts +2 -1
  34. package/dist/api.js +772 -561
  35. package/dist/app.js +241 -204
  36. package/dist/{catalog-runtime-M6ZTPYRV.js → catalog-runtime-GAW5APVI.js} +5 -5
  37. package/dist/chat/actor.d.ts +4 -1
  38. package/dist/chat/agent/request.d.ts +2 -0
  39. package/dist/chat/agent/resume.d.ts +1 -0
  40. package/dist/chat/agent-dispatch/context.d.ts +2 -2
  41. package/dist/chat/agent-invocations/types.d.ts +52 -0
  42. package/dist/chat/api-turns/work.d.ts +108 -0
  43. package/dist/chat/app/services.d.ts +1 -1
  44. package/dist/chat/conversations/history.d.ts +60 -0
  45. package/dist/chat/conversations/provenance.d.ts +6 -0
  46. package/dist/chat/conversations/sql/actor-identity.d.ts +19 -0
  47. package/dist/chat/conversations/store.d.ts +1 -1
  48. package/dist/chat/resource-events/store.d.ts +1 -1
  49. package/dist/chat/runtime/reply-executor.d.ts +1 -3
  50. package/dist/chat/runtime/slack-runtime.d.ts +2 -1
  51. package/dist/chat/runtime/turn-preparation.d.ts +9 -0
  52. package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
  53. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  54. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  55. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  56. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  57. package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
  58. package/dist/chat/services/conversation-memory.d.ts +2 -2
  59. package/dist/chat/services/conversation-title.d.ts +20 -0
  60. package/dist/chat/slack/assistant-thread/title.d.ts +10 -27
  61. package/dist/chat/slack/channel.d.ts +26 -0
  62. package/dist/chat/slack/dispatch-turn.d.ts +1 -0
  63. package/dist/chat/slack/timestamp-param.d.ts +0 -2
  64. package/dist/chat/slack/{tools → tool-support}/canvas/api.d.ts +1 -1
  65. package/dist/chat/slack/{tools → tool-support}/canvas/context.d.ts +3 -0
  66. package/dist/chat/slack/tool-support/channel-access.d.ts +42 -0
  67. package/dist/chat/slack/tool-support/channel-target.d.ts +27 -0
  68. package/dist/chat/slack/tool-support/list/params.d.ts +5 -0
  69. package/dist/chat/slack/tools/canvas/create.d.ts +1 -1
  70. package/dist/chat/slack/tools/channel-join.d.ts +28 -0
  71. package/dist/chat/slack/tools/channel-list-messages.d.ts +3 -2
  72. package/dist/chat/slack/tools/conversation-message-search.d.ts +2 -8
  73. package/dist/chat/slack/tools/message-add-reaction.d.ts +1 -1
  74. package/dist/chat/slack/tools/public-search.d.ts +63 -2
  75. package/dist/chat/slack/tools/send-files.d.ts +1 -1
  76. package/dist/chat/slack/tools/thread-read.d.ts +2 -5
  77. package/dist/chat/source.d.ts +2 -0
  78. package/dist/chat/state/conversation.d.ts +1 -0
  79. package/dist/chat/task-execution/checkpoint.d.ts +1 -0
  80. package/dist/chat/task-execution/state.d.ts +9 -4
  81. package/dist/chat/task-execution/store.d.ts +3 -2
  82. package/dist/chat/task-execution/turn-cursor.d.ts +2 -0
  83. package/dist/chat/task-execution/worker.d.ts +2 -0
  84. package/dist/chat/tasks/read.d.ts +1 -1
  85. package/dist/chat/tools/search-conversation-events.d.ts +1 -1
  86. package/dist/chat/tools/types.d.ts +11 -4
  87. package/dist/chat/tools/watch-resource-events.d.ts +2 -2
  88. package/dist/{chunk-ORO3PWKQ.js → chunk-25SC7D6Z.js} +1 -1
  89. package/dist/{chunk-GGB4WL5A.js → chunk-2JHKISQA.js} +1 -1
  90. package/dist/{chunk-AVZDSUFB.js → chunk-2P6BQQER.js} +4 -4
  91. package/dist/{chunk-7NVJVJID.js → chunk-32CXPIZE.js} +2 -2
  92. package/dist/{chunk-YSB2N563.js → chunk-3GYZ5YEH.js} +121 -87
  93. package/dist/{chunk-DU74WPIC.js → chunk-3I2IVWSZ.js} +1 -1
  94. package/dist/{chunk-SVHUEHUL.js → chunk-3JVUWLR7.js} +65 -4
  95. package/dist/{chunk-RXBVB2JM.js → chunk-3KGQOKIG.js} +1 -1
  96. package/dist/{chunk-YBVXBNSV.js → chunk-4JGM7FXO.js} +2 -2
  97. package/dist/{chunk-AZ7EAOBE.js → chunk-4YKPOYRV.js} +5 -5
  98. package/dist/chunk-5CWUQXXT.js +806 -0
  99. package/dist/{chunk-DLDRQHG5.js → chunk-6G5RCDKP.js} +1 -1
  100. package/dist/{chunk-AYU72WO7.js → chunk-75DSYFFB.js} +47 -70
  101. package/dist/{chunk-YHDERDRO.js → chunk-7BH46NB4.js} +91 -75
  102. package/dist/{chunk-745QJ3ZA.js → chunk-ALJG73MQ.js} +2 -2
  103. package/dist/chunk-ART7P442.js +48 -0
  104. package/dist/{chunk-7A4M7PCV.js → chunk-DK5UT6PQ.js} +1180 -556
  105. package/dist/{chunk-AIOK6LAG.js → chunk-EW2LNCRL.js} +813 -44
  106. package/dist/chunk-EXW76GW4.js +36 -0
  107. package/dist/chunk-GDFF3BQG.js +136 -0
  108. package/dist/{chunk-7UQIVT6G.js → chunk-JMH3DBM5.js} +6 -6
  109. package/dist/{chunk-CWP5RHVX.js → chunk-JMSMXXED.js} +12 -5
  110. package/dist/{chunk-CSZINQJ2.js → chunk-MEMURSBG.js} +1 -1
  111. package/dist/{chunk-YNTTROJT.js → chunk-QIW7OQEO.js} +1 -1
  112. package/dist/{chunk-Q4R73I43.js → chunk-RB26T3LU.js} +58 -28
  113. package/dist/{chunk-4LJO56OJ.js → chunk-RLVZIWNQ.js} +1 -1
  114. package/dist/{chunk-SGZO7UWH.js → chunk-SWHPVZBV.js} +2 -2
  115. package/dist/{chunk-PVNG6UMU.js → chunk-TFBNBXPU.js} +22 -10
  116. package/dist/{chunk-EFLJ2WJH.js → chunk-URDCZAL4.js} +5 -5
  117. package/dist/{chunk-6H5SZR24.js → chunk-UZGASGOD.js} +300 -383
  118. package/dist/{chunk-YEO3VX72.js → chunk-W7UONUIZ.js} +8 -6
  119. package/dist/{chunk-JUUKWRBE.js → chunk-X22XXSZA.js} +1 -1
  120. package/dist/{chunk-X5UY34KT.js → chunk-XPYWWMHR.js} +8 -8
  121. package/dist/{chunk-IIOOO4FQ.js → chunk-ZYMYLLWG.js} +2 -1
  122. package/dist/cli/chat.js +32 -35
  123. package/dist/cli/check.js +6 -6
  124. package/dist/cli/plugins.js +13 -13
  125. package/dist/cli/snapshot-create.js +9 -9
  126. package/dist/cli/upgrade.js +7 -7
  127. package/dist/db/schema/agent-invocations.d.ts +20 -0
  128. package/dist/db/schema/conversation-annotations.d.ts +2 -2
  129. package/dist/db/schema.d.ts +22 -2
  130. package/dist/{db-CSEW4RII.js → db-JBZLRIVY.js} +7 -7
  131. package/dist/instrumentation.js +4 -4
  132. package/dist/nitro.js +2 -2
  133. package/dist/{oauth-callback-server-FUEV5HNG.js → oauth-callback-server-MNTVYY2I.js} +24 -26
  134. package/dist/{runner-U3XHSKSH.js → runner-K24BWZSZ.js} +23 -25
  135. package/dist/{skills-AKE6W3WI.js → skills-AU5ST2CG.js} +6 -6
  136. package/dist/spawn-6PO7CVJ6.js +38 -0
  137. package/dist/{validation-WDTAULUF.js → validation-IXGZCFRO.js} +6 -6
  138. package/dist/version.js +1 -1
  139. package/dist/{work-C3HAO2BG.js → work-WCZIYILX.js} +18 -19
  140. package/dist/{worker-LNP4YKBM.js → worker-U2AACBEY.js} +11 -10
  141. package/package.json +6 -5
  142. package/dist/api/health.d.ts +0 -7
  143. package/dist/api/personal-tokens/create.d.ts +0 -11
  144. package/dist/api/personal-tokens/list.d.ts +0 -12
  145. package/dist/api/personal-tokens/revoke.d.ts +0 -5
  146. package/dist/api/plugin-reports.d.ts +0 -63
  147. package/dist/api/plugins.d.ts +0 -8
  148. package/dist/api/runtime.d.ts +0 -24
  149. package/dist/api/skills.d.ts +0 -6
  150. package/dist/chat/slack/tools/channel-access.d.ts +0 -30
  151. package/dist/chunk-34GS7B6L.js +0 -115
  152. package/dist/chunk-AVOCH2Z5.js +0 -285
  153. package/dist/chunk-HLXXQI5Q.js +0 -238
  154. package/dist/chunk-K4SZAP3K.js +0 -67
  155. package/dist/chunk-R776HKPK.js +0 -81
  156. package/dist/chunk-Z4YU7Z4L.js +0 -76
  157. package/dist/spawn-B6GDTWJ4.js +0 -39
  158. /package/dist/chat/slack/{tools → tool-support}/canvas/markdown.d.ts +0 -0
  159. /package/dist/chat/slack/{tools → tool-support}/channel-capabilities.d.ts +0 -0
  160. /package/dist/chat/slack/{tools → tool-support}/context.d.ts +0 -0
  161. /package/dist/chat/slack/{tools → tool-support}/list/api.d.ts +0 -0
  162. /package/dist/chat/slack/{tools → tool-support}/slack-message-url.d.ts +0 -0
@@ -0,0 +1,36 @@
1
+ import {
2
+ FUNCTION_TIMEOUT_BUFFER_SECONDS,
3
+ getChatConfig
4
+ } from "./chunk-32CXPIZE.js";
5
+
6
+ // src/chat/runtime/request-deadline.ts
7
+ import { AsyncLocalStorage } from "async_hooks";
8
+ var requestDeadlineStorage = new AsyncLocalStorage();
9
+ function createTurnRequestDeadline(startedAtMs) {
10
+ const requestBudgetMs = Math.max(
11
+ 1,
12
+ getChatConfig().functionMaxDurationSeconds * 1e3 - FUNCTION_TIMEOUT_BUFFER_SECONDS * 1e3
13
+ );
14
+ return {
15
+ startedAtMs,
16
+ deadlineAtMs: startedAtMs + requestBudgetMs
17
+ };
18
+ }
19
+ function getTurnRequestDeadline() {
20
+ return requestDeadlineStorage.getStore();
21
+ }
22
+ function runWithTurnRequestDeadline(callback, startedAtMs = Date.now()) {
23
+ const existingDeadline = requestDeadlineStorage.getStore();
24
+ if (existingDeadline) {
25
+ return callback();
26
+ }
27
+ return requestDeadlineStorage.run(
28
+ createTurnRequestDeadline(startedAtMs),
29
+ callback
30
+ );
31
+ }
32
+
33
+ export {
34
+ getTurnRequestDeadline,
35
+ runWithTurnRequestDeadline
36
+ };
@@ -0,0 +1,136 @@
1
+ // src/chat/agent/request.ts
2
+ function isAgentRunFeatureDisabled(policy, feature) {
3
+ return policy?.disabledFeatures?.includes(feature) ?? false;
4
+ }
5
+ var RetryableDeliveryError = class extends Error {
6
+ constructor(cause) {
7
+ super("Assistant delivery was transient or ambiguous", { cause });
8
+ this.name = "RetryableDeliveryError";
9
+ }
10
+ };
11
+ function actorFromRouting(routing) {
12
+ if (routing.dispatch?.actor) {
13
+ return routing.dispatch.actor;
14
+ }
15
+ if (routing.actor) {
16
+ return routing.actor;
17
+ }
18
+ if (routing.credentialContext && !("type" in routing.credentialContext.actor)) {
19
+ return routing.credentialContext.actor;
20
+ }
21
+ return void 0;
22
+ }
23
+ function assertRunRoutingConsistency(request) {
24
+ const { destination, source } = request.routing;
25
+ switch (source.platform) {
26
+ case "slack": {
27
+ if (destination.platform !== "slack") {
28
+ throw new TypeError("Run source and destination platforms do not match");
29
+ }
30
+ if (source.teamId !== destination.teamId) {
31
+ throw new TypeError("Slack source and destination teams do not match");
32
+ }
33
+ break;
34
+ }
35
+ case "local": {
36
+ if (destination.platform !== "local") {
37
+ throw new TypeError("Run source and destination platforms do not match");
38
+ }
39
+ if (source.conversationId !== destination.conversationId) {
40
+ throw new TypeError(
41
+ "Source and destination conversation IDs do not match"
42
+ );
43
+ }
44
+ if (request.routing.surface !== "internal" && destination.conversationId !== request.conversationId) {
45
+ throw new TypeError(
46
+ "Source, destination, and run conversation IDs do not match"
47
+ );
48
+ }
49
+ break;
50
+ }
51
+ case "web": {
52
+ if (request.routing.surface !== "internal" && source.conversationId !== request.conversationId) {
53
+ throw new TypeError(
54
+ "Web source and run conversation IDs do not match"
55
+ );
56
+ }
57
+ switch (destination.platform) {
58
+ case "local": {
59
+ if (source.conversationId !== destination.conversationId) {
60
+ throw new TypeError(
61
+ "Source and destination conversation IDs do not match"
62
+ );
63
+ }
64
+ if (request.routing.surface !== "internal" && destination.conversationId !== request.conversationId) {
65
+ throw new TypeError(
66
+ "Source, destination, and run conversation IDs do not match"
67
+ );
68
+ }
69
+ break;
70
+ }
71
+ case "slack": {
72
+ if (request.routing.publishExternally) {
73
+ throw new TypeError(
74
+ "Web turns on Slack destinations must not publish externally"
75
+ );
76
+ }
77
+ break;
78
+ }
79
+ }
80
+ break;
81
+ }
82
+ }
83
+ const actor = request.routing.dispatch?.actor ?? request.routing.actor;
84
+ if (!actor || actor.platform === "system") {
85
+ return;
86
+ }
87
+ const actorMatchesDestination = (() => {
88
+ switch (actor.platform) {
89
+ case "slack":
90
+ return destination.platform === "slack";
91
+ case "local":
92
+ return destination.platform === "local";
93
+ case "web":
94
+ return destination.platform === "local" || destination.platform === "slack" && request.routing.publishExternally !== true;
95
+ }
96
+ })();
97
+ if (!actorMatchesDestination) {
98
+ throw new TypeError(
99
+ `Actor platform "${actor.platform}" does not match destination platform "${destination.platform}"`
100
+ );
101
+ }
102
+ if (actor.platform === "slack" && destination.platform === "slack" && actor.teamId !== destination.teamId) {
103
+ throw new TypeError("Slack actor team does not match destination team");
104
+ }
105
+ }
106
+ function toolInvocationDestination(routing) {
107
+ if (routing.destination.platform !== "slack" || !routing.toolChannelId) {
108
+ return routing.destination;
109
+ }
110
+ return {
111
+ platform: "slack",
112
+ teamId: routing.destination.teamId,
113
+ channelId: routing.toolChannelId
114
+ };
115
+ }
116
+ function surfaceFromRouting(routing) {
117
+ if (routing.surface) {
118
+ return routing.surface;
119
+ }
120
+ if (routing.source.platform === "slack") {
121
+ return "slack";
122
+ }
123
+ if (routing.source.platform === "web") {
124
+ return "api";
125
+ }
126
+ return "internal";
127
+ }
128
+
129
+ export {
130
+ isAgentRunFeatureDisabled,
131
+ RetryableDeliveryError,
132
+ actorFromRouting,
133
+ assertRunRoutingConsistency,
134
+ toolInvocationDestination,
135
+ surfaceFromRouting
136
+ };
@@ -4,19 +4,19 @@ import {
4
4
  isDmChannel,
5
5
  normalizeSlackConversationId,
6
6
  withSlackRetries
7
- } from "./chunk-SGZO7UWH.js";
7
+ } from "./chunk-SWHPVZBV.js";
8
8
  import {
9
9
  parseDestination
10
- } from "./chunk-YSB2N563.js";
10
+ } from "./chunk-3GYZ5YEH.js";
11
11
  import {
12
12
  getStateAdapter
13
- } from "./chunk-ORO3PWKQ.js";
13
+ } from "./chunk-25SC7D6Z.js";
14
14
  import {
15
15
  normalizeSlackEmojiName
16
- } from "./chunk-7NVJVJID.js";
16
+ } from "./chunk-32CXPIZE.js";
17
17
  import {
18
18
  pluginCatalogRuntime
19
- } from "./chunk-JUUKWRBE.js";
19
+ } from "./chunk-X22XXSZA.js";
20
20
  import {
21
21
  parseSlackMessageTs,
22
22
  parseSlackUserId
@@ -25,7 +25,7 @@ import {
25
25
  isRecord,
26
26
  logInfo,
27
27
  logWarn
28
- } from "./chunk-4LJO56OJ.js";
28
+ } from "./chunk-RLVZIWNQ.js";
29
29
 
30
30
  // src/chat/slack/outbound.ts
31
31
  var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
@@ -8,14 +8,14 @@ import {
8
8
  getConversationStore,
9
9
  parseDestination,
10
10
  sameDestination
11
- } from "./chunk-YSB2N563.js";
11
+ } from "./chunk-3GYZ5YEH.js";
12
12
  import {
13
13
  getDefaultRedisStateAdapterFor,
14
14
  getStateAdapter
15
- } from "./chunk-ORO3PWKQ.js";
15
+ } from "./chunk-25SC7D6Z.js";
16
16
  import {
17
17
  getChatConfig
18
- } from "./chunk-7NVJVJID.js";
18
+ } from "./chunk-32CXPIZE.js";
19
19
  import {
20
20
  parseStoredSlackActor
21
21
  } from "./chunk-HZF5P5UN.js";
@@ -23,7 +23,7 @@ import {
23
23
  isRecord,
24
24
  toOptionalNumber,
25
25
  toOptionalString
26
- } from "./chunk-4LJO56OJ.js";
26
+ } from "./chunk-RLVZIWNQ.js";
27
27
 
28
28
  // src/chat/task-execution/state.ts
29
29
  import { randomUUID } from "crypto";
@@ -69,7 +69,8 @@ var inboundMessageSourceSchema = z.enum([
69
69
  "plugin",
70
70
  "resource_event",
71
71
  "scheduler",
72
- "slack"
72
+ "slack",
73
+ "web"
73
74
  ]);
74
75
  var agentInputSchema = z.object({
75
76
  attachments: z.array(z.unknown()).optional(),
@@ -80,6 +81,7 @@ var agentInputSchema = z.object({
80
81
  message: "agent input requires text or attachments"
81
82
  });
82
83
  var inboundMessageDeliverySchema = z.enum(["defer", "interrupt"]);
84
+ var publishExternallySchema = z.boolean();
83
85
  var inboundMessageSchema = z.object({
84
86
  attemptCount: z.number().finite().optional(),
85
87
  conversationId: z.string().refine((value) => value.trim().length > 0),
@@ -90,6 +92,7 @@ var inboundMessageSchema = z.object({
90
92
  injectedAtMs: z.number().finite().optional(),
91
93
  input: agentInputSchema,
92
94
  receivedAtMs: z.number().finite(),
95
+ publishExternally: publishExternallySchema,
93
96
  source: inboundMessageSourceSchema
94
97
  }).strict();
95
98
  function conversationKey(conversationId) {
@@ -1297,6 +1300,9 @@ async function recordExecutionMetadata(args) {
1297
1300
  updatedAtMs: conversation.updatedAtMs
1298
1301
  });
1299
1302
  }
1303
+ async function getConversation2(args) {
1304
+ return await getConversation(args);
1305
+ }
1300
1306
  async function getConversationWorkState2(args) {
1301
1307
  return await getConversationWorkState(args);
1302
1308
  }
@@ -1497,6 +1503,7 @@ export {
1497
1503
  CONVERSATION_WORK_STALE_ENQUEUE_MS,
1498
1504
  CONVERSATION_WORK_MAX_RETRIES,
1499
1505
  isFinalAttempt,
1506
+ getConversation2 as getConversation,
1500
1507
  getConversationWorkState2 as getConversationWorkState,
1501
1508
  recordConversationRetry2 as recordConversationRetry,
1502
1509
  countPendingConversationMessages,
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-F3B2YJ76.js";
6
6
  import {
7
7
  toOptionalString
8
- } from "./chunk-4LJO56OJ.js";
8
+ } from "./chunk-RLVZIWNQ.js";
9
9
 
10
10
  // src/chat/slack/context.ts
11
11
  import { z } from "zod";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-JUUKWRBE.js";
3
+ } from "./chunk-X22XXSZA.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";
@@ -1,34 +1,34 @@
1
1
  import {
2
2
  resolveBaseUrl
3
- } from "./chunk-7UQIVT6G.js";
3
+ } from "./chunk-JMH3DBM5.js";
4
4
  import {
5
5
  createPluginLogger,
6
6
  getPlugins
7
- } from "./chunk-YHDERDRO.js";
7
+ } from "./chunk-7BH46NB4.js";
8
8
  import {
9
9
  getSlackClient,
10
10
  withSlackRetries
11
- } from "./chunk-SGZO7UWH.js";
11
+ } from "./chunk-SWHPVZBV.js";
12
12
  import {
13
13
  getDb,
14
14
  parseDestination
15
- } from "./chunk-YSB2N563.js";
15
+ } from "./chunk-3GYZ5YEH.js";
16
16
  import {
17
17
  sleep
18
18
  } from "./chunk-EM225ITJ.js";
19
19
  import {
20
20
  acquireActiveLock,
21
21
  getStateAdapter
22
- } from "./chunk-ORO3PWKQ.js";
22
+ } from "./chunk-25SC7D6Z.js";
23
23
  import {
24
24
  pluginCatalogRuntime
25
- } from "./chunk-JUUKWRBE.js";
25
+ } from "./chunk-X22XXSZA.js";
26
26
  import {
27
27
  fetchWithBoundedOAuthErrorBodies
28
- } from "./chunk-GGB4WL5A.js";
28
+ } from "./chunk-2JHKISQA.js";
29
29
  import {
30
30
  isRecord
31
- } from "./chunk-4LJO56OJ.js";
31
+ } from "./chunk-RLVZIWNQ.js";
32
32
 
33
33
  // src/chat/capabilities/router.ts
34
34
  var ProviderCredentialRouter = class {
@@ -244,6 +244,16 @@ function normalizeUser(raw) {
244
244
  ...profileFields.length > 0 ? { profile_fields: profileFields } : {}
245
245
  };
246
246
  }
247
+ function normalizeNameTokens(value) {
248
+ return value.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
249
+ }
250
+ function nameFields(user) {
251
+ return [
252
+ user.name ?? "",
253
+ user.profile?.display_name ?? "",
254
+ user.real_name ?? user.profile?.real_name ?? ""
255
+ ].map((value) => value.toLowerCase().trim()).filter(Boolean);
256
+ }
247
257
  async function lookupSlackUserProfile(userId) {
248
258
  const client = getSlackClient();
249
259
  const result = await withSlackRetries(
@@ -279,21 +289,44 @@ async function lookupSlackUserByEmail(email) {
279
289
  }
280
290
  return normalizeUser(user);
281
291
  }
282
- function scoreMatch(user, queryLower) {
283
- const name = (user.name ?? "").toLowerCase();
284
- const realName = (user.real_name ?? user.profile?.real_name ?? "").toLowerCase();
285
- const displayName = (user.profile?.display_name ?? "").toLowerCase();
286
- if (name === queryLower || displayName === queryLower) return 100;
287
- if (realName === queryLower) return 90;
288
- if (name.startsWith(queryLower) || displayName.startsWith(queryLower))
289
- return 70;
290
- if (realName.startsWith(queryLower)) return 60;
291
- const realNameWords = realName.split(/\s+/);
292
- if (realNameWords.some((w) => w === queryLower)) return 55;
293
- if (realNameWords.some((w) => w.startsWith(queryLower))) return 50;
294
- if (name.includes(queryLower) || displayName.includes(queryLower)) return 30;
295
- if (realName.includes(queryLower)) return 20;
296
- return 0;
292
+ function scoreNameMatch(user, query) {
293
+ const queryLower = query.toLowerCase().trim();
294
+ if (!queryLower) return 0;
295
+ const fields = nameFields(user);
296
+ if (fields.length === 0) return 0;
297
+ let best = 0;
298
+ const queryTokens = normalizeNameTokens(queryLower);
299
+ for (const field of fields) {
300
+ if (field === queryLower) {
301
+ best = Math.max(best, 100);
302
+ continue;
303
+ }
304
+ if (field.startsWith(queryLower)) {
305
+ best = Math.max(best, 70);
306
+ } else if (field.includes(queryLower)) {
307
+ best = Math.max(best, 25);
308
+ }
309
+ const tokens = normalizeNameTokens(field);
310
+ for (const token of tokens) {
311
+ if (token === queryLower) {
312
+ best = Math.max(best, 85);
313
+ } else if (token.startsWith(queryLower)) {
314
+ best = Math.max(best, 60);
315
+ }
316
+ }
317
+ if (queryTokens.length > 1 && queryTokens.every(
318
+ (queryToken) => tokens.some(
319
+ (token) => token === queryToken || token.startsWith(queryToken)
320
+ )
321
+ )) {
322
+ best = Math.max(best, 95);
323
+ }
324
+ }
325
+ return best;
326
+ }
327
+ function compareNameMatches(left, right) {
328
+ if (right.score !== left.score) return right.score - left.score;
329
+ return (left.user.name ?? "").localeCompare(right.user.name ?? "");
297
330
  }
298
331
  async function listWorkspaceUsers(options) {
299
332
  const client = getSlackClient();
@@ -349,12 +382,9 @@ async function searchSlackUsers(options) {
349
382
  maxPages,
350
383
  includeDeleted,
351
384
  includeBots,
352
- score: (member) => scoreMatch(member, queryLower)
353
- });
354
- listed.matches.sort((a, b) => {
355
- if (b.score !== a.score) return b.score - a.score;
356
- return (a.user.name ?? "").localeCompare(b.user.name ?? "");
385
+ score: (member) => scoreNameMatch(member, queryLower)
357
386
  });
387
+ listed.matches.sort(compareNameMatches);
358
388
  return {
359
389
  users: listed.matches.slice(0, limit).map((m) => normalizeUser(m.user)),
360
390
  searched_pages: listed.searched_pages,
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-6GWA276C.js";
10
10
  import {
11
11
  getDeploymentTelemetryAttributes
12
- } from "./chunk-DLDRQHG5.js";
12
+ } from "./chunk-6G5RCDKP.js";
13
13
 
14
14
  // src/chat/logging.ts
15
15
  import path from "path";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-EM225ITJ.js";
4
4
  import {
5
5
  getSlackBotToken
6
- } from "./chunk-7NVJVJID.js";
6
+ } from "./chunk-32CXPIZE.js";
7
7
  import {
8
8
  parseSlackChannelReferenceId
9
9
  } from "./chunk-F3B2YJ76.js";
@@ -12,7 +12,7 @@ import {
12
12
  setSpanAttributes,
13
13
  setSpanStatus,
14
14
  withSpan
15
- } from "./chunk-4LJO56OJ.js";
15
+ } from "./chunk-RLVZIWNQ.js";
16
16
 
17
17
  // src/chat/slack/client.ts
18
18
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
@@ -1,3 +1,6 @@
1
+ import {
2
+ getTurnRequestDeadline
3
+ } from "./chunk-EXW76GW4.js";
1
4
  import {
2
5
  CONVERSATION_WORK_CHECK_IN_INTERVAL_MS,
3
6
  CONVERSATION_WORK_MAX_RETRIES,
@@ -18,37 +21,37 @@ import {
18
21
  releaseConversationWork,
19
22
  requestAnotherSlice,
20
23
  startConversationWork
21
- } from "./chunk-CWP5RHVX.js";
24
+ } from "./chunk-JMSMXXED.js";
22
25
  import {
23
26
  ConversationQueueMessageRejectedError
24
27
  } from "./chunk-JAL3CH4G.js";
25
28
  import {
26
29
  getChatConfig,
27
30
  isProviderRetryError
28
- } from "./chunk-7NVJVJID.js";
31
+ } from "./chunk-32CXPIZE.js";
29
32
  import {
30
33
  logException,
31
34
  logInfo,
32
35
  logWarn,
33
36
  withLogContext
34
- } from "./chunk-4LJO56OJ.js";
37
+ } from "./chunk-RLVZIWNQ.js";
35
38
 
36
39
  // src/chat/task-execution/worker.ts
37
40
  var CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
38
41
  function now(options) {
39
42
  return options.nowMs?.() ?? Date.now();
40
43
  }
41
- function selectContiguousActorBatch(messages) {
44
+ function selectContiguousTurnBatch(messages) {
42
45
  const first = messages[0];
43
46
  if (!first) {
44
47
  return [];
45
48
  }
46
- const nextActorIndex = messages.findIndex(
47
- (message) => message.input.authorId !== first.input.authorId
49
+ const nextTurnIndex = messages.findIndex(
50
+ (message) => message.input.authorId !== first.input.authorId || message.publishExternally !== first.publishExternally
48
51
  );
49
52
  return messages.slice(
50
53
  0,
51
- nextActorIndex === -1 ? messages.length : nextActorIndex
54
+ nextTurnIndex === -1 ? messages.length : nextTurnIndex
52
55
  );
53
56
  }
54
57
  function selectAttemptMessages(work) {
@@ -57,9 +60,9 @@ function selectAttemptMessages(work) {
57
60
  (message) => message.delivery === "interrupt"
58
61
  );
59
62
  if (interrupts.length > 0) {
60
- return selectContiguousActorBatch(interrupts);
63
+ return selectContiguousTurnBatch(interrupts);
61
64
  }
62
- return work.execution.status === "paused" ? [] : selectContiguousActorBatch(messages);
65
+ return work.execution.status === "paused" ? [] : selectContiguousTurnBatch(messages);
63
66
  }
64
67
  function nudgeIdempotencyKey(reason, conversationId, nowMs) {
65
68
  return `${reason}:${conversationId}:${nowMs}`;
@@ -283,7 +286,14 @@ async function processConversationWorkInContext(message, options) {
283
286
  nowMs: now(options),
284
287
  state: options.state
285
288
  });
286
- const shouldYield = () => leaseLost || now(options) >= softYieldDeadlineMs;
289
+ const requestDeadlineAtMs = getTurnRequestDeadline()?.deadlineAtMs;
290
+ const shouldYield = () => (
291
+ // Lease ownership is no longer confirmed, so this worker must stop.
292
+ leaseLost || // The worker soft limit reserves time to persist state and release the lease.
293
+ now(options) >= softYieldDeadlineMs || // Nested work can inherit an older host request deadline. Stop after that
294
+ // absolute deadline, even if this worker acquired its lease later.
295
+ requestDeadlineAtMs !== void 0 && Date.now() >= requestDeadlineAtMs
296
+ );
287
297
  const checkIn = async () => {
288
298
  const checkedIn = await checkInConversationWork({
289
299
  conversationId,
@@ -377,6 +387,7 @@ async function processConversationWorkInContext(message, options) {
377
387
  attemptMessageIds = attemptMessages.map(
378
388
  (message2) => message2.inboundMessageId
379
389
  );
390
+ const publishExternally = attemptMessages[0]?.publishExternally ?? false;
380
391
  attemptSelectedMessageIds = new Set(attemptMessageIds);
381
392
  const ack = async () => {
382
393
  const acknowledged = await ackMessages({
@@ -407,6 +418,7 @@ async function processConversationWorkInContext(message, options) {
407
418
  },
408
419
  conversationId,
409
420
  destination,
421
+ publishExternally,
410
422
  shouldYield,
411
423
  checkIn
412
424
  };
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  ToolInputError
3
- } from "./chunk-HLXXQI5Q.js";
3
+ } from "./chunk-EW2LNCRL.js";
4
4
  import {
5
5
  canRouteResourceEvents,
6
6
  getPlugins
7
- } from "./chunk-YHDERDRO.js";
7
+ } from "./chunk-7BH46NB4.js";
8
8
  import {
9
9
  getDb
10
- } from "./chunk-YSB2N563.js";
10
+ } from "./chunk-3GYZ5YEH.js";
11
11
  import {
12
12
  juniorEventTasks,
13
13
  juniorSchedulerRuns,
14
14
  juniorSchedulerTasks,
15
15
  juniorStats
16
- } from "./chunk-DU74WPIC.js";
16
+ } from "./chunk-3I2IVWSZ.js";
17
17
  import {
18
18
  juniorDestinations
19
19
  } from "./chunk-VFUK3X5B.js";
20
20
  import {
21
21
  logInfo
22
- } from "./chunk-4LJO56OJ.js";
22
+ } from "./chunk-RLVZIWNQ.js";
23
23
 
24
24
  // src/chat/event-tasks/store.ts
25
25
  import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";