@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
@@ -8,17 +8,43 @@
8
8
  * are validated by the Pi adapter when it restores model context.
9
9
  */
10
10
  import { z } from "zod";
11
- /** Store one opaque agent-step payload while Pi owns provider validation. */
12
- export declare const conversationAgentStepPayloadSchema: z.ZodPipe<z.ZodObject<{
13
- role: z.ZodString;
14
- }, z.core.$loose>, z.ZodTransform<{
15
- role: string;
16
- }, {
17
- [x: string]: unknown;
18
- role: string;
19
- }>>;
20
- /** The opaque Pi history entry carried by an `agent_step` event. */
21
- export type ConversationAgentStepPayload = z.output<typeof conversationAgentStepPayloadSchema>;
11
+ /**
12
+ * One replayable agent-history item. Junior owns `type` and user provenance,
13
+ * forbids the provider `role` discriminator, and leaves preserved message
14
+ * fields for the Pi adapter to validate when restoring model context.
15
+ */
16
+ export declare const agentHistoryItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
17
+ type: z.ZodLiteral<"user_message">;
18
+ role: z.ZodOptional<z.ZodNever>;
19
+ provenance: z.ZodObject<{
20
+ authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
21
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
22
+ platform: z.ZodLiteral<"slack">;
23
+ teamId: z.ZodString;
24
+ email: z.ZodOptional<z.ZodString>;
25
+ fullName: z.ZodOptional<z.ZodString>;
26
+ userId: z.ZodString;
27
+ userName: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strict>, z.ZodObject<{
29
+ platform: z.ZodLiteral<"local">;
30
+ email: z.ZodOptional<z.ZodString>;
31
+ fullName: z.ZodOptional<z.ZodString>;
32
+ userId: z.ZodString;
33
+ userName: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strict>, z.ZodObject<{
35
+ platform: z.ZodLiteral<"system">;
36
+ name: z.ZodString;
37
+ }, z.core.$strict>], "platform">>;
38
+ }, z.core.$strict>;
39
+ }, z.core.$loose>, z.ZodObject<{
40
+ type: z.ZodLiteral<"assistant_message">;
41
+ role: z.ZodOptional<z.ZodNever>;
42
+ }, z.core.$loose>, z.ZodObject<{
43
+ type: z.ZodLiteral<"tool_result">;
44
+ role: z.ZodOptional<z.ZodNever>;
45
+ }, z.core.$loose>], "type">;
46
+ /** A native replayable agent-history item. */
47
+ export type AgentHistoryItem = z.output<typeof agentHistoryItemSchema>;
22
48
  /** Validate an event that intentionally replaces active model history. */
23
49
  export declare const historyReplacementSchema: z.ZodObject<{
24
50
  data: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -29,34 +55,36 @@ export declare const historyReplacementSchema: z.ZodObject<{
29
55
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
30
56
  summary: z.ZodOptional<z.ZodString>;
31
57
  replacementHistory: z.ZodArray<z.ZodObject<{
32
- message: z.ZodPipe<z.ZodObject<{
33
- role: z.ZodString;
34
- }, z.core.$loose>, z.ZodTransform<{
35
- role: string;
36
- }, {
37
- [x: string]: unknown;
38
- role: string;
39
- }>>;
40
- provenance: z.ZodOptional<z.ZodObject<{
41
- authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
42
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
43
- platform: z.ZodLiteral<"slack">;
44
- teamId: z.ZodString;
45
- email: z.ZodOptional<z.ZodString>;
46
- fullName: z.ZodOptional<z.ZodString>;
47
- userId: z.ZodString;
48
- userName: z.ZodOptional<z.ZodString>;
49
- }, z.core.$strict>, z.ZodObject<{
50
- platform: z.ZodLiteral<"local">;
51
- email: z.ZodOptional<z.ZodString>;
52
- fullName: z.ZodOptional<z.ZodString>;
53
- userId: z.ZodString;
54
- userName: z.ZodOptional<z.ZodString>;
55
- }, z.core.$strict>, z.ZodObject<{
56
- platform: z.ZodLiteral<"system">;
57
- name: z.ZodString;
58
- }, z.core.$strict>], "platform">>;
59
- }, z.core.$strict>>;
58
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
59
+ type: z.ZodLiteral<"user_message">;
60
+ role: z.ZodOptional<z.ZodNever>;
61
+ provenance: z.ZodObject<{
62
+ authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
63
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
64
+ platform: z.ZodLiteral<"slack">;
65
+ teamId: z.ZodString;
66
+ email: z.ZodOptional<z.ZodString>;
67
+ fullName: z.ZodOptional<z.ZodString>;
68
+ userId: z.ZodString;
69
+ userName: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$strict>, z.ZodObject<{
71
+ platform: z.ZodLiteral<"local">;
72
+ email: z.ZodOptional<z.ZodString>;
73
+ fullName: z.ZodOptional<z.ZodString>;
74
+ userId: z.ZodString;
75
+ userName: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strict>, z.ZodObject<{
77
+ platform: z.ZodLiteral<"system">;
78
+ name: z.ZodString;
79
+ }, z.core.$strict>], "platform">>;
80
+ }, z.core.$strict>;
81
+ }, z.core.$loose>, z.ZodObject<{
82
+ type: z.ZodLiteral<"assistant_message">;
83
+ role: z.ZodOptional<z.ZodNever>;
84
+ }, z.core.$loose>, z.ZodObject<{
85
+ type: z.ZodLiteral<"tool_result">;
86
+ role: z.ZodOptional<z.ZodNever>;
87
+ }, z.core.$loose>], "type">;
60
88
  sourceEventSeq: z.ZodOptional<z.ZodNumber>;
61
89
  }, z.core.$strict>>;
62
90
  }, z.core.$strict>, z.ZodObject<{
@@ -75,34 +103,36 @@ export declare const historyReplacementSchema: z.ZodObject<{
75
103
  }, z.core.$strict>>;
76
104
  summary: z.ZodOptional<z.ZodString>;
77
105
  replacementHistory: z.ZodArray<z.ZodObject<{
78
- message: z.ZodPipe<z.ZodObject<{
79
- role: z.ZodString;
80
- }, z.core.$loose>, z.ZodTransform<{
81
- role: string;
82
- }, {
83
- [x: string]: unknown;
84
- role: string;
85
- }>>;
86
- provenance: z.ZodOptional<z.ZodObject<{
87
- authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
88
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
89
- platform: z.ZodLiteral<"slack">;
90
- teamId: z.ZodString;
91
- email: z.ZodOptional<z.ZodString>;
92
- fullName: z.ZodOptional<z.ZodString>;
93
- userId: z.ZodString;
94
- userName: z.ZodOptional<z.ZodString>;
95
- }, z.core.$strict>, z.ZodObject<{
96
- platform: z.ZodLiteral<"local">;
97
- email: z.ZodOptional<z.ZodString>;
98
- fullName: z.ZodOptional<z.ZodString>;
99
- userId: z.ZodString;
100
- userName: z.ZodOptional<z.ZodString>;
101
- }, z.core.$strict>, z.ZodObject<{
102
- platform: z.ZodLiteral<"system">;
103
- name: z.ZodString;
104
- }, z.core.$strict>], "platform">>;
105
- }, z.core.$strict>>;
106
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
107
+ type: z.ZodLiteral<"user_message">;
108
+ role: z.ZodOptional<z.ZodNever>;
109
+ provenance: z.ZodObject<{
110
+ authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
111
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
112
+ platform: z.ZodLiteral<"slack">;
113
+ teamId: z.ZodString;
114
+ email: z.ZodOptional<z.ZodString>;
115
+ fullName: z.ZodOptional<z.ZodString>;
116
+ userId: z.ZodString;
117
+ userName: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strict>, z.ZodObject<{
119
+ platform: z.ZodLiteral<"local">;
120
+ email: z.ZodOptional<z.ZodString>;
121
+ fullName: z.ZodOptional<z.ZodString>;
122
+ userId: z.ZodString;
123
+ userName: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strict>, z.ZodObject<{
125
+ platform: z.ZodLiteral<"system">;
126
+ name: z.ZodString;
127
+ }, z.core.$strict>], "platform">>;
128
+ }, z.core.$strict>;
129
+ }, z.core.$loose>, z.ZodObject<{
130
+ type: z.ZodLiteral<"assistant_message">;
131
+ role: z.ZodOptional<z.ZodNever>;
132
+ }, z.core.$loose>, z.ZodObject<{
133
+ type: z.ZodLiteral<"tool_result">;
134
+ role: z.ZodOptional<z.ZodNever>;
135
+ }, z.core.$loose>], "type">;
106
136
  sourceEventSeq: z.ZodOptional<z.ZodNumber>;
107
137
  }, z.core.$strict>>;
108
138
  }, z.core.$strict>], "type">;
@@ -144,16 +174,10 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
144
174
  authorIdentityId: z.ZodOptional<z.ZodString>;
145
175
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
146
176
  type: z.ZodLiteral<"message_updated">;
147
- }, z.core.$strict>, z.ZodObject<{
148
- message: z.ZodPipe<z.ZodObject<{
149
- role: z.ZodString;
150
- }, z.core.$loose>, z.ZodTransform<{
151
- role: string;
152
- }, {
153
- [x: string]: unknown;
154
- role: string;
155
- }>>;
156
- provenance: z.ZodOptional<z.ZodObject<{
177
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
178
+ type: z.ZodLiteral<"user_message">;
179
+ role: z.ZodOptional<z.ZodNever>;
180
+ provenance: z.ZodObject<{
157
181
  authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
158
182
  actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
159
183
  platform: z.ZodLiteral<"slack">;
@@ -172,9 +196,14 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
172
196
  platform: z.ZodLiteral<"system">;
173
197
  name: z.ZodString;
174
198
  }, z.core.$strict>], "platform">>;
175
- }, z.core.$strict>>;
176
- type: z.ZodLiteral<"agent_step">;
177
- }, z.core.$strict>, z.ZodObject<{
199
+ }, z.core.$strict>;
200
+ }, z.core.$loose>, z.ZodObject<{
201
+ type: z.ZodLiteral<"assistant_message">;
202
+ role: z.ZodOptional<z.ZodNever>;
203
+ }, z.core.$loose>, z.ZodObject<{
204
+ type: z.ZodLiteral<"tool_result">;
205
+ role: z.ZodOptional<z.ZodNever>;
206
+ }, z.core.$loose>], "type">, z.ZodObject<{
178
207
  type: z.ZodLiteral<"mcp_provider_connected">;
179
208
  provider: z.ZodString;
180
209
  }, z.core.$strict>, z.ZodObject<{
@@ -272,34 +301,36 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
272
301
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
273
302
  summary: z.ZodOptional<z.ZodString>;
274
303
  replacementHistory: z.ZodArray<z.ZodObject<{
275
- message: z.ZodPipe<z.ZodObject<{
276
- role: z.ZodString;
277
- }, z.core.$loose>, z.ZodTransform<{
278
- role: string;
279
- }, {
280
- [x: string]: unknown;
281
- role: string;
282
- }>>;
283
- provenance: z.ZodOptional<z.ZodObject<{
284
- authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
285
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
286
- platform: z.ZodLiteral<"slack">;
287
- teamId: z.ZodString;
288
- email: z.ZodOptional<z.ZodString>;
289
- fullName: z.ZodOptional<z.ZodString>;
290
- userId: z.ZodString;
291
- userName: z.ZodOptional<z.ZodString>;
292
- }, z.core.$strict>, z.ZodObject<{
293
- platform: z.ZodLiteral<"local">;
294
- email: z.ZodOptional<z.ZodString>;
295
- fullName: z.ZodOptional<z.ZodString>;
296
- userId: z.ZodString;
297
- userName: z.ZodOptional<z.ZodString>;
298
- }, z.core.$strict>, z.ZodObject<{
299
- platform: z.ZodLiteral<"system">;
300
- name: z.ZodString;
301
- }, z.core.$strict>], "platform">>;
302
- }, z.core.$strict>>;
304
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
305
+ type: z.ZodLiteral<"user_message">;
306
+ role: z.ZodOptional<z.ZodNever>;
307
+ provenance: z.ZodObject<{
308
+ authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
309
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
310
+ platform: z.ZodLiteral<"slack">;
311
+ teamId: z.ZodString;
312
+ email: z.ZodOptional<z.ZodString>;
313
+ fullName: z.ZodOptional<z.ZodString>;
314
+ userId: z.ZodString;
315
+ userName: z.ZodOptional<z.ZodString>;
316
+ }, z.core.$strict>, z.ZodObject<{
317
+ platform: z.ZodLiteral<"local">;
318
+ email: z.ZodOptional<z.ZodString>;
319
+ fullName: z.ZodOptional<z.ZodString>;
320
+ userId: z.ZodString;
321
+ userName: z.ZodOptional<z.ZodString>;
322
+ }, z.core.$strict>, z.ZodObject<{
323
+ platform: z.ZodLiteral<"system">;
324
+ name: z.ZodString;
325
+ }, z.core.$strict>], "platform">>;
326
+ }, z.core.$strict>;
327
+ }, z.core.$loose>, z.ZodObject<{
328
+ type: z.ZodLiteral<"assistant_message">;
329
+ role: z.ZodOptional<z.ZodNever>;
330
+ }, z.core.$loose>, z.ZodObject<{
331
+ type: z.ZodLiteral<"tool_result">;
332
+ role: z.ZodOptional<z.ZodNever>;
333
+ }, z.core.$loose>], "type">;
303
334
  sourceEventSeq: z.ZodOptional<z.ZodNumber>;
304
335
  }, z.core.$strict>>;
305
336
  }, z.core.$strict>, z.ZodObject<{
@@ -318,74 +349,45 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
318
349
  }, z.core.$strict>>;
319
350
  summary: z.ZodOptional<z.ZodString>;
320
351
  replacementHistory: z.ZodArray<z.ZodObject<{
321
- message: z.ZodPipe<z.ZodObject<{
322
- role: z.ZodString;
323
- }, z.core.$loose>, z.ZodTransform<{
324
- role: string;
325
- }, {
326
- [x: string]: unknown;
327
- role: string;
328
- }>>;
329
- provenance: z.ZodOptional<z.ZodObject<{
330
- authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
331
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
332
- platform: z.ZodLiteral<"slack">;
333
- teamId: z.ZodString;
334
- email: z.ZodOptional<z.ZodString>;
335
- fullName: z.ZodOptional<z.ZodString>;
336
- userId: z.ZodString;
337
- userName: z.ZodOptional<z.ZodString>;
338
- }, z.core.$strict>, z.ZodObject<{
339
- platform: z.ZodLiteral<"local">;
340
- email: z.ZodOptional<z.ZodString>;
341
- fullName: z.ZodOptional<z.ZodString>;
342
- userId: z.ZodString;
343
- userName: z.ZodOptional<z.ZodString>;
344
- }, z.core.$strict>, z.ZodObject<{
345
- platform: z.ZodLiteral<"system">;
346
- name: z.ZodString;
347
- }, z.core.$strict>], "platform">>;
348
- }, z.core.$strict>>;
349
- sourceEventSeq: z.ZodOptional<z.ZodNumber>;
350
- }, z.core.$strict>>;
351
- }, z.core.$strict>], "type">, z.ZodObject<{
352
- type: z.ZodLiteral<"rollback">;
353
- modelProfile: z.ZodString;
354
- modelId: z.ZodString;
355
- replacementHistory: z.ZodArray<z.ZodObject<{
356
- message: z.ZodPipe<z.ZodObject<{
357
- role: z.ZodString;
358
- }, z.core.$loose>, z.ZodTransform<{
359
- role: string;
360
- }, {
361
- [x: string]: unknown;
362
- role: string;
363
- }>>;
364
- provenance: z.ZodOptional<z.ZodObject<{
365
- authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
366
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
367
- platform: z.ZodLiteral<"slack">;
368
- teamId: z.ZodString;
369
- email: z.ZodOptional<z.ZodString>;
370
- fullName: z.ZodOptional<z.ZodString>;
371
- userId: z.ZodString;
372
- userName: z.ZodOptional<z.ZodString>;
373
- }, z.core.$strict>, z.ZodObject<{
374
- platform: z.ZodLiteral<"local">;
375
- email: z.ZodOptional<z.ZodString>;
376
- fullName: z.ZodOptional<z.ZodString>;
377
- userId: z.ZodString;
378
- userName: z.ZodOptional<z.ZodString>;
379
- }, z.core.$strict>, z.ZodObject<{
380
- platform: z.ZodLiteral<"system">;
381
- name: z.ZodString;
382
- }, z.core.$strict>], "platform">>;
383
- }, z.core.$strict>>;
352
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
353
+ type: z.ZodLiteral<"user_message">;
354
+ role: z.ZodOptional<z.ZodNever>;
355
+ provenance: z.ZodObject<{
356
+ authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
357
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
358
+ platform: z.ZodLiteral<"slack">;
359
+ teamId: z.ZodString;
360
+ email: z.ZodOptional<z.ZodString>;
361
+ fullName: z.ZodOptional<z.ZodString>;
362
+ userId: z.ZodString;
363
+ userName: z.ZodOptional<z.ZodString>;
364
+ }, z.core.$strict>, z.ZodObject<{
365
+ platform: z.ZodLiteral<"local">;
366
+ email: z.ZodOptional<z.ZodString>;
367
+ fullName: z.ZodOptional<z.ZodString>;
368
+ userId: z.ZodString;
369
+ userName: z.ZodOptional<z.ZodString>;
370
+ }, z.core.$strict>, z.ZodObject<{
371
+ platform: z.ZodLiteral<"system">;
372
+ name: z.ZodString;
373
+ }, z.core.$strict>], "platform">>;
374
+ }, z.core.$strict>;
375
+ }, z.core.$loose>, z.ZodObject<{
376
+ type: z.ZodLiteral<"assistant_message">;
377
+ role: z.ZodOptional<z.ZodNever>;
378
+ }, z.core.$loose>, z.ZodObject<{
379
+ type: z.ZodLiteral<"tool_result">;
380
+ role: z.ZodOptional<z.ZodNever>;
381
+ }, z.core.$loose>], "type">;
384
382
  sourceEventSeq: z.ZodOptional<z.ZodNumber>;
385
383
  }, z.core.$strict>>;
386
- }, z.core.$strict>]>;
384
+ }, z.core.$strict>], "type">]>;
387
385
  /** One durable conversation event's validated data. */
388
386
  export type ConversationEventData = z.output<typeof conversationEventDataSchema>;
387
+ /** Event type names recognized by current readers and observational queries. */
388
+ export declare const KNOWN_CONVERSATION_EVENT_TYPES: readonly ["message", "message_updated", "user_message", "assistant_message", "tool_result", "mcp_provider_connected", "authorization_requested", "authorization_completed", "tool_execution_started", "message_handled", "messages_summarized", "turn_started", "turn_routed", "turn_completed", "turn_failed", "subagent_started", "subagent_ended", "handoff", "compaction"];
389
+ /** One known durable conversation event type name. */
390
+ export type KnownConversationEventType = (typeof KNOWN_CONVERSATION_EVENT_TYPES)[number];
389
391
  declare const unknownConversationEventDataSchema: z.ZodObject<{
390
392
  type: z.ZodLiteral<"unknown">;
391
393
  originalType: z.ZodString;
@@ -417,16 +419,10 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
417
419
  authorIdentityId: z.ZodOptional<z.ZodString>;
418
420
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
419
421
  type: z.ZodLiteral<"message_updated">;
420
- }, z.core.$strict>, z.ZodObject<{
421
- message: z.ZodPipe<z.ZodObject<{
422
- role: z.ZodString;
423
- }, z.core.$loose>, z.ZodTransform<{
424
- role: string;
425
- }, {
426
- [x: string]: unknown;
427
- role: string;
428
- }>>;
429
- provenance: z.ZodOptional<z.ZodObject<{
422
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
423
+ type: z.ZodLiteral<"user_message">;
424
+ role: z.ZodOptional<z.ZodNever>;
425
+ provenance: z.ZodObject<{
430
426
  authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
431
427
  actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
432
428
  platform: z.ZodLiteral<"slack">;
@@ -445,9 +441,14 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
445
441
  platform: z.ZodLiteral<"system">;
446
442
  name: z.ZodString;
447
443
  }, z.core.$strict>], "platform">>;
448
- }, z.core.$strict>>;
449
- type: z.ZodLiteral<"agent_step">;
450
- }, z.core.$strict>, z.ZodObject<{
444
+ }, z.core.$strict>;
445
+ }, z.core.$loose>, z.ZodObject<{
446
+ type: z.ZodLiteral<"assistant_message">;
447
+ role: z.ZodOptional<z.ZodNever>;
448
+ }, z.core.$loose>, z.ZodObject<{
449
+ type: z.ZodLiteral<"tool_result">;
450
+ role: z.ZodOptional<z.ZodNever>;
451
+ }, z.core.$loose>], "type">, z.ZodObject<{
451
452
  type: z.ZodLiteral<"mcp_provider_connected">;
452
453
  provider: z.ZodString;
453
454
  }, z.core.$strict>, z.ZodObject<{
@@ -545,34 +546,36 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
545
546
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
546
547
  summary: z.ZodOptional<z.ZodString>;
547
548
  replacementHistory: z.ZodArray<z.ZodObject<{
548
- message: z.ZodPipe<z.ZodObject<{
549
- role: z.ZodString;
550
- }, z.core.$loose>, z.ZodTransform<{
551
- role: string;
552
- }, {
553
- [x: string]: unknown;
554
- role: string;
555
- }>>;
556
- provenance: z.ZodOptional<z.ZodObject<{
557
- authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
558
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
559
- platform: z.ZodLiteral<"slack">;
560
- teamId: z.ZodString;
561
- email: z.ZodOptional<z.ZodString>;
562
- fullName: z.ZodOptional<z.ZodString>;
563
- userId: z.ZodString;
564
- userName: z.ZodOptional<z.ZodString>;
565
- }, z.core.$strict>, z.ZodObject<{
566
- platform: z.ZodLiteral<"local">;
567
- email: z.ZodOptional<z.ZodString>;
568
- fullName: z.ZodOptional<z.ZodString>;
569
- userId: z.ZodString;
570
- userName: z.ZodOptional<z.ZodString>;
571
- }, z.core.$strict>, z.ZodObject<{
572
- platform: z.ZodLiteral<"system">;
573
- name: z.ZodString;
574
- }, z.core.$strict>], "platform">>;
575
- }, z.core.$strict>>;
549
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
550
+ type: z.ZodLiteral<"user_message">;
551
+ role: z.ZodOptional<z.ZodNever>;
552
+ provenance: z.ZodObject<{
553
+ authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
554
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
555
+ platform: z.ZodLiteral<"slack">;
556
+ teamId: z.ZodString;
557
+ email: z.ZodOptional<z.ZodString>;
558
+ fullName: z.ZodOptional<z.ZodString>;
559
+ userId: z.ZodString;
560
+ userName: z.ZodOptional<z.ZodString>;
561
+ }, z.core.$strict>, z.ZodObject<{
562
+ platform: z.ZodLiteral<"local">;
563
+ email: z.ZodOptional<z.ZodString>;
564
+ fullName: z.ZodOptional<z.ZodString>;
565
+ userId: z.ZodString;
566
+ userName: z.ZodOptional<z.ZodString>;
567
+ }, z.core.$strict>, z.ZodObject<{
568
+ platform: z.ZodLiteral<"system">;
569
+ name: z.ZodString;
570
+ }, z.core.$strict>], "platform">>;
571
+ }, z.core.$strict>;
572
+ }, z.core.$loose>, z.ZodObject<{
573
+ type: z.ZodLiteral<"assistant_message">;
574
+ role: z.ZodOptional<z.ZodNever>;
575
+ }, z.core.$loose>, z.ZodObject<{
576
+ type: z.ZodLiteral<"tool_result">;
577
+ role: z.ZodOptional<z.ZodNever>;
578
+ }, z.core.$loose>], "type">;
576
579
  sourceEventSeq: z.ZodOptional<z.ZodNumber>;
577
580
  }, z.core.$strict>>;
578
581
  }, z.core.$strict>, z.ZodObject<{
@@ -591,72 +594,39 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
591
594
  }, z.core.$strict>>;
592
595
  summary: z.ZodOptional<z.ZodString>;
593
596
  replacementHistory: z.ZodArray<z.ZodObject<{
594
- message: z.ZodPipe<z.ZodObject<{
595
- role: z.ZodString;
596
- }, z.core.$loose>, z.ZodTransform<{
597
- role: string;
598
- }, {
599
- [x: string]: unknown;
600
- role: string;
601
- }>>;
602
- provenance: z.ZodOptional<z.ZodObject<{
603
- authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
604
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
605
- platform: z.ZodLiteral<"slack">;
606
- teamId: z.ZodString;
607
- email: z.ZodOptional<z.ZodString>;
608
- fullName: z.ZodOptional<z.ZodString>;
609
- userId: z.ZodString;
610
- userName: z.ZodOptional<z.ZodString>;
611
- }, z.core.$strict>, z.ZodObject<{
612
- platform: z.ZodLiteral<"local">;
613
- email: z.ZodOptional<z.ZodString>;
614
- fullName: z.ZodOptional<z.ZodString>;
615
- userId: z.ZodString;
616
- userName: z.ZodOptional<z.ZodString>;
617
- }, z.core.$strict>, z.ZodObject<{
618
- platform: z.ZodLiteral<"system">;
619
- name: z.ZodString;
620
- }, z.core.$strict>], "platform">>;
621
- }, z.core.$strict>>;
597
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
598
+ type: z.ZodLiteral<"user_message">;
599
+ role: z.ZodOptional<z.ZodNever>;
600
+ provenance: z.ZodObject<{
601
+ authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
602
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
603
+ platform: z.ZodLiteral<"slack">;
604
+ teamId: z.ZodString;
605
+ email: z.ZodOptional<z.ZodString>;
606
+ fullName: z.ZodOptional<z.ZodString>;
607
+ userId: z.ZodString;
608
+ userName: z.ZodOptional<z.ZodString>;
609
+ }, z.core.$strict>, z.ZodObject<{
610
+ platform: z.ZodLiteral<"local">;
611
+ email: z.ZodOptional<z.ZodString>;
612
+ fullName: z.ZodOptional<z.ZodString>;
613
+ userId: z.ZodString;
614
+ userName: z.ZodOptional<z.ZodString>;
615
+ }, z.core.$strict>, z.ZodObject<{
616
+ platform: z.ZodLiteral<"system">;
617
+ name: z.ZodString;
618
+ }, z.core.$strict>], "platform">>;
619
+ }, z.core.$strict>;
620
+ }, z.core.$loose>, z.ZodObject<{
621
+ type: z.ZodLiteral<"assistant_message">;
622
+ role: z.ZodOptional<z.ZodNever>;
623
+ }, z.core.$loose>, z.ZodObject<{
624
+ type: z.ZodLiteral<"tool_result">;
625
+ role: z.ZodOptional<z.ZodNever>;
626
+ }, z.core.$loose>], "type">;
622
627
  sourceEventSeq: z.ZodOptional<z.ZodNumber>;
623
628
  }, z.core.$strict>>;
624
- }, z.core.$strict>], "type">, z.ZodObject<{
625
- type: z.ZodLiteral<"rollback">;
626
- modelProfile: z.ZodString;
627
- modelId: z.ZodString;
628
- replacementHistory: z.ZodArray<z.ZodObject<{
629
- message: z.ZodPipe<z.ZodObject<{
630
- role: z.ZodString;
631
- }, z.core.$loose>, z.ZodTransform<{
632
- role: string;
633
- }, {
634
- [x: string]: unknown;
635
- role: string;
636
- }>>;
637
- provenance: z.ZodOptional<z.ZodObject<{
638
- authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
639
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
640
- platform: z.ZodLiteral<"slack">;
641
- teamId: z.ZodString;
642
- email: z.ZodOptional<z.ZodString>;
643
- fullName: z.ZodOptional<z.ZodString>;
644
- userId: z.ZodString;
645
- userName: z.ZodOptional<z.ZodString>;
646
- }, z.core.$strict>, z.ZodObject<{
647
- platform: z.ZodLiteral<"local">;
648
- email: z.ZodOptional<z.ZodString>;
649
- fullName: z.ZodOptional<z.ZodString>;
650
- userId: z.ZodString;
651
- userName: z.ZodOptional<z.ZodString>;
652
- }, z.core.$strict>, z.ZodObject<{
653
- platform: z.ZodLiteral<"system">;
654
- name: z.ZodString;
655
- }, z.core.$strict>], "platform">>;
656
- }, z.core.$strict>>;
657
- sourceEventSeq: z.ZodOptional<z.ZodNumber>;
658
- }, z.core.$strict>>;
659
- }, z.core.$strict>]>;
629
+ }, z.core.$strict>], "type">]>;
660
630
  }, z.core.$strict>, z.ZodObject<{
661
631
  schemaVersion: z.ZodNumber;
662
632
  seq: z.ZodNumber;
@@ -717,16 +687,10 @@ export declare const newConversationEventSchema: z.ZodObject<{
717
687
  authorIdentityId: z.ZodOptional<z.ZodString>;
718
688
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
719
689
  type: z.ZodLiteral<"message_updated">;
720
- }, z.core.$strict>, z.ZodObject<{
721
- message: z.ZodPipe<z.ZodObject<{
722
- role: z.ZodString;
723
- }, z.core.$loose>, z.ZodTransform<{
724
- role: string;
725
- }, {
726
- [x: string]: unknown;
727
- role: string;
728
- }>>;
729
- provenance: z.ZodOptional<z.ZodObject<{
690
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
691
+ type: z.ZodLiteral<"user_message">;
692
+ role: z.ZodOptional<z.ZodNever>;
693
+ provenance: z.ZodObject<{
730
694
  authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
731
695
  actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
732
696
  platform: z.ZodLiteral<"slack">;
@@ -745,9 +709,14 @@ export declare const newConversationEventSchema: z.ZodObject<{
745
709
  platform: z.ZodLiteral<"system">;
746
710
  name: z.ZodString;
747
711
  }, z.core.$strict>], "platform">>;
748
- }, z.core.$strict>>;
749
- type: z.ZodLiteral<"agent_step">;
750
- }, z.core.$strict>, z.ZodObject<{
712
+ }, z.core.$strict>;
713
+ }, z.core.$loose>, z.ZodObject<{
714
+ type: z.ZodLiteral<"assistant_message">;
715
+ role: z.ZodOptional<z.ZodNever>;
716
+ }, z.core.$loose>, z.ZodObject<{
717
+ type: z.ZodLiteral<"tool_result">;
718
+ role: z.ZodOptional<z.ZodNever>;
719
+ }, z.core.$loose>], "type">, z.ZodObject<{
751
720
  type: z.ZodLiteral<"mcp_provider_connected">;
752
721
  provider: z.ZodString;
753
722
  }, z.core.$strict>, z.ZodObject<{
@@ -843,6 +812,25 @@ export declare const newConversationEventSchema: z.ZodObject<{
843
812
  }, z.core.$strict>;
844
813
  /** An event to append; the store assigns `seq` and current history version. */
845
814
  export type NewConversationEvent = z.output<typeof newConversationEventSchema>;
815
+ /** Bounded observational page over the durable conversation event log. */
816
+ export interface ConversationEventQuery {
817
+ /** Exclusive lower bound on `seq`. */
818
+ afterSeq?: number;
819
+ /** Exclusive upper bound on `seq`. */
820
+ beforeSeq?: number;
821
+ /** Maximum events to return. */
822
+ limit: number;
823
+ /** Optional event-type filter. Empty/undefined returns every type. */
824
+ types?: readonly KnownConversationEventType[];
825
+ }
826
+ /** One page of raw conversation events plus pagination hints. */
827
+ export interface ConversationEventPage {
828
+ events: ConversationEvent[];
829
+ /** True when at least one older event exists before the returned page. */
830
+ hasOlder: boolean;
831
+ /** True when at least one newer event exists after the returned page. */
832
+ hasNewer: boolean;
833
+ }
846
834
  /** Persist and read the canonical per-conversation event log. */
847
835
  export interface ConversationEventStore {
848
836
  /** Append events atomically, assigning `seq = max+1` under the lease. */
@@ -851,6 +839,8 @@ export interface ConversationEventStore {
851
839
  replaceHistory(conversationId: string, replacement: HistoryReplacement): Promise<void>;
852
840
  /** One event selected by its retry-stable key across history versions. */
853
841
  loadByIdempotencyKey(conversationId: string, idempotencyKey: string): Promise<ConversationEvent | undefined>;
842
+ /** Latest durable instruction across history versions. */
843
+ loadLatestInstruction(conversationId: string): Promise<ConversationEvent | undefined>;
854
844
  /** Events of the current history version in `seq` order. */
855
845
  loadCurrentHistory(conversationId: string): Promise<ConversationEvent[]>;
856
846
  /** Events in the history version containing `seq`, when it exists. */
@@ -859,5 +849,10 @@ export interface ConversationEventStore {
859
849
  loadMessageHistory(conversationId: string): Promise<MessageHistory>;
860
850
  /** All events across every history version in `seq` order. */
861
851
  loadHistory(conversationId: string): Promise<ConversationEvent[]>;
852
+ /**
853
+ * Bounded raw event page for observational/debug reads.
854
+ * Defaults to the newest matching events when neither bound is set.
855
+ */
856
+ query(conversationId: string, query: ConversationEventQuery): Promise<ConversationEventPage>;
862
857
  }
863
858
  export {};