@sentry/junior 0.125.0 → 0.126.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 (54) hide show
  1. package/dist/{agent-hooks-MF5UZRCO.js → agent-hooks-HDSNWDQM.js} +8 -9
  2. package/dist/api.js +30 -24
  3. package/dist/app.js +49 -37
  4. package/dist/{catalog-runtime-V6SJTUV7.js → catalog-runtime-BDC3UWPG.js} +5 -6
  5. package/dist/chat/agent/request.d.ts +2 -1
  6. package/dist/chat/agent/resume.d.ts +2 -0
  7. package/dist/chat/agent-dispatch/types.d.ts +2 -1
  8. package/dist/chat/conversation-privacy.d.ts +7 -12
  9. package/dist/chat/conversations/destination-visibility.d.ts +7 -0
  10. package/dist/chat/conversations/store.d.ts +3 -3
  11. package/dist/chat/services/turn-session-record.d.ts +4 -1
  12. package/dist/chat/slack/conversation-context.d.ts +4 -7
  13. package/dist/chat/slack/footer.d.ts +10 -1
  14. package/dist/chat/slack/reply.d.ts +9 -2
  15. package/dist/chat/state/turn-session.d.ts +2 -6
  16. package/dist/{chunk-K6MQWEEJ.js → chunk-4PV73JHH.js} +11 -13
  17. package/dist/{chunk-ODB55JM7.js → chunk-6KWO5DU3.js} +9 -9
  18. package/dist/chunk-72SDEHFP.js +102 -0
  19. package/dist/{chunk-CAPBVX4L.js → chunk-ACJZZY5W.js} +2 -2
  20. package/dist/{chunk-XJYGLTYI.js → chunk-APYVVX2Y.js} +1 -1
  21. package/dist/{chunk-2U5CLBYF.js → chunk-EFQX6XBW.js} +1 -1
  22. package/dist/{chunk-Q3UF3K77.js → chunk-EQMSKORN.js} +1 -1
  23. package/dist/{chunk-NM3PMQS6.js → chunk-GHNO2WUH.js} +1 -1
  24. package/dist/{chunk-IHNBJHEP.js → chunk-GK55KLEH.js} +1 -1
  25. package/dist/{chunk-ZXGBLAYQ.js → chunk-JFW62B3Y.js} +1 -1
  26. package/dist/{chunk-MVYNJECP.js → chunk-JP2ZOSQK.js} +15 -5
  27. package/dist/{chunk-LG5TXWXI.js → chunk-KISG7E24.js} +57 -36
  28. package/dist/{chunk-IS4DGI5J.js → chunk-KP7E267S.js} +14 -11
  29. package/dist/{chunk-2R5MASH3.js → chunk-LCRWDMCH.js} +1 -1
  30. package/dist/{chunk-MYKSUTUV.js → chunk-LIDEU7QS.js} +4 -4
  31. package/dist/{chunk-HT7DSLKL.js → chunk-TUHUIBDX.js} +56 -38
  32. package/dist/{chunk-S7G34U75.js → chunk-VUBUFT66.js} +5 -121
  33. package/dist/{chunk-7K57FJXR.js → chunk-WRH7DWFO.js} +13 -11
  34. package/dist/{chunk-KN7QI56S.js → chunk-XLIAQRDI.js} +3 -8
  35. package/dist/{chunk-EXD2Z3YR.js → chunk-XVKJJXHF.js} +16 -14
  36. package/dist/{chunk-JT3YMQR3.js → chunk-YMSVBWBY.js} +8 -8
  37. package/dist/cli/chat.js +23 -23
  38. package/dist/cli/check.js +6 -7
  39. package/dist/cli/plugins.js +11 -12
  40. package/dist/cli/snapshot-create.js +9 -10
  41. package/dist/cli/upgrade.js +6 -7
  42. package/dist/{db-JSDSWK7T.js → db-AZB6AGJL.js} +6 -7
  43. package/dist/instrumentation.js +4 -5
  44. package/dist/nitro.js +2 -2
  45. package/dist/{oauth-callback-server-UMS2T3HN.js → oauth-callback-server-XK4QJLPZ.js} +16 -16
  46. package/dist/{runner-RGOANIRV.js → runner-DSGDSATN.js} +11 -12
  47. package/dist/{skills-GBLPOQOD.js → skills-CO6E3BQJ.js} +6 -7
  48. package/dist/{validation-BMQY6CD4.js → validation-IHLISKM5.js} +6 -7
  49. package/dist/version.js +1 -1
  50. package/migrations/0014_source_visibility.sql +8 -0
  51. package/migrations/meta/0014_snapshot.json +1201 -0
  52. package/migrations/meta/_journal.json +8 -1
  53. package/package.json +5 -5
  54. package/dist/chunk-OB42YVAE.js +0 -16
@@ -9,17 +9,17 @@ import {
9
9
  TURN_REASONING_LEVELS,
10
10
  getChatConfig,
11
11
  modelProfileSchema
12
- } from "./chunk-KN7QI56S.js";
12
+ } from "./chunk-XLIAQRDI.js";
13
13
  import {
14
14
  juniorDestinations
15
15
  } from "./chunk-VFUK3X5B.js";
16
- import {
17
- normalizeIdentityEmail
18
- } from "./chunk-MVYNJECP.js";
19
16
  import {
20
17
  parseSlackChannelReferenceId,
21
18
  parseSlackTeamId
22
19
  } from "./chunk-F3B2YJ76.js";
20
+ import {
21
+ normalizeIdentityEmail
22
+ } from "./chunk-JP2ZOSQK.js";
23
23
 
24
24
  // src/chat/conversations/sql/store.ts
25
25
  import { randomUUID as randomUUID2 } from "crypto";
@@ -176,7 +176,7 @@ function normalizeSessionSource(value) {
176
176
  if (value.platform === "local") {
177
177
  return {
178
178
  platform: "local",
179
- type: "priv",
179
+ visibility: "private",
180
180
  conversationId: value.conversationId
181
181
  };
182
182
  }
@@ -186,7 +186,7 @@ function normalizeSessionSource(value) {
186
186
  }
187
187
  return {
188
188
  platform: "slack",
189
- type: value.type,
189
+ visibility: value.visibility,
190
190
  teamId: value.teamId,
191
191
  channelId: value.channelId,
192
192
  threadTs
@@ -294,7 +294,7 @@ function destinationUpsertFromDestination(args) {
294
294
  providerTenantId: destination.teamId,
295
295
  providerDestinationId: channelId,
296
296
  refreshVisibility: args.visibility !== void 0,
297
- visibility: args.visibility ?? "private",
297
+ visibility: args.visibility ?? "unknown",
298
298
  ...args.channelName ? { displayName: args.channelName } : {},
299
299
  metadata: { platform: "slack" }
300
300
  };
@@ -626,7 +626,10 @@ var SqlStore = class {
626
626
  if (!row) {
627
627
  return void 0;
628
628
  }
629
- return row.visibility === "public" ? "public" : "private";
629
+ if (row.visibility === "public" || row.visibility === "private") {
630
+ return row.visibility;
631
+ }
632
+ return void 0;
630
633
  }
631
634
  /** Serialize all durable mutations for one conversation inside a SQL transaction. */
632
635
  async withConversationMutation(conversationId, callback) {
@@ -759,9 +762,9 @@ var SqlStore = class {
759
762
  set: {
760
763
  kind: sql2`excluded.kind`,
761
764
  displayName: sql2`coalesce(excluded.display_name, ${juniorDestinations.displayName})`,
762
- // Signal-less writes insert as private but must not clobber an
763
- // existing public/private value. Live source signals refresh this
764
- // field so converted channels converge on the next message.
765
+ // Signal-less writes remain unknown and must not clobber an existing
766
+ // public/private value. Live source signals refresh this field so
767
+ // converted channels converge on the next message.
765
768
  visibility: visibilityUpdate,
766
769
  metadata: sql2`coalesce(excluded.metadata_json, ${juniorDestinations.metadata})`,
767
770
  updatedAt: sql2`excluded.updated_at`
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JUNIOR_VERSION
3
- } from "./chunk-ZXGBLAYQ.js";
3
+ } from "./chunk-JFW62B3Y.js";
4
4
 
5
5
  // src/deployment.ts
6
6
  var JUNIOR_HEARTBEAT_ROUTE = "/api/internal/heartbeat";
@@ -2,18 +2,18 @@ import {
2
2
  SANDBOX_WORKSPACE_ROOT,
3
3
  getStateAdapter,
4
4
  sleep
5
- } from "./chunk-XJYGLTYI.js";
5
+ } from "./chunk-APYVVX2Y.js";
6
6
  import {
7
7
  toOptionalTrimmed
8
- } from "./chunk-KN7QI56S.js";
8
+ } from "./chunk-XLIAQRDI.js";
9
9
  import {
10
10
  pluginCatalogRuntime
11
- } from "./chunk-NM3PMQS6.js";
11
+ } from "./chunk-GHNO2WUH.js";
12
12
  import {
13
13
  setSpanAttributes,
14
14
  setSpanStatus,
15
15
  withSpan
16
- } from "./chunk-MVYNJECP.js";
16
+ } from "./chunk-JP2ZOSQK.js";
17
17
 
18
18
  // src/chat/sandbox/snapshot/profile.ts
19
19
  import { createHash } from "crypto";
@@ -30,7 +30,7 @@ import {
30
30
  toMcpProviderError,
31
31
  toolInvocationDestination,
32
32
  uploadFilesToConversation
33
- } from "./chunk-K6MQWEEJ.js";
33
+ } from "./chunk-4PV73JHH.js";
34
34
  import {
35
35
  CooperativeTurnYieldError,
36
36
  JUNIOR_THREAD_STATE_TTL_MS,
@@ -80,7 +80,7 @@ import {
80
80
  stripRuntimeTurnContext,
81
81
  trimTrailingAssistantMessages,
82
82
  updateConversationStats
83
- } from "./chunk-7K57FJXR.js";
83
+ } from "./chunk-WRH7DWFO.js";
84
84
  import {
85
85
  parseSandboxEgressAuthRequiredSignal,
86
86
  parseSandboxEgressPermissionDeniedSignal,
@@ -104,10 +104,13 @@ import {
104
104
  runNonInteractiveCommand,
105
105
  throwSandboxOperationError,
106
106
  wrapSandboxSetupError
107
- } from "./chunk-MYKSUTUV.js";
107
+ } from "./chunk-LIDEU7QS.js";
108
108
  import {
109
109
  incrementStat
110
- } from "./chunk-Q3UF3K77.js";
110
+ } from "./chunk-EQMSKORN.js";
111
+ import {
112
+ parseSlackThreadId
113
+ } from "./chunk-72SDEHFP.js";
111
114
  import {
112
115
  addAgentTurnUsage,
113
116
  hasAgentTurnUsage
@@ -129,7 +132,7 @@ import {
129
132
  normalizeSlackConversationId,
130
133
  resolveChannelCapabilities,
131
134
  withSlackRetries
132
- } from "./chunk-ODB55JM7.js";
135
+ } from "./chunk-6KWO5DU3.js";
133
136
  import {
134
137
  KNOWN_CONVERSATION_EVENT_TYPES,
135
138
  contextProvenance,
@@ -139,7 +142,7 @@ import {
139
142
  instructionActors,
140
143
  instructionProvenanceFor,
141
144
  sameActorIdentity
142
- } from "./chunk-IS4DGI5J.js";
145
+ } from "./chunk-KP7E267S.js";
143
146
  import {
144
147
  SANDBOX_DATA_ROOT,
145
148
  SANDBOX_SKILLS_ROOT,
@@ -149,7 +152,7 @@ import {
149
152
  sandboxSkillFile,
150
153
  sandboxSkillPathResolution,
151
154
  sleep
152
- } from "./chunk-XJYGLTYI.js";
155
+ } from "./chunk-APYVVX2Y.js";
153
156
  import {
154
157
  ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX,
155
158
  COMPACTION_SUMMARY_PREFIX,
@@ -183,10 +186,9 @@ import {
183
186
  renderCurrentInstruction,
184
187
  resolveGatewayModel,
185
188
  unwrapCurrentInstruction
186
- } from "./chunk-KN7QI56S.js";
189
+ } from "./chunk-XLIAQRDI.js";
187
190
  import {
188
191
  canExposeConversationPayload,
189
- parseSlackThreadId,
190
192
  resolveConversationPrivacy,
191
193
  runWithConversationPrivacy,
192
194
  toCanonicalInputMessage,
@@ -194,16 +196,16 @@ import {
194
196
  toGenAiMessagesTraceAttributes,
195
197
  toGenAiPayloadMetadata,
196
198
  toGenAiPayloadTraceAttributes
197
- } from "./chunk-S7G34U75.js";
199
+ } from "./chunk-VUBUFT66.js";
198
200
  import {
199
201
  discoverSkills,
200
202
  findSkillByName,
201
203
  loadSkillsByName,
202
204
  parseSkillInvocation
203
- } from "./chunk-CAPBVX4L.js";
205
+ } from "./chunk-ACJZZY5W.js";
204
206
  import {
205
207
  pluginCatalogRuntime
206
- } from "./chunk-NM3PMQS6.js";
208
+ } from "./chunk-GHNO2WUH.js";
207
209
  import {
208
210
  CredentialUnavailableError,
209
211
  OAuthProviderError,
@@ -211,13 +213,18 @@ import {
211
213
  getOAuthProviderErrorAttributes,
212
214
  resolveAuthTokenPlaceholder,
213
215
  resolvePluginCommandEnv
214
- } from "./chunk-2U5CLBYF.js";
216
+ } from "./chunk-EFQX6XBW.js";
215
217
  import {
216
218
  credentialUserSubjectId
217
219
  } from "./chunk-W3U3YQYI.js";
218
220
  import {
219
221
  isUserActor
220
222
  } from "./chunk-HZF5P5UN.js";
223
+ import {
224
+ parseSlackChannelId,
225
+ parseSlackMessageTs,
226
+ parseSlackUserId
227
+ } from "./chunk-F3B2YJ76.js";
221
228
  import {
222
229
  extractGenAiUsageAttributes,
223
230
  extractGenAiUsageSummary,
@@ -235,12 +242,7 @@ import {
235
242
  summarizeMessageText,
236
243
  withLogContext,
237
244
  withSpan
238
- } from "./chunk-MVYNJECP.js";
239
- import {
240
- parseSlackChannelId,
241
- parseSlackMessageTs,
242
- parseSlackUserId
243
- } from "./chunk-F3B2YJ76.js";
245
+ } from "./chunk-JP2ZOSQK.js";
244
246
  import {
245
247
  startInactiveSpan,
246
248
  withActiveSpan
@@ -1259,6 +1261,21 @@ var AuthorizationFlowDisabledError = class extends Error {
1259
1261
  }
1260
1262
  };
1261
1263
 
1264
+ // src/chat/conversations/destination-visibility.ts
1265
+ async function resolveDestinationVisibility(args) {
1266
+ if (args.visibility) {
1267
+ return args.visibility;
1268
+ }
1269
+ if (args.destination.platform === "local") {
1270
+ return "private";
1271
+ }
1272
+ return await getConversationStore().getDestinationVisibility({
1273
+ provider: "slack",
1274
+ providerDestinationId: args.destination.channelId,
1275
+ providerTenantId: args.destination.teamId
1276
+ });
1277
+ }
1278
+
1262
1279
  // src/chat/tool-support/action-review-history.ts
1263
1280
  import { z as z3 } from "zod";
1264
1281
  var MAX_VISIBLE_HISTORY_CHARS = 12e3;
@@ -1693,10 +1710,7 @@ function formatAvailableSkillsForPrompt(skills) {
1693
1710
  );
1694
1711
  const sections = [];
1695
1712
  if (autoSelectable.length > 0) {
1696
- const available = [
1697
- "<available-skills>",
1698
- "Scan before answering. Load the most specific matching skill; do not answer from memory when a skill fits. A request that names a skill, plugin, provider, or account matching a skill name is a skill match. If none fits, do not load a skill."
1699
- ];
1713
+ const available = ["<available-skills>"];
1700
1714
  for (const skill of autoSelectable) {
1701
1715
  available.push(...formatSkillEntry(skill));
1702
1716
  }
@@ -1817,7 +1831,7 @@ var TOOL_CALL_STYLE_RULES = [
1817
1831
  ];
1818
1832
  var SKILL_POLICY_RULES = [
1819
1833
  "- A `<skill>` block in the current user turn is already loaded. Follow its instructions directly and do not call `loadSkill` for that skill.",
1820
- "- Otherwise, only load skills listed in `<available-skills>`. Never guess or invent a skill name.",
1834
+ "- Otherwise, scan `<available-skills>` before acting. Load the most specific skill whose description matches the request; do not answer from memory when one fits. Only call `loadSkill` with an exact listed `<name>`; if none fits, do not load a skill.",
1821
1835
  "- Load one skill at a time. After `loadSkill`, follow the instructions returned by that tool result."
1822
1836
  ];
1823
1837
  var EXECUTION_CONTRACT_RULES = [
@@ -10775,11 +10789,9 @@ function assertCanQueryConversationEvents(args) {
10775
10789
  if (targetConversationId === accessScope.currentConversationId || targetRootConversationId !== void 0 && targetRootConversationId === accessScope.currentRootConversationId) {
10776
10790
  return;
10777
10791
  }
10778
- const publicPayloadAllowed = canExposeConversationPayload({
10779
- conversationId: targetRootConversationId ?? targetConversationId,
10780
- ...targetVisibility ? { visibility: targetVisibility } : {},
10781
- ...targetDestination?.platform === "slack" ? { channelId: targetDestination.channelId } : {}
10782
- });
10792
+ const publicPayloadAllowed = canExposeConversationPayload(
10793
+ targetVisibility ? { visibility: targetVisibility } : {}
10794
+ );
10783
10795
  if (!publicPayloadAllowed) {
10784
10796
  throw new ToolInputError(
10785
10797
  `Conversation events are not accessible: ${targetConversationId}`
@@ -11678,7 +11690,7 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
11678
11690
  tools.slackCanvasEdit = createSlackCanvasEditTool(state);
11679
11691
  tools.slackCanvasWrite = createSlackCanvasWriteTool(state);
11680
11692
  tools.slackThreadRead = createSlackThreadReadTool(slackContext);
11681
- if (context.conversationId && slackContext.source.type === "pub") {
11693
+ if (context.conversationId && slackContext.source.visibility === "public") {
11682
11694
  tools.searchConversationHistory = createSlackConversationSearchTool(
11683
11695
  {
11684
11696
  kind: "public_provider_tenant",
@@ -14722,6 +14734,7 @@ function createResumeState(args) {
14722
14734
  channelName: args.channelName,
14723
14735
  conversationId: args.conversationId,
14724
14736
  destination: args.destination,
14737
+ ...args.destinationVisibility ? { destinationVisibility: args.destinationVisibility } : {},
14725
14738
  ...args.dispatchId ? { dispatchId: args.dispatchId } : {},
14726
14739
  source: args.runSource,
14727
14740
  sessionId: args.turnId,
@@ -15409,14 +15422,17 @@ async function executeAgentRun(request, streamFn) {
15409
15422
  if (!request.routing.destination) {
15410
15423
  throw new TypeError("Assistant reply generation requires a destination");
15411
15424
  }
15412
- const channelId = request.routing.destination.platform === "slack" ? request.routing.destination.channelId : void 0;
15425
+ const destinationVisibility = await resolveDestinationVisibility({
15426
+ destination: request.routing.destination,
15427
+ visibility: request.routing.destinationVisibility
15428
+ });
15413
15429
  const conversationPrivacy = resolveConversationPrivacy({
15414
- channelId,
15415
- conversationId: request.conversationId,
15416
- // Destination visibility is provider-neutral. Slack event context remains
15417
- // a compatibility fallback for callers that have not projected it yet.
15418
- visibility: request.routing.destinationVisibility ?? request.routing.slackConversation?.visibility
15430
+ visibility: destinationVisibility
15419
15431
  });
15432
+ const resolvedRequest = destinationVisibility ? {
15433
+ ...request,
15434
+ routing: { ...request.routing, destinationVisibility }
15435
+ } : request;
15420
15436
  const credentialActor = request.routing.credentialContext?.actor;
15421
15437
  const actor = actorFromRouting(request.routing);
15422
15438
  const userActor = actor && "userId" in actor ? actor : void 0;
@@ -15436,9 +15452,9 @@ async function executeAgentRun(request, streamFn) {
15436
15452
  return withLogContext(
15437
15453
  runLogContext,
15438
15454
  () => runWithConversationPrivacy(
15439
- conversationPrivacy ?? "private",
15455
+ conversationPrivacy,
15440
15456
  () => executeAgentRunInPrivacyContext(
15441
- request,
15457
+ resolvedRequest,
15442
15458
  conversationPrivacy,
15443
15459
  runLogContext,
15444
15460
  streamFn
@@ -15569,6 +15585,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
15569
15585
  resume = createResumeState({
15570
15586
  channelName: routing.slackConversation?.name,
15571
15587
  destination: routing.destination,
15588
+ ...routing.destinationVisibility ? { destinationVisibility: routing.destinationVisibility } : {},
15572
15589
  ...routing.dispatch?.id ? { dispatchId: routing.dispatch.id } : {},
15573
15590
  durability,
15574
15591
  getLoadedSkillNames: () => loadedSkillNamesForResume,
@@ -16511,6 +16528,7 @@ export {
16511
16528
  getConfigDefaults,
16512
16529
  shouldEmitDevAgentTrace,
16513
16530
  AuthorizationFlowDisabledError,
16531
+ resolveDestinationVisibility,
16514
16532
  buildSteeringPiMessage,
16515
16533
  SANDBOX_EGRESS_PROXY_PATH,
16516
16534
  parseSandboxEgressCredentialToken,
@@ -1,128 +1,16 @@
1
1
  import {
2
- toOptionalString
3
- } from "./chunk-OB42YVAE.js";
4
- import {
5
- parseSlackChannelId,
6
- parseSlackMessageTs,
7
- parseSlackTeamId
8
- } from "./chunk-F3B2YJ76.js";
2
+ logWarn
3
+ } from "./chunk-JP2ZOSQK.js";
9
4
 
10
5
  // src/chat/conversation-privacy.ts
11
6
  import { AsyncLocalStorage } from "async_hooks";
12
-
13
- // src/chat/slack/context.ts
14
- import { z } from "zod";
15
- function toTrimmedSlackString(value) {
16
- const normalized = toOptionalString(value);
17
- return normalized?.trim() || void 0;
18
- }
19
- var slackMessageEnvelopeSchema = z.object({
20
- raw: z.unknown().optional()
21
- });
22
- var rawSlackMessageSchema = z.object({
23
- channel: z.unknown().optional(),
24
- message: z.unknown().optional(),
25
- team: z.unknown().optional(),
26
- team_id: z.unknown().optional(),
27
- thread_ts: z.unknown().optional(),
28
- ts: z.unknown().optional(),
29
- user_team: z.unknown().optional()
30
- });
31
- var nestedRawSlackMessageSchema = z.object({
32
- ts: z.unknown().optional()
33
- });
34
- function readSlackRawMessageContext(message) {
35
- const envelope = slackMessageEnvelopeSchema.safeParse(message);
36
- if (!envelope.success) {
37
- return void 0;
38
- }
39
- const raw = rawSlackMessageSchema.safeParse(envelope.data.raw);
40
- if (!raw.success) {
41
- return void 0;
42
- }
43
- const nestedMessage = nestedRawSlackMessageSchema.safeParse(raw.data.message);
44
- const channelId = parseSlackChannelId(raw.data.channel);
45
- const threadTs = parseSlackMessageTs(raw.data.thread_ts);
46
- const messageTs = parseSlackMessageTs(raw.data.ts);
47
- const nestedMessageTs = nestedMessage.success && parseSlackMessageTs(nestedMessage.data.ts);
48
- const teamId = parseSlackTeamId(raw.data.team_id) ?? parseSlackTeamId(raw.data.team);
49
- const authorTeamId = parseSlackTeamId(raw.data.user_team);
50
- return {
51
- ...channelId ? { channelId } : {},
52
- ...threadTs ? { threadTs } : {},
53
- ...messageTs ? { messageTs } : {},
54
- ...nestedMessageTs ? { nestedMessageTs } : {},
55
- ...teamId ? { teamId } : {},
56
- ...authorTeamId ? { authorTeamId } : {}
57
- };
58
- }
59
- function parseSlackThreadId(threadId) {
60
- const normalizedThreadId = toTrimmedSlackString(threadId);
61
- if (!normalizedThreadId) {
62
- return void 0;
63
- }
64
- const parts = normalizedThreadId.split(":");
65
- if (parts.length !== 3 || parts[0] !== "slack") {
66
- return void 0;
67
- }
68
- const channelId = parseSlackChannelId(parts[1]);
69
- const threadTs = parseSlackMessageTs(parts[2]);
70
- if (!channelId || !threadTs) {
71
- return void 0;
72
- }
73
- return { channelId, threadTs };
74
- }
75
- function resolveSlackChannelIdFromThreadId(threadId) {
76
- return parseSlackThreadId(threadId)?.channelId;
77
- }
78
- function resolveSlackChannelIdFromMessage(message) {
79
- const messageChannelId = parseSlackChannelId(
80
- message.channelId
81
- );
82
- if (messageChannelId) {
83
- return messageChannelId;
84
- }
85
- const raw = message.raw;
86
- if (raw && typeof raw === "object") {
87
- const rawChannel = parseSlackChannelId(
88
- raw.channel
89
- );
90
- if (rawChannel) {
91
- return rawChannel;
92
- }
93
- }
94
- const threadId = toTrimmedSlackString(
95
- message.threadId
96
- );
97
- return resolveSlackChannelIdFromThreadId(threadId);
98
- }
99
-
100
- // src/chat/conversation-privacy.ts
101
7
  var SAFE_METADATA_KEY_LIMIT = 20;
102
8
  var conversationPrivacyStorage = new AsyncLocalStorage();
103
- function privateNarrowingFromChannelId(channelId) {
104
- const normalized = channelId?.trim();
105
- if (!normalized) return void 0;
106
- return normalized.startsWith("D") || normalized.startsWith("G") ? "private" : void 0;
107
- }
108
- function privateNarrowingFromConversationId(conversationId) {
109
- const normalized = conversationId?.trim();
110
- if (!normalized) return void 0;
111
- const slackThread = parseSlackThreadId(normalized);
112
- if (slackThread) {
113
- return privateNarrowingFromChannelId(slackThread.channelId);
114
- }
115
- if (normalized.startsWith("slack:")) {
116
- return void 0;
117
- }
118
- return "private";
119
- }
120
9
  function resolveConversationPrivacy(input) {
121
- const narrowed = privateNarrowingFromChannelId(input.channelId) ?? privateNarrowingFromConversationId(input.conversationId);
122
- if (narrowed === "private") {
123
- return "private";
10
+ if (input.visibility === void 0) {
11
+ logWarn("conversation.visibility.defaulted");
124
12
  }
125
- return input.visibility;
13
+ return input.visibility === "public" ? "public" : "private";
126
14
  }
127
15
  function canExposeConversationPayload(input) {
128
16
  return resolveConversationPrivacy(input) === "public";
@@ -298,10 +186,6 @@ function toGenAiMessagesTraceAttributes(prefix, messages) {
298
186
  }
299
187
 
300
188
  export {
301
- readSlackRawMessageContext,
302
- parseSlackThreadId,
303
- resolveSlackChannelIdFromThreadId,
304
- resolveSlackChannelIdFromMessage,
305
189
  resolveConversationPrivacy,
306
190
  canExposeConversationPayload,
307
191
  getCurrentConversationPrivacy,
@@ -16,34 +16,32 @@ import {
16
16
  instructionProvenanceFor,
17
17
  sanitizePostgresJson,
18
18
  withConversationEventLock
19
- } from "./chunk-IS4DGI5J.js";
19
+ } from "./chunk-KP7E267S.js";
20
20
  import {
21
21
  getStateAdapter,
22
22
  sleep
23
- } from "./chunk-XJYGLTYI.js";
23
+ } from "./chunk-APYVVX2Y.js";
24
24
  import {
25
25
  botConfig,
26
26
  escapeXml,
27
27
  resolveGatewayModel,
28
28
  unwrapCurrentInstruction
29
- } from "./chunk-KN7QI56S.js";
29
+ } from "./chunk-XLIAQRDI.js";
30
30
  import {
31
31
  toStoredSlackActor
32
32
  } from "./chunk-HZF5P5UN.js";
33
+ import {
34
+ parseSlackMessageTs
35
+ } from "./chunk-F3B2YJ76.js";
33
36
  import {
34
37
  getActiveTraceId,
38
+ isRecord,
35
39
  logException,
36
40
  logWarn,
37
- setSpanAttributes
38
- } from "./chunk-MVYNJECP.js";
39
- import {
40
- isRecord,
41
+ setSpanAttributes,
41
42
  toOptionalNumber,
42
43
  toOptionalString
43
- } from "./chunk-OB42YVAE.js";
44
- import {
45
- parseSlackMessageTs
46
- } from "./chunk-F3B2YJ76.js";
44
+ } from "./chunk-JP2ZOSQK.js";
47
45
 
48
46
  // src/chat/turn-context-tag.ts
49
47
  var TURN_CONTEXT_TAG = "runtime-turn-context";
@@ -2013,6 +2011,7 @@ async function persistRunningSessionRecord(args) {
2013
2011
  cumulativeDurationMs: latestSessionRecord?.cumulativeDurationMs,
2014
2012
  cumulativeUsage: latestSessionRecord?.cumulativeUsage,
2015
2013
  ...args.destination ?? latestSessionRecord?.destination ? { destination: args.destination ?? latestSessionRecord?.destination } : {},
2014
+ destinationVisibility: args.destinationVisibility,
2016
2015
  ...args.dispatchId ?? latestSessionRecord?.dispatchId ? { dispatchId: args.dispatchId ?? latestSessionRecord?.dispatchId } : {},
2017
2016
  ...args.source ?? latestSessionRecord?.source ? { source: args.source ?? latestSessionRecord?.source } : {},
2018
2017
  sessionId: args.sessionId,
@@ -2152,6 +2151,7 @@ async function persistAuthPauseSessionRecord(args) {
2152
2151
  args.currentUsage
2153
2152
  ),
2154
2153
  ...args.destination ?? latestSessionRecord?.destination ? { destination: args.destination ?? latestSessionRecord?.destination } : {},
2154
+ destinationVisibility: args.destinationVisibility,
2155
2155
  ...args.dispatchId ?? latestSessionRecord?.dispatchId ? { dispatchId: args.dispatchId ?? latestSessionRecord?.dispatchId } : {},
2156
2156
  ...args.source ?? latestSessionRecord?.source ? { source: args.source ?? latestSessionRecord?.source } : {},
2157
2157
  sessionId: args.sessionId,
@@ -2216,6 +2216,7 @@ async function persistContinuationSessionRecord(args) {
2216
2216
  ...args.destination ?? latestSessionRecord?.destination ? {
2217
2217
  destination: args.destination ?? latestSessionRecord?.destination
2218
2218
  } : {},
2219
+ destinationVisibility: args.destinationVisibility,
2219
2220
  ...args.dispatchId ?? latestSessionRecord?.dispatchId ? { dispatchId: args.dispatchId ?? latestSessionRecord?.dispatchId } : {},
2220
2221
  ...args.source ?? latestSessionRecord?.source ? { source: args.source ?? latestSessionRecord?.source } : {},
2221
2222
  sessionId: args.sessionId,
@@ -2243,6 +2244,7 @@ async function persistContinuationSessionRecord(args) {
2243
2244
  cumulativeDurationMs,
2244
2245
  cumulativeUsage,
2245
2246
  ...args.destination ?? latestSessionRecord?.destination ? { destination: args.destination ?? latestSessionRecord?.destination } : {},
2247
+ destinationVisibility: args.destinationVisibility,
2246
2248
  ...args.dispatchId ?? latestSessionRecord?.dispatchId ? { dispatchId: args.dispatchId ?? latestSessionRecord?.dispatchId } : {},
2247
2249
  ...args.source ?? latestSessionRecord?.source ? { source: args.source ?? latestSessionRecord?.source } : {},
2248
2250
  sessionId: args.sessionId,
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  getCurrentConversationPrivacy,
3
- resolveConversationPrivacy,
4
3
  toCanonicalInputMessage,
5
4
  toCanonicalOutputMessage,
6
5
  toGenAiMessagesTraceAttributes
7
- } from "./chunk-S7G34U75.js";
6
+ } from "./chunk-VUBUFT66.js";
8
7
  import {
9
8
  extractGenAiUsageAttributes,
10
9
  logException,
@@ -12,7 +11,7 @@ import {
12
11
  normalizeGenAiFinishReason,
13
12
  serializeGenAiAttribute,
14
13
  withSpan
15
- } from "./chunk-MVYNJECP.js";
14
+ } from "./chunk-JP2ZOSQK.js";
16
15
 
17
16
  // src/chat/config.ts
18
17
  import { getModel as getModel2 } from "@earendil-works/pi-ai/compat";
@@ -360,11 +359,7 @@ async function completeText(params) {
360
359
  const model = resolveGatewayModel(params.modelId);
361
360
  const apiKey = getPiGatewayApiKey();
362
361
  const authMode = toOptionalTrimmed(process.env.AI_GATEWAY_API_KEY) ? "api_key" : toOptionalTrimmed(process.env.VERCEL_OIDC_TOKEN) ? "oidc" : "api_key";
363
- const privacy = resolveConversationPrivacy({
364
- channelId: typeof params.metadata?.channelId === "string" ? params.metadata.channelId : void 0,
365
- conversationId: typeof params.metadata?.conversationId === "string" ? params.metadata.conversationId : typeof params.metadata?.threadId === "string" ? params.metadata.threadId : void 0
366
- }) ?? getCurrentConversationPrivacy();
367
- const effectivePrivacy = privacy ?? "private";
362
+ const effectivePrivacy = getCurrentConversationPrivacy() ?? "private";
368
363
  const messageAttributeMode = params.messageAttributeMode ?? (effectivePrivacy === "public" ? "content" : "metadata");
369
364
  const requestMessagesAttribute = messageAttributeMode === "content" ? serializeGenAiAttribute(params.messages.map(toCanonicalInputMessage)) : void 0;
370
365
  const systemInstructionsAttribute = params.system && messageAttributeMode === "content" ? serializeGenAiAttribute([{ type: "text", content: params.system }]) : void 0;
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  healthReportSchema
3
3
  } from "./chunk-UTL3MHPC.js";
4
- import {
5
- normalizeSlackConversationId
6
- } from "./chunk-ODB55JM7.js";
7
4
  import {
8
5
  parseSlackThreadId
9
- } from "./chunk-S7G34U75.js";
6
+ } from "./chunk-72SDEHFP.js";
7
+ import {
8
+ normalizeSlackConversationId
9
+ } from "./chunk-6KWO5DU3.js";
10
10
 
11
11
  // src/handlers/health.ts
12
12
  function readHealthReport() {
@@ -56,14 +56,6 @@ function conversationVisibilityFromSlackChannelType(channelType) {
56
56
  if (!channelType) return void 0;
57
57
  return channelType === "channel" ? "public" : "private";
58
58
  }
59
- function visibilityFromChannelIdPrefix(channelId) {
60
- const normalized = normalizeSlackConversationId(channelId);
61
- if (!normalized) return void 0;
62
- if (normalized.startsWith("D") || normalized.startsWith("G")) {
63
- return "private";
64
- }
65
- return void 0;
66
- }
67
59
  function resolveSlackChannelTypeFromMessage(message) {
68
60
  const raw = message.raw;
69
61
  if (!raw || typeof raw !== "object") {
@@ -76,7 +68,9 @@ function resolveSlackConversationContext(input) {
76
68
  const type = typeFromSlackChannelType(input.channelType) ?? typeFromChannelId(input.channelId, input.channelName);
77
69
  if (!type) return void 0;
78
70
  const name = normalizeConversationName(type, input.channelName);
79
- const visibility = conversationVisibilityFromSlackChannelType(input.channelType) ?? visibilityFromChannelIdPrefix(input.channelId);
71
+ const visibility = conversationVisibilityFromSlackChannelType(
72
+ input.channelType
73
+ );
80
74
  return {
81
75
  type,
82
76
  ...name ? { name } : {},
@@ -85,10 +79,18 @@ function resolveSlackConversationContext(input) {
85
79
  }
86
80
  function resolveSlackConversationContextFromThreadId(input) {
87
81
  const slackThread = parseSlackThreadId(input.threadId);
88
- return resolveSlackConversationContext({
82
+ const context = resolveSlackConversationContext({
89
83
  channelId: slackThread?.channelId,
90
84
  channelName: input.channelName
91
85
  });
86
+ if (!context || !input.visibility) {
87
+ return context;
88
+ }
89
+ return {
90
+ ...context,
91
+ type: input.visibility === "private" && context.type === "public_channel" ? "private_channel" : context.type,
92
+ visibility: input.visibility
93
+ };
92
94
  }
93
95
  function formatSlackConversationTypeLabel(type) {
94
96
  if (type === "public_channel") return "Public Channel";