@sentry/junior 0.90.0 → 0.92.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 (131) hide show
  1. package/dist/{agent-hooks-MXAF7RQL.js → agent-hooks-BYSSWCNW.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 +406 -267
  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 +4 -4
  15. package/dist/chat/agent/request.d.ts +21 -13
  16. package/dist/chat/agent/resume.d.ts +5 -4
  17. package/dist/chat/agent/tools.d.ts +2 -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/current-instruction.d.ts +5 -3
  27. package/dist/chat/logging.d.ts +2 -2
  28. package/dist/chat/no-reply.d.ts +1 -1
  29. package/dist/chat/oauth-authorization-message.d.ts +6 -0
  30. package/dist/chat/oauth-flow.d.ts +1 -1
  31. package/dist/chat/pi/messages.d.ts +2 -2
  32. package/dist/chat/pi/transcript.d.ts +15 -0
  33. package/dist/chat/plugins/agent-hooks.d.ts +3 -3
  34. package/dist/chat/plugins/credential-hooks.d.ts +2 -8
  35. package/dist/chat/prompt.d.ts +3 -6
  36. package/dist/chat/runtime/reply-executor.d.ts +1 -1
  37. package/dist/chat/runtime/turn-input.d.ts +1 -1
  38. package/dist/chat/sandbox/egress/schemas.d.ts +2 -2
  39. package/dist/chat/sandbox/egress/session.d.ts +1 -1
  40. package/dist/chat/services/context-compaction.d.ts +1 -1
  41. package/dist/chat/services/conversation-memory.d.ts +1 -1
  42. package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
  43. package/dist/chat/services/message-actor-identity.d.ts +4 -4
  44. package/dist/chat/services/pending-auth.d.ts +2 -2
  45. package/dist/chat/services/plugin-auth-orchestration.d.ts +1 -1
  46. package/dist/chat/services/provider-default-config.d.ts +1 -1
  47. package/dist/chat/services/subscribed-decision.d.ts +1 -1
  48. package/dist/chat/services/turn-result.d.ts +1 -1
  49. package/dist/chat/services/turn-session-record.d.ts +11 -8
  50. package/dist/chat/services/turn-thinking-level.d.ts +1 -1
  51. package/dist/chat/slack/assistant-thread/title.d.ts +1 -1
  52. package/dist/chat/slack/mrkdwn.d.ts +6 -0
  53. package/dist/chat/slack/tools/canvas/create.d.ts +41 -1
  54. package/dist/chat/slack/tools/canvas/edit.d.ts +60 -1
  55. package/dist/chat/slack/tools/canvas/read.d.ts +60 -1
  56. package/dist/chat/slack/tools/canvas/write.d.ts +41 -1
  57. package/dist/chat/slack/tools/channel-list-messages.d.ts +45 -1
  58. package/dist/chat/slack/tools/context.d.ts +3 -3
  59. package/dist/chat/slack/tools/list/add-items.d.ts +42 -1
  60. package/dist/chat/slack/tools/list/create.d.ts +40 -1
  61. package/dist/chat/slack/tools/list/get-items.d.ts +40 -1
  62. package/dist/chat/slack/tools/list/update-item.d.ts +46 -1
  63. package/dist/chat/slack/tools/message-add-reaction.d.ts +40 -1
  64. package/dist/chat/slack/tools/send-message.d.ts +45 -1
  65. package/dist/chat/slack/tools/thread-read.d.ts +44 -1
  66. package/dist/chat/slack/tools/user-lookup.d.ts +45 -1
  67. package/dist/chat/slack/user.d.ts +3 -3
  68. package/dist/chat/slack/vision-context.d.ts +2 -2
  69. package/dist/chat/sql/schema.d.ts +2 -19
  70. package/dist/chat/state/conversation-details.d.ts +4 -4
  71. package/dist/chat/state/conversation.d.ts +1 -1
  72. package/dist/chat/state/session-log.d.ts +140 -26
  73. package/dist/chat/state/turn-session.d.ts +18 -5
  74. package/dist/chat/task-execution/slack-work.d.ts +2 -2
  75. package/dist/chat/task-execution/state.d.ts +4 -4
  76. package/dist/chat/tool-support/zod-tool.d.ts +16 -4
  77. package/dist/chat/tools/advisor/tool.d.ts +41 -1
  78. package/dist/chat/tools/definition.d.ts +10 -0
  79. package/dist/chat/tools/execute-tool.d.ts +41 -1
  80. package/dist/chat/tools/resource-events.d.ts +124 -3
  81. package/dist/chat/tools/runtime/report-progress.d.ts +40 -1
  82. package/dist/chat/tools/sandbox/bash.d.ts +41 -1
  83. package/dist/chat/tools/sandbox/edit-file.d.ts +44 -1
  84. package/dist/chat/tools/sandbox/find-files.d.ts +42 -1
  85. package/dist/chat/tools/sandbox/grep.d.ts +46 -1
  86. package/dist/chat/tools/sandbox/list-dir.d.ts +41 -1
  87. package/dist/chat/tools/sandbox/read-file.d.ts +42 -1
  88. package/dist/chat/tools/sandbox/write-file.d.ts +41 -1
  89. package/dist/chat/tools/search-tools.d.ts +102 -1
  90. package/dist/chat/tools/skill/call-mcp-tool.d.ts +10 -1
  91. package/dist/chat/tools/skill/load-skill.d.ts +40 -1
  92. package/dist/chat/tools/skill/search-mcp-tools.d.ts +100 -1
  93. package/dist/chat/tools/system-time.d.ts +38 -1
  94. package/dist/chat/tools/types.d.ts +4 -4
  95. package/dist/chat/tools/web/fetch-tool.d.ts +41 -1
  96. package/dist/chat/tools/web/image-generate.d.ts +62 -1
  97. package/dist/chat/tools/web/search.d.ts +41 -1
  98. package/dist/{chunk-HXL2ZV74.js → chunk-3F54A3YM.js} +82 -11
  99. package/dist/{chunk-BKSZL4QO.js → chunk-7DVIELX3.js} +670 -401
  100. package/dist/{chunk-GCWD2VHP.js → chunk-7FS3K243.js} +284 -124
  101. package/dist/{chunk-AOISHLSF.js → chunk-ACJENBVF.js} +143 -20
  102. package/dist/{chunk-IRRMABQD.js → chunk-APIVR44P.js} +10 -10
  103. package/dist/{chunk-PHZHJTCK.js → chunk-BMQ5DXHV.js} +30 -52
  104. package/dist/{chunk-XP7F4LYB.js → chunk-BTH37NCU.js} +4 -4
  105. package/dist/{chunk-5GBUZI6M.js → chunk-H7KUZAMZ.js} +4 -4
  106. package/dist/{chunk-TYUXD3FN.js → chunk-MC4ZZE4Q.js} +1 -1
  107. package/dist/{chunk-QCKGI74V.js → chunk-N25HRI6B.js} +10 -10
  108. package/dist/{chunk-2S7M37HY.js → chunk-NIFONS4W.js} +86 -47
  109. package/dist/{chunk-ONFOWI2D.js → chunk-OJP53WIU.js} +16 -15
  110. package/dist/{chunk-NW7AXDA5.js → chunk-OZJXGX4U.js} +2 -2
  111. package/dist/{chunk-KC42JAAQ.js → chunk-PFXC67GJ.js} +3 -3
  112. package/dist/{chunk-ZUK7BL63.js → chunk-S6QKIGRM.js} +66 -54
  113. package/dist/{chunk-IX76WFJV.js → chunk-TF5VLGA7.js} +10 -10
  114. package/dist/{chunk-DACFZ5CI.js → chunk-VY7TVOIK.js} +16 -12
  115. package/dist/{chunk-AN2437E3.js → chunk-YTNPU7I2.js} +2 -2
  116. package/dist/{chunk-3MPOMK3K.js → chunk-YYBX2BD5.js} +61 -3
  117. package/dist/{chunk-RS6ANWVT.js → chunk-ZATRYQLR.js} +1 -1
  118. package/dist/cli/chat.js +20 -20
  119. package/dist/cli/check.js +3 -3
  120. package/dist/cli/plugins.js +9 -9
  121. package/dist/cli/snapshot-warmup.js +6 -6
  122. package/dist/cli/upgrade.js +9 -9
  123. package/dist/{db-CXI7PR5U.js → db-GCK43OO3.js} +4 -4
  124. package/dist/instrumentation.js +1 -1
  125. package/dist/reporting/conversations.d.ts +3 -3
  126. package/dist/reporting.d.ts +1 -1
  127. package/dist/reporting.js +48 -50
  128. package/dist/{runner-FKL3RAHA.js → runner-XWTFA26U.js} +20 -18
  129. package/dist/{validation-I7GD2YWS.js → validation-KYAWETI4.js} +3 -3
  130. package/package.json +6 -6
  131. package/dist/chat/requester.d.ts +0 -68
@@ -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-OJP53WIU.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-7FS3K243.js";
16
19
  import {
17
20
  createPluginEmbedder,
18
21
  createPluginModel,
19
22
  getPlugins
20
- } from "./chunk-DACFZ5CI.js";
23
+ } from "./chunk-VY7TVOIK.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 = {}) {
@@ -4,7 +4,7 @@ import {
4
4
  juniorDestinations,
5
5
  juniorIdentities,
6
6
  juniorUsers
7
- } from "./chunk-2S7M37HY.js";
7
+ } from "./chunk-NIFONS4W.js";
8
8
 
9
9
  // src/api/people/shared.ts
10
10
  import { and, asc, desc, eq, sql } from "drizzle-orm";
@@ -106,7 +106,7 @@ function summaryFromRow(row, nowMs) {
106
106
  startedAt: row.createdAt.toISOString(),
107
107
  status: statusFromRow(row, nowMs),
108
108
  surface,
109
- requesterIdentity: {
109
+ actorIdentity: {
110
110
  email: row.email,
111
111
  ...row.fullName ? { fullName: row.fullName } : {},
112
112
  slackUserId: row.providerSubjectId,
@@ -162,14 +162,14 @@ function addSignals(target, value) {
162
162
  target.failed += value.failed ? 1 : 0;
163
163
  target.hung += value.hung ? 1 : 0;
164
164
  }
165
- function identityWithEmail(requester) {
166
- const email = normalizeEmail(requester?.email);
165
+ function identityWithEmail(actor) {
166
+ const email = normalizeEmail(actor?.email);
167
167
  if (!email) return void 0;
168
168
  return {
169
169
  email,
170
- ...requester?.fullName ? { fullName: requester.fullName } : {},
171
- ...requester?.slackUserId ? { slackUserId: requester.slackUserId } : {},
172
- ...requester?.slackUserName ? { slackUserName: requester.slackUserName } : {}
170
+ ...actor?.fullName ? { fullName: actor.fullName } : {},
171
+ ...actor?.slackUserId ? { slackUserId: actor.slackUserId } : {},
172
+ ...actor?.slackUserName ? { slackUserName: actor.slackUserName } : {}
173
173
  };
174
174
  }
175
175
  function mergeIdentity(current, next) {
@@ -197,7 +197,7 @@ function statsItems(map) {
197
197
  (left, right) => right.conversations - left.conversations || right.runs - left.runs || right.durationMs - left.durationMs || left.label.localeCompare(right.label)
198
198
  );
199
199
  }
200
- async function requesterRows(options = {}, email) {
200
+ async function actorRows(options = {}, email) {
201
201
  const normalizedEmail = normalizeEmail(email);
202
202
  const rows = await (options.db ?? getDb()).select({
203
203
  channelName: juniorConversations.channelName,
@@ -217,7 +217,7 @@ async function requesterRows(options = {}, email) {
217
217
  updatedAt: juniorConversations.updatedAt
218
218
  }).from(juniorConversations).innerJoin(
219
219
  juniorIdentities,
220
- eq(juniorIdentities.id, juniorConversations.requesterIdentityId)
220
+ eq(juniorIdentities.id, juniorConversations.actorIdentityId)
221
221
  ).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(
222
222
  juniorDestinations,
223
223
  eq(juniorDestinations.id, juniorConversations.destinationId)
@@ -257,5 +257,5 @@ export {
257
257
  mergeIdentity,
258
258
  activityDays,
259
259
  statsItems,
260
- requesterRows
260
+ actorRows
261
261
  };
@@ -1,7 +1,6 @@
1
1
  import {
2
- escapeXml,
3
2
  getInterruptionMarker
4
- } from "./chunk-GCWD2VHP.js";
3
+ } from "./chunk-7FS3K243.js";
5
4
  import {
6
5
  SANDBOX_DATA_ROOT,
7
6
  SANDBOX_WORKSPACE_ROOT,
@@ -9,48 +8,19 @@ import {
9
8
  } from "./chunk-G3E7SCME.js";
10
9
  import {
11
10
  TURN_CONTEXT_TAG,
12
- botConfig
13
- } from "./chunk-HXL2ZV74.js";
11
+ botConfig,
12
+ escapeXml
13
+ } from "./chunk-3F54A3YM.js";
14
14
  import {
15
15
  logInfo,
16
16
  logWarn
17
- } from "./chunk-ZUK7BL63.js";
17
+ } from "./chunk-S6QKIGRM.js";
18
18
  import {
19
19
  listReferenceFiles,
20
20
  soulPathCandidates,
21
21
  worldPathCandidates
22
22
  } from "./chunk-6APU57E6.js";
23
23
 
24
- // src/chat/current-instruction.ts
25
- var CURRENT_INSTRUCTION_TAG = "current-instruction";
26
- var CURRENT_INSTRUCTION_PATTERN = new RegExp(
27
- `<${CURRENT_INSTRUCTION_TAG}>\\n([\\s\\S]*?)\\n</${CURRENT_INSTRUCTION_TAG}>`
28
- );
29
- var STANDALONE_CURRENT_INSTRUCTION_PATTERN = new RegExp(
30
- `^<${CURRENT_INSTRUCTION_TAG}>\\n([\\s\\S]*?)\\n</${CURRENT_INSTRUCTION_TAG}>$`
31
- );
32
- function unescapeXml(value) {
33
- return value.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&gt;", ">").replaceAll("&lt;", "<").replaceAll("&amp;", "&");
34
- }
35
- function renderCurrentInstruction(instruction) {
36
- return [
37
- `<${CURRENT_INSTRUCTION_TAG}>`,
38
- escapeXml(instruction),
39
- `</${CURRENT_INSTRUCTION_TAG}>`
40
- ].join("\n");
41
- }
42
- function extractCurrentInstructionBody(text) {
43
- const match = text.match(STANDALONE_CURRENT_INSTRUCTION_PATTERN);
44
- return match?.[1];
45
- }
46
- function unwrapCurrentInstruction(text) {
47
- const match = text.match(CURRENT_INSTRUCTION_PATTERN);
48
- if (!match) {
49
- return void 0;
50
- }
51
- return unescapeXml(match[1]);
52
- }
53
-
54
24
  // src/chat/prompt.ts
55
25
  import fs from "fs";
56
26
  import path from "path";
@@ -81,6 +51,15 @@ function truncateStatusText(text) {
81
51
  }
82
52
 
83
53
  // src/chat/slack/mrkdwn.ts
54
+ function escapeSlackMrkdwnText(text) {
55
+ return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
56
+ }
57
+ function escapeSlackLinkUrl(url) {
58
+ return url.replaceAll("&", "&amp;").replaceAll("<", "%3C").replaceAll(">", "%3E");
59
+ }
60
+ function formatSlackLink(url, label) {
61
+ return `<${escapeSlackLinkUrl(url)}|${escapeSlackMrkdwnText(label)}>`;
62
+ }
84
63
  function readInlineCodeSpan(line, start) {
85
64
  if (line[start] !== "`") {
86
65
  return void 0;
@@ -568,12 +547,12 @@ function formatConfigurationValue(value) {
568
547
  return escapeXml(String(value));
569
548
  }
570
549
  }
571
- function renderRequesterBlock(fields) {
550
+ function renderActorBlock(fields) {
572
551
  const lines = Object.entries(fields).filter(([, value]) => Boolean(value)).map(([key, value]) => `- ${key}: ${escapeXml(value)}`);
573
552
  if (lines.length === 0) {
574
553
  return null;
575
554
  }
576
- return ["<requester>", ...lines, "</requester>"];
555
+ return ["<actor>", ...lines, "</actor>"];
577
556
  }
578
557
  function renderTag(tag, lines) {
579
558
  return [`<${tag}>`, ...lines, `</${tag}>`];
@@ -744,7 +723,7 @@ var EXECUTION_CONTRACT_RULES = [
744
723
  ];
745
724
  var CONVERSATION_RULES = [
746
725
  "- In thread follow-ups, answer from prior thread context; do not repeat resolved clarifying questions.",
747
- "- Preserve attribution roles from thread context: the requester is the person asking now, which may differ from the original reporter or subject.",
726
+ "- Preserve attribution roles from thread context: the actor is the person asking now, which may differ from the original reporter or subject.",
748
727
  "- Treat event notifications as subscribed conversation updates, not user-authored commands. Use their subscription intent to decide whether to reply, inspect, suggest, or stay brief.",
749
728
  "- Runtime owns continuation and authorization notices; on resumed turns, answer with the final requested content only."
750
729
  ];
@@ -754,7 +733,7 @@ var SLACK_ACTION_RULES = [
754
733
  "- sendMessage has no target argument; it always sends into the active Slack conversation/thread. For top-level channel posts, other channels, or named recipients, explain that this runtime can only send into the active conversation.",
755
734
  "- sendMessage is not final-reply delivery. After using sendMessage, provide a brief normal final answer unless the user requested no further text.",
756
735
  "- Ambient reaction requests target the current inbound message; do not ask for a message reference.",
757
- `- Side-effect-only completion for addReaction: call the requested tool first; if it succeeds and fully satisfies the request, final message must be exactly ${NO_REPLY_MARKER}.`
736
+ `- When no visible final thread reply is useful, make the final message exactly ${NO_REPLY_MARKER}.`
758
737
  ];
759
738
  var SAFETY_RULES = [
760
739
  "- Stay within the user's request and the runtime's available capabilities; do not pursue independent goals, persistence, replication, credential gathering, or access expansion.",
@@ -805,7 +784,7 @@ function buildOutputSection(platform) {
805
784
  "- Use Slack-flavored Markdown: **bold** section labels, `code`, [text](url) links, bullet lists, and fenced code blocks. No hash-prefixed headings and no tables. When the answer primarily lists several URLs, show each URL bare instead of as a labeled link.",
806
785
  "- Keep replies brief and scannable; use bullets or short code blocks when helpful, and one compact thread reply when it fits.",
807
786
  "- When a research or document-style answer would benefit from continuation, multiple sections, or future reference value, create a Slack canvas and keep the thread reply to one or two short sentences plus the link; do not recap the canvas contents.",
808
- "- End every turn with a final user-facing markdown response unless the Slack action rules allow a side-effect-only completion.",
787
+ "- End every turn with a final user-facing markdown response unless the Slack action rules allow a no-reply completion.",
809
788
  "</output>"
810
789
  ].join("\n");
811
790
  }
@@ -874,8 +853,8 @@ function buildDispatchSection(params) {
874
853
  "- dispatch.delivery: the runtime delivers the final answer to the destination",
875
854
  "- dispatch.delivery_rule: do not request or require a separate posting tool just to deliver the final answer",
876
855
  ...params.actor ? [
877
- `- dispatch.actor.type: ${escapeXml(params.actor.type)}`,
878
- `- dispatch.actor.id: ${escapeXml(params.actor.id)}`
856
+ `- dispatch.actor.platform: ${escapeXml(params.actor.platform)}`,
857
+ `- dispatch.actor.name: ${escapeXml(params.actor.name)}`
879
858
  ] : [],
880
859
  ...params.plugin ? [`- dispatch.plugin: ${escapeXml(params.plugin)}`] : [],
881
860
  ...formatSourceLines(params.source),
@@ -894,13 +873,13 @@ function buildContextSection(params) {
894
873
  ])
895
874
  );
896
875
  }
897
- const requesterLines = renderRequesterBlock({
898
- full_name: params.requester?.fullName,
899
- user_name: params.requester?.userName,
900
- user_id: params.requester?.userId
876
+ const actorLines = renderActorBlock({
877
+ full_name: params.actor?.fullName,
878
+ user_name: params.actor?.userName,
879
+ user_id: params.actor?.userId
901
880
  });
902
- if (requesterLines) {
903
- blocks.push(requesterLines);
881
+ if (actorLines) {
882
+ blocks.push(actorLines);
904
883
  }
905
884
  const dispatchLines = buildDispatchSection(params.dispatch);
906
885
  if (dispatchLines) {
@@ -1023,7 +1002,7 @@ function buildTurnContextPrompt(params) {
1023
1002
  }) : null,
1024
1003
  pluginPromptContributions,
1025
1004
  includeSessionContext ? buildContextSection({
1026
- requester: params.requester,
1005
+ actor: params.actor,
1027
1006
  artifactState: params.artifactState,
1028
1007
  configuration: params.configuration,
1029
1008
  dispatch: params.dispatch,
@@ -1048,10 +1027,9 @@ export {
1048
1027
  isNoReplyMarker,
1049
1028
  containsNoReplyMarker,
1050
1029
  stripNoReplyMarker,
1051
- renderCurrentInstruction,
1052
- extractCurrentInstructionBody,
1053
- unwrapCurrentInstruction,
1054
1030
  truncateStatusText,
1031
+ escapeSlackMrkdwnText,
1032
+ formatSlackLink,
1055
1033
  normalizeSlackStatusText,
1056
1034
  splitSlackReplyText,
1057
1035
  buildSlackOutputMessage,
@@ -3,7 +3,7 @@ import {
3
3
  logWarn,
4
4
  parseActorUserId,
5
5
  setSpanAttributes
6
- } from "./chunk-ZUK7BL63.js";
6
+ } from "./chunk-S6QKIGRM.js";
7
7
  import {
8
8
  discoverInstalledPluginPackageContent,
9
9
  normalizePluginPackageNames,
@@ -1093,8 +1093,8 @@ var credentialUserActorSchema = z2.object({
1093
1093
  userId: exactActorIdSchema
1094
1094
  }).strict();
1095
1095
  var credentialSystemActorSchema = z2.object({
1096
- type: z2.literal("system"),
1097
- id: exactActorIdSchema
1096
+ platform: z2.literal("system"),
1097
+ name: exactActorIdSchema
1098
1098
  }).strict();
1099
1099
  var credentialSubjectSchema = z2.object({
1100
1100
  type: z2.literal("user"),
@@ -1112,7 +1112,7 @@ var credentialContextSchema = z2.union([
1112
1112
  }).strict()
1113
1113
  ]);
1114
1114
  function credentialUserSubjectId(context) {
1115
- if (context.actor.type === "user") {
1115
+ if ("type" in context.actor) {
1116
1116
  return context.actor.userId;
1117
1117
  }
1118
1118
  return "subject" in context ? context.subject?.userId : void 0;
@@ -3,16 +3,16 @@ import {
3
3
  } from "./chunk-G3E7SCME.js";
4
4
  import {
5
5
  getStateAdapter
6
- } from "./chunk-RS6ANWVT.js";
6
+ } from "./chunk-ZATRYQLR.js";
7
7
  import {
8
8
  toOptionalTrimmed
9
- } from "./chunk-HXL2ZV74.js";
9
+ } from "./chunk-3F54A3YM.js";
10
10
  import {
11
11
  pluginCatalogRuntime
12
- } from "./chunk-XP7F4LYB.js";
12
+ } from "./chunk-BTH37NCU.js";
13
13
  import {
14
14
  withSpan
15
- } from "./chunk-ZUK7BL63.js";
15
+ } from "./chunk-S6QKIGRM.js";
16
16
 
17
17
  // src/chat/sandbox/runtime-dependency-snapshots.ts
18
18
  import { createHash } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-XP7F4LYB.js";
3
+ } from "./chunk-BTH37NCU.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  normalizeSlackConversationId
3
- } from "./chunk-DACFZ5CI.js";
3
+ } from "./chunk-VY7TVOIK.js";
4
4
  import {
5
5
  getStateAdapter
6
- } from "./chunk-RS6ANWVT.js";
6
+ } from "./chunk-ZATRYQLR.js";
7
7
  import {
8
8
  parseSlackThreadId
9
- } from "./chunk-3MPOMK3K.js";
9
+ } from "./chunk-YYBX2BD5.js";
10
10
  import {
11
- parseStoredSlackRequester
12
- } from "./chunk-ZUK7BL63.js";
11
+ parseStoredSlackActor
12
+ } from "./chunk-S6QKIGRM.js";
13
13
  import {
14
14
  isRecord,
15
15
  toOptionalNumber
@@ -174,8 +174,8 @@ function conversationContextKey(conversationId) {
174
174
  function conversationTitleKey(conversationId) {
175
175
  return `${CONVERSATION_PREFIX}:${conversationId}:title`;
176
176
  }
177
- function parseOriginRequester(value) {
178
- return parseStoredSlackRequester(value);
177
+ function parseOriginActor(value) {
178
+ return parseStoredSlackActor(value);
179
179
  }
180
180
  function parseOriginSurface(value) {
181
181
  if (value === "slack" || value === "api" || value === "scheduler" || value === "internal") {
@@ -187,7 +187,7 @@ function storedContextFromInput(context) {
187
187
  return {
188
188
  ...context.channelName ? { channelName: context.channelName } : {},
189
189
  ...context.originSurface ? { originSurface: context.originSurface } : {},
190
- ...context.originRequester ? { originRequester: context.originRequester } : {},
190
+ ...context.originActor ? { originActor: context.originActor } : {},
191
191
  startedAtMs: context.startedAtMs
192
192
  };
193
193
  }
@@ -198,7 +198,7 @@ function parseContext(value) {
198
198
  return {
199
199
  ...typeof value.channelName === "string" && value.channelName.trim() ? { channelName: value.channelName.trim() } : {},
200
200
  ...parseOriginSurface(value.originSurface) ? { originSurface: parseOriginSurface(value.originSurface) } : {},
201
- ...parseOriginRequester(value.originRequester) ? { originRequester: parseOriginRequester(value.originRequester) } : {},
201
+ ...parseOriginActor(value.originActor) ? { originActor: parseOriginActor(value.originActor) } : {},
202
202
  startedAtMs
203
203
  };
204
204
  }
@@ -255,7 +255,7 @@ async function getConversationDetails(conversationId) {
255
255
  ...title?.titleSourceMessageId ? { titleSourceMessageId: title.titleSourceMessageId } : {},
256
256
  ...context?.channelName ? { channelName: context.channelName } : {},
257
257
  ...context?.originSurface ? { originSurface: context.originSurface } : {},
258
- ...context?.originRequester ? { originRequester: context.originRequester } : {},
258
+ ...context?.originActor ? { originActor: context.originActor } : {},
259
259
  ...context?.startedAtMs !== void 0 ? { startedAtMs: context.startedAtMs } : {}
260
260
  };
261
261
  }