@sentry/junior 0.103.0 → 0.104.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 (77) hide show
  1. package/dist/{agent-hooks-NHIXBJW3.js → agent-hooks-EOFSY2PD.js} +3 -3
  2. package/dist/api/conversations/archive.d.ts +7 -0
  3. package/dist/api/conversations/detail.d.ts +7 -0
  4. package/dist/api/conversations/list.d.ts +109 -0
  5. package/dist/api/conversations/routes.d.ts +3 -0
  6. package/dist/api/conversations/schema.d.ts +72 -69
  7. package/dist/api/conversations/stats.d.ts +7 -0
  8. package/dist/api/conversations/subagent.d.ts +7 -0
  9. package/dist/api/http.d.ts +5 -0
  10. package/dist/api/locations/detail.d.ts +10 -2
  11. package/dist/api/locations/list.d.ts +7 -0
  12. package/dist/api/locations/routes.d.ts +3 -0
  13. package/dist/api/locations/schema.d.ts +4 -3
  14. package/dist/api/people/list.d.ts +7 -0
  15. package/dist/api/people/profile.d.ts +7 -0
  16. package/dist/api/people/routes.d.ts +3 -0
  17. package/dist/api/people/schema.d.ts +35 -33
  18. package/dist/api/people/shared.d.ts +3 -3
  19. package/dist/api/route.d.ts +7 -0
  20. package/dist/api/schema.js +11 -17
  21. package/dist/api.js +2184 -88
  22. package/dist/app.js +107 -101
  23. package/dist/chat/conversations/history.d.ts +6 -6
  24. package/dist/chat/conversations/store.d.ts +1 -0
  25. package/dist/chat/pi/messages.d.ts +2 -2
  26. package/dist/chat/plugins/agent-hooks.d.ts +2 -2
  27. package/dist/chat/resource-events/store.d.ts +2 -2
  28. package/dist/chat/slack/tools/conversation-search.d.ts +2 -2
  29. package/dist/chat/state/session-log.d.ts +2 -2
  30. package/dist/chat/task-execution/store.d.ts +2 -2
  31. package/dist/chat/tools/search-tools.d.ts +2 -2
  32. package/dist/chunk-AIRE7Q2W.js +362 -0
  33. package/dist/{chunk-HOBDQQJY.js → chunk-BCULHGZK.js} +23 -3
  34. package/dist/{chunk-DEQZ23O3.js → chunk-O7ILGCMJ.js} +77 -0
  35. package/dist/{chunk-C4BT2P2K.js → chunk-QDKRE3LS.js} +339 -8
  36. package/dist/{chunk-GY5ZRYPH.js → chunk-QVTVCJR4.js} +5 -5
  37. package/dist/{chunk-JXQWOCBE.js → chunk-RMZ65YAA.js} +2 -2
  38. package/dist/{chunk-E2VS47AZ.js → chunk-RYDF4GOX.js} +2 -2
  39. package/dist/{chunk-OE453VRG.js → chunk-TMWUGGSA.js} +26 -28
  40. package/dist/{chunk-JPXLAJUU.js → chunk-VDHMFCDY.js} +9 -10
  41. package/dist/cli/chat.js +10 -11
  42. package/dist/cli/plugins.js +4 -4
  43. package/dist/cli/upgrade.js +3 -4
  44. package/dist/db/schema/conversations.d.ts +17 -0
  45. package/dist/db/schema.d.ts +17 -0
  46. package/dist/{db-I343BSOM.js → db-PDMC67T3.js} +1 -1
  47. package/dist/{legacy-import-M7VBOQTK.js → legacy-import-G333RHJZ.js} +2 -2
  48. package/dist/reporting-schema.d.ts +4 -4
  49. package/dist/{runner-IEE5G4NV.js → runner-6A7MQRUE.js} +7 -8
  50. package/migrations/0004_useful_magus.sql +1 -0
  51. package/migrations/meta/0004_snapshot.json +1041 -0
  52. package/migrations/meta/_journal.json +7 -0
  53. package/package.json +6 -6
  54. package/dist/api/conversations/list.query.d.ts +0 -103
  55. package/dist/chunk-2RNOB32R.js +0 -17
  56. package/dist/chunk-6FPTHPXF.js +0 -77
  57. package/dist/chunk-6LBNXC4F.js +0 -66
  58. package/dist/chunk-7LLRS2OK.js +0 -215
  59. package/dist/chunk-B43K4C5K.js +0 -102
  60. package/dist/chunk-BQCPAIAB.js +0 -319
  61. package/dist/chunk-FW7DVHTL.js +0 -673
  62. package/dist/chunk-GCGRQJR5.js +0 -84
  63. package/dist/chunk-HRDWLE7Q.js +0 -273
  64. package/dist/chunk-LVUKF5CE.js +0 -63
  65. package/dist/chunk-QNVHH5PU.js +0 -20
  66. package/dist/chunk-QOZOJNSE.js +0 -96
  67. package/dist/chunk-VKFOVMZL.js +0 -331
  68. package/dist/detail-ENVV4HIY.js +0 -68
  69. package/dist/detail-UIOKVIET.js +0 -29
  70. package/dist/list-WR5U6JVM.js +0 -30
  71. package/dist/list-XZ4HKQ4R.js +0 -121
  72. package/dist/list-ZOUSMSEH.js +0 -30
  73. package/dist/plugin-conversations-DTUP4RH6.js +0 -37
  74. package/dist/profile-UO2N3XXG.js +0 -212
  75. package/dist/reporting/plugin-conversations.d.ts +0 -3
  76. package/dist/stats-NZIET4LT.js +0 -174
  77. package/dist/subagent-DY6XKTJ5.js +0 -49
@@ -1,319 +0,0 @@
1
- import {
2
- ensureLegacyConversationImport
3
- } from "./chunk-E2VS47AZ.js";
4
- import {
5
- contextProvenance,
6
- getAgentStepStore
7
- } from "./chunk-HOBDQQJY.js";
8
-
9
- // src/chat/conversations/projection.ts
10
- import { isDeepStrictEqual } from "util";
11
- function authorizationObservationMessage(entry, createdAtMs) {
12
- const label = entry.kind === "mcp" ? "MCP authorization" : "Authorization";
13
- return {
14
- role: "user",
15
- content: [
16
- {
17
- type: "text",
18
- text: `${label} completed for provider "${entry.provider}". Continue the blocked request and retry the provider operation if needed.`
19
- }
20
- ],
21
- timestamp: createdAtMs
22
- };
23
- }
24
- function piEntryProvenance(entry) {
25
- return entry.provenance ?? contextProvenance;
26
- }
27
- function projectSteps(steps, opts) {
28
- const messages = [];
29
- const provenance = [];
30
- const seqs = [];
31
- let modelProfile = "standard";
32
- let modelId;
33
- for (const step of steps) {
34
- if (opts?.maxSeq !== void 0 && step.seq > opts.maxSeq) {
35
- break;
36
- }
37
- if (step.entry.type === "context_epoch_started") {
38
- modelProfile = step.entry.modelProfile ?? "standard";
39
- modelId = step.entry.modelId;
40
- continue;
41
- }
42
- if (step.entry.type === "pi_message") {
43
- messages.push(step.entry.message);
44
- provenance.push(piEntryProvenance(step.entry));
45
- seqs.push(step.seq);
46
- continue;
47
- }
48
- if (step.entry.type === "authorization_completed") {
49
- messages.push(
50
- authorizationObservationMessage(step.entry, step.createdAtMs)
51
- );
52
- provenance.push(contextProvenance);
53
- seqs.push(step.seq);
54
- }
55
- }
56
- return { messages, provenance, seqs, modelProfile, modelId };
57
- }
58
- function connectedMcpProvidersFromSteps(steps) {
59
- const providers = /* @__PURE__ */ new Set();
60
- for (const step of steps) {
61
- if (step.entry.type === "mcp_provider_connected") {
62
- providers.add(step.entry.provider);
63
- }
64
- }
65
- return [...providers].sort((left, right) => left.localeCompare(right));
66
- }
67
- function isUserMessage(message) {
68
- return message.role === "user";
69
- }
70
- function countMatchingPrefix(left, right) {
71
- const limit = Math.min(left.length, right.length);
72
- for (let index = 0; index < limit; index += 1) {
73
- if (!isDeepStrictEqual(left[index], right[index])) {
74
- return index;
75
- }
76
- }
77
- return limit;
78
- }
79
- function resolveCommitProvenance(args) {
80
- if (args.explicitProvenance) {
81
- if (args.explicitProvenance.length !== args.nextMessages.length) {
82
- throw new Error("commit provenance must align one-to-one with messages");
83
- }
84
- return args.explicitProvenance;
85
- }
86
- const matchingPrefix = args.matchingPrefix;
87
- const provenance = args.nextMessages.map(
88
- (_, index) => index < matchingPrefix ? args.existing.provenance[index] ?? contextProvenance : contextProvenance
89
- );
90
- if (args.newMessageProvenance) {
91
- for (let index = args.nextMessages.length - 1; index >= matchingPrefix; index -= 1) {
92
- if (isUserMessage(args.nextMessages[index])) {
93
- provenance[index] = args.newMessageProvenance;
94
- break;
95
- }
96
- }
97
- }
98
- if (args.trailingMessageProvenance) {
99
- if (args.trailingMessageProvenance.length > provenance.length) {
100
- throw new Error(
101
- "trailing commit provenance cannot exceed committed messages"
102
- );
103
- }
104
- const newMessageCount = args.nextMessages.length - matchingPrefix;
105
- if (args.trailingMessageProvenance.length > newMessageCount) {
106
- throw new Error(
107
- "trailing commit provenance must align to newly committed messages"
108
- );
109
- }
110
- const start = provenance.length - args.trailingMessageProvenance.length;
111
- args.trailingMessageProvenance.forEach((entry, offset) => {
112
- provenance[start + offset] = entry;
113
- });
114
- }
115
- return provenance;
116
- }
117
- async function importLegacyIfNeeded(args) {
118
- await ensureLegacyConversationImport({ conversationId: args.conversationId });
119
- }
120
- async function loadProjection(args) {
121
- await importLegacyIfNeeded(args);
122
- const steps = await getAgentStepStore().loadCurrentEpoch(args.conversationId);
123
- return projectSteps(steps).messages;
124
- }
125
- async function loadConversationProjection(args) {
126
- await importLegacyIfNeeded(args);
127
- const steps = await getAgentStepStore().loadCurrentEpoch(args.conversationId);
128
- const { messages, provenance, modelProfile, modelId } = projectSteps(steps);
129
- return { messages, provenance, modelProfile, modelId };
130
- }
131
- async function openConversationProjection(args) {
132
- await importLegacyIfNeeded(args);
133
- const stepStore = getAgentStepStore();
134
- const steps = await stepStore.loadCurrentEpoch(args.conversationId);
135
- const projection = projectSteps(steps);
136
- if (steps.some(
137
- (step) => step.entry.type === "context_epoch_started" || step.entry.type === "pi_message"
138
- )) {
139
- return projection;
140
- }
141
- await stepStore.startEpoch(args.conversationId, {
142
- reason: "initial",
143
- modelProfile: "standard",
144
- modelId: args.modelId,
145
- messages: []
146
- });
147
- return {
148
- messages: projection.messages,
149
- provenance: projection.provenance,
150
- modelProfile: "standard",
151
- modelId: args.modelId
152
- };
153
- }
154
- async function loadTurnProjection(args) {
155
- await importLegacyIfNeeded(args);
156
- const stepStore = getAgentStepStore();
157
- if (args.committedSeq < 0) {
158
- return projectSteps(await stepStore.loadCurrentEpoch(args.conversationId));
159
- }
160
- const history = await stepStore.loadHistory(args.conversationId);
161
- const committedStep = history.find((step) => step.seq === args.committedSeq);
162
- if (!committedStep) {
163
- return void 0;
164
- }
165
- const epochSteps = history.filter(
166
- (step) => step.contextEpoch === committedStep.contextEpoch
167
- );
168
- return args.includeTail ? projectSteps(epochSteps) : projectSteps(epochSteps, { maxSeq: args.committedSeq });
169
- }
170
- async function loadConnectedMcpProviders(args) {
171
- await importLegacyIfNeeded(args);
172
- const steps = await getAgentStepStore().loadCurrentEpoch(args.conversationId);
173
- return connectedMcpProvidersFromSteps(steps);
174
- }
175
- function messageTimestamp(message) {
176
- const timestamp = message.timestamp;
177
- return typeof timestamp === "number" ? timestamp : Date.now();
178
- }
179
- async function commitMessages(args) {
180
- const stepStore = getAgentStepStore();
181
- const currentSteps = await stepStore.loadCurrentEpoch(args.conversationId);
182
- const existing = projectSteps(currentSteps);
183
- const matchingPrefix = countMatchingPrefix(existing.messages, args.messages);
184
- const nextProvenance = resolveCommitProvenance({
185
- existing,
186
- nextMessages: args.messages,
187
- matchingPrefix,
188
- ...args.provenance ? { explicitProvenance: args.provenance } : {},
189
- ...args.trailingMessageProvenance ? { trailingMessageProvenance: args.trailingMessageProvenance } : {},
190
- ...args.newMessageProvenance ? { newMessageProvenance: args.newMessageProvenance } : {}
191
- });
192
- if (currentSteps.length === 0) {
193
- await stepStore.startEpoch(args.conversationId, {
194
- reason: "initial",
195
- modelProfile: "standard",
196
- modelId: args.modelId,
197
- messages: args.messages.map((message, index) => ({
198
- message,
199
- createdAtMs: messageTimestamp(message),
200
- provenance: nextProvenance[index]
201
- }))
202
- });
203
- } else if (matchingPrefix === existing.messages.length) {
204
- const newMessages = args.messages.slice(matchingPrefix);
205
- await stepStore.append(
206
- args.conversationId,
207
- newMessages.map((message, index) => ({
208
- entry: {
209
- type: "pi_message",
210
- message,
211
- provenance: nextProvenance[matchingPrefix + index]
212
- },
213
- createdAtMs: messageTimestamp(message)
214
- }))
215
- );
216
- } else {
217
- await stepStore.startEpoch(args.conversationId, {
218
- reason: "rollback",
219
- modelProfile: existing.modelProfile,
220
- modelId: args.modelId,
221
- messages: args.messages.map((message, index) => ({
222
- message,
223
- createdAtMs: messageTimestamp(message),
224
- provenance: nextProvenance[index]
225
- }))
226
- });
227
- }
228
- const committed = projectSteps(
229
- await stepStore.loadCurrentEpoch(args.conversationId)
230
- );
231
- return {
232
- committedSeq: committed.seqs.at(-1) ?? -1,
233
- messageSeqs: committed.seqs,
234
- provenance: nextProvenance
235
- };
236
- }
237
- async function recordMcpProviderConnected(args) {
238
- const stepStore = getAgentStepStore();
239
- const steps = await stepStore.loadCurrentEpoch(args.conversationId);
240
- if (connectedMcpProvidersFromSteps(steps).includes(args.provider)) {
241
- return;
242
- }
243
- await stepStore.append(args.conversationId, [
244
- {
245
- entry: { type: "mcp_provider_connected", provider: args.provider },
246
- createdAtMs: Date.now()
247
- }
248
- ]);
249
- }
250
- async function recordAuthorizationRequested(args) {
251
- const stepStore = getAgentStepStore();
252
- const steps = await stepStore.loadCurrentEpoch(args.conversationId);
253
- if (steps.some(
254
- (step) => step.entry.type === "authorization_requested" && step.entry.authorizationId === args.authorizationId
255
- )) {
256
- return;
257
- }
258
- await stepStore.append(args.conversationId, [
259
- {
260
- entry: {
261
- type: "authorization_requested",
262
- kind: args.kind,
263
- provider: args.provider,
264
- actorId: args.actorId,
265
- authorizationId: args.authorizationId,
266
- delivery: args.delivery
267
- },
268
- createdAtMs: Date.now()
269
- }
270
- ]);
271
- }
272
- async function recordAuthorizationCompleted(args) {
273
- const stepStore = getAgentStepStore();
274
- const steps = await stepStore.loadCurrentEpoch(args.conversationId);
275
- if (steps.some(
276
- (step) => step.entry.type === "authorization_completed" && step.entry.authorizationId === args.authorizationId
277
- )) {
278
- return;
279
- }
280
- await stepStore.append(args.conversationId, [
281
- {
282
- entry: {
283
- type: "authorization_completed",
284
- kind: args.kind,
285
- provider: args.provider,
286
- actorId: args.actorId,
287
- authorizationId: args.authorizationId
288
- },
289
- createdAtMs: Date.now()
290
- }
291
- ]);
292
- }
293
- async function recordToolExecutionStarted(args) {
294
- await getAgentStepStore().append(args.conversationId, [
295
- {
296
- entry: {
297
- type: "tool_execution_started",
298
- toolCallId: args.toolCallId,
299
- toolName: args.toolName,
300
- ...args.args !== void 0 ? { args: args.args } : {}
301
- },
302
- createdAtMs: args.createdAtMs ?? Date.now()
303
- }
304
- ]);
305
- }
306
-
307
- export {
308
- projectSteps,
309
- loadProjection,
310
- loadConversationProjection,
311
- openConversationProjection,
312
- loadTurnProjection,
313
- loadConnectedMcpProviders,
314
- commitMessages,
315
- recordMcpProviderConnected,
316
- recordAuthorizationRequested,
317
- recordAuthorizationCompleted,
318
- recordToolExecutionStarted
319
- };