@sentry/junior 0.115.0 → 0.116.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 (111) hide show
  1. package/dist/{agent-hooks-4EUUXP2F.js → agent-hooks-67NFITDH.js} +9 -9
  2. package/dist/api/conversations/detail.d.ts +18 -0
  3. package/dist/api/conversations/event-page.d.ts +1 -1
  4. package/dist/api/conversations/events.d.ts +1 -1
  5. package/dist/api/people/profile.d.ts +2 -2
  6. package/dist/api/people/shared.d.ts +1 -1
  7. package/dist/api/personal-tokens/create.d.ts +11 -0
  8. package/dist/api/personal-tokens/list.d.ts +12 -0
  9. package/dist/api/personal-tokens/revoke.d.ts +5 -0
  10. package/dist/api/personal-tokens/routes.d.ts +4 -0
  11. package/dist/api/plugins.d.ts +0 -1
  12. package/dist/api/route.d.ts +1 -1
  13. package/dist/api/schema/conversation.d.ts +18 -0
  14. package/dist/api/schema/person.d.ts +3 -3
  15. package/dist/api/schema/personal-token.d.ts +38 -0
  16. package/dist/api/schema.d.ts +2 -0
  17. package/dist/api/schema.js +15 -3
  18. package/dist/api.d.ts +1 -0
  19. package/dist/api.js +179 -39
  20. package/dist/app.js +1035 -853
  21. package/dist/{catalog-runtime-Y32UEQLB.js → catalog-runtime-CWZY6GTH.js} +5 -5
  22. package/dist/chat/agent/request.d.ts +1 -0
  23. package/dist/chat/agent/resume.d.ts +1 -0
  24. package/dist/chat/agent/sandbox.d.ts +1 -0
  25. package/dist/chat/agent/tools.d.ts +1 -0
  26. package/dist/chat/agent-dispatch/context.d.ts +2 -0
  27. package/dist/chat/agent-dispatch/heartbeat.d.ts +11 -5
  28. package/dist/chat/agent-dispatch/signing.d.ts +14 -5
  29. package/dist/chat/agent-dispatch/store.d.ts +36 -15
  30. package/dist/chat/agent-dispatch/types.d.ts +23 -10
  31. package/dist/chat/agent-dispatch/work.d.ts +58 -0
  32. package/dist/chat/app/factory.d.ts +12 -3
  33. package/dist/chat/conversations/history.d.ts +285 -290
  34. package/dist/chat/conversations/projection.d.ts +2 -2
  35. package/dist/chat/mcp/tool-manager.d.ts +2 -1
  36. package/dist/chat/pi/conversation-events.d.ts +6 -2
  37. package/dist/chat/plugins/annotations.d.ts +8 -0
  38. package/dist/chat/plugins/registry.d.ts +0 -3
  39. package/dist/chat/plugins/types.d.ts +0 -2
  40. package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
  41. package/dist/chat/runtime/reply-executor.d.ts +6 -1
  42. package/dist/chat/runtime/slack-resume.d.ts +5 -1
  43. package/dist/chat/runtime/turn-input.d.ts +3 -0
  44. package/dist/chat/sandbox/sandbox.d.ts +2 -1
  45. package/dist/chat/sandbox/session.d.ts +2 -11
  46. package/dist/chat/sandbox/workspace.d.ts +10 -2
  47. package/dist/chat/services/turn-session-record.d.ts +14 -1
  48. package/dist/chat/slack/dispatch-turn.d.ts +25 -0
  49. package/dist/chat/state/turn-session.d.ts +11 -0
  50. package/dist/chat/tool-support/text-range-result.d.ts +3 -0
  51. package/dist/chat/tool-support/zod-tool.d.ts +1 -0
  52. package/dist/chat/tools/definition.d.ts +3 -10
  53. package/dist/chat/tools/query-conversation-events.d.ts +68 -0
  54. package/dist/chat/tools/sandbox/file-utils.d.ts +8 -1
  55. package/dist/chat/tools/sandbox/find-files.d.ts +2 -1
  56. package/dist/chat/tools/sandbox/grep.d.ts +2 -1
  57. package/dist/{chunk-6FKLPVF3.js → chunk-25GU5B5E.js} +1 -1
  58. package/dist/{chunk-PVZHG2XZ.js → chunk-3H45VOBZ.js} +32 -7
  59. package/dist/{chunk-NVUQSFWX.js → chunk-3JOGUT46.js} +3 -15
  60. package/dist/{chunk-G5SX4UPR.js → chunk-4DD6AOCG.js} +2 -2
  61. package/dist/{chunk-67CVNDJ7.js → chunk-53ZKTQO6.js} +1 -1
  62. package/dist/{chunk-43RYMWJ2.js → chunk-5UNB623T.js} +809 -213
  63. package/dist/{chunk-2QG4MZQ7.js → chunk-6RQ5GCWH.js} +2 -2
  64. package/dist/{chunk-MIAKQNYX.js → chunk-6ZK6FZIV.js} +1 -1
  65. package/dist/{chunk-6V762AB4.js → chunk-BXLS3I4W.js} +1 -1
  66. package/dist/{chunk-CWEZEPD4.js → chunk-CI3VK7X5.js} +68 -2
  67. package/dist/{chunk-EW5MLKT5.js → chunk-JZPQ5K4V.js} +1 -55
  68. package/dist/{chunk-HWCQRGLL.js → chunk-KBNDFU6J.js} +105 -37
  69. package/dist/{chunk-FHC4JUSF.js → chunk-MGH5ADQS.js} +1 -2
  70. package/dist/{chunk-TVE25LPW.js → chunk-N7TMYLF2.js} +1 -1
  71. package/dist/{chunk-CEYOL62C.js → chunk-OF5FODBL.js} +120 -20
  72. package/dist/{chunk-6OPTF4BQ.js → chunk-PE44LDDQ.js} +0 -1
  73. package/dist/{chunk-LYA2AB5G.js → chunk-PGKWXHYJ.js} +8 -52
  74. package/dist/{chunk-SYJT7AKB.js → chunk-PZGPCOSD.js} +1 -1
  75. package/dist/{chunk-JQFJO5WH.js → chunk-RXRQJF7Y.js} +74 -17
  76. package/dist/{chunk-G36V2YGB.js → chunk-TC4ZEM2D.js} +33 -1
  77. package/dist/{chunk-AGLQYELI.js → chunk-UEVLIYK5.js} +170 -170
  78. package/dist/{chunk-YCLO7D7M.js → chunk-VKZ6WVAY.js} +77 -26
  79. package/dist/{chunk-RAVKCKXA.js → chunk-VZCSLYCE.js} +20 -5
  80. package/dist/{chunk-SG5WAA7H.js → chunk-WKU7TY22.js} +0 -3
  81. package/dist/cli/chat.js +23 -23
  82. package/dist/cli/check.js +6 -6
  83. package/dist/cli/plugins.js +13 -13
  84. package/dist/cli/snapshot-warmup.js +8 -8
  85. package/dist/cli/upgrade.js +7 -7
  86. package/dist/db/schema/api-tokens.d.ts +160 -0
  87. package/dist/db/schema/conversation-annotations.d.ts +142 -0
  88. package/dist/db/schema.d.ts +305 -1
  89. package/dist/{db-KBSJHAZU.js → db-57FHVGGQ.js} +6 -6
  90. package/dist/handlers/agent-dispatch.d.ts +7 -3
  91. package/dist/instrumentation.js +2 -2
  92. package/dist/nitro.js +5 -5
  93. package/dist/{oauth-callback-server-EYRMJTCS.js → oauth-callback-server-PAQRPXZX.js} +18 -18
  94. package/dist/personal-tokens/store.d.ts +27 -0
  95. package/dist/{plugins-PZMDS7AT.js → plugins-IUJA4VBU.js} +1 -1
  96. package/dist/reporting-schema.d.ts +0 -2
  97. package/dist/{runner-RQGZ5Z2S.js → runner-4ISZYJEX.js} +12 -12
  98. package/dist/{skills-JJQIE3BT.js → skills-UE2KXQMB.js} +6 -6
  99. package/dist/{validation-MZ47PZP5.js → validation-PO5LHTJT.js} +6 -6
  100. package/dist/version.js +1 -1
  101. package/migrations/0008_sticky_rage.sql +14 -0
  102. package/migrations/0009_slippery_harrier.sql +12 -0
  103. package/migrations/0010_native_conversation_history.sql +142 -0
  104. package/migrations/meta/0008_snapshot.json +1076 -0
  105. package/migrations/meta/0009_snapshot.json +1146 -0
  106. package/migrations/meta/0010_snapshot.json +1190 -0
  107. package/migrations/meta/_journal.json +22 -1
  108. package/package.json +6 -7
  109. package/dist/chat/agent-dispatch/runner.d.ts +0 -13
  110. package/dist/chat/capabilities/catalog.d.ts +0 -16
  111. package/dist/{chunk-KNFROR7R.js → chunk-5I6ORJUY.js} +1 -1
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-6FKLPVF3.js";
3
+ } from "./chunk-25GU5B5E.js";
4
4
  import {
5
5
  logWarn
6
- } from "./chunk-NVUQSFWX.js";
6
+ } from "./chunk-3JOGUT46.js";
7
7
  import {
8
8
  skillRoots
9
9
  } from "./chunk-3V7OFJZC.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createVercelQueueClient
3
- } from "./chunk-KNFROR7R.js";
3
+ } from "./chunk-5I6ORJUY.js";
4
4
 
5
5
  // src/chat/task-execution/queue-signing.ts
6
6
  import { createHmac, timingSafeEqual } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-6FKLPVF3.js";
3
+ } from "./chunk-25GU5B5E.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";
@@ -1,19 +1,83 @@
1
+ import {
2
+ juniorConversationAnnotations
3
+ } from "./chunk-RXRQJF7Y.js";
1
4
  import {
2
5
  sleep
3
6
  } from "./chunk-4ZNGQH7C.js";
4
7
  import {
5
8
  getSlackBotToken
6
- } from "./chunk-SYJT7AKB.js";
9
+ } from "./chunk-PZGPCOSD.js";
7
10
  import {
8
11
  logWarn,
9
12
  setSpanAttributes,
10
13
  setSpanStatus,
11
14
  withSpan
12
- } from "./chunk-NVUQSFWX.js";
15
+ } from "./chunk-3JOGUT46.js";
13
16
  import {
14
17
  parseSlackChannelReferenceId
15
18
  } from "./chunk-F3B2YJ76.js";
16
19
 
20
+ // src/chat/plugins/annotations.ts
21
+ import { and, desc, eq } from "drizzle-orm";
22
+ import {
23
+ conversationAnnotationInputSchema
24
+ } from "@sentry/junior-plugin-api";
25
+ function createPluginAnnotations(args) {
26
+ return {
27
+ async upsert(input) {
28
+ const annotation = conversationAnnotationInputSchema.parse(input);
29
+ const now = /* @__PURE__ */ new Date();
30
+ await args.db.insert(juniorConversationAnnotations).values({
31
+ annotation,
32
+ conversationId: args.conversationId,
33
+ createdAt: now,
34
+ key: annotation.key,
35
+ kind: annotation.kind,
36
+ plugin: args.plugin,
37
+ updatedAt: now
38
+ }).onConflictDoUpdate({
39
+ target: [
40
+ juniorConversationAnnotations.conversationId,
41
+ juniorConversationAnnotations.plugin,
42
+ juniorConversationAnnotations.kind,
43
+ juniorConversationAnnotations.key
44
+ ],
45
+ set: { annotation, updatedAt: now }
46
+ });
47
+ },
48
+ async remove(kind, key) {
49
+ await args.db.delete(juniorConversationAnnotations).where(
50
+ and(
51
+ eq(
52
+ juniorConversationAnnotations.conversationId,
53
+ args.conversationId
54
+ ),
55
+ eq(juniorConversationAnnotations.plugin, args.plugin),
56
+ eq(juniorConversationAnnotations.kind, kind),
57
+ eq(juniorConversationAnnotations.key, key)
58
+ )
59
+ );
60
+ },
61
+ async list() {
62
+ return (await listConversationAnnotations(args.db, args.conversationId)).filter((a) => a.plugin === args.plugin);
63
+ }
64
+ };
65
+ }
66
+ async function listConversationAnnotations(db, conversationId) {
67
+ const rows = await db.select().from(juniorConversationAnnotations).where(eq(juniorConversationAnnotations.conversationId, conversationId)).orderBy(desc(juniorConversationAnnotations.updatedAt));
68
+ return rows.flatMap((row) => {
69
+ const parsed = conversationAnnotationInputSchema.safeParse(row.annotation);
70
+ return parsed.success ? [
71
+ {
72
+ ...parsed.data,
73
+ plugin: row.plugin,
74
+ createdAt: row.createdAt.toISOString(),
75
+ updatedAt: row.updatedAt.toISOString()
76
+ }
77
+ ] : [];
78
+ });
79
+ }
80
+
17
81
  // src/chat/slack/client.ts
18
82
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
19
83
  import { WebClient } from "@slack/web-api";
@@ -435,6 +499,8 @@ async function downloadPrivateSlackFile(url) {
435
499
  }
436
500
 
437
501
  export {
502
+ createPluginAnnotations,
503
+ listConversationAnnotations,
438
504
  runWithWorkspaceTeamId,
439
505
  getWorkspaceTeamId,
440
506
  SlackActionError,
@@ -5,7 +5,7 @@ import {
5
5
  logInfo,
6
6
  logWarn,
7
7
  setSpanAttributes
8
- } from "./chunk-NVUQSFWX.js";
8
+ } from "./chunk-3JOGUT46.js";
9
9
  import {
10
10
  discoverInstalledPluginPackageContent,
11
11
  normalizePluginPackageNames
@@ -105,11 +105,6 @@ function inlineManifestSource(manifest) {
105
105
  setDefined(result, "name", manifest.name);
106
106
  setDefined(result, "display-name", manifest.displayName);
107
107
  setDefined(result, "description", manifest.description);
108
- setDefined(
109
- result,
110
- "capabilities",
111
- inlineTokenListSource(manifest.name, manifest.capabilities)
112
- );
113
108
  setDefined(
114
109
  result,
115
110
  "config-keys",
@@ -138,7 +133,6 @@ function inlineManifestSource(manifest) {
138
133
 
139
134
  // src/chat/plugins/manifest.ts
140
135
  var PLUGIN_NAME_RE = /^[a-z][a-z0-9-]*$/;
141
- var SHORT_CAPABILITY_RE = /^[a-z0-9-]+(\.[a-z0-9-]+)*$/;
142
136
  var SHORT_CONFIG_KEY_RE = /^[a-z0-9]+(\.[a-z0-9-]+)*$/;
143
137
  var TARGET_FLAG_RE = /^-{1,2}[A-Za-z0-9][A-Za-z0-9-]*$/;
144
138
  var AUTH_TOKEN_ENV_RE = /^[A-Z][A-Z0-9_]*$/;
@@ -321,9 +315,6 @@ var manifestSourceSchema = z.object({
321
315
  }),
322
316
  "display-name": nonEmptyTrimmedString,
323
317
  description: nonEmptyTrimmedString,
324
- capabilities: z.array(z.string(), {
325
- error: "must be an array when provided"
326
- }).optional(),
327
318
  "config-keys": z.array(z.string(), {
328
319
  error: "must be an array when provided"
329
320
  }).optional(),
@@ -361,7 +352,6 @@ function manifestConfigPatch(config) {
361
352
  const result = {};
362
353
  setDefined2(result, "display-name", config.displayName);
363
354
  setDefined2(result, "description", config.description);
364
- setDefined2(result, "capabilities", config.capabilities);
365
355
  setDefined2(result, "config-keys", config.configKeys);
366
356
  setDefined2(result, "domains", config.domains);
367
357
  setDefined2(result, "api-headers", config.apiHeaders);
@@ -854,11 +844,6 @@ function parseManifestSource(parsedSource, dir, config, options) {
854
844
  if (path2 === "description") {
855
845
  throw new Error(`Invalid plugin description in ${dir}`);
856
846
  }
857
- if (path2 === "capabilities") {
858
- throw new Error(
859
- `Plugin ${String(parsedSource.name ?? "unknown")} capabilities must be an array when provided`
860
- );
861
- }
862
847
  if (path2 === "config-keys") {
863
848
  throw new Error(
864
849
  `Plugin ${String(parsedSource.name ?? "unknown")} config-keys must be an array when provided`
@@ -917,14 +902,6 @@ function parseManifestSource(parsedSource, dir, config, options) {
917
902
  throw new Error(issue?.message ?? `Invalid plugin manifest in ${dir}`);
918
903
  }
919
904
  const data = sourceResult.data;
920
- const capabilities = (data.capabilities ?? []).map((cap) => {
921
- if (!SHORT_CAPABILITY_RE.test(cap)) {
922
- throw new Error(
923
- `Invalid capability token "${cap}" in plugin ${data.name}`
924
- );
925
- }
926
- return `${data.name}.${cap}`;
927
- });
928
905
  const configKeys = (data["config-keys"] ?? []).map((key) => {
929
906
  if (!SHORT_CONFIG_KEY_RE.test(key)) {
930
907
  throw new Error(`Invalid config key "${key}" in plugin ${data.name}`);
@@ -959,7 +936,6 @@ function parseManifestSource(parsedSource, dir, config, options) {
959
936
  name: data.name,
960
937
  displayName: data["display-name"],
961
938
  description: data.description,
962
- capabilities,
963
939
  configKeys,
964
940
  ...domains ? { domains } : {},
965
941
  ...apiHeaders ? { apiHeaders } : {},
@@ -1550,7 +1526,6 @@ function createLoadedPluginState(signature) {
1550
1526
  signature,
1551
1527
  pluginDefinitions: [],
1552
1528
  pluginMigrationRoots: /* @__PURE__ */ new Map(),
1553
- capabilityToPlugin: /* @__PURE__ */ new Map(),
1554
1529
  domainToPlugin: /* @__PURE__ */ new Map(),
1555
1530
  pluginConfigKeys: /* @__PURE__ */ new Set(),
1556
1531
  pluginsByName: /* @__PURE__ */ new Map(),
@@ -1569,13 +1544,6 @@ function registerPluginManifest(state, manifest, pluginDir, skillsDir, migration
1569
1544
  if (state.pluginsByName.has(manifest.name)) {
1570
1545
  throw new Error(`Duplicate plugin name "${manifest.name}"`);
1571
1546
  }
1572
- for (const cap of manifest.capabilities) {
1573
- if (state.capabilityToPlugin.has(cap)) {
1574
- throw new Error(
1575
- `Duplicate capability "${cap}" in plugin "${manifest.name}"`
1576
- );
1577
- }
1578
- }
1579
1547
  for (const domain of providerDomains(manifest)) {
1580
1548
  const owner = state.domainToPlugin.get(domain);
1581
1549
  if (owner) {
@@ -1595,9 +1563,6 @@ function registerPluginManifest(state, manifest, pluginDir, skillsDir, migration
1595
1563
  if (definition.migrationsDir) {
1596
1564
  state.pluginMigrationRoots.set(manifest.name, definition.migrationsDir);
1597
1565
  }
1598
- for (const cap of manifest.capabilities) {
1599
- state.capabilityToPlugin.set(cap, definition);
1600
- }
1601
1566
  for (const key of manifest.configKeys) {
1602
1567
  state.pluginConfigKeys.add(key);
1603
1568
  }
@@ -1817,7 +1782,6 @@ function logLoadedPlugins(state) {
1817
1782
  {},
1818
1783
  {
1819
1784
  "app.plugin.name": plugin.manifest.name,
1820
- "app.plugin.capability_count": plugin.manifest.capabilities.length,
1821
1785
  "app.plugin.config_key_count": plugin.manifest.configKeys.length,
1822
1786
  "app.plugin.has_mcp": Boolean(plugin.manifest.mcp),
1823
1787
  "file.directory": plugin.dir,
@@ -1854,20 +1818,6 @@ function createPluginCatalogRuntime() {
1854
1818
  getSignature() {
1855
1819
  return ensurePluginsLoaded(runtime).signature;
1856
1820
  },
1857
- getCapabilityProviders() {
1858
- const state = ensurePluginsLoaded(runtime);
1859
- return state.pluginDefinitions.map((plugin) => ({
1860
- provider: plugin.manifest.name,
1861
- capabilities: [...plugin.manifest.capabilities],
1862
- configKeys: [...plugin.manifest.configKeys],
1863
- ...plugin.manifest.target ? {
1864
- target: {
1865
- ...plugin.manifest.target,
1866
- ...plugin.manifest.target.commandFlags ? { commandFlags: [...plugin.manifest.target.commandFlags] } : {}
1867
- }
1868
- } : {}
1869
- }));
1870
- },
1871
1821
  getProviders() {
1872
1822
  return [...ensurePluginsLoaded(runtime).pluginDefinitions];
1873
1823
  },
@@ -1971,9 +1921,6 @@ function createPluginCatalogRuntime() {
1971
1921
  isProvider(provider) {
1972
1922
  return ensurePluginsLoaded(runtime).pluginsByName.has(provider);
1973
1923
  },
1974
- isCapability(capability) {
1975
- return ensurePluginsLoaded(runtime).capabilityToPlugin.has(capability);
1976
- },
1977
1924
  isConfigKey(key) {
1978
1925
  return ensurePluginsLoaded(runtime).pluginConfigKeys.has(key);
1979
1926
  },
@@ -1996,7 +1943,6 @@ function createPluginCatalogRuntime() {
1996
1943
  }
1997
1944
  setSpanAttributes({
1998
1945
  "app.plugin.name": name,
1999
- "app.plugin.capabilities": plugin.manifest.capabilities,
2000
1946
  "app.plugin.has_oauth": Boolean(plugin.manifest.oauth)
2001
1947
  });
2002
1948
  return broker;
@@ -4,18 +4,18 @@ import {
4
4
  juniorConversations,
5
5
  juniorIdentities,
6
6
  juniorUsers
7
- } from "./chunk-JQFJO5WH.js";
7
+ } from "./chunk-RXRQJF7Y.js";
8
8
  import {
9
9
  TURN_REASONING_LEVELS,
10
10
  getChatConfig,
11
11
  modelProfileSchema
12
- } from "./chunk-SYJT7AKB.js";
12
+ } from "./chunk-PZGPCOSD.js";
13
13
  import {
14
14
  juniorDestinations
15
15
  } from "./chunk-VFUK3X5B.js";
16
16
  import {
17
17
  normalizeIdentityEmail
18
- } from "./chunk-NVUQSFWX.js";
18
+ } from "./chunk-3JOGUT46.js";
19
19
  import {
20
20
  parseSlackChannelReferenceId,
21
21
  parseSlackTeamId
@@ -59,12 +59,6 @@ function sameDestination(left, right) {
59
59
  }
60
60
  return false;
61
61
  }
62
- function destinationKey(destination) {
63
- if (destination.platform === "local") {
64
- return destination.conversationId;
65
- }
66
- return `slack:${destination.teamId}:${destination.channelId}`;
67
- }
68
62
 
69
63
  // src/chat/identities/sql.ts
70
64
  import { randomUUID } from "crypto";
@@ -741,9 +735,11 @@ import {
741
735
  asc as asc2,
742
736
  desc as desc2,
743
737
  eq as eq3,
738
+ gt,
744
739
  gte,
745
740
  inArray,
746
741
  isNotNull,
742
+ lt,
747
743
  lte,
748
744
  sql as sql4
749
745
  } from "drizzle-orm";
@@ -796,20 +792,31 @@ var handoffModelProfileSchema = modelProfileSchema.refine(
796
792
  (profile) => profile !== "standard",
797
793
  "handoff profile must not be standard"
798
794
  );
799
- var conversationAgentStepPayloadSchema = z2.object({ role: z2.string() }).passthrough().transform((value) => value);
800
- var conversationMessageDataSchema = z2.object({
801
- message: conversationAgentStepPayloadSchema,
802
- provenance: conversationMessageProvenanceSchema.optional()
803
- }).strict();
804
- var agentStepEventDataSchema = conversationMessageDataSchema.extend({
805
- type: z2.literal("agent_step")
806
- });
807
- var replacementHistoryMessageSchema = conversationMessageDataSchema.extend({
808
- // Preserve the copied message's position when a turn resumes. Synthetic
809
- // summary and handoff messages have no source event.
795
+ var userMessageEventDataSchema = z2.object({
796
+ type: z2.literal("user_message"),
797
+ role: z2.never().optional(),
798
+ provenance: conversationMessageProvenanceSchema
799
+ }).passthrough();
800
+ var assistantMessageEventDataSchema = z2.object({
801
+ type: z2.literal("assistant_message"),
802
+ role: z2.never().optional()
803
+ }).passthrough();
804
+ var toolResultEventDataSchema = z2.object({
805
+ type: z2.literal("tool_result"),
806
+ role: z2.never().optional()
807
+ }).passthrough();
808
+ var agentHistoryItemSchema = z2.discriminatedUnion("type", [
809
+ userMessageEventDataSchema,
810
+ assistantMessageEventDataSchema,
811
+ toolResultEventDataSchema
812
+ ]);
813
+ var nativeReplacementHistoryItemSchema = z2.object({
814
+ item: agentHistoryItemSchema,
815
+ // Preserve the copied item's position when a turn resumes. Synthetic
816
+ // summary and handoff items have no source event.
810
817
  sourceEventSeq: z2.number().int().nonnegative().optional()
811
- });
812
- var replacementHistorySchema = z2.array(replacementHistoryMessageSchema);
818
+ }).strict();
819
+ var replacementHistorySchema = z2.array(nativeReplacementHistoryItemSchema);
813
820
  var compactionDetailsSchema = z2.object({
814
821
  reason: z2.literal("capacity"),
815
822
  estimatedInputTokens: z2.number().int().nonnegative(),
@@ -839,12 +846,6 @@ var historyReplacementEventDataSchema = z2.discriminatedUnion("type", [
839
846
  replacementHistory: replacementHistorySchema
840
847
  }).strict()
841
848
  ]);
842
- var legacyRollbackEventDataSchema = z2.object({
843
- type: z2.literal("rollback"),
844
- modelProfile: modelProfileSchema,
845
- modelId: z2.string().min(1),
846
- replacementHistory: replacementHistorySchema
847
- }).strict();
848
849
  var historyReplacementSchema = z2.object({
849
850
  data: historyReplacementEventDataSchema,
850
851
  createdAtMs: z2.number().finite()
@@ -975,7 +976,7 @@ var subagentEndedEventDataSchema = z2.object({
975
976
  var appendableConversationEventDataSchema = z2.union([
976
977
  messageEventDataSchema,
977
978
  messageUpdatedEventDataSchema,
978
- agentStepEventDataSchema,
979
+ agentHistoryItemSchema,
979
980
  mcpProviderConnectedEventDataSchema,
980
981
  authorizationRequestedEventDataSchema,
981
982
  authorizationCompletedEventDataSchema,
@@ -991,13 +992,14 @@ var appendableConversationEventDataSchema = z2.union([
991
992
  ]);
992
993
  var conversationEventDataSchema = z2.union([
993
994
  appendableConversationEventDataSchema,
994
- historyReplacementEventDataSchema,
995
- legacyRollbackEventDataSchema
995
+ historyReplacementEventDataSchema
996
996
  ]);
997
- var knownConversationEventTypeSchema = z2.enum([
997
+ var KNOWN_CONVERSATION_EVENT_TYPES = [
998
998
  "message",
999
999
  "message_updated",
1000
- "agent_step",
1000
+ "user_message",
1001
+ "assistant_message",
1002
+ "tool_result",
1001
1003
  "mcp_provider_connected",
1002
1004
  "authorization_requested",
1003
1005
  "authorization_completed",
@@ -1011,9 +1013,9 @@ var knownConversationEventTypeSchema = z2.enum([
1011
1013
  "subagent_started",
1012
1014
  "subagent_ended",
1013
1015
  "handoff",
1014
- "compaction",
1015
- "rollback"
1016
- ]);
1016
+ "compaction"
1017
+ ];
1018
+ var knownConversationEventTypeSchema = z2.enum(KNOWN_CONVERSATION_EVENT_TYPES);
1017
1019
  var unknownConversationEventDataSchema = z2.object({
1018
1020
  type: z2.literal("unknown"),
1019
1021
  originalType: z2.string().min(1),
@@ -1270,6 +1272,16 @@ var SqlConversationEventStore = class {
1270
1272
  ).orderBy(asc2(juniorConversationEvents.seq));
1271
1273
  return rows.map(eventFromRow);
1272
1274
  }
1275
+ async loadLatestInstruction(conversationId) {
1276
+ const [row] = await this.executor.db().select().from(juniorConversationEvents).where(
1277
+ and3(
1278
+ eq3(juniorConversationEvents.conversationId, conversationId),
1279
+ eq3(juniorConversationEvents.type, "user_message"),
1280
+ sql4`${juniorConversationEvents.payload}->'provenance'->>'authority' = 'instruction'`
1281
+ )
1282
+ ).orderBy(desc2(juniorConversationEvents.seq)).limit(1);
1283
+ return row ? eventFromRow(row) : void 0;
1284
+ }
1273
1285
  async loadMessageHistory(conversationId) {
1274
1286
  const [compactionRow] = await this.executor.db().select().from(juniorConversationEvents).where(
1275
1287
  and3(
@@ -1292,6 +1304,61 @@ var SqlConversationEventStore = class {
1292
1304
  const rows = await this.executor.db().select().from(juniorConversationEvents).where(eq3(juniorConversationEvents.conversationId, conversationId)).orderBy(asc2(juniorConversationEvents.seq));
1293
1305
  return rows.map(eventFromRow);
1294
1306
  }
1307
+ async query(conversationId, query) {
1308
+ if (query.limit < 1) {
1309
+ throw new Error("Conversation event query limit must be at least 1");
1310
+ }
1311
+ if (query.afterSeq !== void 0 && query.beforeSeq !== void 0 && query.afterSeq >= query.beforeSeq) {
1312
+ return { events: [], hasOlder: false, hasNewer: false };
1313
+ }
1314
+ const typeFilter = query.types && query.types.length > 0 ? inArray(juniorConversationEvents.type, [...query.types]) : void 0;
1315
+ const bounds = and3(
1316
+ eq3(juniorConversationEvents.conversationId, conversationId),
1317
+ query.afterSeq === void 0 ? void 0 : gt(juniorConversationEvents.seq, query.afterSeq),
1318
+ query.beforeSeq === void 0 ? void 0 : lt(juniorConversationEvents.seq, query.beforeSeq),
1319
+ typeFilter
1320
+ );
1321
+ const newestFirst = query.afterSeq === void 0;
1322
+ const rows = await this.executor.db().select().from(juniorConversationEvents).where(bounds).orderBy(
1323
+ newestFirst ? desc2(juniorConversationEvents.seq) : asc2(juniorConversationEvents.seq)
1324
+ ).limit(query.limit + 1);
1325
+ const overflow = rows.length > query.limit;
1326
+ const pageRows = overflow ? rows.slice(0, query.limit) : rows;
1327
+ const events = (newestFirst ? [...pageRows].reverse() : pageRows).map(
1328
+ eventFromRow
1329
+ );
1330
+ if (events.length === 0) {
1331
+ return { events, hasOlder: false, hasNewer: false };
1332
+ }
1333
+ const firstSeq = events[0].seq;
1334
+ const lastSeq = events[events.length - 1].seq;
1335
+ const hasOlder = newestFirst && overflow ? true : await this.hasMatchingEvent({
1336
+ conversationId,
1337
+ beforeSeq: firstSeq,
1338
+ typeFilter
1339
+ });
1340
+ const hasNewer = !newestFirst && overflow ? true : await this.hasMatchingEvent({
1341
+ conversationId,
1342
+ afterSeq: lastSeq,
1343
+ typeFilter
1344
+ });
1345
+ return { events, hasOlder, hasNewer };
1346
+ }
1347
+ /** Return whether any matching event exists inside the exclusive seq window. */
1348
+ async hasMatchingEvent(args) {
1349
+ if (args.afterSeq !== void 0 && args.beforeSeq !== void 0 && args.afterSeq >= args.beforeSeq) {
1350
+ return false;
1351
+ }
1352
+ const [row] = await this.executor.db().select({ seq: juniorConversationEvents.seq }).from(juniorConversationEvents).where(
1353
+ and3(
1354
+ eq3(juniorConversationEvents.conversationId, args.conversationId),
1355
+ args.afterSeq === void 0 ? void 0 : gt(juniorConversationEvents.seq, args.afterSeq),
1356
+ args.beforeSeq === void 0 ? void 0 : lt(juniorConversationEvents.seq, args.beforeSeq),
1357
+ args.typeFilter
1358
+ )
1359
+ ).limit(1);
1360
+ return row !== void 0;
1361
+ }
1295
1362
  /** Read the next sequence and active model-history version. */
1296
1363
  async readCursor(conversationId) {
1297
1364
  const rows = await this.executor.db().select({
@@ -1436,10 +1503,11 @@ export {
1436
1503
  parseDestination,
1437
1504
  requireSlackDestination,
1438
1505
  sameDestination,
1439
- destinationKey,
1440
1506
  instructionProvenanceFor,
1441
1507
  contextProvenance,
1442
1508
  instructionActors,
1509
+ agentHistoryItemSchema,
1510
+ KNOWN_CONVERSATION_EVENT_TYPES,
1443
1511
  decodeStoredConversationEvent,
1444
1512
  sanitizePostgresJson,
1445
1513
  withConversationEventLock,
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@sentry/junior",
4
- version: "0.115.0",
4
+ version: "0.116.0",
5
5
  private: false,
6
6
  publishConfig: {
7
7
  access: "public"
@@ -82,7 +82,6 @@ var package_default = {
82
82
  "@vercel/queue": "^0.2.0",
83
83
  "@vercel/sandbox": "2.8.0",
84
84
  ai: "^6.0.190",
85
- "bash-tool": "^1.3.16",
86
85
  chat: "4.29.0",
87
86
  commander: "^14.0.3",
88
87
  "drizzle-orm": "catalog:",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JUNIOR_VERSION
3
- } from "./chunk-FHC4JUSF.js";
3
+ } from "./chunk-MGH5ADQS.js";
4
4
 
5
5
  // src/deployment.ts
6
6
  var JUNIOR_HEARTBEAT_ROUTE = "/api/internal/heartbeat";