@sentry/junior 0.205.0 → 0.206.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.
- package/dist/{agent-D4nu8MQV.js → agent-C9yuiZUF.js} +247 -67
- package/dist/{agent-hooks-DXHpTJ4m.js → agent-hooks-DNjlz2A-.js} +1078 -12
- package/dist/{agent-runner-C04colea.js → agent-runner-E67lFrDG.js} +5 -5
- package/dist/api/schema.d.ts +77 -0
- package/dist/api/schema.js +2 -2
- package/dist/api.js +44 -511
- package/dist/{app-Cb776lL8.d.ts → app-AxGmJHwK.d.ts} +7 -0
- package/dist/app.d.ts +1 -1
- package/dist/app.js +50 -80
- package/dist/{auth-pause-state-C2P3guS1.js → auth-pause-state-MVZ6xvEK.js} +6 -6
- package/dist/briefs-CvJFQvhJ.js +398 -0
- package/dist/{catalog-runtime-CXw3asJD.js → catalog-runtime-TBR8n4e1.js} +1 -1
- package/dist/{checkpoint-CrViJ8Ps.js → checkpoint-BY47jJCB.js} +7 -6
- package/dist/cli/chat.js +14 -12
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +1 -0
- package/dist/cli/main.js +5 -1
- package/dist/cli/plugins.js +3 -3
- package/dist/cli/run.d.ts +2 -1
- package/dist/cli/run.js +2 -1
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-BOtJQ7Pc.js → client-ceE7NtvC.js} +4 -367
- package/dist/config-CIE83sR2.js +386 -0
- package/dist/{schema-Rn8-XEaN.js → conversation-AA4R1VUn.js} +580 -558
- package/dist/{conversation-privacy-BZRA6Pes.js → conversation-privacy-Auyq26XQ.js} +1 -1
- package/dist/{credential-sync-Bep34IB_.js → credential-sync-BO33aNQd.js} +20 -19
- package/dist/{execution-stats-B6lgWxCK.js → execution-stats-SiS2FLcv.js} +4 -4
- package/dist/{executor-BlUhFL7_.js → executor-BfbYPW63.js} +31 -3
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-DLMqIK74.js → job-queue-CyTc24Es.js} +1 -1
- package/dist/{logging-BMJzdDlP.js → logging-D37bayDc.js} +1 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-WwG5_Zgm.js → oauth-callback-server-BtfOeHTZ.js} +2 -2
- package/dist/{pending-auth-CUbXq06G.js → pending-auth-BPUzcs7n.js} +2 -2
- package/dist/{profile-T0tXE4zu.js → profile-CSixooTi.js} +4 -3
- package/dist/prompt-3gqNY1Ka.js +552 -0
- package/dist/{registry-BA0__8ai.js → registry-DiR0-xRg.js} +1 -1
- package/dist/{resolve-bvD1ORdv.js → resolve-Bn5q__9b.js} +2 -2
- package/dist/{runner-BXYxfIUL.js → runner-DFx3dIJH.js} +9 -9
- package/dist/{sandbox-egress-signals-ngEPjSEW.js → sandbox-egress-signals-bwvjihxA.js} +1 -1
- package/dist/schema-8GXFfclK.js +559 -0
- package/dist/{skills-DJOlYdBs.js → skills-BhM5qyCF.js} +2 -2
- package/dist/{spawn-h0R1bTEo.js → spawn-Dk0PqdH6.js} +2 -2
- package/dist/{stats-3YZn-Swi.js → stats-DKRP4rsY.js} +6 -6
- package/dist/{task-queue-CoXwd2eq.js → task-queue-CdpTvu4R.js} +3 -3
- package/dist/{task-runner-B2_mJZj0.js → task-runner-alpjVSxQ.js} +10 -10
- package/dist/{thread-state-CqZ1m-es.js → thread-state-CRK7aA41.js} +5 -5
- package/dist/{turn-execution-fI6PZ0iI.js → turn-execution-XtyzIHog.js} +3 -3
- package/dist/{turn-lifecycle-CcnwrOcp.js → turn-lifecycle-VbwZLfBv.js} +1 -1
- package/dist/{usage-B5SfMb3H.js → usage-D4A48Bdl.js} +4 -125
- package/dist/{validation-DfWcvhuS.js → validation-jn_46o4U.js} +1 -1
- package/dist/{version-oD-oPrbO.js → version-DcfJxB4z.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/web-authorization-CsfLSfEs.js +38 -0
- package/dist/{web-input-BOuq3oKK.js → web-input-BPp_sc7t.js} +6 -6
- package/dist/{work-B91LQKHr.js → work-Di-ubSGg.js} +9 -9
- package/dist/{worker-BcRRTe6k.js → worker-Cu_D5Mr8.js} +5 -4
- package/migrations/0040_conversation_briefs.sql +17 -0
- package/migrations/meta/0040_snapshot.json +3516 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -5
- package/dist/history-CqTuSAdI.js +0 -441
- package/dist/usage-schema-CKaDkH_j.js +0 -20
- package/dist/web-authorization-Crbzlmzo.js +0 -76
|
@@ -281,6 +281,13 @@
|
|
|
281
281
|
"when": 1788535952747,
|
|
282
282
|
"tag": "0039_attachment_provider",
|
|
283
283
|
"breakpoints": true
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"idx": 40,
|
|
287
|
+
"version": "7",
|
|
288
|
+
"when": 1788952455016,
|
|
289
|
+
"tag": "0040_conversation_briefs",
|
|
290
|
+
"breakpoints": true
|
|
284
291
|
}
|
|
285
292
|
]
|
|
286
293
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.206.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"pg": "^8.16.3",
|
|
86
86
|
"yaml": "^2.9.0",
|
|
87
87
|
"zod": "^4.5.4",
|
|
88
|
-
"@sentry/junior-plugin-api": "0.
|
|
88
|
+
"@sentry/junior-plugin-api": "0.206.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@emnapi/core": "^1.10.0",
|
|
@@ -104,9 +104,9 @@
|
|
|
104
104
|
"typescript": "^6.0.3",
|
|
105
105
|
"vercel": "^54.4.0",
|
|
106
106
|
"vitest": "^4.1.7",
|
|
107
|
-
"@sentry/junior-
|
|
108
|
-
"@sentry/junior-memory": "0.
|
|
109
|
-
"@sentry/junior-
|
|
107
|
+
"@sentry/junior-github": "0.206.0",
|
|
108
|
+
"@sentry/junior-memory": "0.206.0",
|
|
109
|
+
"@sentry/junior-testing": "0.0.0"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"build": "tsdown",
|
package/dist/history-CqTuSAdI.js
DELETED
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
import { c as TURN_REASONING_LEVELS, o as modelProfileSchema } from "./model-profile-CZmVoGdX.js";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { actorSchema } from "@sentry/junior-plugin-api";
|
|
4
|
-
//#region src/chat/conversations/provenance.ts
|
|
5
|
-
/**
|
|
6
|
-
* Durable message attribution shared by storage and projections.
|
|
7
|
-
* Attribution never grants credential authority.
|
|
8
|
-
*/
|
|
9
|
-
const conversationMessageAuthoritySchema = z.union([z.literal("instruction"), z.literal("context")]);
|
|
10
|
-
/** Canonical authority and actor metadata for one durable message event. */
|
|
11
|
-
const conversationMessageProvenanceSchema = z.object({
|
|
12
|
-
authority: conversationMessageAuthoritySchema,
|
|
13
|
-
actor: actorSchema.optional()
|
|
14
|
-
}).strict();
|
|
15
|
-
/** Build instruction provenance for an optional actor. */
|
|
16
|
-
function instructionProvenanceFor(actor) {
|
|
17
|
-
return actor ? {
|
|
18
|
-
authority: "instruction",
|
|
19
|
-
actor
|
|
20
|
-
} : { authority: "instruction" };
|
|
21
|
-
}
|
|
22
|
-
/** Unattributed ambient-context provenance for non-instruction messages. */
|
|
23
|
-
const contextProvenance = { authority: "context" };
|
|
24
|
-
function actorIdentityKey(actor) {
|
|
25
|
-
if (actor.platform === "system") return `system ${actor.name}`;
|
|
26
|
-
return actor.platform === "slack" ? `slack\u0000${actor.teamId}\u0000${actor.userId}` : `${actor.platform}\u0000${actor.userId}`;
|
|
27
|
-
}
|
|
28
|
-
/** Compare two actors by runtime identity only, never by display metadata. */
|
|
29
|
-
function sameActorIdentity(left, right) {
|
|
30
|
-
return Boolean(left && right && actorIdentityKey(left) === actorIdentityKey(right));
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Return distinct instruction actors in first-seen order for attribution only.
|
|
34
|
-
* Never use this list as credential authority.
|
|
35
|
-
*/
|
|
36
|
-
function instructionActors(provenance) {
|
|
37
|
-
const seen = /* @__PURE__ */ new Set();
|
|
38
|
-
const actors = [];
|
|
39
|
-
for (const entry of provenance) {
|
|
40
|
-
if (entry.authority !== "instruction" || !entry.actor) continue;
|
|
41
|
-
const identity = actorIdentityKey(entry.actor);
|
|
42
|
-
if (seen.has(identity)) continue;
|
|
43
|
-
seen.add(identity);
|
|
44
|
-
actors.push(entry.actor);
|
|
45
|
-
}
|
|
46
|
-
return actors;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/chat/conversations/history.ts
|
|
50
|
-
/**
|
|
51
|
-
* Durable conversation event history port.
|
|
52
|
-
*
|
|
53
|
-
* Events append under the conversation lease in stable sequence order.
|
|
54
|
-
* Compaction and handoff replace the active model history without rewriting
|
|
55
|
-
* prior events. Unsupported stored events remain readable as opaque facts,
|
|
56
|
-
* while malformed known events fail loudly. Provider-specific message fields
|
|
57
|
-
* are validated by the Pi adapter when it restores model context.
|
|
58
|
-
*/
|
|
59
|
-
const userMessageEventDataSchema = z.object({
|
|
60
|
-
type: z.literal("user_message"),
|
|
61
|
-
role: z.never().optional(),
|
|
62
|
-
provenance: conversationMessageProvenanceSchema
|
|
63
|
-
}).passthrough();
|
|
64
|
-
const assistantMessageEventDataSchema = z.object({
|
|
65
|
-
type: z.literal("assistant_message"),
|
|
66
|
-
role: z.never().optional()
|
|
67
|
-
}).passthrough();
|
|
68
|
-
const toolResultEventDataSchema = z.object({
|
|
69
|
-
type: z.literal("tool_result"),
|
|
70
|
-
role: z.never().optional()
|
|
71
|
-
}).passthrough();
|
|
72
|
-
/**
|
|
73
|
-
* One replayable agent-history item. Junior owns `type` and user provenance,
|
|
74
|
-
* forbids the provider `role` discriminator, and leaves preserved message
|
|
75
|
-
* fields for the Pi adapter to validate when restoring model context.
|
|
76
|
-
*/
|
|
77
|
-
const agentHistoryItemSchema = z.discriminatedUnion("type", [
|
|
78
|
-
userMessageEventDataSchema,
|
|
79
|
-
assistantMessageEventDataSchema,
|
|
80
|
-
toolResultEventDataSchema
|
|
81
|
-
]);
|
|
82
|
-
const nativeReplacementHistoryItemSchema = z.object({
|
|
83
|
-
item: agentHistoryItemSchema,
|
|
84
|
-
sourceEventSeq: z.number().int().nonnegative().optional()
|
|
85
|
-
}).strict();
|
|
86
|
-
/**
|
|
87
|
-
* The complete agent history used immediately after a replacement. Later
|
|
88
|
-
* native history events append to it. Replacement entries are replayed model
|
|
89
|
-
* history, not new conversation activity.
|
|
90
|
-
*/
|
|
91
|
-
const replacementHistorySchema = z.array(nativeReplacementHistoryItemSchema);
|
|
92
|
-
const compactionDetailsSchema = z.object({
|
|
93
|
-
reason: z.literal("capacity"),
|
|
94
|
-
estimatedInputTokens: z.number().int().nonnegative(),
|
|
95
|
-
replacementInputTokens: z.number().int().nonnegative().optional(),
|
|
96
|
-
triggerTokens: z.number().int().nonnegative(),
|
|
97
|
-
inputLimitTokens: z.number().int().positive(),
|
|
98
|
-
inputMessageCount: z.number().int().nonnegative(),
|
|
99
|
-
retainedMessageCount: z.number().int().nonnegative(),
|
|
100
|
-
summaryChars: z.number().int().nonnegative()
|
|
101
|
-
}).strict();
|
|
102
|
-
const historyReplacementEventDataSchema = z.discriminatedUnion("type", [z.object({
|
|
103
|
-
type: z.literal("handoff"),
|
|
104
|
-
modelProfile: modelProfileSchema,
|
|
105
|
-
modelId: z.string().min(1),
|
|
106
|
-
reasoningLevel: z.string().min(1).optional(),
|
|
107
|
-
triggeringToolCallId: z.string().min(1).optional(),
|
|
108
|
-
summary: z.string().min(1).optional(),
|
|
109
|
-
replacementHistory: replacementHistorySchema
|
|
110
|
-
}).strict(), z.object({
|
|
111
|
-
type: z.literal("compaction"),
|
|
112
|
-
modelProfile: modelProfileSchema,
|
|
113
|
-
modelId: z.string().min(1),
|
|
114
|
-
details: compactionDetailsSchema.optional(),
|
|
115
|
-
summary: z.string().min(1).optional(),
|
|
116
|
-
replacementHistory: replacementHistorySchema
|
|
117
|
-
}).strict()]);
|
|
118
|
-
/** Validate an event that intentionally replaces active model history. */
|
|
119
|
-
const historyReplacementSchema = z.object({
|
|
120
|
-
data: historyReplacementEventDataSchema,
|
|
121
|
-
createdAtMs: z.number().finite()
|
|
122
|
-
}).strict();
|
|
123
|
-
const mcpProviderConnectedEventDataSchema = z.object({
|
|
124
|
-
type: z.literal("mcp_provider_connected"),
|
|
125
|
-
provider: z.string().min(1),
|
|
126
|
-
credentialSubjectId: z.string().min(1)
|
|
127
|
-
}).strict();
|
|
128
|
-
const unownedMcpProviderConnectedEventDataSchema = z.object({
|
|
129
|
-
type: z.literal("mcp_provider_connected_unowned"),
|
|
130
|
-
provider: z.string().min(1)
|
|
131
|
-
}).strict();
|
|
132
|
-
const authorizationKindSchema = z.union([z.literal("plugin"), z.literal("mcp")]);
|
|
133
|
-
const authorizationRequestedEventDataSchema = z.object({
|
|
134
|
-
type: z.literal("authorization_requested"),
|
|
135
|
-
kind: authorizationKindSchema,
|
|
136
|
-
provider: z.string().min(1),
|
|
137
|
-
actorId: z.string().min(1),
|
|
138
|
-
authorizationId: z.string().min(1),
|
|
139
|
-
delivery: z.union([z.literal("private_link_sent"), z.literal("private_link_reused")])
|
|
140
|
-
}).strict();
|
|
141
|
-
const authorizationCompletedEventDataSchema = z.object({
|
|
142
|
-
type: z.literal("authorization_completed"),
|
|
143
|
-
kind: authorizationKindSchema,
|
|
144
|
-
provider: z.string().min(1),
|
|
145
|
-
actorId: z.string().min(1),
|
|
146
|
-
authorizationId: z.string().min(1)
|
|
147
|
-
}).strict();
|
|
148
|
-
const toolExecutionStartedEventDataSchema = z.object({
|
|
149
|
-
type: z.literal("tool_execution_started"),
|
|
150
|
-
toolCallId: z.string().min(1),
|
|
151
|
-
toolName: z.string().min(1)
|
|
152
|
-
}).strict();
|
|
153
|
-
const guardianActionReviewedEventDataSchema = z.object({
|
|
154
|
-
type: z.literal("guardian_action_reviewed"),
|
|
155
|
-
turnId: z.string().min(1),
|
|
156
|
-
toolCallId: z.string().min(1),
|
|
157
|
-
toolName: z.string().min(1),
|
|
158
|
-
costUsd: z.number().finite().nonnegative().optional(),
|
|
159
|
-
decision: z.enum([
|
|
160
|
-
"allow",
|
|
161
|
-
"ask",
|
|
162
|
-
"deny"
|
|
163
|
-
]),
|
|
164
|
-
riskLevel: z.enum([
|
|
165
|
-
"low",
|
|
166
|
-
"medium",
|
|
167
|
-
"high",
|
|
168
|
-
"critical"
|
|
169
|
-
]),
|
|
170
|
-
userAuthorization: z.enum([
|
|
171
|
-
"high",
|
|
172
|
-
"medium",
|
|
173
|
-
"low",
|
|
174
|
-
"unknown"
|
|
175
|
-
])
|
|
176
|
-
}).strict();
|
|
177
|
-
const conversationMessageRoleSchema = z.union([
|
|
178
|
-
z.literal("user"),
|
|
179
|
-
z.literal("assistant"),
|
|
180
|
-
z.literal("system")
|
|
181
|
-
]);
|
|
182
|
-
const messageEventDataSchema = z.object({
|
|
183
|
-
type: z.literal("message"),
|
|
184
|
-
messageId: z.string().min(1),
|
|
185
|
-
role: conversationMessageRoleSchema,
|
|
186
|
-
text: z.string(),
|
|
187
|
-
authorIdentityId: z.string().min(1).optional(),
|
|
188
|
-
meta: z.record(z.string(), z.unknown()).optional()
|
|
189
|
-
}).strict();
|
|
190
|
-
const messageUpdatedEventDataSchema = messageEventDataSchema.extend({ type: z.literal("message_updated") });
|
|
191
|
-
const messageHandledEventDataSchema = z.object({
|
|
192
|
-
type: z.literal("message_handled"),
|
|
193
|
-
messageId: z.string().min(1)
|
|
194
|
-
}).strict();
|
|
195
|
-
const messagesSummarizedEventDataSchema = z.object({
|
|
196
|
-
type: z.literal("messages_summarized"),
|
|
197
|
-
historyFromSeq: z.number().int().nonnegative(),
|
|
198
|
-
compactions: z.array(z.object({
|
|
199
|
-
coveredMessageCount: z.number().int().nonnegative(),
|
|
200
|
-
createdAtMs: z.number(),
|
|
201
|
-
id: z.string().min(1),
|
|
202
|
-
summary: z.string()
|
|
203
|
-
}).strict())
|
|
204
|
-
}).strict();
|
|
205
|
-
/** Product surface that owns a durable conversation turn. */
|
|
206
|
-
const conversationTurnSurfaceSchema = z.enum([
|
|
207
|
-
"slack",
|
|
208
|
-
"api",
|
|
209
|
-
"scheduler",
|
|
210
|
-
"internal"
|
|
211
|
-
]);
|
|
212
|
-
/** Where a failed turn stopped. */
|
|
213
|
-
const conversationTurnFailureCodeSchema = z.enum([
|
|
214
|
-
"agent_run_failed",
|
|
215
|
-
"delivery_failed",
|
|
216
|
-
"model_execution_failed",
|
|
217
|
-
"persistence_failed"
|
|
218
|
-
]);
|
|
219
|
-
/**
|
|
220
|
-
* Why a failed turn stopped.
|
|
221
|
-
* Values are fixed labels only. Do not store raw exception text.
|
|
222
|
-
*/
|
|
223
|
-
const conversationTurnFailureReasonSchema = z.enum([
|
|
224
|
-
"auth",
|
|
225
|
-
"permission",
|
|
226
|
-
"rate_limit",
|
|
227
|
-
"capacity",
|
|
228
|
-
"timeout",
|
|
229
|
-
"network",
|
|
230
|
-
"server",
|
|
231
|
-
"invalid_request",
|
|
232
|
-
"invalid_response",
|
|
233
|
-
"quota",
|
|
234
|
-
"content_policy",
|
|
235
|
-
"unknown",
|
|
236
|
-
"empty_output",
|
|
237
|
-
"tool_errors",
|
|
238
|
-
"suppressed_output"
|
|
239
|
-
]);
|
|
240
|
-
const turnStartedEventDataSchema = z.object({
|
|
241
|
-
type: z.literal("turn_started"),
|
|
242
|
-
turnId: z.string().min(1),
|
|
243
|
-
inputMessageIds: z.array(z.string().min(1)).min(1),
|
|
244
|
-
surface: conversationTurnSurfaceSchema
|
|
245
|
-
}).strict().refine((data) => new Set(data.inputMessageIds).size === data.inputMessageIds.length, "turn input message ids must be unique");
|
|
246
|
-
const turnRoutedEventDataSchema = z.object({
|
|
247
|
-
type: z.literal("turn_routed"),
|
|
248
|
-
turnId: z.string().min(1),
|
|
249
|
-
modelProfile: modelProfileSchema,
|
|
250
|
-
modelId: z.string().min(1),
|
|
251
|
-
costUsd: z.number().finite().nonnegative().optional(),
|
|
252
|
-
reasoningLevel: z.enum(TURN_REASONING_LEVELS),
|
|
253
|
-
confidence: z.number().min(0).max(1).optional(),
|
|
254
|
-
source: z.enum([
|
|
255
|
-
"configured",
|
|
256
|
-
"inherited",
|
|
257
|
-
"router"
|
|
258
|
-
])
|
|
259
|
-
}).strict();
|
|
260
|
-
const turnContextEventDataSchema = z.object({
|
|
261
|
-
type: z.literal("turn_context"),
|
|
262
|
-
turnId: z.string().min(1),
|
|
263
|
-
pluginName: z.string().min(1),
|
|
264
|
-
kind: z.string().min(1).max(64),
|
|
265
|
-
version: z.number().int().positive(),
|
|
266
|
-
content: z.record(z.string(), z.unknown())
|
|
267
|
-
}).strict();
|
|
268
|
-
const structuredConversationEventDataSchema = z.object({
|
|
269
|
-
type: z.literal("structured_event"),
|
|
270
|
-
namespace: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
271
|
-
name: z.string().regex(/^[a-z][a-z0-9_]*$/),
|
|
272
|
-
version: z.number().int().positive(),
|
|
273
|
-
turnId: z.string().min(1).optional(),
|
|
274
|
-
content: z.record(z.string(), z.unknown())
|
|
275
|
-
}).strict();
|
|
276
|
-
/** Durable attachment metadata on host-owned delivery events. */
|
|
277
|
-
const deliveredAttachmentSchema = z.object({
|
|
278
|
-
id: z.string().min(1),
|
|
279
|
-
filename: z.string().min(1),
|
|
280
|
-
contentType: z.string().min(1),
|
|
281
|
-
bytes: z.number().int().nonnegative()
|
|
282
|
-
}).strict();
|
|
283
|
-
/** Host-owned transcript item for files delivered to humans this turn. */
|
|
284
|
-
const attachmentsDeliveredEventDataSchema = z.object({
|
|
285
|
-
type: z.literal("attachments_delivered"),
|
|
286
|
-
attachments: z.array(deliveredAttachmentSchema).min(1),
|
|
287
|
-
toolCallId: z.string().min(1).optional(),
|
|
288
|
-
turnId: z.string().min(1).optional()
|
|
289
|
-
}).strict();
|
|
290
|
-
const turnCompletedEventDataSchema = z.object({
|
|
291
|
-
type: z.literal("turn_completed"),
|
|
292
|
-
turnId: z.string().min(1),
|
|
293
|
-
outcome: z.enum([
|
|
294
|
-
"success",
|
|
295
|
-
"no_reply",
|
|
296
|
-
"cancelled"
|
|
297
|
-
])
|
|
298
|
-
}).strict();
|
|
299
|
-
const turnFailedEventDataSchema = z.object({
|
|
300
|
-
type: z.literal("turn_failed"),
|
|
301
|
-
turnId: z.string().min(1),
|
|
302
|
-
failureCode: conversationTurnFailureCodeSchema,
|
|
303
|
-
failureReason: conversationTurnFailureReasonSchema.optional(),
|
|
304
|
-
eventId: z.string().regex(/^[a-f0-9]{32}$/i).optional()
|
|
305
|
-
}).strict();
|
|
306
|
-
const subagentStartedEventDataSchema = z.object({
|
|
307
|
-
type: z.literal("subagent_started"),
|
|
308
|
-
subagentInvocationId: z.string().min(1),
|
|
309
|
-
subagentKind: z.string().min(1),
|
|
310
|
-
modelId: z.string().min(1).optional(),
|
|
311
|
-
parentToolCallId: z.string().min(1).optional(),
|
|
312
|
-
reasoningLevel: z.string().min(1).optional(),
|
|
313
|
-
childConversationId: z.string().min(1)
|
|
314
|
-
}).strict();
|
|
315
|
-
const subagentEndedEventDataSchema = z.object({
|
|
316
|
-
type: z.literal("subagent_ended"),
|
|
317
|
-
subagentInvocationId: z.string().min(1),
|
|
318
|
-
outcome: z.union([
|
|
319
|
-
z.literal("success"),
|
|
320
|
-
z.literal("error"),
|
|
321
|
-
z.literal("aborted")
|
|
322
|
-
]),
|
|
323
|
-
errorCode: z.string().min(1).optional()
|
|
324
|
-
}).strict();
|
|
325
|
-
/** Prevent ordinary appends from bypassing history-replacement validation. */
|
|
326
|
-
const appendableConversationEventDataSchema = z.union([
|
|
327
|
-
messageEventDataSchema,
|
|
328
|
-
messageUpdatedEventDataSchema,
|
|
329
|
-
agentHistoryItemSchema,
|
|
330
|
-
mcpProviderConnectedEventDataSchema,
|
|
331
|
-
authorizationRequestedEventDataSchema,
|
|
332
|
-
authorizationCompletedEventDataSchema,
|
|
333
|
-
toolExecutionStartedEventDataSchema,
|
|
334
|
-
guardianActionReviewedEventDataSchema,
|
|
335
|
-
messageHandledEventDataSchema,
|
|
336
|
-
messagesSummarizedEventDataSchema,
|
|
337
|
-
turnStartedEventDataSchema,
|
|
338
|
-
turnContextEventDataSchema,
|
|
339
|
-
structuredConversationEventDataSchema,
|
|
340
|
-
attachmentsDeliveredEventDataSchema,
|
|
341
|
-
turnRoutedEventDataSchema,
|
|
342
|
-
turnCompletedEventDataSchema,
|
|
343
|
-
turnFailedEventDataSchema,
|
|
344
|
-
subagentStartedEventDataSchema,
|
|
345
|
-
subagentEndedEventDataSchema
|
|
346
|
-
]);
|
|
347
|
-
/** Strict event-data contract reused by the SQL row codec. */
|
|
348
|
-
const conversationEventDataSchema = z.union([
|
|
349
|
-
appendableConversationEventDataSchema,
|
|
350
|
-
historyReplacementEventDataSchema,
|
|
351
|
-
unownedMcpProviderConnectedEventDataSchema
|
|
352
|
-
]);
|
|
353
|
-
/** Event type names recognized by current readers and observational queries. */
|
|
354
|
-
const KNOWN_CONVERSATION_EVENT_TYPES = [
|
|
355
|
-
"message",
|
|
356
|
-
"message_updated",
|
|
357
|
-
"user_message",
|
|
358
|
-
"assistant_message",
|
|
359
|
-
"tool_result",
|
|
360
|
-
"mcp_provider_connected",
|
|
361
|
-
"mcp_provider_connected_unowned",
|
|
362
|
-
"authorization_requested",
|
|
363
|
-
"authorization_completed",
|
|
364
|
-
"tool_execution_started",
|
|
365
|
-
"guardian_action_reviewed",
|
|
366
|
-
"message_handled",
|
|
367
|
-
"messages_summarized",
|
|
368
|
-
"turn_started",
|
|
369
|
-
"turn_context",
|
|
370
|
-
"structured_event",
|
|
371
|
-
"attachments_delivered",
|
|
372
|
-
"turn_routed",
|
|
373
|
-
"turn_completed",
|
|
374
|
-
"turn_failed",
|
|
375
|
-
"subagent_started",
|
|
376
|
-
"subagent_ended",
|
|
377
|
-
"handoff",
|
|
378
|
-
"compaction"
|
|
379
|
-
];
|
|
380
|
-
const knownConversationEventTypeSchema = z.enum(KNOWN_CONVERSATION_EVENT_TYPES);
|
|
381
|
-
const unknownConversationEventDataSchema = z.object({
|
|
382
|
-
type: z.literal("unknown"),
|
|
383
|
-
originalType: z.string().min(1),
|
|
384
|
-
payload: z.unknown()
|
|
385
|
-
}).strict();
|
|
386
|
-
const conversationEventEnvelopeSchema = z.object({
|
|
387
|
-
schemaVersion: z.number().int().nonnegative(),
|
|
388
|
-
seq: z.number().int().nonnegative(),
|
|
389
|
-
historyVersion: z.number().int().nonnegative(),
|
|
390
|
-
idempotencyKey: z.string().min(1).optional(),
|
|
391
|
-
createdAtMs: z.number().finite()
|
|
392
|
-
}).strict();
|
|
393
|
-
/**
|
|
394
|
-
* Canonical ordered envelope for the durable conversation log.
|
|
395
|
-
* `schemaVersion` is persisted with every physical event row.
|
|
396
|
-
*/
|
|
397
|
-
const conversationEventSchema = z.union([conversationEventEnvelopeSchema.extend({
|
|
398
|
-
schemaVersion: z.literal(1),
|
|
399
|
-
data: conversationEventDataSchema
|
|
400
|
-
}), conversationEventEnvelopeSchema.extend({ data: unknownConversationEventDataSchema })]);
|
|
401
|
-
const storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
|
|
402
|
-
type: z.string().min(1),
|
|
403
|
-
payload: z.unknown()
|
|
404
|
-
});
|
|
405
|
-
/**
|
|
406
|
-
* Decode a physical event row without making old or future event types
|
|
407
|
-
* unreadable. Unsupported rows stay opaque until an upgrade migration defines
|
|
408
|
-
* their semantics; known version-one events remain strict so corrupt canonical
|
|
409
|
-
* data cannot be mistaken for compatibility data.
|
|
410
|
-
*/
|
|
411
|
-
function decodeStoredConversationEvent(value) {
|
|
412
|
-
const stored = storedConversationEventSchema.parse(value);
|
|
413
|
-
const { type, payload, ...envelope } = stored;
|
|
414
|
-
const knownType = knownConversationEventTypeSchema.safeParse(type).success;
|
|
415
|
-
if (stored.schemaVersion === 1 && knownType) {
|
|
416
|
-
const data = typeof payload === "object" && payload !== null && !Array.isArray(payload) ? {
|
|
417
|
-
...payload,
|
|
418
|
-
type
|
|
419
|
-
} : { type };
|
|
420
|
-
return conversationEventSchema.parse({
|
|
421
|
-
...envelope,
|
|
422
|
-
data
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
return conversationEventSchema.parse({
|
|
426
|
-
...envelope,
|
|
427
|
-
data: {
|
|
428
|
-
type: "unknown",
|
|
429
|
-
originalType: type,
|
|
430
|
-
payload
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
/** Validate an append without permitting model-history replacement events. */
|
|
435
|
-
const newConversationEventSchema = z.object({
|
|
436
|
-
data: appendableConversationEventDataSchema,
|
|
437
|
-
idempotencyKey: z.string().min(1).optional(),
|
|
438
|
-
createdAtMs: z.number().finite()
|
|
439
|
-
}).strict();
|
|
440
|
-
//#endregion
|
|
441
|
-
export { conversationTurnFailureReasonSchema as a, newConversationEventSchema as c, instructionProvenanceFor as d, sameActorIdentity as f, conversationTurnFailureCodeSchema as i, contextProvenance as l, agentHistoryItemSchema as n, decodeStoredConversationEvent as o, conversationEventDataSchema as r, historyReplacementSchema as s, KNOWN_CONVERSATION_EVENT_TYPES as t, instructionActors as u };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
//#region src/usage-schema.ts
|
|
3
|
-
const usageCostSchema = z.object({
|
|
4
|
-
input: z.number().finite().nonnegative().optional(),
|
|
5
|
-
output: z.number().finite().nonnegative().optional(),
|
|
6
|
-
cacheRead: z.number().finite().nonnegative().optional(),
|
|
7
|
-
cacheWrite: z.number().finite().nonnegative().optional(),
|
|
8
|
-
total: z.number().finite().nonnegative().optional()
|
|
9
|
-
}).strict();
|
|
10
|
-
const usageSchema = z.object({
|
|
11
|
-
inputTokens: z.number().int().nonnegative().optional(),
|
|
12
|
-
outputTokens: z.number().int().nonnegative().optional(),
|
|
13
|
-
cachedInputTokens: z.number().int().nonnegative().optional(),
|
|
14
|
-
cacheCreationTokens: z.number().int().nonnegative().optional(),
|
|
15
|
-
reasoningTokens: z.number().int().nonnegative().optional(),
|
|
16
|
-
totalTokens: z.number().int().nonnegative().optional(),
|
|
17
|
-
cost: usageCostSchema.optional()
|
|
18
|
-
}).strict();
|
|
19
|
-
//#endregion
|
|
20
|
-
export { usageSchema as t };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { a as getClient } from "./sentry-CD3SdJl-.js";
|
|
2
|
-
import { w as getStateAdapter } from "./profile-T0tXE4zu.js";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
//#region src/chat/sentry-links.ts
|
|
5
|
-
function getSentryOrgSlug() {
|
|
6
|
-
return process.env.SENTRY_ORG_SLUG?.trim() || void 0;
|
|
7
|
-
}
|
|
8
|
-
function isSentrySaasDsnHost(host) {
|
|
9
|
-
return host === "sentry.io" || host.endsWith(".sentry.io");
|
|
10
|
-
}
|
|
11
|
-
function buildSentryWebBaseUrl(dsn) {
|
|
12
|
-
if (isSentrySaasDsnHost(dsn.host)) return "https://sentry.io";
|
|
13
|
-
const port = dsn.port ? `:${dsn.port}` : "";
|
|
14
|
-
const path = dsn.path ? `/${dsn.path}` : "";
|
|
15
|
-
return `${dsn.protocol}://${dsn.host}${port}${path}`;
|
|
16
|
-
}
|
|
17
|
-
function buildSentryOrgPath(args) {
|
|
18
|
-
const dsn = getClient()?.getDsn();
|
|
19
|
-
if (!dsn?.host || !dsn.projectId) return;
|
|
20
|
-
const orgSlug = getSentryOrgSlug();
|
|
21
|
-
if (!orgSlug) return;
|
|
22
|
-
const params = new URLSearchParams();
|
|
23
|
-
params.set("project", dsn.projectId);
|
|
24
|
-
if (args.query) for (const [key, value] of Object.entries(args.query)) params.set(key, value);
|
|
25
|
-
const path = `${args.path}?${params.toString()}`;
|
|
26
|
-
if (isSentrySaasDsnHost(dsn.host)) return `https://${orgSlug}.sentry.io/${path}`;
|
|
27
|
-
return `${buildSentryWebBaseUrl(dsn)}/organizations/${orgSlug}/${path}`;
|
|
28
|
-
}
|
|
29
|
-
/** Build a Sentry conversation URL only when the runtime has enough Sentry config. */
|
|
30
|
-
function buildSentryConversationUrl(conversationId) {
|
|
31
|
-
return buildSentryOrgPath({ path: `explore/conversations/${encodeURIComponent(conversationId)}/` });
|
|
32
|
-
}
|
|
33
|
-
/** Build a Sentry event URL only when the runtime has enough Sentry config. */
|
|
34
|
-
function buildSentryEventUrl(eventId) {
|
|
35
|
-
return buildSentryOrgPath({
|
|
36
|
-
path: "issues/",
|
|
37
|
-
query: { query: eventId }
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/chat/conversations/web-authorization.ts
|
|
42
|
-
const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
|
|
43
|
-
const WEB_AUTHORIZATION_TTL_MS = 864e5;
|
|
44
|
-
function authorizationKey(conversationId, actorId) {
|
|
45
|
-
return `${WEB_AUTHORIZATION_PREFIX}:${conversationId}:${actorId}`;
|
|
46
|
-
}
|
|
47
|
-
/** Build authorization delivery for one web turn. */
|
|
48
|
-
function createWebAuthorization(args) {
|
|
49
|
-
return {
|
|
50
|
-
createState: async () => randomUUID(),
|
|
51
|
-
deliver: async (request) => {
|
|
52
|
-
await getStateAdapter().set(authorizationKey(args.conversationId, args.actorId), JSON.stringify({
|
|
53
|
-
...request,
|
|
54
|
-
...args
|
|
55
|
-
}), WEB_AUTHORIZATION_TTL_MS);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/** Read the pending authorization request for one web actor. */
|
|
60
|
-
async function getWebAuthorization(args) {
|
|
61
|
-
const value = await getStateAdapter().get(authorizationKey(args.conversationId, args.actorId));
|
|
62
|
-
if (typeof value !== "string") return void 0;
|
|
63
|
-
try {
|
|
64
|
-
const parsed = JSON.parse(value);
|
|
65
|
-
if (parsed.actorId !== args.actorId || parsed.conversationId !== args.conversationId || typeof parsed.authorizationUrl !== "string" || typeof parsed.label !== "string" || typeof parsed.completionText !== "string") return;
|
|
66
|
-
return parsed;
|
|
67
|
-
} catch {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/** Remove a web authorization request after the parked turn continues. */
|
|
72
|
-
async function deleteWebAuthorization(args) {
|
|
73
|
-
await getStateAdapter().delete(authorizationKey(args.conversationId, args.actorId));
|
|
74
|
-
}
|
|
75
|
-
//#endregion
|
|
76
|
-
export { buildSentryEventUrl as a, buildSentryConversationUrl as i, deleteWebAuthorization as n, getWebAuthorization as r, createWebAuthorization as t };
|