@sentry/junior 0.236.0 → 0.238.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/{context-0Et9iVSB.js → actor-BTtLaeWy.js} +1 -96
- package/dist/admin-ZGlZ8lY6.js +33 -0
- package/dist/{agent-hooks-Da_H0jHv.js → agent-hooks-CxdSqU2u.js} +1426 -2965
- package/dist/{agent-runner-uP7QRc4c.js → agent-runner-ZS1LHtSR.js} +275 -143
- package/dist/api/schema.d.ts +4 -0
- package/dist/api/schema.js +4 -3
- package/dist/api.d.ts +1 -1
- package/dist/api.js +32 -25
- package/dist/{app-MEd7wbF0.d.ts → app-FB2hmHpZ.d.ts} +1 -1
- package/dist/app.d.ts +1 -1
- package/dist/app.js +27 -23
- package/dist/{automation-B9Kc1gcf.js → automation-CrQGQ2MT.js} +3 -2
- package/dist/{briefs-DrjBPQFy.js → briefs-B6IhUAgK.js} +4 -4
- package/dist/{catalog-runtime-C7339Cfm.js → catalog-runtime-BzNg07bb.js} +1 -1
- package/dist/{checkpoint-DaD7_Gsb.js → checkpoint-DWGyJg4c.js} +19 -10
- package/dist/cli/chat.js +13 -13
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +6 -2
- package/dist/cli/plugins.js +5 -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.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-Ch9Hg9NU.js → client-CKs0rj3A.js} +2 -2
- package/dist/{config-JR9wke1W.js → config-DRw358bB.js} +2 -2
- package/dist/{conversation-9Fxa1Zbq.js → conversation-DwD-vquD.js} +3 -517
- package/dist/{conversation-privacy-au02dyZK.js → conversation-privacy-DAYxHp74.js} +1 -1
- package/dist/{credential-sync-BWTA3LnL.js → credential-sync-DmRbuyE4.js} +15 -14
- package/dist/{db-Ca9Nt5ci.d.ts → db-CWZP77Ex.d.ts} +1 -1
- package/dist/{executor-BW9XWgUQ.js → executor-DgPk8Lsx.js} +5 -2
- package/dist/experimental-Qn9rKLgx.js +50 -0
- package/dist/history-BLTUgFYO.js +518 -0
- package/dist/{images-BdG7zcNf.js → images-puyEuXoY.js} +3 -3
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-BqXd0ZPV.js → job-queue-BL9stv_E.js} +1 -1
- package/dist/{logging-B4sKwmCG.js → logging-BNi_jyHb.js} +1 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-authorization-BjRN99dc.js → oauth-authorization-Zv1oLB1J.js} +1 -1
- package/dist/{oauth-callback-server-B_1p98Mb.js → oauth-callback-server-BHtVbKvO.js} +2 -2
- package/dist/pending-auth-DulDjfwL.js +433 -0
- package/dist/{profile-BamYnmhO.js → profile-C2TScny6.js} +5 -7
- package/dist/{prompt-Ctwy6hSI.js → prompt-CMU-B4FA.js} +1 -1
- package/dist/{registry-CXNv9fDX.js → registry-D1RsbgDb.js} +111 -3
- package/dist/{resolve-C9ETkt4T.js → resolve-CuY3dhxy.js} +2 -2
- package/dist/{runner-DnBGVRnW.js → runner-BUkReLln.js} +10 -10
- package/dist/{sandbox-egress-signals-DwJ7Boi_.js → sandbox-egress-signals-etjG6qQX.js} +1 -1
- package/dist/{schema-CJiqDc5r.js → schema-CxWAN2zq.js} +2 -2
- package/dist/{skills-Dd8O9Aav.js → skills-BGhThSGR.js} +2 -2
- package/dist/{spawn-DFdRspSD.js → spawn-PtyOnoXt.js} +2 -2
- package/dist/{store-DoewL5mG.d.ts → store-BxxbxBlm.d.ts} +7 -0
- package/dist/{task-queue-DGQEOk1A.js → task-queue-Bi2uNATu.js} +3 -3
- package/dist/{task-runner-C5XCIDSF.js → task-runner-CDoZCo8g.js} +20 -10
- package/dist/{thread-state-D3E29wZk.js → thread-state-B-t88gH0.js} +6 -5
- package/dist/{turn-failure-response-TDoj0aZz.js → turn-failure-response-di4Jx90o.js} +10 -9
- package/dist/{turn-lifecycle-DOnU45p7.js → turn-lifecycle-ByhUHYjD.js} +1 -1
- package/dist/{turn-session-routing-DbpZZoin.js → turn-session-routing-QjNvsevm.js} +1 -1
- package/dist/{validation-B9lMbisx.js → validation-D3li76Ti.js} +2 -3
- package/dist/{version-CWkIGcLU.js → version-Chc6bVG5.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/viewer-DsyM9kb9.js +1636 -0
- package/dist/{web-authorization-PPaoj2ns.js → web-authorization-Enb5lVYt.js} +6 -6
- package/dist/{web-input-CfNxXtHm.js → web-input-efQlcCis.js} +64 -502
- package/dist/{work-DNaoFrEe.js → work-CeiA_ZxD.js} +9 -10
- package/dist/{worker-xeJLxYwm.js → worker-BJb2hsUB.js} +5 -5
- package/migrations/0047_user_timezone.sql +1 -0
- package/migrations/0048_user_admin.sql +1 -0
- package/migrations/meta/0047_snapshot.json +3713 -0
- package/migrations/meta/0048_snapshot.json +3720 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +4 -4
- package/dist/pending-auth-WqF4Gh8Z.js +0 -59
package/dist/cli/upgrade.d.ts
CHANGED
package/dist/cli/upgrade.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as getChatConfig } from "../config-
|
|
2
|
-
import { t as createJuniorSqlExecutor } from "../executor-
|
|
3
|
-
import { t as createPluginCatalogRuntime } from "../registry-
|
|
1
|
+
import { i as getChatConfig } from "../config-DRw358bB.js";
|
|
2
|
+
import { t as createJuniorSqlExecutor } from "../executor-DgPk8Lsx.js";
|
|
3
|
+
import { t as createPluginCatalogRuntime } from "../registry-D1RsbgDb.js";
|
|
4
4
|
import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-egKWjgue.js";
|
|
5
5
|
import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
|
|
6
6
|
import { basename, dirname, join, resolve } from "node:path";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as logException, g as serializeGenAiAttribute, i as extractGenAiUsageAttributes, m as normalizeGenAiFinishReason, p as logWarn, w as withSpan } from "./logging-
|
|
2
|
-
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-
|
|
1
|
+
import { d as logException, g as serializeGenAiAttribute, i as extractGenAiUsageAttributes, m as normalizeGenAiFinishReason, p as logWarn, w as withSpan } from "./logging-BNi_jyHb.js";
|
|
2
|
+
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-DAYxHp74.js";
|
|
3
3
|
import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
|
|
4
4
|
import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
|
|
5
5
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-
|
|
3
|
-
import { p as logWarn } from "./logging-
|
|
2
|
+
import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-CKs0rj3A.js";
|
|
3
|
+
import { p as logWarn } from "./logging-BNi_jyHb.js";
|
|
4
4
|
import { l as TURN_REASONING_LEVELS, s as modelProfileSchema, t as DEFAULT_MODEL_PROFILES, u as parseTurnReasoningLevel } from "./model-profile-BwU8mqwD.js";
|
|
5
5
|
//#region src/chat/slack/emoji.ts
|
|
6
6
|
const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
|
|
@@ -1,520 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as conversationTurnFailureReasonSchema, i as conversationTurnFailureCodeSchema, m as usageSchema } from "./history-BLTUgFYO.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
//#region src/usage-schema.ts
|
|
5
|
-
const usageCostSchema = z.object({
|
|
6
|
-
input: z.number().finite().nonnegative().optional(),
|
|
7
|
-
output: z.number().finite().nonnegative().optional(),
|
|
8
|
-
cacheRead: z.number().finite().nonnegative().optional(),
|
|
9
|
-
cacheWrite: z.number().finite().nonnegative().optional(),
|
|
10
|
-
total: z.number().finite().nonnegative().optional()
|
|
11
|
-
}).strict();
|
|
12
|
-
const usageSchema = z.object({
|
|
13
|
-
inputTokens: z.number().int().nonnegative().optional(),
|
|
14
|
-
outputTokens: z.number().int().nonnegative().optional(),
|
|
15
|
-
cachedInputTokens: z.number().int().nonnegative().optional(),
|
|
16
|
-
cacheCreationTokens: z.number().int().nonnegative().optional(),
|
|
17
|
-
reasoningTokens: z.number().int().nonnegative().optional(),
|
|
18
|
-
totalTokens: z.number().int().nonnegative().optional(),
|
|
19
|
-
cost: usageCostSchema.optional()
|
|
20
|
-
}).strict();
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/chat/conversations/provenance.ts
|
|
23
|
-
/**
|
|
24
|
-
* Durable message attribution shared by storage and projections.
|
|
25
|
-
* Attribution never grants credential authority.
|
|
26
|
-
*/
|
|
27
|
-
const conversationMessageAuthoritySchema = z.union([z.literal("instruction"), z.literal("context")]);
|
|
28
|
-
/** Canonical authority and actor metadata for one durable message event. */
|
|
29
|
-
const conversationMessageProvenanceSchema = z.object({
|
|
30
|
-
authority: conversationMessageAuthoritySchema,
|
|
31
|
-
actor: actorSchema.optional()
|
|
32
|
-
}).strict();
|
|
33
|
-
/** Build instruction provenance for an optional actor. */
|
|
34
|
-
function instructionProvenanceFor(actor) {
|
|
35
|
-
return actor ? {
|
|
36
|
-
authority: "instruction",
|
|
37
|
-
actor
|
|
38
|
-
} : { authority: "instruction" };
|
|
39
|
-
}
|
|
40
|
-
/** Unattributed ambient-context provenance for non-instruction messages. */
|
|
41
|
-
const contextProvenance = { authority: "context" };
|
|
42
|
-
function actorIdentityKey(actor) {
|
|
43
|
-
if (actor.platform === "system") return `system ${actor.name}`;
|
|
44
|
-
return actor.platform === "slack" ? `slack\u0000${actor.teamId}\u0000${actor.userId}` : `${actor.platform}\u0000${actor.userId}`;
|
|
45
|
-
}
|
|
46
|
-
/** Compare two actors by runtime identity only, never by display metadata. */
|
|
47
|
-
function sameActorIdentity(left, right) {
|
|
48
|
-
return Boolean(left && right && actorIdentityKey(left) === actorIdentityKey(right));
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Return distinct instruction actors in first-seen order for attribution only.
|
|
52
|
-
* Never use this list as credential authority.
|
|
53
|
-
*/
|
|
54
|
-
function instructionActors(provenance) {
|
|
55
|
-
const seen = /* @__PURE__ */ new Set();
|
|
56
|
-
const actors = [];
|
|
57
|
-
for (const entry of provenance) {
|
|
58
|
-
if (entry.authority !== "instruction" || !entry.actor) continue;
|
|
59
|
-
const identity = actorIdentityKey(entry.actor);
|
|
60
|
-
if (seen.has(identity)) continue;
|
|
61
|
-
seen.add(identity);
|
|
62
|
-
actors.push(entry.actor);
|
|
63
|
-
}
|
|
64
|
-
return actors;
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/chat/conversations/history-payload.ts
|
|
68
|
-
const messageFieldsSchema = z.record(z.string(), z.unknown());
|
|
69
|
-
const replacementEntrySchema = z.object({ item: z.string() }).passthrough();
|
|
70
|
-
/** Identify history events that store message fields as JSON strings. */
|
|
71
|
-
function isEncodedHistoryType(type) {
|
|
72
|
-
return type === "user_message" || type === "assistant_message" || type === "tool_result" || type === "handoff" || type === "compaction";
|
|
73
|
-
}
|
|
74
|
-
/** Encode agent history before SQL can change keys or string contents. */
|
|
75
|
-
function encodeHistoryPayload(data) {
|
|
76
|
-
const { type, ...payload } = data;
|
|
77
|
-
if (!isEncodedHistoryType(type)) return {
|
|
78
|
-
schemaVersion: 1,
|
|
79
|
-
payload
|
|
80
|
-
};
|
|
81
|
-
if (data.type === "handoff" || data.type === "compaction") return {
|
|
82
|
-
schemaVersion: 2,
|
|
83
|
-
payload: {
|
|
84
|
-
...payload,
|
|
85
|
-
replacementHistory: data.replacementHistory.map(({ item, ...entry }) => ({
|
|
86
|
-
...entry,
|
|
87
|
-
item: JSON.stringify(item)
|
|
88
|
-
}))
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const { provenance, ...message } = payload;
|
|
92
|
-
return {
|
|
93
|
-
schemaVersion: 2,
|
|
94
|
-
payload: {
|
|
95
|
-
message: JSON.stringify(message),
|
|
96
|
-
provenance,
|
|
97
|
-
model: message.model,
|
|
98
|
-
provider: message.provider,
|
|
99
|
-
usage: message.usage,
|
|
100
|
-
toolCallId: message.toolCallId
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
/** Decode stored history for validation by the conversation event schema. */
|
|
105
|
-
function decodeHistoryPayload(type, payload) {
|
|
106
|
-
const fields = messageFieldsSchema.parse(payload);
|
|
107
|
-
if (type === "handoff" || type === "compaction") return {
|
|
108
|
-
...fields,
|
|
109
|
-
replacementHistory: z.array(replacementEntrySchema).parse(fields.replacementHistory).map(({ item, ...entry }) => ({
|
|
110
|
-
...entry,
|
|
111
|
-
item: JSON.parse(item)
|
|
112
|
-
}))
|
|
113
|
-
};
|
|
114
|
-
const message = messageFieldsSchema.parse(JSON.parse(z.string().parse(fields.message)));
|
|
115
|
-
if (fields.provenance !== void 0) message.provenance = fields.provenance;
|
|
116
|
-
return message;
|
|
117
|
-
}
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/chat/conversations/history.ts
|
|
120
|
-
/**
|
|
121
|
-
* Durable conversation event history port.
|
|
122
|
-
*
|
|
123
|
-
* Events append under the conversation lease in stable sequence order.
|
|
124
|
-
* Compaction and handoff replace the active model history without rewriting
|
|
125
|
-
* prior events. Unsupported stored events remain readable as opaque facts,
|
|
126
|
-
* while malformed known events fail loudly. Provider-specific message fields
|
|
127
|
-
* are validated by the Pi adapter when it restores model context.
|
|
128
|
-
*/
|
|
129
|
-
const userMessageEventDataSchema = z.object({
|
|
130
|
-
type: z.literal("user_message"),
|
|
131
|
-
role: z.never().optional(),
|
|
132
|
-
provenance: conversationMessageProvenanceSchema
|
|
133
|
-
}).passthrough();
|
|
134
|
-
const assistantMessageEventDataSchema = z.object({
|
|
135
|
-
type: z.literal("assistant_message"),
|
|
136
|
-
role: z.never().optional()
|
|
137
|
-
}).passthrough();
|
|
138
|
-
const toolResultEventDataSchema = z.object({
|
|
139
|
-
type: z.literal("tool_result"),
|
|
140
|
-
role: z.never().optional()
|
|
141
|
-
}).passthrough();
|
|
142
|
-
/**
|
|
143
|
-
* One replayable agent-history item. Junior owns `type` and user provenance,
|
|
144
|
-
* forbids the provider `role` discriminator, and leaves preserved message
|
|
145
|
-
* fields for the Pi adapter to validate when restoring model context.
|
|
146
|
-
*/
|
|
147
|
-
const agentHistoryItemSchema = z.discriminatedUnion("type", [
|
|
148
|
-
userMessageEventDataSchema,
|
|
149
|
-
assistantMessageEventDataSchema,
|
|
150
|
-
toolResultEventDataSchema
|
|
151
|
-
]);
|
|
152
|
-
const nativeReplacementHistoryItemSchema = z.object({
|
|
153
|
-
item: agentHistoryItemSchema,
|
|
154
|
-
sourceEventSeq: z.number().int().nonnegative().optional()
|
|
155
|
-
}).strict();
|
|
156
|
-
/**
|
|
157
|
-
* The complete agent history used immediately after a replacement. Later
|
|
158
|
-
* native history events append to it. Replacement entries are replayed model
|
|
159
|
-
* history, not new conversation activity.
|
|
160
|
-
*/
|
|
161
|
-
const replacementHistorySchema = z.array(nativeReplacementHistoryItemSchema);
|
|
162
|
-
const compactionDetailsSchema = z.object({
|
|
163
|
-
reason: z.literal("capacity"),
|
|
164
|
-
estimatedInputTokens: z.number().int().nonnegative(),
|
|
165
|
-
replacementInputTokens: z.number().int().nonnegative().optional(),
|
|
166
|
-
triggerTokens: z.number().int().nonnegative(),
|
|
167
|
-
inputLimitTokens: z.number().int().positive(),
|
|
168
|
-
inputMessageCount: z.number().int().nonnegative(),
|
|
169
|
-
retainedMessageCount: z.number().int().nonnegative(),
|
|
170
|
-
summaryChars: z.number().int().nonnegative()
|
|
171
|
-
}).strict();
|
|
172
|
-
const historyReplacementEventDataSchema = z.discriminatedUnion("type", [z.object({
|
|
173
|
-
type: z.literal("handoff"),
|
|
174
|
-
modelProfile: modelProfileSchema,
|
|
175
|
-
modelId: z.string().min(1),
|
|
176
|
-
reasoningLevel: z.string().min(1).optional(),
|
|
177
|
-
triggeringToolCallId: z.string().min(1).optional(),
|
|
178
|
-
summary: z.string().min(1).optional(),
|
|
179
|
-
replacementHistory: replacementHistorySchema
|
|
180
|
-
}).strict(), z.object({
|
|
181
|
-
type: z.literal("compaction"),
|
|
182
|
-
modelProfile: modelProfileSchema,
|
|
183
|
-
modelId: z.string().min(1),
|
|
184
|
-
details: compactionDetailsSchema.optional(),
|
|
185
|
-
summary: z.string().min(1).optional(),
|
|
186
|
-
replacementHistory: replacementHistorySchema
|
|
187
|
-
}).strict()]);
|
|
188
|
-
/** Validate an event that intentionally replaces active model history. */
|
|
189
|
-
const historyReplacementSchema = z.object({
|
|
190
|
-
data: historyReplacementEventDataSchema,
|
|
191
|
-
createdAtMs: z.number().finite()
|
|
192
|
-
}).strict();
|
|
193
|
-
const mcpProviderConnectedEventDataSchema = z.object({
|
|
194
|
-
type: z.literal("mcp_provider_connected"),
|
|
195
|
-
provider: z.string().min(1),
|
|
196
|
-
credentialSubjectId: z.string().min(1)
|
|
197
|
-
}).strict();
|
|
198
|
-
const unownedMcpProviderConnectedEventDataSchema = z.object({
|
|
199
|
-
type: z.literal("mcp_provider_connected_unowned"),
|
|
200
|
-
provider: z.string().min(1)
|
|
201
|
-
}).strict();
|
|
202
|
-
const authorizationKindSchema = z.union([z.literal("plugin"), z.literal("mcp")]);
|
|
203
|
-
const authorizationRequestedEventDataSchema = z.object({
|
|
204
|
-
type: z.literal("authorization_requested"),
|
|
205
|
-
kind: authorizationKindSchema,
|
|
206
|
-
provider: z.string().min(1),
|
|
207
|
-
actorId: z.string().min(1),
|
|
208
|
-
authorizationId: z.string().min(1),
|
|
209
|
-
delivery: z.union([z.literal("private_link_sent"), z.literal("private_link_reused")])
|
|
210
|
-
}).strict();
|
|
211
|
-
const authorizationCompletedEventDataSchema = z.object({
|
|
212
|
-
type: z.literal("authorization_completed"),
|
|
213
|
-
kind: authorizationKindSchema,
|
|
214
|
-
provider: z.string().min(1),
|
|
215
|
-
actorId: z.string().min(1),
|
|
216
|
-
authorizationId: z.string().min(1)
|
|
217
|
-
}).strict();
|
|
218
|
-
const toolExecutionStartedEventDataSchema = z.object({
|
|
219
|
-
type: z.literal("tool_execution_started"),
|
|
220
|
-
toolCallId: z.string().min(1),
|
|
221
|
-
toolName: z.string().min(1)
|
|
222
|
-
}).strict();
|
|
223
|
-
const guardianActionReviewedEventDataSchema = z.object({
|
|
224
|
-
type: z.literal("guardian_action_reviewed"),
|
|
225
|
-
turnId: z.string().min(1),
|
|
226
|
-
toolCallId: z.string().min(1),
|
|
227
|
-
toolName: z.string().min(1),
|
|
228
|
-
costUsd: z.number().finite().nonnegative().optional(),
|
|
229
|
-
decision: z.enum([
|
|
230
|
-
"allow",
|
|
231
|
-
"ask",
|
|
232
|
-
"deny"
|
|
233
|
-
]),
|
|
234
|
-
riskLevel: z.enum([
|
|
235
|
-
"low",
|
|
236
|
-
"medium",
|
|
237
|
-
"high",
|
|
238
|
-
"critical"
|
|
239
|
-
]),
|
|
240
|
-
userAuthorization: z.enum([
|
|
241
|
-
"high",
|
|
242
|
-
"medium",
|
|
243
|
-
"low",
|
|
244
|
-
"unknown"
|
|
245
|
-
])
|
|
246
|
-
}).strict();
|
|
247
|
-
const conversationMessageRoleSchema = z.union([
|
|
248
|
-
z.literal("user"),
|
|
249
|
-
z.literal("assistant"),
|
|
250
|
-
z.literal("system")
|
|
251
|
-
]);
|
|
252
|
-
const messageEventDataSchema = z.object({
|
|
253
|
-
type: z.literal("message"),
|
|
254
|
-
messageId: z.string().min(1),
|
|
255
|
-
role: conversationMessageRoleSchema,
|
|
256
|
-
text: z.string(),
|
|
257
|
-
authorIdentityId: z.string().min(1).optional(),
|
|
258
|
-
meta: z.record(z.string(), z.unknown()).optional()
|
|
259
|
-
}).strict();
|
|
260
|
-
const messageUpdatedEventDataSchema = messageEventDataSchema.extend({ type: z.literal("message_updated") });
|
|
261
|
-
const messageHandledEventDataSchema = z.object({
|
|
262
|
-
type: z.literal("message_handled"),
|
|
263
|
-
messageId: z.string().min(1)
|
|
264
|
-
}).strict();
|
|
265
|
-
const messagesSummarizedEventDataSchema = z.object({
|
|
266
|
-
type: z.literal("messages_summarized"),
|
|
267
|
-
historyFromSeq: z.number().int().nonnegative(),
|
|
268
|
-
compactions: z.array(z.object({
|
|
269
|
-
coveredMessageCount: z.number().int().nonnegative(),
|
|
270
|
-
createdAtMs: z.number(),
|
|
271
|
-
id: z.string().min(1),
|
|
272
|
-
summary: z.string()
|
|
273
|
-
}).strict())
|
|
274
|
-
}).strict();
|
|
275
|
-
/** Product surface that owns a durable conversation turn. */
|
|
276
|
-
const conversationTurnSurfaceSchema = z.enum([
|
|
277
|
-
"slack",
|
|
278
|
-
"api",
|
|
279
|
-
"scheduler",
|
|
280
|
-
"internal"
|
|
281
|
-
]);
|
|
282
|
-
/** Where a failed turn stopped. */
|
|
283
|
-
const conversationTurnFailureCodeSchema = z.enum([
|
|
284
|
-
"agent_run_failed",
|
|
285
|
-
"delivery_failed",
|
|
286
|
-
"model_execution_failed",
|
|
287
|
-
"persistence_failed"
|
|
288
|
-
]);
|
|
289
|
-
/**
|
|
290
|
-
* Why a failed turn stopped.
|
|
291
|
-
* Values are fixed labels only. Do not store raw exception text.
|
|
292
|
-
*/
|
|
293
|
-
const conversationTurnFailureReasonSchema = z.enum([
|
|
294
|
-
"auth",
|
|
295
|
-
"permission",
|
|
296
|
-
"rate_limit",
|
|
297
|
-
"capacity",
|
|
298
|
-
"timeout",
|
|
299
|
-
"network",
|
|
300
|
-
"server",
|
|
301
|
-
"invalid_request",
|
|
302
|
-
"invalid_response",
|
|
303
|
-
"quota",
|
|
304
|
-
"content_policy",
|
|
305
|
-
"unknown",
|
|
306
|
-
"empty_output",
|
|
307
|
-
"tool_errors",
|
|
308
|
-
"suppressed_output"
|
|
309
|
-
]);
|
|
310
|
-
const turnStartedEventDataSchema = z.object({
|
|
311
|
-
type: z.literal("turn_started"),
|
|
312
|
-
turnId: z.string().min(1),
|
|
313
|
-
inputMessageIds: z.array(z.string().min(1)).min(1),
|
|
314
|
-
surface: conversationTurnSurfaceSchema
|
|
315
|
-
}).strict().refine((data) => new Set(data.inputMessageIds).size === data.inputMessageIds.length, "turn input message ids must be unique");
|
|
316
|
-
const turnRoutedEventDataSchema = z.object({
|
|
317
|
-
type: z.literal("turn_routed"),
|
|
318
|
-
turnId: z.string().min(1),
|
|
319
|
-
modelProfile: modelProfileSchema,
|
|
320
|
-
modelId: z.string().min(1),
|
|
321
|
-
costUsd: z.number().finite().nonnegative().optional(),
|
|
322
|
-
reasoningLevel: z.enum(TURN_REASONING_LEVELS),
|
|
323
|
-
confidence: z.number().min(0).max(1).optional(),
|
|
324
|
-
source: z.enum([
|
|
325
|
-
"configured",
|
|
326
|
-
"inherited",
|
|
327
|
-
"router"
|
|
328
|
-
])
|
|
329
|
-
}).strict();
|
|
330
|
-
const turnContextEventDataSchema = z.object({
|
|
331
|
-
type: z.literal("turn_context"),
|
|
332
|
-
turnId: z.string().min(1),
|
|
333
|
-
pluginName: z.string().min(1),
|
|
334
|
-
kind: z.string().min(1).max(64),
|
|
335
|
-
version: z.number().int().positive(),
|
|
336
|
-
content: z.record(z.string(), z.unknown())
|
|
337
|
-
}).strict();
|
|
338
|
-
const structuredConversationEventDataSchema = z.object({
|
|
339
|
-
type: z.literal("structured_event"),
|
|
340
|
-
namespace: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
341
|
-
name: z.string().regex(/^[a-z][a-z0-9_]*$/),
|
|
342
|
-
version: z.number().int().positive(),
|
|
343
|
-
turnId: z.string().min(1).optional(),
|
|
344
|
-
content: z.record(z.string(), z.unknown())
|
|
345
|
-
}).strict();
|
|
346
|
-
/** Durable attachment metadata on host-owned delivery events. */
|
|
347
|
-
const deliveredAttachmentSchema = z.object({
|
|
348
|
-
id: z.string().min(1),
|
|
349
|
-
filename: z.string().min(1),
|
|
350
|
-
contentType: z.string().min(1),
|
|
351
|
-
bytes: z.number().int().nonnegative()
|
|
352
|
-
}).strict();
|
|
353
|
-
/** Host-owned transcript item for files delivered to humans this turn. */
|
|
354
|
-
const attachmentsDeliveredEventDataSchema = z.object({
|
|
355
|
-
type: z.literal("attachments_delivered"),
|
|
356
|
-
attachments: z.array(deliveredAttachmentSchema).min(1),
|
|
357
|
-
toolCallId: z.string().min(1).optional(),
|
|
358
|
-
turnId: z.string().min(1).optional()
|
|
359
|
-
}).strict();
|
|
360
|
-
const turnCompletedEventDataSchema = z.object({
|
|
361
|
-
type: z.literal("turn_completed"),
|
|
362
|
-
turnId: z.string().min(1),
|
|
363
|
-
outcome: z.enum([
|
|
364
|
-
"success",
|
|
365
|
-
"no_reply",
|
|
366
|
-
"cancelled"
|
|
367
|
-
])
|
|
368
|
-
}).strict();
|
|
369
|
-
const turnFailedEventDataSchema = z.object({
|
|
370
|
-
type: z.literal("turn_failed"),
|
|
371
|
-
turnId: z.string().min(1),
|
|
372
|
-
failureCode: conversationTurnFailureCodeSchema,
|
|
373
|
-
failureReason: conversationTurnFailureReasonSchema.optional(),
|
|
374
|
-
eventId: z.string().regex(/^[a-f0-9]{32}$/i).optional()
|
|
375
|
-
}).strict();
|
|
376
|
-
const subagentStartedEventDataSchema = z.object({
|
|
377
|
-
type: z.literal("subagent_started"),
|
|
378
|
-
subagentInvocationId: z.string().min(1),
|
|
379
|
-
subagentKind: z.string().min(1),
|
|
380
|
-
modelId: z.string().min(1).optional(),
|
|
381
|
-
parentToolCallId: z.string().min(1).optional(),
|
|
382
|
-
reasoningLevel: z.string().min(1).optional(),
|
|
383
|
-
childConversationId: z.string().min(1)
|
|
384
|
-
}).strict();
|
|
385
|
-
const subagentEndedEventDataSchema = z.object({
|
|
386
|
-
type: z.literal("subagent_ended"),
|
|
387
|
-
subagentInvocationId: z.string().min(1),
|
|
388
|
-
outcome: z.union([
|
|
389
|
-
z.literal("success"),
|
|
390
|
-
z.literal("error"),
|
|
391
|
-
z.literal("aborted")
|
|
392
|
-
]),
|
|
393
|
-
errorCode: z.string().min(1).optional()
|
|
394
|
-
}).strict();
|
|
395
|
-
/** Prevent ordinary appends from bypassing history-replacement validation. */
|
|
396
|
-
const appendableConversationEventDataSchema = z.union([
|
|
397
|
-
messageEventDataSchema,
|
|
398
|
-
messageUpdatedEventDataSchema,
|
|
399
|
-
agentHistoryItemSchema,
|
|
400
|
-
mcpProviderConnectedEventDataSchema,
|
|
401
|
-
authorizationRequestedEventDataSchema,
|
|
402
|
-
authorizationCompletedEventDataSchema,
|
|
403
|
-
toolExecutionStartedEventDataSchema,
|
|
404
|
-
guardianActionReviewedEventDataSchema,
|
|
405
|
-
messageHandledEventDataSchema,
|
|
406
|
-
messagesSummarizedEventDataSchema,
|
|
407
|
-
turnStartedEventDataSchema,
|
|
408
|
-
turnContextEventDataSchema,
|
|
409
|
-
structuredConversationEventDataSchema,
|
|
410
|
-
attachmentsDeliveredEventDataSchema,
|
|
411
|
-
turnRoutedEventDataSchema,
|
|
412
|
-
turnCompletedEventDataSchema,
|
|
413
|
-
turnFailedEventDataSchema,
|
|
414
|
-
subagentStartedEventDataSchema,
|
|
415
|
-
subagentEndedEventDataSchema
|
|
416
|
-
]);
|
|
417
|
-
/** Strict event-data contract reused by the SQL row codec. */
|
|
418
|
-
const conversationEventDataSchema = z.union([
|
|
419
|
-
appendableConversationEventDataSchema,
|
|
420
|
-
historyReplacementEventDataSchema,
|
|
421
|
-
unownedMcpProviderConnectedEventDataSchema
|
|
422
|
-
]);
|
|
423
|
-
/** Event type names recognized by current readers and observational queries. */
|
|
424
|
-
const KNOWN_CONVERSATION_EVENT_TYPES = [
|
|
425
|
-
"message",
|
|
426
|
-
"message_updated",
|
|
427
|
-
"user_message",
|
|
428
|
-
"assistant_message",
|
|
429
|
-
"tool_result",
|
|
430
|
-
"mcp_provider_connected",
|
|
431
|
-
"mcp_provider_connected_unowned",
|
|
432
|
-
"authorization_requested",
|
|
433
|
-
"authorization_completed",
|
|
434
|
-
"tool_execution_started",
|
|
435
|
-
"guardian_action_reviewed",
|
|
436
|
-
"message_handled",
|
|
437
|
-
"messages_summarized",
|
|
438
|
-
"turn_started",
|
|
439
|
-
"turn_context",
|
|
440
|
-
"structured_event",
|
|
441
|
-
"attachments_delivered",
|
|
442
|
-
"turn_routed",
|
|
443
|
-
"turn_completed",
|
|
444
|
-
"turn_failed",
|
|
445
|
-
"subagent_started",
|
|
446
|
-
"subagent_ended",
|
|
447
|
-
"handoff",
|
|
448
|
-
"compaction"
|
|
449
|
-
];
|
|
450
|
-
const knownConversationEventTypeSchema = z.enum(KNOWN_CONVERSATION_EVENT_TYPES);
|
|
451
|
-
const unknownConversationEventDataSchema = z.object({
|
|
452
|
-
type: z.literal("unknown"),
|
|
453
|
-
originalType: z.string().min(1),
|
|
454
|
-
payload: z.unknown()
|
|
455
|
-
}).strict();
|
|
456
|
-
const conversationEventEnvelopeSchema = z.object({
|
|
457
|
-
schemaVersion: z.number().int().nonnegative(),
|
|
458
|
-
seq: z.number().int().nonnegative(),
|
|
459
|
-
historyVersion: z.number().int().nonnegative(),
|
|
460
|
-
idempotencyKey: z.string().min(1).optional(),
|
|
461
|
-
createdAtMs: z.number().finite()
|
|
462
|
-
}).strict();
|
|
463
|
-
/**
|
|
464
|
-
* Canonical ordered envelope for the durable conversation log.
|
|
465
|
-
* `schemaVersion` is persisted with every physical event row.
|
|
466
|
-
*/
|
|
467
|
-
const conversationEventSchema = z.union([conversationEventEnvelopeSchema.extend({
|
|
468
|
-
schemaVersion: z.union([z.literal(1), z.literal(2)]),
|
|
469
|
-
data: conversationEventDataSchema
|
|
470
|
-
}).refine((event) => event.schemaVersion === 1 || isEncodedHistoryType(event.data.type)), conversationEventEnvelopeSchema.extend({ data: unknownConversationEventDataSchema })]);
|
|
471
|
-
const storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
|
|
472
|
-
type: z.string().min(1),
|
|
473
|
-
payload: z.unknown()
|
|
474
|
-
});
|
|
475
|
-
/**
|
|
476
|
-
* Decode a physical event row without making old or future event types
|
|
477
|
-
* unreadable. Unsupported rows stay opaque until an upgrade migration defines
|
|
478
|
-
* their semantics; supported events remain strict so corrupt canonical
|
|
479
|
-
* data cannot be mistaken for compatibility data.
|
|
480
|
-
*/
|
|
481
|
-
function decodeStoredConversationEvent(value) {
|
|
482
|
-
const stored = storedConversationEventSchema.parse(value);
|
|
483
|
-
const { type, payload, ...envelope } = stored;
|
|
484
|
-
const knownType = knownConversationEventTypeSchema.safeParse(type).success;
|
|
485
|
-
if (stored.schemaVersion === 2 && isEncodedHistoryType(type)) return conversationEventSchema.parse({
|
|
486
|
-
...envelope,
|
|
487
|
-
data: {
|
|
488
|
-
...decodeHistoryPayload(type, payload),
|
|
489
|
-
type
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
if (stored.schemaVersion === 1 && knownType) {
|
|
493
|
-
const data = typeof payload === "object" && payload !== null && !Array.isArray(payload) ? {
|
|
494
|
-
...payload,
|
|
495
|
-
type
|
|
496
|
-
} : { type };
|
|
497
|
-
return conversationEventSchema.parse({
|
|
498
|
-
...envelope,
|
|
499
|
-
data
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
return conversationEventSchema.parse({
|
|
503
|
-
...envelope,
|
|
504
|
-
data: {
|
|
505
|
-
type: "unknown",
|
|
506
|
-
originalType: type,
|
|
507
|
-
payload
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
/** Validate an append without permitting model-history replacement events. */
|
|
512
|
-
const newConversationEventSchema = z.object({
|
|
513
|
-
data: appendableConversationEventDataSchema,
|
|
514
|
-
idempotencyKey: z.string().min(1).optional(),
|
|
515
|
-
createdAtMs: z.number().finite()
|
|
516
|
-
}).strict();
|
|
517
|
-
//#endregion
|
|
3
|
+
import { codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, objectFactFields, objectTypeSchema } from "@sentry/junior-plugin-api";
|
|
518
4
|
//#region src/chat/automations/card.ts
|
|
519
5
|
/** Saved automation facts shown with a Message, not a live status view. */
|
|
520
6
|
const automationCardSchema = z.object({
|
|
@@ -1368,4 +854,4 @@ const conversationStatsReportSchema = z.object({
|
|
|
1368
854
|
windowStart: z.string()
|
|
1369
855
|
}).strict();
|
|
1370
856
|
//#endregion
|
|
1371
|
-
export {
|
|
857
|
+
export { forkConversationResponseSchema as A, parseBriefInput as B, conversationReportEventSchema as C, createConversationBodySchema as D, conversationSummaryReportSchema as E, isVisionImageMediaType as F, removedCardSchema as G, messageCardRef as H, briefCodeChangeSchema as I, resolveMessageCards as K, briefLinkSchema as L, MAX_INPUT_IMAGE_BYTES as M, readMessageAttachments as N, createConversationMessageBodySchema as O, INPUT_IMAGE_TYPES as P, briefOutcomeStatusSchema as R, conversationReportEventDataSchema as S, conversationStatsReportSchema as T, messageCardText as U, annotationCard as V, readMessageCardRefs as W, conversationParamsSchema as _, cancelConversationPendingMessagesBodySchema as a, conversationPendingMessageSchema as b, conversationAttachmentParamsSchema as c, conversationDetailReportSchema as d, conversationEventHistorySchema as f, conversationFeedSchema as g, conversationFeedQuerySchema as h, archiveConversationResponseSchema as i, MAX_INPUT_IMAGES as j, forkConversationBodySchema as k, conversationAuxiliaryCostsSchema as l, conversationEventsQuerySchema as m, actorIdentitySchema as n, cancelConversationPendingMessagesResponseSchema as o, conversationEventPageSchema as p, archiveConversationBodySchema as r, conversationActivityPreviewSchema as s, acceptedConversationMessageSchema as t, conversationDetailQuerySchema as u, conversationPendingAuthorizationSchema as v, conversationStatsItemSchema as w, conversationPendingMessagesReportSchema as x, conversationPendingMessageDeliverySchema as y, conversationBriefSchema as z };
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as escapeXml } from "./client-
|
|
3
|
-
import { d as logException, h as runBestEffort, p as logWarn } from "./logging-
|
|
4
|
-
import { a as getRuntimeMetadata, n as botConfig } from "./config-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { Mn as createUserTokenStore, On as postSlackMessage, _ as resolvePluginOAuthAccount, _n as formatProviderLabel, d as getMcpAuthSession, f as getMcpStoredOAuthCredentials, o as finalizeMcpAuthorization, p as putMcpStoredOAuthCredentials, s as deleteMcpAuthSession, vn as parseOAuthStatePayload, vt as getMcpProviderErrorAttributes, x as lookupSlackUserProfile, yn as resolveBaseUrl } from "./agent-runner-ZS1LHtSR.js";
|
|
2
|
+
import { f as escapeXml } from "./client-CKs0rj3A.js";
|
|
3
|
+
import { d as logException, h as runBestEffort, p as logWarn } from "./logging-BNi_jyHb.js";
|
|
4
|
+
import { a as getRuntimeMetadata, n as botConfig } from "./config-DRw358bB.js";
|
|
5
|
+
import { f as parseSlackUserId } from "./actor-BTtLaeWy.js";
|
|
6
|
+
import { A as upsertLinkedIdentity, f as getSqlExecutor, k as upsertIdentity } from "./viewer-DsyM9kb9.js";
|
|
7
7
|
import { i as homeDir } from "./package-discovery-BVvSnQBB.js";
|
|
8
|
-
import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-
|
|
9
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
10
|
-
import { t as discoverSkills } from "./skills-
|
|
11
|
-
import { B as recordAuthenticationLinked, V as recordAuthorizationCompleted, s as getTurnRecord } from "./checkpoint-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
8
|
+
import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-D1RsbgDb.js";
|
|
9
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BzNg07bb.js";
|
|
10
|
+
import { t as discoverSkills } from "./skills-BGhThSGR.js";
|
|
11
|
+
import { B as recordAuthenticationLinked, V as recordAuthorizationCompleted, s as getTurnRecord } from "./checkpoint-DWGyJg4c.js";
|
|
12
|
+
import { at as getSlackClient } from "./agent-hooks-CxdSqU2u.js";
|
|
13
|
+
import { E as acquireActiveLock, w as getStateAdapter } from "./profile-C2TScny6.js";
|
|
14
|
+
import { i as getConversationPendingAuth } from "./pending-auth-DulDjfwL.js";
|
|
15
|
+
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-B-t88gH0.js";
|
|
16
|
+
import { n as deleteWebAuthorization, o as wakeAuthorizedTurn, s as wakePausedTurn } from "./web-authorization-Enb5lVYt.js";
|
|
16
17
|
import { n as relayLocalOAuthCallback } from "./oauth-relay-CdCnu80W.js";
|
|
17
18
|
import path from "node:path";
|
|
18
19
|
import { z } from "zod";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as logException } from "./logging-
|
|
1
|
+
import { d as logException } from "./logging-BNi_jyHb.js";
|
|
2
2
|
import { g as startSpanManual } from "./sentry-CgWZM_kV.js";
|
|
3
|
-
import "./config-
|
|
3
|
+
import "./config-DRw358bB.js";
|
|
4
4
|
import { n as juniorDestinations, r as timestamptz } from "./destinations-BeBiJeEM.js";
|
|
5
5
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
6
6
|
import { getTableColumns, sql } from "drizzle-orm";
|
|
@@ -39,6 +39,9 @@ const juniorUsers = pgTable("junior_users", {
|
|
|
39
39
|
primaryEmail: text("primary_email").notNull(),
|
|
40
40
|
primaryEmailNormalized: text("primary_email_normalized").notNull(),
|
|
41
41
|
displayName: text("display_name"),
|
|
42
|
+
timezone: text("timezone"),
|
|
43
|
+
/** Junior-wide admin role. Only the `junior admin` CLI changes it. */
|
|
44
|
+
isAdmin: boolean("is_admin").notNull().default(false),
|
|
42
45
|
createdAt: timestamptz("created_at").notNull(),
|
|
43
46
|
updatedAt: timestamptz("updated_at").notNull()
|
|
44
47
|
}, (table) => [uniqueIndex("junior_users_primary_email_normalized_uidx").on(table.primaryEmailNormalized)]);
|