@sentry/junior 0.91.0 → 0.92.1

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 (128) hide show
  1. package/dist/{agent-hooks-MXAF7RQL.js → agent-hooks-KL7I3ZRC.js} +7 -7
  2. package/dist/api/people/list.d.ts +3 -3
  3. package/dist/api/people/list.js +15 -15
  4. package/dist/api/people/list.query.d.ts +2 -2
  5. package/dist/api/people/profile.d.ts +3 -3
  6. package/dist/api/people/profile.js +12 -12
  7. package/dist/api/people/profile.query.d.ts +2 -2
  8. package/dist/api/people/shared.d.ts +13 -13
  9. package/dist/api/people/types.d.ts +12 -12
  10. package/dist/api-reference.d.ts +1 -1
  11. package/dist/app.js +365 -265
  12. package/dist/{catalog-runtime-DXE6NXHT.js → catalog-runtime-NZHMSMYC.js} +2 -2
  13. package/dist/chat/actor.d.ts +75 -0
  14. package/dist/chat/agent/prompt.d.ts +2 -2
  15. package/dist/chat/agent/request.d.ts +13 -13
  16. package/dist/chat/agent/resume.d.ts +5 -4
  17. package/dist/chat/agent/tools.d.ts +4 -2
  18. package/dist/chat/capabilities/jr-rpc-command.d.ts +1 -1
  19. package/dist/chat/conversation-privacy.d.ts +11 -0
  20. package/dist/chat/conversations/sql/migrations.d.ts +1 -1
  21. package/dist/chat/conversations/sql/schema/conversations.d.ts +2 -19
  22. package/dist/chat/conversations/sql/schema.d.ts +2 -19
  23. package/dist/chat/conversations/sql/store.d.ts +3 -3
  24. package/dist/chat/conversations/store.d.ts +4 -4
  25. package/dist/chat/credentials/context.d.ts +4 -4
  26. package/dist/chat/logging.d.ts +2 -2
  27. package/dist/chat/no-reply.d.ts +1 -1
  28. package/dist/chat/oauth-flow.d.ts +1 -1
  29. package/dist/chat/pi/messages.d.ts +2 -2
  30. package/dist/chat/pi/transcript.d.ts +15 -0
  31. package/dist/chat/plugins/agent-hooks.d.ts +5 -3
  32. package/dist/chat/plugins/credential-hooks.d.ts +2 -8
  33. package/dist/chat/prompt.d.ts +3 -6
  34. package/dist/chat/runtime/reply-executor.d.ts +1 -1
  35. package/dist/chat/runtime/turn-input.d.ts +1 -1
  36. package/dist/chat/sandbox/egress/schemas.d.ts +2 -2
  37. package/dist/chat/sandbox/egress/session.d.ts +1 -1
  38. package/dist/chat/services/context-compaction.d.ts +1 -1
  39. package/dist/chat/services/conversation-memory.d.ts +1 -1
  40. package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
  41. package/dist/chat/services/message-actor-identity.d.ts +4 -4
  42. package/dist/chat/services/pending-auth.d.ts +2 -2
  43. package/dist/chat/services/plugin-auth-orchestration.d.ts +1 -1
  44. package/dist/chat/services/provider-default-config.d.ts +1 -1
  45. package/dist/chat/services/subscribed-decision.d.ts +1 -1
  46. package/dist/chat/services/turn-result.d.ts +1 -1
  47. package/dist/chat/services/turn-session-record.d.ts +11 -8
  48. package/dist/chat/services/turn-thinking-level.d.ts +1 -1
  49. package/dist/chat/slack/assistant-thread/title.d.ts +1 -1
  50. package/dist/chat/slack/tools/canvas/create.d.ts +41 -1
  51. package/dist/chat/slack/tools/canvas/edit.d.ts +60 -1
  52. package/dist/chat/slack/tools/canvas/read.d.ts +60 -1
  53. package/dist/chat/slack/tools/canvas/write.d.ts +41 -1
  54. package/dist/chat/slack/tools/channel-list-messages.d.ts +45 -1
  55. package/dist/chat/slack/tools/context.d.ts +3 -3
  56. package/dist/chat/slack/tools/list/add-items.d.ts +42 -1
  57. package/dist/chat/slack/tools/list/create.d.ts +40 -1
  58. package/dist/chat/slack/tools/list/get-items.d.ts +40 -1
  59. package/dist/chat/slack/tools/list/update-item.d.ts +46 -1
  60. package/dist/chat/slack/tools/message-add-reaction.d.ts +40 -1
  61. package/dist/chat/slack/tools/send-message.d.ts +45 -1
  62. package/dist/chat/slack/tools/thread-read.d.ts +44 -1
  63. package/dist/chat/slack/tools/user-lookup.d.ts +45 -1
  64. package/dist/chat/slack/user.d.ts +3 -3
  65. package/dist/chat/slack/vision-context.d.ts +2 -2
  66. package/dist/chat/sql/schema.d.ts +2 -19
  67. package/dist/chat/state/conversation-details.d.ts +4 -4
  68. package/dist/chat/state/conversation.d.ts +1 -1
  69. package/dist/chat/state/session-log.d.ts +140 -26
  70. package/dist/chat/state/turn-session.d.ts +18 -5
  71. package/dist/chat/task-execution/slack-work.d.ts +2 -2
  72. package/dist/chat/task-execution/state.d.ts +4 -4
  73. package/dist/chat/tool-support/zod-tool.d.ts +16 -4
  74. package/dist/chat/tools/advisor/tool.d.ts +41 -1
  75. package/dist/chat/tools/definition.d.ts +10 -0
  76. package/dist/chat/tools/execute-tool.d.ts +41 -1
  77. package/dist/chat/tools/resource-events.d.ts +124 -3
  78. package/dist/chat/tools/runtime/report-progress.d.ts +40 -1
  79. package/dist/chat/tools/sandbox/bash.d.ts +41 -1
  80. package/dist/chat/tools/sandbox/edit-file.d.ts +44 -1
  81. package/dist/chat/tools/sandbox/find-files.d.ts +42 -1
  82. package/dist/chat/tools/sandbox/grep.d.ts +46 -1
  83. package/dist/chat/tools/sandbox/list-dir.d.ts +41 -1
  84. package/dist/chat/tools/sandbox/read-file.d.ts +42 -1
  85. package/dist/chat/tools/sandbox/write-file.d.ts +41 -1
  86. package/dist/chat/tools/search-tools.d.ts +102 -1
  87. package/dist/chat/tools/skill/call-mcp-tool.d.ts +10 -1
  88. package/dist/chat/tools/skill/load-skill.d.ts +40 -1
  89. package/dist/chat/tools/skill/search-mcp-tools.d.ts +100 -1
  90. package/dist/chat/tools/system-time.d.ts +38 -1
  91. package/dist/chat/tools/types.d.ts +4 -4
  92. package/dist/chat/tools/web/fetch-tool.d.ts +41 -1
  93. package/dist/chat/tools/web/image-generate.d.ts +62 -1
  94. package/dist/chat/tools/web/search.d.ts +41 -1
  95. package/dist/{chunk-HXL2ZV74.js → chunk-3F54A3YM.js} +82 -11
  96. package/dist/{chunk-ZGDTBSQ7.js → chunk-56SIBIVF.js} +930 -660
  97. package/dist/{chunk-DACFZ5CI.js → chunk-7K3JALTQ.js} +18 -12
  98. package/dist/{chunk-IRRMABQD.js → chunk-APIVR44P.js} +10 -10
  99. package/dist/{chunk-XP7F4LYB.js → chunk-BTH37NCU.js} +4 -4
  100. package/dist/{chunk-5GBUZI6M.js → chunk-H7KUZAMZ.js} +4 -4
  101. package/dist/{chunk-PIB4EOW6.js → chunk-IWKVXO3F.js} +19 -72
  102. package/dist/{chunk-TYUXD3FN.js → chunk-MC4ZZE4Q.js} +1 -1
  103. package/dist/{chunk-2S7M37HY.js → chunk-NIFONS4W.js} +86 -47
  104. package/dist/{chunk-AOISHLSF.js → chunk-O6ZYIHFC.js} +143 -20
  105. package/dist/{chunk-GCWD2VHP.js → chunk-OQQU3SD6.js} +285 -124
  106. package/dist/{chunk-NW7AXDA5.js → chunk-OZJXGX4U.js} +2 -2
  107. package/dist/{chunk-KC42JAAQ.js → chunk-PFXC67GJ.js} +3 -3
  108. package/dist/{chunk-QCKGI74V.js → chunk-PGR4WGZW.js} +10 -10
  109. package/dist/{chunk-ZUK7BL63.js → chunk-S6QKIGRM.js} +66 -54
  110. package/dist/{chunk-IX76WFJV.js → chunk-TF5VLGA7.js} +10 -10
  111. package/dist/{chunk-AN2437E3.js → chunk-YTNPU7I2.js} +2 -2
  112. package/dist/{chunk-3MPOMK3K.js → chunk-YYBX2BD5.js} +61 -3
  113. package/dist/{chunk-ONFOWI2D.js → chunk-Z4FOYQXW.js} +16 -15
  114. package/dist/{chunk-RS6ANWVT.js → chunk-ZATRYQLR.js} +1 -1
  115. package/dist/cli/chat.js +20 -20
  116. package/dist/cli/check.js +3 -3
  117. package/dist/cli/plugins.js +9 -9
  118. package/dist/cli/snapshot-warmup.js +6 -6
  119. package/dist/cli/upgrade.js +9 -9
  120. package/dist/{db-CXI7PR5U.js → db-GCK43OO3.js} +4 -4
  121. package/dist/instrumentation.js +1 -1
  122. package/dist/reporting/conversations.d.ts +3 -3
  123. package/dist/reporting.d.ts +1 -1
  124. package/dist/reporting.js +48 -50
  125. package/dist/{runner-FKL3RAHA.js → runner-Y73GZ2VE.js} +20 -18
  126. package/dist/{validation-I7GD2YWS.js → validation-KYAWETI4.js} +3 -3
  127. package/package.json +6 -6
  128. package/dist/chat/requester.d.ts +0 -68
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-HXL2ZV74.js";
3
+ } from "./chunk-3F54A3YM.js";
4
4
  import {
5
5
  parseDestination,
6
6
  sameDestination
7
7
  } from "./chunk-GHGPTPBL.js";
8
8
  import {
9
9
  normalizeIdentityEmail,
10
- parseStoredSlackRequester
11
- } from "./chunk-ZUK7BL63.js";
10
+ parseStoredSlackActor
11
+ } from "./chunk-S6QKIGRM.js";
12
12
 
13
13
  // src/chat/conversations/sql/store.ts
14
14
  import { randomUUID as randomUUID2 } from "crypto";
@@ -139,16 +139,13 @@ var juniorConversations = pgTable4(
139
139
  actorIdentityId: text4("actor_identity_id").references(
140
140
  () => juniorIdentities.id
141
141
  ),
142
- requesterIdentityId: text4("requester_identity_id").references(
143
- () => juniorIdentities.id
144
- ),
145
142
  creatorIdentityId: text4("creator_identity_id").references(
146
143
  () => juniorIdentities.id
147
144
  ),
148
145
  credentialSubjectIdentityId: text4(
149
146
  "credential_subject_identity_id"
150
147
  ).references(() => juniorIdentities.id),
151
- requester: jsonb3("requester_json").$type(),
148
+ actor: jsonb3("actor_json").$type(),
152
149
  channelName: text4("channel_name"),
153
150
  title: text4("title"),
154
151
  createdAt: timestamptz("created_at").notNull(),
@@ -178,10 +175,6 @@ var juniorConversations = pgTable4(
178
175
  table.actorIdentityId,
179
176
  table.lastActivityAt.desc()
180
177
  ),
181
- index3("junior_conversations_requester_activity_idx").on(
182
- table.requesterIdentityId,
183
- table.lastActivityAt.desc()
184
- ),
185
178
  index3("junior_conversations_origin_idx").on(
186
179
  table.originType,
187
180
  table.originId,
@@ -546,13 +539,69 @@ CREATE INDEX IF NOT EXISTS junior_identities_verified_email_idx
546
539
  AND email_normalized IS NOT NULL
547
540
  `
548
541
  ];
542
+ var actorCutoverStatements = [
543
+ `
544
+ UPDATE junior_conversations
545
+ SET actor_identity_id = requester_identity_id
546
+ WHERE requester_identity_id IS NOT NULL
547
+ `,
548
+ `
549
+ DO $$
550
+ BEGIN
551
+ IF EXISTS (
552
+ SELECT 1
553
+ FROM information_schema.columns
554
+ WHERE table_name = 'junior_conversations'
555
+ AND column_name = 'requester_json'
556
+ ) AND NOT EXISTS (
557
+ SELECT 1
558
+ FROM information_schema.columns
559
+ WHERE table_name = 'junior_conversations'
560
+ AND column_name = 'actor_json'
561
+ ) THEN
562
+ ALTER TABLE junior_conversations
563
+ RENAME COLUMN requester_json TO actor_json;
564
+ END IF;
565
+ END $$;
566
+ `,
567
+ `
568
+ ALTER TABLE junior_conversations
569
+ ADD COLUMN IF NOT EXISTS actor_json JSONB
570
+ `,
571
+ `
572
+ DO $$
573
+ BEGIN
574
+ IF EXISTS (
575
+ SELECT 1
576
+ FROM information_schema.columns
577
+ WHERE table_name = 'junior_conversations'
578
+ AND column_name = 'requester_json'
579
+ ) THEN
580
+ UPDATE junior_conversations
581
+ SET actor_json = COALESCE(actor_json, requester_json);
582
+ END IF;
583
+ END $$;
584
+ `,
585
+ `
586
+ DROP INDEX IF EXISTS junior_conversations_requester_activity_idx
587
+ `,
588
+ `
589
+ ALTER TABLE junior_conversations
590
+ DROP COLUMN IF EXISTS requester_identity_id
591
+ `,
592
+ `
593
+ ALTER TABLE junior_conversations
594
+ DROP COLUMN IF EXISTS requester_json
595
+ `
596
+ ];
549
597
  var migrations = [
550
598
  defineMigration("0001_conversation_core", coreMetadataStatements),
551
599
  defineMigration(
552
600
  "0002_slack_destination_visibility_backfill",
553
601
  destinationVisibilityBackfillStatements
554
602
  ),
555
- defineMigration("0003_user_identities", userIdentityStatements)
603
+ defineMigration("0003_user_identities", userIdentityStatements),
604
+ defineMigration("0004_actor_cutover", actorCutoverStatements)
556
605
  ];
557
606
  function parseStoredMigrationRecord(value) {
558
607
  return migrationRecordSchema.parse(value);
@@ -629,18 +678,18 @@ function sourceFromValue(value) {
629
678
  }
630
679
  return void 0;
631
680
  }
632
- function identityFromRequester(requester) {
633
- if (!requester?.slackUserId) {
681
+ function identityFromActor(actor) {
682
+ if (!actor?.slackUserId) {
634
683
  return void 0;
635
684
  }
636
685
  return {
637
686
  kind: "user",
638
687
  provider: "slack",
639
- providerTenantId: requester.teamId,
640
- providerSubjectId: requester.slackUserId,
641
- ...requester.fullName ? { displayName: requester.fullName } : {},
642
- ...requester.slackUserName ? { handle: requester.slackUserName } : {},
643
- ...requester.email ? { email: requester.email, emailVerified: true } : {},
688
+ providerTenantId: actor.teamId,
689
+ providerSubjectId: actor.slackUserId,
690
+ ...actor.fullName ? { displayName: actor.fullName } : {},
691
+ ...actor.slackUserName ? { handle: actor.slackUserName } : {},
692
+ ...actor.email ? { email: actor.email, emailVerified: true } : {},
644
693
  metadata: { platform: "slack" }
645
694
  };
646
695
  }
@@ -672,7 +721,7 @@ function systemIdentityFromSource(source) {
672
721
  return void 0;
673
722
  }
674
723
  function actorIdentityForConversation(conversation) {
675
- return identityFromRequester(conversation.requester) ?? systemIdentityFromSource(conversation.source);
724
+ return identityFromActor(conversation.actor) ?? systemIdentityFromSource(conversation.source);
676
725
  }
677
726
  function originTypeFromSource(source) {
678
727
  return source;
@@ -722,7 +771,7 @@ function privacyFromRow(row) {
722
771
  }
723
772
  return row.destinationVisibility === "public" ? "public" : "private";
724
773
  }
725
- function requesterFromIdentityRow(identity, fallback) {
774
+ function actorFromIdentityRow(identity, fallback) {
726
775
  if (!identity || identity.provider !== "slack") {
727
776
  return fallback;
728
777
  }
@@ -743,15 +792,15 @@ function conversationFromRow(readRow) {
743
792
  throw new Error("Conversation record schema version is invalid");
744
793
  }
745
794
  const destination = row.destination === void 0 || row.destination === null ? void 0 : parseDestination(row.destination);
746
- const requester = requesterFromIdentityRow(
747
- readRow.requesterIdentity,
748
- parseStoredSlackRequester(row.requester)
795
+ const actor = actorFromIdentityRow(
796
+ readRow.actorIdentity,
797
+ parseStoredSlackActor(row.actor)
749
798
  );
750
799
  if (row.destination !== void 0 && row.destination !== null && !destination) {
751
800
  throw new Error("Conversation record destination is invalid");
752
801
  }
753
- if (row.requester !== void 0 && row.requester !== null && !requester) {
754
- throw new Error("Conversation record requester is invalid");
802
+ if (row.actor !== void 0 && row.actor !== null && !actor) {
803
+ throw new Error("Conversation record actor is invalid");
755
804
  }
756
805
  const source = row.source === void 0 || row.source === null ? void 0 : sourceFromValue(row.source);
757
806
  if (row.source !== void 0 && row.source !== null && !source) {
@@ -772,7 +821,7 @@ function conversationFromRow(readRow) {
772
821
  updatedAtMs: requiredMsFromDate(row.updatedAt),
773
822
  execution,
774
823
  ...destination ? { destination } : {},
775
- ...requester ? { requester } : {},
824
+ ...actor ? { actor } : {},
776
825
  ...row.channelName ? { channelName: row.channelName } : {},
777
826
  ...source ? { source } : {},
778
827
  ...row.title ? { title: row.title } : {},
@@ -802,7 +851,7 @@ function assertSameConversationDestination(args) {
802
851
  `Conversation destination changed for ${args.conversationId}`
803
852
  );
804
853
  }
805
- function mergeRequester(current2, next) {
854
+ function mergeActor(current2, next) {
806
855
  if (!current2) {
807
856
  return next;
808
857
  }
@@ -879,7 +928,7 @@ var SqlStore = class {
879
928
  destination: current2.destination ?? args.destination,
880
929
  source: current2.source ?? args.source,
881
930
  channelName: current2.channelName ?? args.channelName,
882
- requester: mergeRequester(current2.requester, args.requester),
931
+ actor: mergeActor(current2.actor, args.actor),
883
932
  title: current2.title ?? args.title,
884
933
  lastActivityAtMs: Math.max(current2.lastActivityAtMs, activityAtMs),
885
934
  updatedAtMs: nowMs,
@@ -903,7 +952,7 @@ var SqlStore = class {
903
952
  updatedAtMs: args.updatedAtMs,
904
953
  ...args.channelName ? { channelName: args.channelName } : {},
905
954
  ...args.destination ? { destination: args.destination } : {},
906
- ...args.requester ? { requester: args.requester } : {},
955
+ ...args.actor ? { actor: args.actor } : {},
907
956
  ...args.source ? { source: args.source } : {},
908
957
  ...args.title ? { title: args.title } : {},
909
958
  ...args.visibility ? { visibility: args.visibility } : {},
@@ -936,7 +985,7 @@ var SqlStore = class {
936
985
  existing.lastActivityAtMs,
937
986
  conversation.lastActivityAtMs
938
987
  ),
939
- requester: existing.requester ?? conversation.requester,
988
+ actor: existing.actor ?? conversation.actor,
940
989
  source: existing.source ?? conversation.source,
941
990
  title: existing.title ?? conversation.title,
942
991
  updatedAtMs: Math.max(
@@ -953,13 +1002,13 @@ var SqlStore = class {
953
1002
  const rows = await this.executor.db().select({
954
1003
  conversation: juniorConversations,
955
1004
  destinationVisibility: juniorDestinations.visibility,
956
- requesterIdentity: juniorIdentities
1005
+ actorIdentity: juniorIdentities
957
1006
  }).from(juniorConversations).leftJoin(
958
1007
  juniorDestinations,
959
1008
  eq2(juniorDestinations.id, juniorConversations.destinationId)
960
1009
  ).leftJoin(
961
1010
  juniorIdentities,
962
- eq2(juniorIdentities.id, juniorConversations.requesterIdentityId)
1011
+ eq2(juniorIdentities.id, juniorConversations.actorIdentityId)
963
1012
  ).orderBy(
964
1013
  desc(juniorConversations.lastActivityAt),
965
1014
  asc(juniorConversations.conversationId)
@@ -1003,13 +1052,13 @@ var SqlStore = class {
1003
1052
  const rows = await this.executor.db().select({
1004
1053
  conversation: juniorConversations,
1005
1054
  destinationVisibility: juniorDestinations.visibility,
1006
- requesterIdentity: juniorIdentities
1055
+ actorIdentity: juniorIdentities
1007
1056
  }).from(juniorConversations).leftJoin(
1008
1057
  juniorDestinations,
1009
1058
  eq2(juniorDestinations.id, juniorConversations.destinationId)
1010
1059
  ).leftJoin(
1011
1060
  juniorIdentities,
1012
- eq2(juniorIdentities.id, juniorConversations.requesterIdentityId)
1061
+ eq2(juniorIdentities.id, juniorConversations.actorIdentityId)
1013
1062
  ).where(eq2(juniorConversations.conversationId, conversationId));
1014
1063
  return rows[0];
1015
1064
  }
@@ -1028,14 +1077,6 @@ var SqlStore = class {
1028
1077
  }),
1029
1078
  conversation.updatedAtMs
1030
1079
  );
1031
- const requesterIdentityObservation = identityFromRequester(
1032
- conversation.requester
1033
- );
1034
- const requesterIdentity = requesterIdentityObservation ? await upsertIdentity(
1035
- this.executor,
1036
- requesterIdentityObservation,
1037
- conversation.updatedAtMs
1038
- ) : void 0;
1039
1080
  const actorIdentityObservation = actorIdentityForConversation(conversation);
1040
1081
  const actorIdentity = actorIdentityObservation ? await upsertIdentity(
1041
1082
  this.executor,
@@ -1052,10 +1093,9 @@ var SqlStore = class {
1052
1093
  destinationId: destinationId ?? null,
1053
1094
  destination: conversation.destination ?? null,
1054
1095
  actorIdentityId: actorIdentity?.id ?? null,
1055
- requesterIdentityId: requesterIdentity?.id ?? null,
1056
1096
  creatorIdentityId: null,
1057
1097
  credentialSubjectIdentityId: null,
1058
- requester: conversation.requester ?? null,
1098
+ actor: conversation.actor ?? null,
1059
1099
  channelName: conversation.channelName ?? null,
1060
1100
  title: conversation.title ?? null,
1061
1101
  createdAt: dateFromMs2(conversation.createdAtMs),
@@ -1076,10 +1116,9 @@ var SqlStore = class {
1076
1116
  destinationId: sql4`coalesce(excluded.destination_id, ${juniorConversations.destinationId})`,
1077
1117
  destination: sql4`coalesce(excluded.destination_json, ${juniorConversations.destination})`,
1078
1118
  actorIdentityId: sql4`coalesce(excluded.actor_identity_id, ${juniorConversations.actorIdentityId})`,
1079
- requesterIdentityId: sql4`coalesce(excluded.requester_identity_id, ${juniorConversations.requesterIdentityId})`,
1080
1119
  creatorIdentityId: sql4`coalesce(excluded.creator_identity_id, ${juniorConversations.creatorIdentityId})`,
1081
1120
  credentialSubjectIdentityId: sql4`coalesce(excluded.credential_subject_identity_id, ${juniorConversations.credentialSubjectIdentityId})`,
1082
- requester: sql4`coalesce(excluded.requester_json, ${juniorConversations.requester})`,
1121
+ actor: sql4`coalesce(excluded.actor_json, ${juniorConversations.actor})`,
1083
1122
  channelName: sql4`coalesce(excluded.channel_name, ${juniorConversations.channelName})`,
1084
1123
  title: sql4`coalesce(excluded.title, ${juniorConversations.title})`,
1085
1124
  createdAt: sql4`least(${juniorConversations.createdAt}, excluded.created_at)`,
@@ -5,44 +5,49 @@ import {
5
5
  } from "./chunk-KNFROR7R.js";
6
6
  import {
7
7
  clearPendingAuth,
8
+ getPersistedThreadState,
8
9
  markTurnCompleted,
9
10
  mergeArtifactsState
10
- } from "./chunk-ONFOWI2D.js";
11
+ } from "./chunk-Z4FOYQXW.js";
12
+ import {
13
+ coerceThreadConversationState
14
+ } from "./chunk-PFXC67GJ.js";
11
15
  import {
12
- escapeXml,
13
16
  getAgentTurnSessionRecord,
14
17
  getInterruptionMarker
15
- } from "./chunk-GCWD2VHP.js";
18
+ } from "./chunk-OQQU3SD6.js";
16
19
  import {
17
20
  createPluginEmbedder,
18
21
  createPluginModel,
19
22
  getPlugins
20
- } from "./chunk-DACFZ5CI.js";
23
+ } from "./chunk-7K3JALTQ.js";
21
24
  import {
22
25
  createPluginLogger,
23
26
  createPluginState
24
- } from "./chunk-NW7AXDA5.js";
27
+ } from "./chunk-OZJXGX4U.js";
25
28
  import {
26
29
  getStateAdapter
27
- } from "./chunk-RS6ANWVT.js";
30
+ } from "./chunk-ZATRYQLR.js";
28
31
  import {
29
32
  getDb
30
- } from "./chunk-2S7M37HY.js";
33
+ } from "./chunk-NIFONS4W.js";
31
34
  import {
32
35
  GEN_AI_PROVIDER_NAME,
33
36
  botConfig,
37
+ escapeXml,
34
38
  getPiMessageRole,
39
+ instructionTextForProjection,
35
40
  isToolResultError,
36
41
  isToolResultMessage,
37
42
  normalizeToolNameFromResult,
38
43
  resolveGatewayModel,
39
44
  stripRuntimeTurnContext
40
- } from "./chunk-HXL2ZV74.js";
45
+ } from "./chunk-3F54A3YM.js";
41
46
  import {
42
47
  buildTurnFailureResponse,
43
48
  logWarn,
44
49
  setSpanAttributes
45
- } from "./chunk-ZUK7BL63.js";
50
+ } from "./chunk-S6QKIGRM.js";
46
51
  import {
47
52
  parseSlackMessageTs
48
53
  } from "./chunk-LFLTJQVR.js";
@@ -275,7 +280,7 @@ async function summarizeConversationChunk(messages, conversation, context, deps)
275
280
  modelId: botConfig.fastModelId,
276
281
  threadId: context.threadId ?? "",
277
282
  channelId: context.channelId ?? "",
278
- requesterId: context.requesterId ?? "",
283
+ actorId: context.actorId ?? "",
279
284
  runId: context.runId ?? ""
280
285
  }
281
286
  });
@@ -288,7 +293,7 @@ async function summarizeConversationChunk(messages, conversation, context, deps)
288
293
  "conversation_compaction_summary_failed",
289
294
  {
290
295
  slackThreadId: context.threadId,
291
- slackUserId: context.requesterId,
296
+ slackUserId: context.actorId,
292
297
  slackChannelId: context.channelId,
293
298
  runId: context.runId,
294
299
  assistantUserName: botConfig.userName,
@@ -456,7 +461,7 @@ function getAgentTurnDiagnosticsAttributes(reply) {
456
461
  "app.ai.tool_call_count": reply.diagnostics.toolCalls.length,
457
462
  "app.ai.used_primary_text": reply.diagnostics.usedPrimaryText,
458
463
  ...reply.diagnostics.thinkingLevel ? {
459
- "app.ai.reasoning_effort": reply.diagnostics.thinkingLevel
464
+ "gen_ai.request.reasoning.level": reply.diagnostics.thinkingLevel
460
465
  } : {},
461
466
  ...reply.diagnostics.stopReason ? {
462
467
  "gen_ai.response.finish_reasons": [reply.diagnostics.stopReason]
@@ -496,7 +501,10 @@ function finalizeFailedTurnReply(args) {
496
501
  }
497
502
 
498
503
  // src/chat/plugins/task-runner.ts
499
- import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
504
+ import {
505
+ isPrivateSource,
506
+ pluginRunContextSchema
507
+ } from "@sentry/junior-plugin-api";
500
508
  var PLUGIN_TASK_LOCK_TTL_MS = 5 * 60 * 1e3;
501
509
  function isRecord(value) {
502
510
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
@@ -540,14 +548,41 @@ function sanitizeText(text) {
540
548
  "[image data omitted]"
541
549
  ).replaceAll("\0", " ").trim();
542
550
  }
543
- function runTranscriptEntry(message) {
551
+ function sameActorIdentity(left, right) {
552
+ if (!left || !right || left.platform !== right.platform) {
553
+ return false;
554
+ }
555
+ if (left.platform === "system" || right.platform === "system") {
556
+ return left.platform === "system" && right.platform === "system" && left.name === right.name;
557
+ }
558
+ if (left.platform === "slack" && right.platform === "slack") {
559
+ return left.teamId === right.teamId && left.userId === right.userId;
560
+ }
561
+ return left.userId === right.userId;
562
+ }
563
+ function messageProvenance(provenance) {
564
+ return {
565
+ authority: provenance.authority,
566
+ ...provenance.actor ? { actor: provenance.actor } : {}
567
+ };
568
+ }
569
+ function runTranscriptEntry(message, provenance, runActor) {
544
570
  const role = getPiMessageRole(message);
545
571
  if (role === "user" || role === "assistant") {
546
- const text2 = messageText(message);
572
+ const text2 = role === "user" ? instructionTextForProjection(messageText(message)) : messageText(message);
547
573
  if (!text2) {
548
574
  return void 0;
549
575
  }
550
- return { type: "message", role, text: text2 };
576
+ if (role === "assistant") {
577
+ return { type: "message", role, text: text2 };
578
+ }
579
+ return {
580
+ type: "message",
581
+ role,
582
+ text: text2,
583
+ provenance: messageProvenance(provenance),
584
+ isRunActor: sameActorIdentity(provenance.actor, runActor)
585
+ };
551
586
  }
552
587
  if (!isToolResultMessage(message)) {
553
588
  return void 0;
@@ -564,6 +599,85 @@ function runTranscriptEntry(message) {
564
599
  ...text ? { text } : {}
565
600
  };
566
601
  }
602
+ function turnMessagesWithProvenance(record) {
603
+ const startIndex = record.turnStartMessageIndex ?? 0;
604
+ const messages = record.piMessages.slice(startIndex);
605
+ const provenance = record.piMessageProvenance.slice(startIndex);
606
+ const paired = [];
607
+ for (const [index, message] of messages.entries()) {
608
+ for (const stripped of stripRuntimeTurnContext([message])) {
609
+ paired.push({
610
+ message: stripped,
611
+ provenance: provenance[index] ?? { authority: "context" }
612
+ });
613
+ }
614
+ }
615
+ return paired;
616
+ }
617
+ function slackContextAuthor(source, message) {
618
+ const userId = message.author?.userId?.trim();
619
+ if (!userId) {
620
+ return void 0;
621
+ }
622
+ return {
623
+ platform: "slack",
624
+ teamId: source.teamId,
625
+ userId,
626
+ ...message.author?.userName ? { userName: message.author.userName } : {},
627
+ ...message.author?.fullName ? { fullName: message.author.fullName } : {}
628
+ };
629
+ }
630
+ function slackTimestampMs(value) {
631
+ const timestamp = parseSlackMessageTs(value);
632
+ if (!timestamp) {
633
+ return void 0;
634
+ }
635
+ const timestampMs = Number(timestamp) * 1e3;
636
+ return Number.isFinite(timestampMs) ? timestampMs : void 0;
637
+ }
638
+ function conversationMessageTimestampMs(message) {
639
+ if (message.meta?.slackTs !== void 0) {
640
+ return slackTimestampMs(message.meta.slackTs);
641
+ }
642
+ return Number.isFinite(message.createdAtMs) ? message.createdAtMs : void 0;
643
+ }
644
+ function messageExistedAtRunCompletion(message, completedAtMs) {
645
+ const messageTimestampMs = conversationMessageTimestampMs(message);
646
+ return messageTimestampMs !== void 0 && messageTimestampMs <= completedAtMs;
647
+ }
648
+ async function loadConversationContextTranscriptEntries(record) {
649
+ const source = record.source;
650
+ if (source?.platform !== "slack" || isPrivateSource(source)) {
651
+ return [];
652
+ }
653
+ const state = await getPersistedThreadState(record.conversationId);
654
+ const conversation = coerceThreadConversationState(state);
655
+ const entries = [];
656
+ for (const message of conversation.messages) {
657
+ if (message.role !== "user") {
658
+ continue;
659
+ }
660
+ if (!messageExistedAtRunCompletion(message, record.updatedAtMs)) {
661
+ continue;
662
+ }
663
+ const text = sanitizeText(message.text);
664
+ if (!text) {
665
+ continue;
666
+ }
667
+ const author = slackContextAuthor(source, message);
668
+ entries.push({
669
+ type: "message",
670
+ role: "user",
671
+ text,
672
+ provenance: {
673
+ authority: "context",
674
+ ...author ? { actor: author } : {}
675
+ },
676
+ isRunActor: sameActorIdentity(author, record.actor)
677
+ });
678
+ }
679
+ return entries;
680
+ }
567
681
  async function withPluginTaskLock(taskId, callback) {
568
682
  const state = getStateAdapter();
569
683
  await state.connect();
@@ -596,17 +710,26 @@ async function loadPluginRun(params) {
596
710
  "Completed plugin task session record is missing source or destination"
597
711
  );
598
712
  }
599
- const sessionMessages = stripRuntimeTurnContext(
600
- record.piMessages.slice(record.turnStartMessageIndex ?? 0)
713
+ const runEntries = turnMessagesWithProvenance(record).map(
714
+ ({ message, provenance }) => runTranscriptEntry(message, provenance, record.actor)
715
+ ).filter((entry) => Boolean(entry));
716
+ const runMessageTexts = new Set(
717
+ runEntries.filter((entry) => entry.type === "message").map((entry) => entry.text)
718
+ );
719
+ const contextEntries = (await loadConversationContextTranscriptEntries(record)).filter(
720
+ (entry) => entry.type !== "message" || !runMessageTexts.has(entry.text)
601
721
  );
602
722
  return pluginRunContextSchema.parse({
603
723
  completedAtMs: record.updatedAtMs,
604
724
  conversationId: record.conversationId,
605
725
  destination: record.destination,
606
- ...record.requester ? { requester: record.requester } : {},
726
+ // Derived from the full run provenance on the record, not the sliced or
727
+ // stripped transcript, so it reflects every committed instruction actor.
728
+ actors: record.actors,
729
+ ...record.actor ? { actor: record.actor } : {},
607
730
  runId: record.sessionId,
608
731
  source: record.source,
609
- transcript: sessionMessages.map(runTranscriptEntry).filter((entry) => Boolean(entry))
732
+ transcript: [...contextEntries, ...runEntries]
610
733
  });
611
734
  }
612
735
  function taskPluginContext(plugin, message, options = {}) {