@sentry/junior 0.78.0 → 0.80.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 (53) hide show
  1. package/dist/{agent-hooks-OFDNZJB2.js → agent-hooks-ZGTDOXQY.js} +11 -10
  2. package/dist/api-reference.d.ts +1 -1
  3. package/dist/app.js +39 -41
  4. package/dist/catalog-runtime-IVWRAPSI.js +12 -0
  5. package/dist/chat/conversation-privacy.d.ts +4 -0
  6. package/dist/chat/plugins/catalog-runtime.d.ts +1 -0
  7. package/dist/chat/plugins/registry.d.ts +27 -26
  8. package/dist/chat/sentry-payload-filter.d.ts +14 -0
  9. package/dist/chat/sentry.d.ts +1 -1
  10. package/dist/chat/state/session-log.d.ts +84 -0
  11. package/dist/chat/tools/advisor/tool.d.ts +1 -0
  12. package/dist/chat/tools/definition.d.ts +6 -0
  13. package/dist/{chunk-LUNMJQ7D.js → chunk-2AJ4TEKE.js} +6 -6
  14. package/dist/{chunk-ST6YNAXG.js → chunk-3DA7X2U3.js} +6 -3
  15. package/dist/{chunk-PNGAJ75P.js → chunk-3JKTVW4R.js} +7 -8
  16. package/dist/{chunk-Q6XFTRV5.js → chunk-4XHCVBXH.js} +2 -2
  17. package/dist/{chunk-Z4CIQ3EB.js → chunk-66NX7MNW.js} +1 -1
  18. package/dist/{chunk-Q3XNY442.js → chunk-6APU57E6.js} +1 -3
  19. package/dist/{chunk-T77LUIX3.js → chunk-ABRNFE3N.js} +7 -211
  20. package/dist/chunk-DR75T7J3.js +225 -0
  21. package/dist/{chunk-KIDP757T.js → chunk-FAGWUF44.js} +17 -7
  22. package/dist/{chunk-OJ53FYVG.js → chunk-FTMXFBDC.js} +14 -0
  23. package/dist/{chunk-RARSKPVT.js → chunk-GUO4EE7L.js} +2 -2
  24. package/dist/{chunk-2ECJXSVQ.js → chunk-IOBSRZK5.js} +1 -1
  25. package/dist/{chunk-EJN6G5A2.js → chunk-KF7522P3.js} +5 -19
  26. package/dist/{chunk-C2YBH4S6.js → chunk-LX5GBMEP.js} +6 -6
  27. package/dist/{chunk-237T7XAN.js → chunk-PQ2U2AO3.js} +3 -3
  28. package/dist/{chunk-YLVJRYTD.js → chunk-TW23AT22.js} +190 -196
  29. package/dist/{chunk-2MSW5BZY.js → chunk-W2QGQCKG.js} +129 -62
  30. package/dist/{chunk-Y3EG7S7P.js → chunk-WCXVEQPI.js} +7 -8
  31. package/dist/{chunk-LXTPBU4K.js → chunk-X2FL5ZH5.js} +1 -1
  32. package/dist/{chunk-SSWBYEFH.js → chunk-Y3YUOEAZ.js} +13 -7
  33. package/dist/{chunk-QDQVOMBA.js → chunk-YA2JCC7G.js} +165 -14
  34. package/dist/{chunk-VALUBQ7R.js → chunk-ZPCGQRFJ.js} +1 -1
  35. package/dist/cli/chat.js +12 -10
  36. package/dist/cli/check.js +7 -7
  37. package/dist/cli/main.js +1 -1
  38. package/dist/cli/plugins.js +17 -16
  39. package/dist/cli/snapshot-warmup.js +14 -15
  40. package/dist/cli/upgrade.js +20 -22
  41. package/dist/db-GQJKBX5W.js +18 -0
  42. package/dist/instrumentation.js +76 -3
  43. package/dist/nitro.js +8 -7
  44. package/dist/reporting/conversations.d.ts +30 -0
  45. package/dist/reporting.d.ts +1 -1
  46. package/dist/reporting.js +115 -24
  47. package/dist/{runner-WW4GJFUB.js → runner-JOVPVMIH.js} +18 -17
  48. package/dist/{sentry-4CP5NNQ5.js → sentry-EGFOV3DH.js} +5 -3
  49. package/dist/validation-TN6HMZAD.js +15 -0
  50. package/package.json +4 -4
  51. package/dist/db-NGQ3JCMF.js +0 -17
  52. package/dist/registry-RRIDPJBT.js +0 -46
  53. package/dist/validation-MDMYBRFB.js +0 -15
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  JUNIOR_THREAD_STATE_TTL_MS,
3
3
  buildConversationStatePatch
4
- } from "./chunk-Z4CIQ3EB.js";
4
+ } from "./chunk-66NX7MNW.js";
5
5
  import {
6
6
  buildNonInteractiveShellScript,
7
7
  createSandboxInstance,
@@ -10,7 +10,7 @@ import {
10
10
  isSnapshotMissingError,
11
11
  resolveRuntimeDependencySnapshot,
12
12
  runNonInteractiveCommand
13
- } from "./chunk-PNGAJ75P.js";
13
+ } from "./chunk-3JKTVW4R.js";
14
14
  import {
15
15
  pluginTaskId,
16
16
  pluginTaskParamsSchema,
@@ -27,8 +27,11 @@ import {
27
27
  loadConnectedMcpProviders,
28
28
  recordAuthorizationRequested,
29
29
  recordMcpProviderConnected,
30
+ recordSubagentEnded,
31
+ recordSubagentStarted,
32
+ recordToolExecutionStarted,
30
33
  upsertAgentTurnSessionRecord
31
- } from "./chunk-QDQVOMBA.js";
34
+ } from "./chunk-YA2JCC7G.js";
32
35
  import {
33
36
  createPluginEmbedder,
34
37
  createPluginHookRunner,
@@ -39,14 +42,14 @@ import {
39
42
  getPlugins,
40
43
  getSlackToolContext,
41
44
  resolveChannelCapabilities
42
- } from "./chunk-SSWBYEFH.js";
45
+ } from "./chunk-Y3YUOEAZ.js";
43
46
  import {
44
47
  createPluginLogger,
45
48
  createPluginState
46
- } from "./chunk-RARSKPVT.js";
49
+ } from "./chunk-GUO4EE7L.js";
47
50
  import {
48
51
  getDb
49
- } from "./chunk-237T7XAN.js";
52
+ } from "./chunk-PQ2U2AO3.js";
50
53
  import {
51
54
  SANDBOX_DATA_ROOT,
52
55
  SANDBOX_SKILLS_ROOT,
@@ -57,7 +60,7 @@ import {
57
60
  import {
58
61
  acquireActiveLock,
59
62
  getStateAdapter
60
- } from "./chunk-LXTPBU4K.js";
63
+ } from "./chunk-X2FL5ZH5.js";
61
64
  import {
62
65
  SlackActionError,
63
66
  downloadPrivateSlackFile,
@@ -68,7 +71,7 @@ import {
68
71
  normalizeSlackConversationId,
69
72
  parseDestination,
70
73
  withSlackRetries
71
- } from "./chunk-Q6XFTRV5.js";
74
+ } from "./chunk-4XHCVBXH.js";
72
75
  import {
73
76
  GEN_AI_PROVIDER_NAME,
74
77
  GEN_AI_SERVER_ADDRESS,
@@ -95,54 +98,48 @@ import {
95
98
  nextProviderRetry,
96
99
  normalizeSlackEmojiName,
97
100
  normalizeToolNameFromResult,
98
- parseSlackThreadId,
99
- resolveConversationPrivacy,
100
101
  resolveGatewayModel,
101
102
  stripRuntimeTurnContext,
102
103
  summarizeMessageText,
104
+ toObservablePromptPart,
105
+ trimTrailingAssistantMessages,
106
+ upsertActiveSkill
107
+ } from "./chunk-ABRNFE3N.js";
108
+ import {
109
+ parseSlackThreadId,
110
+ resolveConversationPrivacy,
111
+ runWithConversationPrivacy,
103
112
  toGenAiMessageMetadata,
104
113
  toGenAiMessagesTraceAttributes,
105
114
  toGenAiPayloadMetadata,
106
115
  toGenAiPayloadTraceAttributes,
107
- toGenAiTextMetadata,
108
- toObservablePromptPart,
109
- trimTrailingAssistantMessages,
110
- upsertActiveSkill
111
- } from "./chunk-T77LUIX3.js";
116
+ toGenAiTextMetadata
117
+ } from "./chunk-DR75T7J3.js";
112
118
  import {
113
119
  discoverSkills,
114
120
  findSkillByName,
115
121
  loadSkillsByName,
116
122
  parseSkillInvocation
117
- } from "./chunk-Y3EG7S7P.js";
123
+ } from "./chunk-WCXVEQPI.js";
118
124
  import {
119
- createPluginBroker,
120
125
  credentialContextSchema,
121
- getPluginCapabilityProviders,
122
- getPluginCatalogSignature,
123
- getPluginDefinition,
124
- getPluginDisplayName,
125
- getPluginMcpProviders,
126
- getPluginOAuthConfig,
127
- getPluginProviders,
128
- isPluginConfigKey,
126
+ pluginCatalogRuntime,
129
127
  resolveAuthTokenPlaceholder,
130
128
  resolvePluginCommandEnv
131
- } from "./chunk-YLVJRYTD.js";
129
+ } from "./chunk-TW23AT22.js";
132
130
  import {
133
131
  createRequester,
134
132
  parseActorUserId
135
- } from "./chunk-VALUBQ7R.js";
133
+ } from "./chunk-ZPCGQRFJ.js";
136
134
  import {
137
135
  listReferenceFiles
138
- } from "./chunk-Q3XNY442.js";
136
+ } from "./chunk-6APU57E6.js";
139
137
  import {
140
138
  extractGenAiUsageAttributes,
141
139
  extractGenAiUsageSummary,
142
140
  getActiveTraceId,
143
141
  getLogContextAttributes,
144
142
  getTracePropagationHeaders,
145
- isRecord,
146
143
  logError,
147
144
  logException,
148
145
  logInfo,
@@ -152,13 +149,16 @@ import {
152
149
  setSpanAttributes,
153
150
  setSpanStatus,
154
151
  setTags,
155
- toOptionalString,
156
152
  withSpan
157
- } from "./chunk-EJN6G5A2.js";
153
+ } from "./chunk-KF7522P3.js";
154
+ import {
155
+ isRecord,
156
+ toOptionalString
157
+ } from "./chunk-FTMXFBDC.js";
158
158
  import {
159
159
  startInactiveSpan,
160
160
  withActiveSpan
161
- } from "./chunk-ST6YNAXG.js";
161
+ } from "./chunk-3DA7X2U3.js";
162
162
 
163
163
  // src/chat/configuration/defaults.ts
164
164
  var installDefaults = {};
@@ -179,7 +179,7 @@ function setConfigDefaults(defaults) {
179
179
  );
180
180
  }
181
181
  for (const key of Object.keys(defaults)) {
182
- if (!isPluginConfigKey(key)) {
182
+ if (!pluginCatalogRuntime.isConfigKey(key)) {
183
183
  throw new Error(
184
184
  `configDefaults: "${key}" is not a registered plugin config key`
185
185
  );
@@ -678,14 +678,14 @@ function markTurnFailed(args) {
678
678
 
679
679
  // src/chat/respond.ts
680
680
  import { Agent as Agent2 } from "@earendil-works/pi-agent-core";
681
- import { THREAD_STATE_TTL_MS as THREAD_STATE_TTL_MS3 } from "chat";
681
+ import { THREAD_STATE_TTL_MS as THREAD_STATE_TTL_MS4 } from "chat";
682
682
 
683
683
  // src/chat/capabilities/catalog.ts
684
684
  var cachedCatalog;
685
685
  function getCapabilityCatalog() {
686
- const signature = getPluginCatalogSignature();
686
+ const signature = pluginCatalogRuntime.getSignature();
687
687
  if (cachedCatalog?.signature === signature) return cachedCatalog;
688
- const providers = getPluginCapabilityProviders();
688
+ const providers = pluginCatalogRuntime.getCapabilityProviders();
689
689
  const capabilityToProvider = /* @__PURE__ */ new Map();
690
690
  for (const provider of providers) {
691
691
  for (const capability of provider.capabilities) {
@@ -811,12 +811,14 @@ function createUserTokenStore() {
811
811
  function createProviderCredentialRouter(userTokenStore) {
812
812
  logCapabilityCatalogLoadedOnce();
813
813
  const brokersByProvider = {};
814
- for (const plugin of getPluginProviders()) {
814
+ for (const plugin of pluginCatalogRuntime.getProviders()) {
815
815
  const { name } = plugin.manifest;
816
816
  if (!plugin.manifest.credentials && !plugin.manifest.apiHeaders) {
817
817
  continue;
818
818
  }
819
- brokersByProvider[name] = createPluginBroker(name, { userTokenStore });
819
+ brokersByProvider[name] = pluginCatalogRuntime.createBroker(name, {
820
+ userTokenStore
821
+ });
820
822
  }
821
823
  return new ProviderCredentialRouter({ brokersByProvider });
822
824
  }
@@ -1071,7 +1073,7 @@ ${usage}
1071
1073
  exitCode: 2
1072
1074
  });
1073
1075
  }
1074
- const plugins = getPluginProviders().map((plugin) => ({
1076
+ const plugins = pluginCatalogRuntime.getProviders().map((plugin) => ({
1075
1077
  name: plugin.manifest.name,
1076
1078
  displayName: plugin.manifest.displayName,
1077
1079
  description: plugin.manifest.description,
@@ -5796,6 +5798,7 @@ import {
5796
5798
  Agent
5797
5799
  } from "@earendil-works/pi-agent-core";
5798
5800
  import { Type as Type21 } from "@sinclair/typebox";
5801
+ import { THREAD_STATE_TTL_MS } from "chat";
5799
5802
 
5800
5803
  // src/chat/tools/advisor/session-store.ts
5801
5804
  var ADVISOR_SESSION_TTL_MS = JUNIOR_THREAD_STATE_TTL_MS;
@@ -5892,7 +5895,7 @@ function createAdvisorTool(context) {
5892
5895
  description: "Curated evidence packet: relevant requirements, constraints, current plan, alternatives, code snippets, diffs, command output, and open questions."
5893
5896
  })
5894
5897
  }),
5895
- execute: async ({ question, context: suppliedContext }) => {
5898
+ execute: async ({ question, context: suppliedContext }, { toolCallId } = {}) => {
5896
5899
  if (typeof question !== "string" || !question.trim()) {
5897
5900
  return failure(
5898
5901
  "invalid_question",
@@ -5914,6 +5917,32 @@ function createAdvisorTool(context) {
5914
5917
  );
5915
5918
  }
5916
5919
  const conversationId = context.conversationId;
5920
+ const advisorSessionKey = getAdvisorSessionKey(conversationId);
5921
+ const subagentInvocationId = typeof toolCallId === "string" && toolCallId.length > 0 ? toolCallId : `advisor:${Date.now()}`;
5922
+ const endSubagent = async (outcome, errorCode) => recordSubagentEnded({
5923
+ conversationId,
5924
+ sessionId: context.parentSessionId,
5925
+ subagentInvocationId,
5926
+ outcome,
5927
+ ...errorCode ? { errorCode } : {},
5928
+ ttlMs: THREAD_STATE_TTL_MS
5929
+ });
5930
+ await recordSubagentStarted({
5931
+ conversationId,
5932
+ sessionId: context.parentSessionId,
5933
+ parentConversationId: conversationId,
5934
+ parentSessionId: context.parentSessionId,
5935
+ ...typeof toolCallId === "string" && toolCallId.length > 0 ? { parentToolCallId: toolCallId } : {},
5936
+ subagentInvocationId,
5937
+ subagentKind: "advisor",
5938
+ transcriptRef: {
5939
+ type: "advisor_session",
5940
+ parentConversationId: conversationId,
5941
+ key: advisorSessionKey
5942
+ },
5943
+ historyMode: "shared",
5944
+ ttlMs: THREAD_STATE_TTL_MS
5945
+ });
5917
5946
  const conversationPrivacy = context.conversationPrivacy ?? "private";
5918
5947
  const requestText = [
5919
5948
  "<advisor-task>",
@@ -5951,6 +5980,7 @@ function createAdvisorTool(context) {
5951
5980
  advisorMessages = await store.load(conversationId);
5952
5981
  } catch {
5953
5982
  setSpanStatus("error");
5983
+ await endSubagent("error", "session_unavailable");
5954
5984
  return failure(
5955
5985
  "session_unavailable",
5956
5986
  "Advisor guidance is unavailable because advisor history could not be loaded. Continue without assuming advisor history."
@@ -5965,7 +5995,7 @@ function createAdvisorTool(context) {
5965
5995
  thinkingLevel: context.config.thinkingLevel,
5966
5996
  tools: context.getTools()
5967
5997
  },
5968
- sessionId: getAdvisorSessionKey(conversationId),
5998
+ sessionId: advisorSessionKey,
5969
5999
  streamFn: context.streamFn
5970
6000
  });
5971
6001
  advisorAgent.state.messages = advisorMessages;
@@ -5974,6 +6004,7 @@ function createAdvisorTool(context) {
5974
6004
  await advisorAgent.prompt(requestMessage);
5975
6005
  } catch {
5976
6006
  setSpanStatus("error");
6007
+ await endSubagent("error", "unavailable");
5977
6008
  return failure(
5978
6009
  "unavailable",
5979
6010
  "Advisor guidance is unavailable. Continue without advisor guidance if the next step is clear from verified evidence."
@@ -5992,6 +6023,10 @@ function createAdvisorTool(context) {
5992
6023
  });
5993
6024
  if (!assistant || assistant.stopReason === "error" || assistant.stopReason === "aborted") {
5994
6025
  setSpanStatus("error");
6026
+ await endSubagent(
6027
+ assistant?.stopReason === "aborted" ? "aborted" : "error",
6028
+ "unavailable"
6029
+ );
5995
6030
  return failure(
5996
6031
  "unavailable",
5997
6032
  "Advisor guidance is unavailable. Continue without advisor guidance if the next step is clear from verified evidence."
@@ -6002,11 +6037,13 @@ function createAdvisorTool(context) {
6002
6037
  await store.save(conversationId, advisorAgent.state.messages);
6003
6038
  } catch {
6004
6039
  setSpanStatus("error");
6040
+ await endSubagent("error", "session_unavailable");
6005
6041
  return failure(
6006
6042
  "session_unavailable",
6007
6043
  "Advisor guidance is unavailable because advisor history could not be saved. Retry the advisor call or continue without assuming advisor history."
6008
6044
  );
6009
6045
  }
6046
+ await endSubagent("success");
6010
6047
  setSpanStatus("ok");
6011
6048
  return success(memo);
6012
6049
  },
@@ -6954,7 +6991,7 @@ function parseOAuthStatePayload(value) {
6954
6991
  };
6955
6992
  }
6956
6993
  function formatProviderLabel(provider) {
6957
- const displayName = getPluginDisplayName(provider);
6994
+ const displayName = pluginCatalogRuntime.getDisplayName(provider);
6958
6995
  if (!displayName) {
6959
6996
  throw new Error(`Unknown plugin provider display name: "${provider}"`);
6960
6997
  }
@@ -7037,7 +7074,7 @@ async function deliverPrivateMessage(input) {
7037
7074
  }
7038
7075
  }
7039
7076
  async function startOAuthFlow(provider, input) {
7040
- const providerConfig = getPluginOAuthConfig(provider);
7077
+ const providerConfig = pluginCatalogRuntime.getOAuthConfig(provider);
7041
7078
  if (!providerConfig) {
7042
7079
  return {
7043
7080
  ok: false,
@@ -7394,7 +7431,7 @@ function manifestDomains(manifest) {
7394
7431
  return [...domains].sort((left, right) => left.localeCompare(right));
7395
7432
  }
7396
7433
  function providerEntries() {
7397
- return getPluginProviders().map((plugin) => ({
7434
+ return pluginCatalogRuntime.getProviders().map((plugin) => ({
7398
7435
  provider: plugin.manifest.name,
7399
7436
  domains: manifestDomains(plugin.manifest)
7400
7437
  })).filter((entry) => entry.domains.length > 0).sort((left, right) => left.provider.localeCompare(right.provider));
@@ -7460,7 +7497,7 @@ function buildSandboxEgressNetworkPolicy(input) {
7460
7497
  }
7461
7498
  async function resolveSandboxCommandEnvironment() {
7462
7499
  const env = {};
7463
- for (const plugin of getPluginProviders().sort(
7500
+ for (const plugin of pluginCatalogRuntime.getProviders().sort(
7464
7501
  (left, right) => left.manifest.name.localeCompare(right.manifest.name)
7465
7502
  )) {
7466
7503
  Object.assign(env, resolvePluginCommandEnv(plugin.manifest));
@@ -9200,7 +9237,7 @@ function normalizeToolResult(result, isSandboxResult) {
9200
9237
  import { PluginToolInputError } from "@sentry/junior-plugin-api";
9201
9238
 
9202
9239
  // src/chat/services/plugin-auth-orchestration.ts
9203
- import { THREAD_STATE_TTL_MS } from "chat";
9240
+ import { THREAD_STATE_TTL_MS as THREAD_STATE_TTL_MS2 } from "chat";
9204
9241
 
9205
9242
  // src/chat/mcp/auth-store.ts
9206
9243
  import {
@@ -9562,7 +9599,7 @@ function createPluginAuthOrchestration(input) {
9562
9599
  if (pendingPause) {
9563
9600
  throw pendingPause;
9564
9601
  }
9565
- if (!input.requesterId || !getPluginOAuthConfig(provider)) {
9602
+ if (!input.requesterId || !pluginCatalogRuntime.getOAuthConfig(provider)) {
9566
9603
  throw new Error(`Cannot start plugin authorization for ${provider}`);
9567
9604
  }
9568
9605
  if (input.authorizationFlowMode === "disabled") {
@@ -9630,7 +9667,7 @@ function createPluginAuthOrchestration(input) {
9630
9667
  sessionId: input.sessionId
9631
9668
  }),
9632
9669
  delivery: reusingPendingLink ? "private_link_reused" : "private_link_sent",
9633
- ttlMs: THREAD_STATE_TTL_MS
9670
+ ttlMs: THREAD_STATE_TTL_MS2
9634
9671
  });
9635
9672
  }
9636
9673
  pendingPause = new PluginAuthorizationPauseError(
@@ -9669,7 +9706,7 @@ function createPluginAuthOrchestration(input) {
9669
9706
  signal.message ?? `${formatProviderLabel(provider)} credentials are required. Please connect your ${formatProviderLabel(provider)} account and try again.`
9670
9707
  );
9671
9708
  }
9672
- if (!getPluginOAuthConfig(authorization.provider)) {
9709
+ if (!pluginCatalogRuntime.getOAuthConfig(authorization.provider)) {
9673
9710
  throw new PluginCredentialFailureError(
9674
9711
  provider,
9675
9712
  signal.message ?? `${formatProviderLabel(provider)} credentials are required but the provider is not configured for OAuth.`
@@ -10767,7 +10804,7 @@ async function persistYieldSessionRecord(args) {
10767
10804
  }
10768
10805
 
10769
10806
  // src/chat/services/mcp-auth-orchestration.ts
10770
- import { THREAD_STATE_TTL_MS as THREAD_STATE_TTL_MS2 } from "chat";
10807
+ import { THREAD_STATE_TTL_MS as THREAD_STATE_TTL_MS3 } from "chat";
10771
10808
 
10772
10809
  // src/chat/mcp/oauth.ts
10773
10810
  import { randomUUID as randomUUID3 } from "crypto";
@@ -10929,7 +10966,7 @@ function getMcpOAuthCallbackPath(provider) {
10929
10966
  return `/api/oauth/callback/mcp/${provider}`;
10930
10967
  }
10931
10968
  function requirePluginWithMcp(provider) {
10932
- const plugin = getPluginDefinition(provider);
10969
+ const plugin = pluginCatalogRuntime.getDefinition(provider);
10933
10970
  if (!plugin?.manifest.mcp) {
10934
10971
  throw new Error(`Plugin "${provider}" does not support MCP`);
10935
10972
  }
@@ -11145,7 +11182,7 @@ function createMcpAuthOrchestration(input) {
11145
11182
  sessionId
11146
11183
  }),
11147
11184
  delivery: reusingPendingLink ? "private_link_reused" : "private_link_sent",
11148
- ttlMs: THREAD_STATE_TTL_MS2
11185
+ ttlMs: THREAD_STATE_TTL_MS3
11149
11186
  });
11150
11187
  pendingPause = new McpAuthorizationPauseError(
11151
11188
  provider,
@@ -11385,6 +11422,20 @@ function withoutTrailingUncheckpointedUserPrompt(messages, userContentParts) {
11385
11422
  return messages.slice(0, -1);
11386
11423
  }
11387
11424
  async function generateAssistantReply(messageText2, context) {
11425
+ const conversationPrivacy = resolveConversationPrivacy({
11426
+ channelId: context.correlation?.channelId,
11427
+ conversationId: context.correlation?.conversationId ?? context.correlation?.threadId ?? context.correlation?.runId
11428
+ });
11429
+ return runWithConversationPrivacy(
11430
+ conversationPrivacy ?? "private",
11431
+ () => generateAssistantReplyInPrivacyContext(
11432
+ messageText2,
11433
+ context,
11434
+ conversationPrivacy
11435
+ )
11436
+ );
11437
+ }
11438
+ async function generateAssistantReplyInPrivacyContext(messageText2, context, conversationPrivacy) {
11388
11439
  if (!context.destination) {
11389
11440
  throw new TypeError("Assistant reply generation requires a destination");
11390
11441
  }
@@ -11422,10 +11473,6 @@ async function generateAssistantReply(messageText2, context) {
11422
11473
  actorType: credentialActor.type,
11423
11474
  actorId: credentialActor.type === "user" ? credentialActor.userId : credentialActor.id
11424
11475
  } : {};
11425
- const conversationPrivacy = resolveConversationPrivacy({
11426
- channelId: context.correlation?.channelId,
11427
- conversationId: context.correlation?.conversationId ?? context.correlation?.threadId ?? context.correlation?.runId
11428
- });
11429
11476
  const sessionRecordLogContext = {
11430
11477
  threadId: context.correlation?.threadId,
11431
11478
  requesterId: context.correlation?.requesterId,
@@ -11442,7 +11489,7 @@ async function generateAssistantReply(messageText2, context) {
11442
11489
  await recordMcpProviderConnected({
11443
11490
  conversationId: timeoutResumeConversationId,
11444
11491
  provider,
11445
- ttlMs: THREAD_STATE_TTL_MS3
11492
+ ttlMs: THREAD_STATE_TTL_MS4
11446
11493
  });
11447
11494
  connectedMcpProviders.add(provider);
11448
11495
  };
@@ -11478,7 +11525,7 @@ async function generateAssistantReply(messageText2, context) {
11478
11525
  });
11479
11526
  if (!startupDiscoveryLogged) {
11480
11527
  startupDiscoveryLogged = true;
11481
- const plugins = getPluginProviders();
11528
+ const plugins = pluginCatalogRuntime.getProviders();
11482
11529
  const roots = [
11483
11530
  ...new Set(availableSkills.map((skill) => skill.skillPath))
11484
11531
  ].sort();
@@ -11536,6 +11583,19 @@ async function generateAssistantReply(messageText2, context) {
11536
11583
  canRecordMcpProviders = Boolean(
11537
11584
  turnSessionState.canUseTurnSession && sessionConversationId && sessionId
11538
11585
  );
11586
+ const recordParentToolExecutionStart = async (event) => {
11587
+ if (!turnSessionState.canUseTurnSession || !sessionConversationId || !sessionId) {
11588
+ return;
11589
+ }
11590
+ await recordToolExecutionStarted({
11591
+ conversationId: sessionConversationId,
11592
+ sessionId,
11593
+ toolCallId: event.toolCallId,
11594
+ toolName: event.toolName,
11595
+ args: event.args,
11596
+ ttlMs: THREAD_STATE_TTL_MS4
11597
+ });
11598
+ };
11539
11599
  const persistedConfigurationValues = context.channelConfiguration ? await context.channelConfiguration.resolveValues() : {};
11540
11600
  configurationValues = {
11541
11601
  ...getConfigDefaults(),
@@ -11724,10 +11784,13 @@ async function generateAssistantReply(messageText2, context) {
11724
11784
  authorizationFlowMode: context.authorizationFlowMode,
11725
11785
  userTokenStore
11726
11786
  });
11727
- mcpToolManager = new McpToolManager(getPluginMcpProviders(), {
11728
- authProviderFactory: mcpAuth.authProviderFactory,
11729
- onAuthorizationRequired: mcpAuth.onAuthorizationRequired
11730
- });
11787
+ mcpToolManager = new McpToolManager(
11788
+ pluginCatalogRuntime.getMcpProviders(),
11789
+ {
11790
+ authProviderFactory: mcpAuth.authProviderFactory,
11791
+ onAuthorizationRequired: mcpAuth.onAuthorizationRequired
11792
+ }
11793
+ );
11731
11794
  const turnMcpToolManager = mcpToolManager;
11732
11795
  const getPendingAuthPause = () => pluginAuth.getPendingPause() ?? mcpAuth.getPendingPause();
11733
11796
  setTags({
@@ -11755,6 +11818,7 @@ async function generateAssistantReply(messageText2, context) {
11755
11818
  config: botConfig.advisor,
11756
11819
  conversationId: sessionConversationId,
11757
11820
  conversationPrivacy,
11821
+ parentSessionId: sessionId,
11758
11822
  logContext: spanContext,
11759
11823
  getTools: () => advisorTools,
11760
11824
  streamFn: createTracedStreamFn({ conversationPrivacy })
@@ -12081,6 +12145,9 @@ async function generateAssistantReply(messageText2, context) {
12081
12145
  }
12082
12146
  });
12083
12147
  const unsubscribe = agent.subscribe((event) => {
12148
+ if (event.type === "tool_execution_start") {
12149
+ return recordParentToolExecutionStart(event);
12150
+ }
12084
12151
  if (event.type === "turn_end" && event.toolResults.length > 0) {
12085
12152
  return persistSafeBoundary([...agent.state.messages]).then(
12086
12153
  () => void 0
@@ -1,13 +1,12 @@
1
1
  import {
2
- getPluginForSkillPath,
3
- getPluginSkillRoots
4
- } from "./chunk-YLVJRYTD.js";
2
+ pluginCatalogRuntime
3
+ } from "./chunk-TW23AT22.js";
5
4
  import {
6
5
  skillRoots
7
- } from "./chunk-Q3XNY442.js";
6
+ } from "./chunk-6APU57E6.js";
8
7
  import {
9
8
  logWarn
10
- } from "./chunk-EJN6G5A2.js";
9
+ } from "./chunk-KF7522P3.js";
11
10
 
12
11
  // src/chat/skills.ts
13
12
  import fs from "fs/promises";
@@ -162,7 +161,7 @@ function resolveSkillRoots(options) {
162
161
  const additionalRoots = options?.additionalRoots ?? [];
163
162
  const envRoots = process.env.SKILL_DIRS?.split(path.delimiter).filter(Boolean) ?? [];
164
163
  const defaults = skillRoots();
165
- const pluginRoots = getPluginSkillRoots();
164
+ const pluginRoots = pluginCatalogRuntime.getSkillRoots();
166
165
  const seen = /* @__PURE__ */ new Set();
167
166
  const resolved = [];
168
167
  for (const root of [
@@ -181,7 +180,7 @@ function resolveSkillRoots(options) {
181
180
  return resolved;
182
181
  }
183
182
  function resolveSkillPlugin(meta) {
184
- const plugin = getPluginForSkillPath(meta.skillPath);
183
+ const plugin = pluginCatalogRuntime.getForSkillPath(meta.skillPath);
185
184
  if (meta.pluginProvider && plugin?.manifest.name !== meta.pluginProvider) {
186
185
  throw new Error(
187
186
  `Skill "${meta.name}" metadata names plugin "${meta.pluginProvider}" but is not owned by that plugin`
@@ -233,7 +232,7 @@ async function readSkillDirectory(skillDir) {
233
232
  return null;
234
233
  }
235
234
  const { name, description, allowedTools, disableModelInvocation } = parsed.skill;
236
- const plugin = getPluginForSkillPath(skillDir);
235
+ const plugin = pluginCatalogRuntime.getForSkillPath(skillDir);
237
236
  return {
238
237
  name,
239
238
  description,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-T77LUIX3.js";
3
+ } from "./chunk-ABRNFE3N.js";
4
4
 
5
5
  // src/chat/state/adapter.ts
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createPluginLogger,
3
3
  createPluginState
4
- } from "./chunk-RARSKPVT.js";
4
+ } from "./chunk-GUO4EE7L.js";
5
5
  import {
6
6
  getDb
7
- } from "./chunk-237T7XAN.js";
7
+ } from "./chunk-PQ2U2AO3.js";
8
8
  import {
9
9
  SANDBOX_WORKSPACE_ROOT
10
10
  } from "./chunk-G3E7SCME.js";
@@ -13,20 +13,20 @@ import {
13
13
  isConversationScopedChannel,
14
14
  isDmChannel,
15
15
  normalizeSlackConversationId
16
- } from "./chunk-Q6XFTRV5.js";
16
+ } from "./chunk-4XHCVBXH.js";
17
17
  import {
18
18
  botConfig,
19
19
  completeObject,
20
20
  embedTexts
21
- } from "./chunk-T77LUIX3.js";
21
+ } from "./chunk-ABRNFE3N.js";
22
22
  import {
23
23
  isActorUserId,
24
24
  parseActorUserId
25
- } from "./chunk-VALUBQ7R.js";
25
+ } from "./chunk-ZPCGQRFJ.js";
26
26
  import {
27
27
  logInfo,
28
28
  logWarn
29
- } from "./chunk-EJN6G5A2.js";
29
+ } from "./chunk-KF7522P3.js";
30
30
 
31
31
  // src/chat/plugins/agent-hooks.ts
32
32
  import { promptMessageSchema } from "@sentry/junior-plugin-api";
@@ -522,7 +522,13 @@ function getPluginTools(context) {
522
522
  `Duplicate plugin tool "${name}" from plugin "${pluginName}"`
523
523
  );
524
524
  }
525
- tools[name] = tool;
525
+ const definition = tool;
526
+ definition.identity = {
527
+ id: `${pluginName}.${name}`,
528
+ name,
529
+ plugin: pluginName
530
+ };
531
+ tools[name] = definition;
526
532
  }
527
533
  }
528
534
  return tools;